30 require
'../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/member.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
41 $langs->loadLangs(array(
"companies",
"bills",
"members",
"users",
"mails",
'other'));
43 $action =
GETPOST(
'action',
'aZ09');
44 $confirm =
GETPOST(
'confirm',
'alpha');
46 $typeid =
GETPOST(
'typeid',
'int');
49 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
50 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
51 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
53 if (empty($page) || $page == -1) { $page = 0; }
54 $offset = $limit * $page;
55 $pageprev = $page - 1;
56 $pagenext = $page + 1;
59 if (!$sortfield) $sortfield =
"c.rowid";
60 if (!$sortorder) $sortorder =
"DESC";
64 $result =
restrictedArea($user,
'adherent', $rowid,
'',
'cotisation');
71 $extrafields->fetch_name_optionals_label($object->table_element);
76 $defaultdelayunit =
'y';
80 $result = $object->fetch($rowid);
83 $canadduser = ($user->admin || $user->rights->user->user->creer);
85 if ($object->user_id) {
87 $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer)
88 || (($user->id != $object->user_id) && $user->rights->user->user->creer));
89 $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password)
90 || (($user->id != $object->user_id) && $user->rights->user->user->password));
95 $canaddmember = $user->rights->adherent->creer;
98 $caneditfieldmember = $user->rights->adherent->creer;
102 $hookmanager->initHooks(array(
'subscription'));
105 $hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
106 $hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
107 $hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
115 if ($action ==
'confirm_create_thirdparty' && $confirm ==
'yes' && $user->rights->societe->creer) {
119 $result = $company->create_from_member($object,
GETPOST(
'companyname',
'alpha'),
GETPOST(
'companyalias',
'alpha'),
GETPOST(
'customercode',
'alpha'));
122 $langs->load(
"errors");
125 $action =
'addsubscription';
132 if ($action ==
'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) {
134 if (empty($user->rights->user->user->creer)) {
135 if ($_POST[
"userid"] != $user->id && $_POST[
"userid"] != $object->user_id) {
137 setEventMessages($langs->trans(
"ErrorUserPermissionAllowsToLinksToItselfOnly"), null,
'errors');
142 if ($_POST[
"userid"] != $object->user_id) {
143 $result = $object->setUserId($_POST[
"userid"]);
145 $_POST[
'action'] =
'';
151 if ($action ==
'setsocid') {
154 if (
GETPOST(
'socid',
'int') != $object->fk_soc) {
155 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
156 $sql .=
" WHERE fk_soc = '".GETPOST(
'socid',
'int').
"'";
157 $resql = $db->query($sql);
159 $obj = $db->fetch_object(
$resql);
160 if ($obj && $obj->rowid > 0) {
162 $othermember->fetch($obj->rowid);
163 $thirdparty =
new Societe($db);
164 $thirdparty->fetch(
GETPOST(
'socid',
'int'));
166 setEventMessages($langs->trans(
"ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null,
'errors');
171 $result = $object->setThirdPartyId(
GETPOST(
'socid',
'int'));
173 $_POST[
'action'] =
'';
180 if ($user->rights->adherent->cotisation->creer && $action ==
'subscription' && !$_POST[
"cancel"]) {
183 $langs->load(
"banks");
185 $result = $object->fetch($rowid);
186 $result = $adht->fetch($object->typeid);
189 $datesubscription = 0;
192 if ($_POST[
"reyear"] && $_POST[
"remonth"] && $_POST[
"reday"]) {
193 $datesubscription =
dol_mktime(0, 0, 0, $_POST[
"remonth"], $_POST[
"reday"], $_POST[
"reyear"]);
195 if ($_POST[
"endyear"] && $_POST[
"endmonth"] && $_POST[
"endday"]) {
196 $datesubend =
dol_mktime(0, 0, 0, $_POST[
"endmonth"], $_POST[
"endday"], $_POST[
"endyear"]);
198 if ($_POST[
"paymentyear"] && $_POST[
"paymentmonth"] && $_POST[
"paymentday"]) {
199 $paymentdate =
dol_mktime(0, 0, 0, $_POST[
"paymentmonth"], $_POST[
"paymentday"], $_POST[
"paymentyear"]);
202 $label = $_POST[
"label"];
205 $accountid = $_POST[
"accountid"];
206 $operation = $_POST[
"operation"];
207 $num_chq =
GETPOST(
"num_chq",
"alphanohtml");
208 $emetteur_nom = $_POST[
"chqemetteur"];
209 $emetteur_banque = $_POST[
"chqbank"];
210 $option = $_POST[
"paymentsave"];
211 if (empty($option)) $option =
'none';
212 $sendalsoemail =
GETPOST(
"sendmail",
'alpha');
215 if (!$datesubscription) {
217 $langs->load(
"errors");
218 $errmsg = $langs->trans(
"ErrorBadDateFormat", $langs->transnoentitiesnoconv(
"DateSubscription"));
220 $action =
'addsubscription';
222 if (
GETPOST(
'end') && !$datesubend) {
224 $langs->load(
"errors");
225 $errmsg = $langs->trans(
"ErrorBadDateFormat", $langs->transnoentitiesnoconv(
"DateEndSubscription"));
227 $action =
'addsubscription';
232 if (($option ==
'bankviainvoice' || $option ==
'bankdirect') && !$paymentdate) {
234 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DatePayment"));
236 $action =
'addsubscription';
240 if (!$error && $adht->subscription) {
241 if (!is_numeric($amount)) {
243 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount"));
246 $action =
'addsubscription';
248 if (!empty($conf->banque->enabled) && $_POST[
"paymentsave"] !=
'none') {
249 if ($_POST[
"subscription"]) {
250 if (!$_POST[
"label"]) $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label"));
251 if ($_POST[
"paymentsave"] !=
'invoiceonly' && !$_POST[
"operation"]) $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode"));
252 if ($_POST[
"paymentsave"] !=
'invoiceonly' && !($_POST[
"accountid"] > 0)) $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"FinancialAccount"));
254 if ($_POST[
"accountid"]) $errmsg = $langs->trans(
"ErrorDoNotProvideAccountsIfNullAmount");
260 $action =
'addsubscription';
267 if (!$error && $action ==
'subscription') {
271 $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend);
274 $errmsg = $object->error;
279 $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque);
292 $action =
'addsubscription';
302 if ($object->email && $sendalsoemail) {
304 'datesubscription' => $datesubscription,
306 'ccountid' => $accountid,
307 'operation' => $operation,
309 'num_chq' => $num_chq,
310 'emetteur_nom' => $emetteur_nom,
311 'emetteur_banque' => $emetteur_banque,
312 'datesubend' => $datesubend
314 $reshook = $hookmanager->executeHooks(
'sendMail', $parameters, $object, $action);
319 if (empty($reshook)) {
324 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
328 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
330 $outputlangs->loadLangs(array(
"main",
"members"));
333 $arraydefaultmessage = null;
334 $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
336 if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
338 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
339 $subject = $arraydefaultmessage->topic;
340 $msg = $arraydefaultmessage->content;
350 $listofpaths = array();
351 $listofnames = array();
352 $listofmimes = array();
353 if (is_object($object->invoice) && (!is_object($arraydefaultmessage) || intval($arraydefaultmessage->joinfiles))) {
354 $invoicediroutput = $conf->facture->dir_output;
355 $fileparams =
dol_most_recent_file($invoicediroutput.
'/'.$object->invoice->ref, preg_quote($object->invoice->ref,
'/').
'[^\-]+');
356 $file = $fileparams[
'fullname'];
358 $listofpaths = array($file);
359 $listofnames = array(basename($file));
363 $moreinheader =
'X-Dolibarr-Info: send_an_email by adherents/subscription.php'.
"\r\n";
365 $result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
'', $moreinheader);
367 $errmsg = $object->error;
370 setEventMessages($langs->trans(
"EmailSentToMember", $object->email), null,
'mesgs');
380 $_POST[
"subscription"] =
'';
381 $_POST[
"accountid"] =
'';
382 $_POST[
"operation"] =
'';
383 $_POST[
"label"] =
'';
384 $_POST[
"num_chq"] =
'';
395 $form =
new Form($db);
399 $title = $langs->trans(
"Member").
" - ".$langs->trans(
"Subscriptions");
400 $helpurl =
"EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros";
405 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
406 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
407 $param .=
'&id='.$rowid;
408 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
414 $res = $object->fetch($rowid);
417 $adht->fetch($object->typeid);
422 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++;
423 if (!empty($conf->societe->enabled)) $rowspan++;
425 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
426 print '<input type="hidden" name="token" value="'.newToken().
'">';
427 print '<input type="hidden" name="rowid" value="'.$object->id.
'">';
431 $linkback =
'<a href="'.DOL_URL_ROOT.
'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
435 print '<div class="fichecenter">';
436 print '<div class="fichehalfleft">';
438 print '<div class="underbanner clearboth"></div>';
439 print '<table class="border centpercent tableforfield">';
442 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
443 print '<tr><td class="titlefield">'.$langs->trans(
"Login").
' / '.$langs->trans(
"Id").
'</td><td class="valeur">'.$object->login.
' </td></tr>';
447 print '<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td class="valeur">'.$adht->getNomUrl(1).
"</td></tr>\n";
450 print '<tr><td>'.$langs->trans(
"MemberNature").
'</td><td class="valeur" >'.$object->getmorphylib().
'</td>';
454 print '<tr><td>'.$langs->trans(
"Gender").
'</td>';
456 if ($object->gender)
print $langs->trans(
"Gender".$object->gender);
460 print '<tr><td>'.$langs->trans(
"Company").
'</td><td class="valeur">'.$object->company.
'</td></tr>';
463 print '<tr><td>'.$langs->trans(
"UserTitle").
'</td><td class="valeur">'.$object->getCivilityLabel().
' </td>';
467 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
468 print '<tr><td>'.$langs->trans(
"Password").
'</td><td>'.preg_replace(
'/./i',
'*', $object->pass);
470 print preg_replace(
'/./i',
'*', $object->pass);
473 print $langs->trans(
"Crypted").
': '.$object->pass_indatabase_crypted;
475 print $langs->trans(
"Hidden");
478 if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) {
479 $langs->load(
"errors");
480 $htmltext = $langs->trans(
"WarningPasswordSetWithNoAccount");
481 print ' '.$form->textwithpicto(
'', $htmltext, 1,
'warning');
487 print '<tr><td>'.$langs->trans(
"SubscriptionEndDate").
'</td><td class="valeur">';
488 if ($object->datefin) {
490 if ($object->hasDelay()) {
491 print " ".img_warning($langs->trans(
"Late"));
494 if (!$adht->subscription) {
495 print $langs->trans(
"SubscriptionNotRecorded");
496 if ($object->statut > 0)
print " ".img_warning($langs->trans(
"Late"));
498 print $langs->trans(
"SubscriptionNotReceived");
499 if ($object->statut > 0)
print " ".img_warning($langs->trans(
"Late"));
507 print '<div class="fichehalfright"><div class="ficheaddleft">';
509 print '<div class="underbanner clearboth"></div>';
510 print '<table class="border tableforfield" width="100%">';
513 print '<tr><td class="titlefield">'.$langs->trans(
"DateOfBirth").
'</td><td class="valeur">'.
dol_print_date($object->birth,
'day').
'</td></tr>';
516 print '<tr><td>'.$langs->trans(
"Public").
'</td><td class="valeur">'.
yn($object->public).
'</td></tr>';
519 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
520 print '<tr><td>'.$langs->trans(
"Categories").
'</td>';
521 print '<td colspan="2">';
522 print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1);
528 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
531 if (!empty($conf->societe->enabled)) {
533 print '<table class="nobordernopadding" width="100%"><tr><td>';
534 print $langs->trans(
"LinkedToDolibarrThirdParty");
536 if ($action !=
'editthirdparty' && $user->rights->adherent->creer)
print '<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editthirdparty&rowid='.$object->id.
'">'.
img_edit($langs->trans(
'SetLinkToThirdParty'), 1).
'</a></td>';
537 print '</tr></table>';
538 print
'</td><td colspan="2" class="valeur">';
539 if ($action ==
'editthirdparty') {
541 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'" name="form'.$htmlname.
'">';
542 print
'<input type="hidden" name="rowid" value="'.$object->id.
'">';
543 print
'<input type="hidden" name="action" value="set'.$htmlname.
'">';
544 print
'<input type="hidden" name="token" value="'.newToken().
'">';
545 print
'<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
547 print $form->select_company($object->fk_soc,
'socid',
'', 1);
549 print
'<td class="left"><input type="submit" class="button" value="'.$langs->trans(
"Modify").
'"></td>';
550 print
'</tr></table></form>';
552 if ($object->fk_soc) {
554 $result = $company->fetch($object->fk_soc);
555 print $company->getNomUrl(1);
557 print $langs->trans(
"NoThirdPartyAssociatedToMember");
565 print
'<table class="nobordernopadding" width="100%"><tr><td>';
566 print $langs->trans(
"LinkedToDolibarrUser");
568 if ($action !=
'editlogin' && $user->rights->adherent->creer) {
569 print
'<td class="right">';
570 if ($user->rights->user->user->creer) {
571 print
'<a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editlogin&rowid='.$object->id.
'">'.
img_edit($langs->trans(
'SetLinkToUser'), 1).
'</a>';
575 print
'</tr></table>';
576 print
'</td><td colspan="2" class="valeur">';
577 if ($action ==
'editlogin') {
578 $form->form_users(
$_SERVER[
'PHP_SELF'].
'?rowid='.$object->id, $object->user_id,
'userid',
'');
580 if ($object->user_id) {
581 $form->form_users(
$_SERVER[
'PHP_SELF'].
'?rowid='.$object->id, $object->user_id,
'none');
582 }
else print $langs->trans(
"NoDolibarrAccess");
588 print
"</div></div></div>\n";
589 print
'<div style="clear:both"></div>';
601 if ($user->rights->adherent->cotisation->creer) {
602 if ($action !=
'addsubscription' && $action !=
'create_thirdparty') {
603 print
'<div class="tabsAction">';
605 if ($object->statut > 0) print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$rowid.
'&action=addsubscription">'.$langs->trans(
"AddSubscription").
"</a></div>";
606 else print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"ValidateBefore")).
'">'.$langs->trans(
"AddSubscription").
'</a></div>';
615 if ($action !=
'addsubscription' && $action !=
'create_thirdparty') {
616 $sql =
"SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,";
617 $sql .=
" c.rowid as crowid, c.subscription,";
618 $sql .=
" c.datec, c.fk_type as cfk_type,";
619 $sql .=
" c.dateadh as dateh,";
621 $sql .=
" c.fk_bank,";
622 $sql .=
" b.rowid as bid,";
623 $sql .=
" ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code";
624 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as d, ".MAIN_DB_PREFIX.
"subscription as c";
625 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON c.fk_bank = b.rowid";
626 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account as ba ON b.fk_account = ba.rowid";
627 $sql .=
" WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid;
628 $sql .= $db->order($sortfield, $sortorder);
630 $result = $db->query($sql);
634 $num = $db->num_rows($result);
636 print
'<table class="noborder centpercent">'.
"\n";
638 print
'<tr class="liste_titre">';
645 if (!empty($conf->banque->enabled)) {
650 $accountstatic =
new Account($db);
656 $objp = $db->fetch_object($result);
658 $adh->id = $objp->rowid;
659 $adh->typeid = $objp->type;
661 $subscriptionstatic->ref = $objp->crowid;
662 $subscriptionstatic->id = $objp->crowid;
664 $typeid = $objp->cfk_type;
666 $adht->fetch($typeid);
669 print
'<tr class="oddeven">';
670 print
'<td>'.$subscriptionstatic->getNomUrl(1).
'</td>';
671 print
'<td class="center">'.dol_print_date($db->jdate($objp->datec),
'dayhour').
"</td>\n";
672 print
'<td class="center">';
674 print $adht->getNomUrl(1);
677 print
'<td class="center">'.dol_print_date($db->jdate($objp->dateh),
'day').
"</td>\n";
678 print
'<td class="center">'.dol_print_date($db->jdate($objp->datef),
'day').
"</td>\n";
679 print
'<td class="right">'.price($objp->subscription).
'</td>';
680 if (!empty($conf->banque->enabled)) {
681 print
'<td class="right">';
683 $accountstatic->label = $objp->label;
684 $accountstatic->id = $objp->baid;
685 $accountstatic->number = $objp->number;
686 $accountstatic->account_number = $objp->account_number;
687 $accountstatic->currency_code = $objp->currency_code;
689 if (!empty($conf->accounting->enabled) && $objp->fk_accountancy_journal > 0) {
691 $accountingjournal->fetch($objp->fk_accountancy_journal);
693 $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
696 $accountstatic->ref = $objp->ref;
697 print $accountstatic->getNomUrl(1);
709 if (!empty($conf->banque->enabled)) $colspan++;
710 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
720 if (($action !=
'addsubscription' && $action !=
'create_thirdparty')) {
722 $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled));
724 if ($useonlinepayment) {
727 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
728 print showOnlinePaymentUrl(
'membersubscription', $object->ref);
736 if (($action ==
'addsubscription' || $action ==
'create_thirdparty') && $user->rights->adherent->cotisation->creer) {
746 if (
GETPOST(
'paymentsave') ==
'bankdirect') $bankdirect = 1;
747 if (
GETPOST(
'paymentsave') ==
'invoiceonly') $invoiceonly = 1;
748 if (
GETPOST(
'paymentsave') ==
'bankviainvoice') $bankviainvoice = 1;
750 if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'bankviainvoice' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $bankviainvoice = 1;
751 elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'bankdirect' && !empty($conf->banque->enabled)) $bankdirect = 1;
752 elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $invoiceonly = 1;
755 print "\
n\
n<!--
Form add subscription -->\
n";
757 if ($conf->use_javascript_ajax) {
759 print
"\n".
'<script type="text/javascript" language="javascript">';
760 print
'$(document).ready(function () {
761 $(".bankswitchclass, .bankswitchclass2").'.(($bankdirect || $bankviainvoice) ?
'show()' :
'hide()').
';
762 $("#none, #invoiceonly").click(function() {
763 $(".bankswitchclass").hide();
764 $(".bankswitchclass2").hide();
766 $("#bankdirect, #bankviainvoice").click(function() {
767 $(".bankswitchclass").show();
768 $(".bankswitchclass2").show();
770 $("#selectoperation").change(function() {
771 var code = $(this).val();
774 $(".fieldrequireddyn").addClass("fieldrequired");
775 if ($("#fieldchqemetteur").val() == "")
777 $("#fieldchqemetteur").val($("#memberlabel").val());
782 $(".fieldrequireddyn").removeClass("fieldrequired");
786 if (
GETPOST(
'paymentsave')) print
'$("#'.
GETPOST(
'paymentsave').
'").prop("checked",true);';
788 print
'</script>'.
"\n";
793 if ($action ==
'create_thirdparty') {
795 $fullname = $object->getFullName($langs);
797 if ($object->morphy ==
'mor') {
798 $companyname = $object->company;
799 if (!empty($fullname)) $companyalias = $fullname;
801 $companyname = $fullname;
802 if (!empty($object->company)) $companyalias = $object->company;
806 $formquestion = array(
807 array(
'label' => $langs->trans(
"NameToCreate"),
'type' =>
'text',
'name' =>
'companyname',
'value' => $companyname,
'morecss' =>
'minwidth300',
'moreattr' =>
'maxlength="128"'),
808 array(
'label' => $langs->trans(
"AliasNames"),
'type' =>
'text',
'name' =>
'companyalias',
'value' => $companyalias,
'morecss' =>
'minwidth300',
'moreattr' =>
'maxlength="128"')
811 if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) {
812 $tmpcompany =
new Societe($db);
813 $tmpcompany->name = $companyname;
814 $tmpcompany->get_codeclient($tmpcompany, 0);
815 $customercode = $tmpcompany->code_client;
816 $formquestion[] = array(
817 'label' => $langs->trans(
"CustomerCode"),
819 'name' =>
'customercode',
820 'value' => $customercode,
821 'morecss' =>
'minwidth300',
822 'moreattr' =>
'maxlength="128"',
827 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?rowid=".$object->id, $langs->trans(
"CreateDolibarrThirdParty"), $langs->trans(
"ConfirmCreateThirdParty"),
"confirm_create_thirdparty", $formquestion, 1);
831 print
'<form name="subscription" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
832 print
'<input type="hidden" name="token" value="'.newToken().
'">';
833 print
'<input type="hidden" name="action" value="subscription">';
834 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
835 print
'<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).
'">';
836 print
'<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($object->company).
'">';
840 print
"<table class=\"border\" width=\"100%\">\n";
855 print
'<td class="fieldrequired">'.$langs->trans(
"DateSubscription").
'</td><td>';
860 $datefrom = $object->datevalid;
861 if ($object->datefin > 0) {
865 print $form->selectDate($datefrom,
'',
'',
'',
'',
"subscription", 1, 1);
875 print
'<tr><td>'.$langs->trans(
"DateEndSubscription").
'</td><td>';
876 print $form->selectDate($dateto,
'end',
'',
'',
'',
"subscription", 1, 0);
879 if ($adht->subscription) {
881 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Amount").
'</td><td><input type="text" name="subscription" size="6" value="'.
GETPOST(
'subscription').
'"> '.$langs->trans(
"Currency".$conf->currency).
'</td></tr>';
884 print
'<tr><td>'.$langs->trans(
"Label").
'</td>';
885 print
'<td><input name="label" type="text" size="32" value="';
886 if (empty($conf->global->MEMBER_NO_DEFAULT_LABEL)) print $langs->trans(
"Subscription").
' '.
dol_print_date(($datefrom ? $datefrom : time()),
"%Y");
887 print
'"></td></tr>';
890 if ((!empty($conf->banque->enabled) || !empty($conf->facture->enabled)) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) {
892 if ($object->fk_soc) {
893 $result = $company->fetch($object->fk_soc);
900 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'MoreActions');
903 print
'<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"'.(empty($bankdirect) && empty($invoiceonly) && empty($bankviainvoice) ?
' checked' :
'').
'> '.$langs->trans(
"None").
'<br>';
905 if (!empty($conf->banque->enabled)) {
906 print
'<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"'.(!empty($bankdirect) ?
' checked' :
'');
907 print
'> '.$langs->trans(
"MoreActionBankDirect").
'<br>';
910 if (!empty($conf->societe->enabled) && !empty($conf->facture->enabled)) {
911 print
'<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(!empty($invoiceonly) ?
' checked' :
'');
913 print
'> '.$langs->trans(
"MoreActionInvoiceOnly");
914 if ($object->fk_soc) print
' ('.$langs->trans(
"ThirdParty").
': '.$company->getNomUrl(1).
')';
917 if (empty($object->fk_soc)) print
img_warning($langs->trans(
"NoThirdPartyAssociatedToMember"));
918 print $langs->trans(
"NoThirdPartyAssociatedToMember");
919 print
' - <a href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$object->id.
'&action=create_thirdparty">';
920 print $langs->trans(
"CreateDolibarrThirdParty");
923 if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS !=
'defaultforfoundationcountry') print
'. <span class="opacitymedium">'.$langs->trans(
"NoVatOnSubscription", 0).
'</span>';
924 if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
926 $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
930 print
'. '.$langs->transnoentitiesnoconv(
"ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1));
935 if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) {
936 print
'<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(!empty($bankviainvoice) ?
' checked' :
'');
938 print
'> '.$langs->trans(
"MoreActionBankViaInvoice");
939 if ($object->fk_soc) print
' ('.$langs->trans(
"ThirdParty").
': '.$company->getNomUrl(1).
')';
942 if (empty($object->fk_soc)) print
img_warning($langs->trans(
"NoThirdPartyAssociatedToMember"));
943 print $langs->trans(
"NoThirdPartyAssociatedToMember");
944 print
' - <a href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$object->id.
'&action=create_thirdparty">';
945 print $langs->trans(
"CreateDolibarrThirdParty");
948 if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS !=
'defaultforfoundationcountry') print
'. <span class="opacitymedium">'.$langs->trans(
"NoVatOnSubscription", 0).
'</span>';
949 if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
951 $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
955 print
'. '.$langs->transnoentitiesnoconv(
"ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1));
962 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"FinancialAccount").
'</td><td>';
963 $form->select_comptes(
GETPOST(
'accountid'),
'accountid', 0,
'', 2);
964 print
"</td></tr>\n";
967 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
968 $form->select_types_paiements(
GETPOST(
'operation'),
'operation',
'', 2);
969 print
"</td></tr>\n";
972 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"DatePayment").
'</td><td>';
973 print $form->selectDate(isset($paymentdate) ? $paymentdate : -1,
'payment', 0, 0, 1,
'subscription', 1, 1);
974 print
"</td></tr>\n";
976 print
'<tr class="bankswitchclass2"><td>'.$langs->trans(
'Numero');
977 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
979 print
'<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(!
GETPOST(
'num_chq') ?
'' :
GETPOST(
'num_chq')).
'"></td></tr>';
981 print
'<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans(
'CheckTransmitter');
982 print
' <em>('.$langs->trans(
"ChequeMaker").
')</em>';
984 print
'<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(!
GETPOST(
'chqemetteur') ?
'' :
GETPOST(
'chqemetteur')).
'"></td></tr>';
986 print
'<tr class="bankswitchclass2"><td>'.$langs->trans(
'Bank');
987 print
' <em>('.$langs->trans(
"ChequeBank").
')</em>';
989 print
'<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(!
GETPOST(
'chqbank') ?
'' :
GETPOST(
'chqbank')).
'"></td></tr>';
993 print
'<tr><td></td><td></td></tr>';
995 print
'<tr><td>'.$langs->trans(
"SendAcknowledgementByMail").
'</td>';
997 if (!$object->email) {
998 print $langs->trans(
"NoEMail");
1001 $adht->fetch($object->typeid);
1008 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1011 $outputlangs =
new Translate(
'', $conf);
1012 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
1014 $outputlangs->loadLangs(array(
"main",
"members"));
1016 $arraydefaultmessage = null;
1017 $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
1019 if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
1021 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1022 $subject = $arraydefaultmessage->topic;
1023 $msg = $arraydefaultmessage->content;
1031 $tmp =
'<input name="sendmail" type="checkbox"'.(GETPOST(
'sendmail',
'alpha') ?
' checked' : (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ?
' checked' :
'')).
'>';
1033 $helpcontent .=
'<b>'.$langs->trans(
"MailFrom").
'</b>: '.$conf->global->ADHERENT_MAIL_FROM.
'<br>'.
"\n";
1034 $helpcontent .=
'<b>'.$langs->trans(
"MailRecipient").
'</b>: '.$object->email.
'<br>'.
"\n";
1035 $helpcontent .=
'<b>'.$langs->trans(
"MailTopic").
'</b>:<br>'.
"\n";
1036 if ($subjecttosend) {
1037 $helpcontent .= $subjecttosend.
"\n";
1039 $langs->load(
"errors");
1040 $helpcontent .=
'<span class="error">'.$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Module310Name")).
'</span>'.
"\n";
1042 $helpcontent .=
"<br>";
1043 $helpcontent .=
'<b>'.$langs->trans(
"MailText").
'</b>:<br>';
1047 $langs->load(
"errors");
1048 $helpcontent .=
'<span class="error">'.$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Module310Name")).
'</span>'.
"\n";
1050 print $form->textwithpicto($tmp, $helpcontent, 1,
'help',
'', 0, 2,
'helpemailtosend');
1058 print
'<div class="center">';
1059 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"AddSubscription").
'">';
1060 print
' ';
1061 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1066 print
"\n<!-- End form subscription -->\n\n";
1072 $langs->load(
"errors");
1073 print $langs->trans(
"ErrorRecordNotFound");
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Class to manage products or services.
dol_now($mode= 'auto')
Return date for now.
setEventMessage($mesgs, $style= 'mesgs')
Set event message in dol_events session object.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom= 'UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
member_prepare_head(Adherent $object)
Return array head with list of tabs to view object informations.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
Class to manage bank accounts.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_mimetype($file, $default= 'application/octet-stream', $mode=0)
Return mime type of a file.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
Class to manage members of a foundation.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
Class to manage translations.
Class to manage members type.
Class to manage subscriptions of foundation members.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_most_recent_file($dir, $regexfilter= '', $excludefilter=array('(\.meta|_preview.*\.png)$', '^\.'), $nohook=false, $mode= '')
Return file(s) into a directory (by default most recent)
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
print $_SERVER["PHP_SELF"] n
Edit parameters.
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
Class to manage accounting accounts.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...