31 require
'../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/member.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
42 $langs->loadLangs(array(
"companies",
"bills",
"members",
"users",
"mails",
'other'));
44 $optioncss =
GETPOST(
'optioncss',
'aZ');
46 $action =
GETPOST(
'action',
'aZ09');
47 $confirm =
GETPOST(
'confirm',
'alpha');
50 $ref =
GETPOST(
'ref',
'alphanohtml');
51 $typeid =
GETPOST(
'typeid',
'int');
55 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
56 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
57 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
59 if (empty($page) || $page == -1) {
62 $offset = $limit * $page;
63 $pageprev = $page - 1;
64 $pagenext = $page + 1;
68 $sortfield =
"c.rowid";
79 $extrafields->fetch_name_optionals_label($object->table_element);
84 $hookmanager->initHooks(array(
'subscription'));
87 $hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
88 $hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
89 $hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
96 if ($id > 0 || !empty($ref)) {
98 $result = $object->fetch($id, $ref);
101 $canadduser = ($user->admin || $user->hasRight(
"user",
"user",
"creer"));
103 if ($object->user_id) {
105 $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight(
"user",
"self",
"creer"))
106 || (($user->id != $object->user_id) && $user->hasRight(
"user",
"user",
"creer")));
107 $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight(
"user",
"self",
"password"))
108 || (($user->id != $object->user_id) && $user->hasRight(
"user",
"user",
"password")));
113 $canaddmember = $user->hasRight(
'adherent',
'creer');
116 $caneditfieldmember = $user->hasRight(
'adherent',
'creer');
120 $result =
restrictedArea($user,
'adherent', $object->id,
'',
'',
'socid',
'rowid', 0);
127 $parameters = array();
128 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
134 if (empty($reshook) && $action ==
'confirm_create_thirdparty' && $confirm ==
'yes' && $user->rights->societe->creer) {
138 $result = $company->create_from_member($object,
GETPOST(
'companyname',
'alpha'),
GETPOST(
'companyalias',
'alpha'),
GETPOST(
'customercode',
'alpha'));
141 $langs->load(
"errors");
144 $action =
'addsubscription';
151 if (empty($reshook) && $action ==
'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) {
153 if (empty($user->rights->user->user->creer)) {
154 if (
GETPOST(
"userid",
'int') != $user->id &&
GETPOST(
"userid",
'int') != $object->user_id) {
156 setEventMessages($langs->trans(
"ErrorUserPermissionAllowsToLinksToItselfOnly"),
null,
'errors');
161 if (
GETPOST(
"userid",
'int') != $object->user_id) {
162 $result = $object->setUserId(
GETPOST(
"userid",
'int'));
171 if (empty($reshook) && $action ==
'setsocid') {
174 if (
GETPOST(
'socid',
'int') != $object->fk_soc) {
175 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
176 $sql .=
" WHERE fk_soc = '".GETPOST(
'socid',
'int').
"'";
177 $resql = $db->query($sql);
179 $obj = $db->fetch_object(
$resql);
180 if ($obj && $obj->rowid > 0) {
182 $othermember->fetch($obj->rowid);
183 $thirdparty =
new Societe($db);
184 $thirdparty->fetch(
GETPOST(
'socid',
'int'));
186 setEventMessages($langs->trans(
"ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name),
null,
'errors');
191 $result = $object->setThirdPartyId(
GETPOST(
'socid',
'int'));
201 if ($user->rights->adherent->cotisation->creer && $action ==
'subscription' && !$cancel) {
204 $langs->load(
"banks");
206 $result = $object->fetch($rowid);
207 $result = $adht->fetch($object->typeid);
210 $datesubscription = 0;
212 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
213 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
221 if (
GETPOST(
"paymentyear",
'int') &&
GETPOST(
"paymentmonth",
'int') &&
GETPOST(
"paymentday",
'int')) {
228 $accountid =
GETPOST(
"accountid",
'int');
229 $operation =
GETPOST(
"operation",
"alphanohtml");
230 $num_chq =
GETPOST(
"num_chq",
"alphanohtml");
231 $emetteur_nom =
GETPOST(
"chqemetteur");
232 $emetteur_banque =
GETPOST(
"chqbank");
233 $option =
GETPOST(
"paymentsave");
234 if (empty($option)) {
237 $sendalsoemail =
GETPOST(
"sendmail",
'alpha');
240 if (!$datesubscription) {
242 $langs->load(
"errors");
243 $errmsg = $langs->trans(
"ErrorBadDateFormat", $langs->transnoentitiesnoconv(
"DateSubscription"));
245 $action =
'addsubscription';
247 if (
GETPOST(
'end') && !$datesubend) {
249 $langs->load(
"errors");
250 $errmsg = $langs->trans(
"ErrorBadDateFormat", $langs->transnoentitiesnoconv(
"DateEndSubscription"));
252 $action =
'addsubscription';
257 if (($option ==
'bankviainvoice' || $option ==
'bankdirect') && !$paymentdate) {
259 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DatePayment"));
261 $action =
'addsubscription';
265 if ($adht->subscription) {
266 if (!is_numeric($amount)) {
268 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount"));
271 $action =
'addsubscription';
277 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label"));
280 $action =
'addsubscription';
282 if (
GETPOST(
"paymentsave") !=
'invoiceonly' && !
GETPOST(
"operation")) {
283 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode"));
286 $action =
'addsubscription';
288 if (
GETPOST(
"paymentsave") !=
'invoiceonly' && !(
GETPOST(
"accountid",
'int') > 0)) {
289 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"FinancialAccount"));
292 $action =
'addsubscription';
295 if (
GETPOST(
"accountid",
'int')) {
296 $errmsg = $langs->trans(
"ErrorDoNotProvideAccountsIfNullAmount");
299 $action =
'addsubscription';
307 if (!$error && $action ==
'subscription') {
311 $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend);
314 $errmsg = $object->error;
319 $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque);
332 $action =
'addsubscription';
342 if ($object->email && $sendalsoemail) {
344 'datesubscription' => $datesubscription,
346 'ccountid' => $accountid,
347 'operation' => $operation,
349 'num_chq' => $num_chq,
350 'emetteur_nom' => $emetteur_nom,
351 'emetteur_banque' => $emetteur_banque,
352 'datesubend' => $datesubend
354 $reshook = $hookmanager->executeHooks(
'sendMail', $parameters, $object, $action);
359 if (empty($reshook)) {
364 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
368 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
370 $outputlangs->loadLangs(array(
"main",
"members"));
373 $arraydefaultmessage =
null;
374 $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
376 if (!empty($labeltouse)) {
377 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
380 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
381 $subject = $arraydefaultmessage->topic;
382 $msg = $arraydefaultmessage->content;
392 $listofpaths = array();
393 $listofnames = array();
394 $listofmimes = array();
395 if (is_object($object->invoice) && (!is_object($arraydefaultmessage) || intval($arraydefaultmessage->joinfiles))) {
396 $invoicediroutput = $conf->facture->dir_output;
397 $fileparams =
dol_most_recent_file($invoicediroutput.
'/'.$object->invoice->ref, preg_quote($object->invoice->ref,
'/').
'[^\-]+');
398 $file = $fileparams[
'fullname'];
400 $listofpaths = array($file);
401 $listofnames = array(basename($file));
405 $moreinheader =
'X-Dolibarr-Info: send_an_email by adherents/subscription.php'.
"\r\n";
407 $result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
'', $moreinheader);
409 $errmsg = $object->error;
412 setEventMessages($langs->trans(
"EmailSentToMember", $object->email),
null,
'mesgs');
422 $_POST[
"subscription"] =
'';
423 $_POST[
"accountid"] =
'';
424 $_POST[
"operation"] =
'';
425 $_POST[
"label"] =
'';
426 $_POST[
"num_chq"] =
'';
441 $title = $langs->trans(
"Member").
" - ".$langs->trans(
"Subscriptions");
443 $help_url =
"EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder";
449 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
450 $param .=
'&contextpage='.urlencode($contextpage);
452 if ($limit > 0 && $limit != $conf->liste_limit) {
453 $param .=
'&limit='.urlencode($limit);
455 $param .=
'&id='.$rowid;
456 if ($optioncss !=
'') {
457 $param .=
'&optioncss='.urlencode($optioncss);
464 $res = $object->fetch($rowid);
470 $adht->fetch($object->typeid);
472 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
473 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
478 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
485 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
486 print
'<input type="hidden" name="token" value="'.newToken().
'">';
487 print
'<input type="hidden" name="rowid" value="'.$object->id.
'">';
491 $linkback =
'<a href="'.DOL_URL_ROOT.
'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
493 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/adherents/vcard.php?id='.$object->id.
'" class="refid">';
494 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
495 $morehtmlref .=
'</a>';
497 dol_banner_tab($object,
'rowid', $linkback, 1,
'rowid',
'ref', $morehtmlref);
499 print
'<div class="fichecenter">';
500 print
'<div class="fichehalfleft">';
502 print
'<div class="underbanner clearboth"></div>';
503 print
'<table class="border centpercent tableforfield">';
506 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
507 print
'<tr><td class="titlefield">'.$langs->trans(
"Login").
' / '.$langs->trans(
"Id").
'</td><td class="valeur">'.
dol_escape_htmltag($object->login).
'</td></tr>';
511 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td>';
512 print
'<td class="valeur">'.$adht->getNomUrl(1).
"</td></tr>\n";
515 print
'<tr><td>'.$langs->trans(
"MemberNature").
'</td>';
516 print
'<td class="valeur" >'.$object->getmorphylib(
'', 1).
'</td>';
520 print
'<tr><td>'.$langs->trans(
"Company").
'</td><td class="valeur">'.
dol_escape_htmltag($object->company).
'</td></tr>';
523 print
'<tr><td>'.$langs->trans(
"UserTitle").
'</td><td class="valeur">'.$object->getCivilityLabel().
'</td>';
527 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
528 print
'<tr><td>'.$langs->trans(
"Password").
'</td><td>';
530 print preg_replace(
'/./i',
'*', $object->pass);
533 print
'<!-- '.$langs->trans(
"Crypted").
': '.$object->pass_indatabase_crypted.
' -->';
535 print
'<span class="opacitymedium">'.$langs->trans(
"Hidden").
'</span>';
537 if (!empty($object->pass_indatabase) && empty($object->user_id)) {
538 $langs->load(
"errors");
539 $htmltext = $langs->trans(
"WarningPasswordSetWithNoAccount");
540 print
' '.$form->textwithpicto(
'', $htmltext, 1,
'warning');
546 print
'<tr><td>'.$langs->trans(
"SubscriptionEndDate").
'</td><td class="valeur">';
547 if ($object->datefin) {
549 if ($object->hasDelay()) {
550 print
" ".img_warning($langs->trans(
"Late"));
553 if ($object->need_subscription == 0) {
554 print $langs->trans(
"SubscriptionNotNeeded");
555 } elseif (!$adht->subscription) {
556 print $langs->trans(
"SubscriptionNotRecorded");
558 print
" ".img_warning($langs->trans(
"Late"));
561 print $langs->trans(
"SubscriptionNotReceived");
563 print
" ".img_warning($langs->trans(
"Late"));
573 print
'<div class="fichehalfright">';
574 print
'<div class="underbanner clearboth"></div>';
576 print
'<table class="border tableforfield centpercent">';
579 if (
isModEnabled(
'categorie') && !empty($user->rights->categorie->lire)) {
580 print
'<tr><td>'.$langs->trans(
"Categories").
'</td>';
581 print
'<td colspan="2">';
582 print
$form->showCategories($object->id, Categorie::TYPE_MEMBER, 1);
587 print
'<tr><td class="titlefield">'.$langs->trans(
"DateOfBirth").
'</td><td class="valeur">'.
dol_print_date($object->birth,
'day').
'</td></tr>';
590 print
'<tr><td>'.$langs->trans(
"Public").
'</td><td class="valeur">'.
yn($object->public).
'</td></tr>';
594 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
599 print
'<table class="nobordernopadding" width="100%"><tr><td>';
600 print $langs->trans(
"LinkedToDolibarrThirdParty");
602 if ($action !=
'editthirdparty' && $user->hasRight(
'adherent',
'creer')) {
603 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editthirdparty&token='.
newToken().
'&rowid='.$object->id.
'">'.
img_edit($langs->trans(
'SetLinkToThirdParty'), 1).
'</a></td>';
605 print
'</tr></table>';
606 print
'</td><td colspan="2" class="valeur">';
607 if ($action ==
'editthirdparty') {
609 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'" name="form'.$htmlname.
'">';
610 print
'<input type="hidden" name="rowid" value="'.$object->id.
'">';
611 print
'<input type="hidden" name="action" value="set'.$htmlname.
'">';
612 print
'<input type="hidden" name="token" value="'.newToken().
'">';
613 print
'<table class="nobordernopadding">';
615 print
$form->select_company($object->fk_soc,
'socid',
'', 1);
617 print
'<td class="left"><input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
618 print
'</tr></table></form>';
620 if ($object->fk_soc) {
622 $result = $company->fetch($object->fk_soc);
623 print $company->getNomUrl(1);
626 $tmparray = $company->getOutstandingBills(
'customer');
627 if (!empty($tmparray[
'refs'])) {
628 print
' - '.img_picto($langs->trans(
"Invoices"),
'bill',
'class="paddingright"').
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?socid='.$object->socid.
'">'.$langs->trans(
"Invoices").
' ('.count($tmparray[
'refs']).
')';
633 print
'<span class="opacitymedium">'.$langs->trans(
"NoThirdPartyAssociatedToMember").
'</span>';
641 print
'<table class="nobordernopadding" width="100%"><tr><td>';
642 print $langs->trans(
"LinkedToDolibarrUser");
644 if ($action !=
'editlogin' && $user->hasRight(
'adherent',
'creer')) {
645 print
'<td class="right">';
646 if ($user->hasRight(
"user",
"user",
"creer")) {
647 print
'<a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editlogin&token='.
newToken().
'&rowid='.$object->id.
'">'.
img_edit($langs->trans(
'SetLinkToUser'), 1).
'</a>';
651 print
'</tr></table>';
652 print
'</td><td colspan="2" class="valeur">';
653 if ($action ==
'editlogin') {
654 $form->form_users($_SERVER[
'PHP_SELF'].
'?rowid='.$object->id, $object->user_id,
'userid',
'');
656 if ($object->user_id) {
657 $linkeduser =
new User($db);
658 $linkeduser->fetch($object->user_id);
659 print $linkeduser->getNomUrl(-1);
661 print
'<span class="opacitymedium">'.$langs->trans(
"NoDolibarrAccess").
'</span>';
668 print
"</div></div>\n";
669 print
'<div style="clear:both"></div>';
679 if ($user->rights->adherent->cotisation->creer) {
680 if ($action !=
'addsubscription' && $action !=
'create_thirdparty') {
681 print
'<div class="tabsAction">';
683 if ($object->statut > 0) {
684 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$rowid.
'&action=addsubscription&token='.
newToken().
'">'.$langs->trans(
"AddSubscription").
"</a></div>";
686 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"ValidateBefore")).
'">'.$langs->trans(
"AddSubscription").
'</a></div>';
696 if ($action !=
'addsubscription' && $action !=
'create_thirdparty') {
697 $sql =
"SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,";
698 $sql .=
" c.rowid as crowid, c.subscription,";
699 $sql .=
" c.datec, c.fk_type as cfk_type,";
700 $sql .=
" c.dateadh as dateh,";
702 $sql .=
" c.fk_bank,";
703 $sql .=
" b.rowid as bid,";
704 $sql .=
" ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code";
705 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as d, ".MAIN_DB_PREFIX.
"subscription as c";
706 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON c.fk_bank = b.rowid";
707 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account as ba ON b.fk_account = ba.rowid";
708 $sql .=
" WHERE d.rowid = c.fk_adherent AND d.rowid=".((int) $rowid);
709 $sql .= $db->order($sortfield, $sortorder);
711 $result = $db->query($sql);
715 $num = $db->num_rows($result);
717 print
'<table class="noborder centpercent">'.
"\n";
719 print
'<tr class="liste_titre">';
721 print_liste_field_titre(
'DateCreation', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
723 print_liste_field_titre(
'DateStart', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
724 print_liste_field_titre(
'DateEnd', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
727 print_liste_field_titre(
'Account', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
731 $accountstatic =
new Account($db);
737 $objp = $db->fetch_object($result);
739 $adh->id = $objp->rowid;
740 $adh->typeid = $objp->type;
742 $subscriptionstatic->ref = $objp->crowid;
743 $subscriptionstatic->id = $objp->crowid;
745 $typeid = $objp->cfk_type;
747 $adht->fetch($typeid);
750 print
'<tr class="oddeven">';
751 print
'<td>'.$subscriptionstatic->getNomUrl(1).
'</td>';
752 print
'<td class="center">'.dol_print_date($db->jdate($objp->datec),
'dayhour').
"</td>\n";
753 print
'<td class="center">';
755 print $adht->getNomUrl(1);
758 print
'<td class="center">'.dol_print_date($db->jdate($objp->dateh),
'day').
"</td>\n";
759 print
'<td class="center">'.dol_print_date($db->jdate($objp->datef),
'day').
"</td>\n";
760 print
'<td class="right">'.price($objp->subscription).
'</td>';
762 print
'<td class="right">';
764 $accountstatic->label = $objp->label;
765 $accountstatic->id = $objp->baid;
766 $accountstatic->number = $objp->number;
767 $accountstatic->account_number = $objp->account_number;
768 $accountstatic->currency_code = $objp->currency_code;
770 if (
isModEnabled(
'accounting') && $objp->fk_accountancy_journal > 0) {
772 $accountingjournal->fetch($objp->fk_accountancy_journal);
774 $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
777 $accountstatic->ref = $objp->ref;
778 print $accountstatic->getNomUrl(1);
793 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
803 if (($action !=
'addsubscription' && $action !=
'create_thirdparty')) {
807 if ($useonlinepayment) {
810 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
811 print showOnlinePaymentUrl(
'membersubscription', $object->ref);
819 if (($action ==
'addsubscription' || $action ==
'create_thirdparty') && $user->rights->adherent->cotisation->creer) {
829 if (
GETPOST(
'paymentsave') ==
'bankdirect') {
832 if (
GETPOST(
'paymentsave') ==
'invoiceonly') {
835 if (
GETPOST(
'paymentsave') ==
'bankviainvoice') {
839 if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'bankviainvoice' &&
isModEnabled(
'banque') &&
isModEnabled(
'societe') &&
isModEnabled(
'facture')) {
841 } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'bankdirect' &&
isModEnabled(
'banque')) {
843 } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'invoiceonly' &&
isModEnabled(
'banque') &&
isModEnabled(
'societe') &&
isModEnabled(
'facture')) {
848 print
"\n\n<!-- Form add subscription -->\n";
850 if ($conf->use_javascript_ajax) {
852 print
"\n".
'<script type="text/javascript">';
853 print
'$(document).ready(function () {
854 $(".bankswitchclass, .bankswitchclass2").'.(($bankdirect || $bankviainvoice) ?
'show()' :
'hide()').
';
855 $("#none, #invoiceonly").click(function() {
856 $(".bankswitchclass").hide();
857 $(".bankswitchclass2").hide();
859 $("#bankdirect, #bankviainvoice").click(function() {
860 $(".bankswitchclass").show();
861 $(".bankswitchclass2").show();
863 $("#selectoperation").change(function() {
864 var code = $(this).val();
867 $(".fieldrequireddyn").addClass("fieldrequired");
868 if ($("#fieldchqemetteur").val() == "")
870 $("#fieldchqemetteur").val($("#memberlabel").val());
875 $(".fieldrequireddyn").removeClass("fieldrequired");
880 print
'$("#'.GETPOST(
'paymentsave',
'aZ09').
'").prop("checked", true);';
883 print
'</script>'.
"\n";
888 if ($action ==
'create_thirdparty') {
890 $fullname = $object->getFullName($langs);
892 if ($object->morphy ==
'mor') {
893 $companyname = $object->company;
894 if (!empty($fullname)) {
895 $companyalias = $fullname;
898 $companyname = $fullname;
899 if (!empty($object->company)) {
900 $companyalias = $object->company;
905 $formquestion = array(
906 array(
'label' => $langs->trans(
"NameToCreate"),
'type' =>
'text',
'name' =>
'companyname',
'value' => $companyname,
'morecss' =>
'minwidth300',
'moreattr' =>
'maxlength="128"'),
907 array(
'label' => $langs->trans(
"AliasNames"),
'type' =>
'text',
'name' =>
'companyalias',
'value' => $companyalias,
'morecss' =>
'minwidth300',
'moreattr' =>
'maxlength="128"')
910 if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) {
911 $tmpcompany =
new Societe($db);
912 $tmpcompany->name = $companyname;
913 $tmpcompany->get_codeclient($tmpcompany, 0);
914 $customercode = $tmpcompany->code_client;
915 $formquestion[] = array(
916 'label' => $langs->trans(
"CustomerCode"),
918 'name' =>
'customercode',
919 'value' => $customercode,
920 'morecss' =>
'minwidth300',
921 'moreattr' =>
'maxlength="128"',
926 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?rowid=".$object->id, $langs->trans(
"CreateDolibarrThirdParty"), $langs->trans(
"ConfirmCreateThirdParty"),
"confirm_create_thirdparty", $formquestion, 1);
930 print
'<form name="subscription" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
931 print
'<input type="hidden" name="token" value="'.newToken().
'">';
932 print
'<input type="hidden" name="action" value="subscription">';
933 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
934 print
'<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).
'">';
935 print
'<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($object->company).
'">';
939 print
"<table class=\"border\" width=\"100%\">\n";
951 print
'<td class="fieldrequired">'.$langs->trans(
"DateSubscription").
'</td><td>';
956 $datefrom = $object->datevalid;
963 print
$form->selectDate($datefrom,
'',
'',
'',
'',
"subscription", 1, 1);
973 print
'<tr><td>'.$langs->trans(
"DateEndSubscription").
'</td><td>';
974 print
$form->selectDate($dateto,
'end',
'',
'',
'',
"subscription", 1, 0);
977 if ($adht->subscription) {
979 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Amount").
'</td><td><input type="text" name="subscription" size="6" value="'.
price(
GETPOSTISSET(
'subscription') ?
GETPOST(
'subscription') : $adht->amount).
'"> '.$langs->trans(
"Currency".$conf->currency) .
'</td></tr>';
982 print
'<tr><td>'.$langs->trans(
"Label").
'</td>';
983 print
'<td><input name="label" type="text" size="32" value="';
984 if (empty($conf->global->MEMBER_NO_DEFAULT_LABEL)) {
985 print $langs->trans(
"Subscription").
' '.
dol_print_date(($datefrom ? $datefrom : time()),
"%Y");
987 print
'"></td></tr>';
990 if ((
isModEnabled(
'banque') ||
isModEnabled(
'facture')) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) {
992 if ($object->fk_soc) {
993 $result = $company->fetch($object->fk_soc);
1000 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'MoreActions');
1003 print
'<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"'.(empty($bankdirect) && empty($invoiceonly) && empty($bankviainvoice) ?
' checked' :
'').
'>';
1004 print
'<label for="none"> '.$langs->trans(
"None").
'</label><br>';
1007 print
'<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"'.(!empty($bankdirect) ?
' checked' :
'');
1008 print
'><label for="bankdirect"> '.$langs->trans(
"MoreActionBankDirect").
'</label><br>';
1012 print
'<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(!empty($invoiceonly) ?
' checked' :
'');
1014 print
'><label for="invoiceonly"> '.$langs->trans(
"MoreActionInvoiceOnly");
1015 if ($object->fk_soc) {
1016 print
' ('.$langs->trans(
"ThirdParty").
': '.$company->getNomUrl(1).
')';
1019 if (empty($object->fk_soc)) {
1020 print
img_warning($langs->trans(
"NoThirdPartyAssociatedToMember"));
1022 print $langs->trans(
"NoThirdPartyAssociatedToMember");
1023 print
' - <a href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$object->id.
'&action=create_thirdparty">';
1024 print $langs->trans(
"CreateDolibarrThirdParty");
1027 if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS !=
'defaultforfoundationcountry') {
1028 print
'. <span class="opacitymedium">'.$langs->trans(
"NoVatOnSubscription", 0).
'</span>';
1030 if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (
isModEnabled(
'product') ||
isModEnabled(
'service'))) {
1032 $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
1036 print
'. '.$langs->transnoentitiesnoconv(
"ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1));
1038 print
'</label><br>';
1042 print
'<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(!empty($bankviainvoice) ?
' checked' :
'');
1044 print
'><label for="bankviainvoice"> '.$langs->trans(
"MoreActionBankViaInvoice");
1045 if ($object->fk_soc) {
1046 print
' ('.$langs->trans(
"ThirdParty").
': '.$company->getNomUrl(1).
')';
1049 if (empty($object->fk_soc)) {
1050 print
img_warning($langs->trans(
"NoThirdPartyAssociatedToMember"));
1052 print $langs->trans(
"NoThirdPartyAssociatedToMember");
1053 print
' - <a href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$object->id.
'&action=create_thirdparty">';
1054 print $langs->trans(
"CreateDolibarrThirdParty");
1057 if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS !=
'defaultforfoundationcountry') {
1058 print
'. <span class="opacitymedium">'.$langs->trans(
"NoVatOnSubscription", 0).
'</span>';
1060 if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (
isModEnabled(
'product')||
isModEnabled(
'service'))) {
1062 $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
1066 print
'. '.$langs->transnoentitiesnoconv(
"ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1));
1068 print
'</label><br>';
1073 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"FinancialAccount").
'</td><td>';
1075 $form->select_comptes(
GETPOST(
'accountid'),
'accountid', 0,
'', 2,
'', 0,
'minwidth200');
1076 print
"</td></tr>\n";
1079 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
1080 print
$form->select_types_paiements(
GETPOST(
'operation'),
'operation',
'', 2, 1, 0, 0, 1,
'minwidth200', 1);
1081 print
"</td></tr>\n";
1084 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"DatePayment").
'</td><td>';
1085 print
$form->selectDate(isset($paymentdate) ? $paymentdate : -1,
'payment', 0, 0, 1,
'subscription', 1, 1);
1086 print
"</td></tr>\n";
1088 print
'<tr class="bankswitchclass2"><td>'.$langs->trans(
'Numero');
1089 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
1091 print
'<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(!
GETPOST(
'num_chq') ?
'' :
GETPOST(
'num_chq')).
'"></td></tr>';
1093 print
'<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans(
'CheckTransmitter');
1094 print
' <em>('.$langs->trans(
"ChequeMaker").
')</em>';
1096 print
'<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(!
GETPOST(
'chqemetteur') ?
'' :
GETPOST(
'chqemetteur')).
'"></td></tr>';
1098 print
'<tr class="bankswitchclass2"><td>'.$langs->trans(
'Bank');
1099 print
' <em>('.$langs->trans(
"ChequeBank").
')</em>';
1101 print
'<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(!
GETPOST(
'chqbank') ?
'' :
GETPOST(
'chqbank')).
'"></td></tr>';
1105 print
'<tr><td></td><td></td></tr>';
1107 print
'<tr><td>'.$langs->trans(
"SendAcknowledgementByMail").
'</td>';
1109 if (!$object->email) {
1110 print $langs->trans(
"NoEMail");
1113 $adht->fetch($object->typeid);
1120 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1123 $outputlangs =
new Translate(
'', $conf);
1124 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
1126 $outputlangs->loadLangs(array(
"main",
"members"));
1128 $arraydefaultmessage =
null;
1129 $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
1131 if (!empty($labeltouse)) {
1132 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
1135 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1136 $subject = $arraydefaultmessage->topic;
1137 $msg = $arraydefaultmessage->content;
1145 $tmp =
'<input name="sendmail" type="checkbox"'.(GETPOST(
'sendmail',
'alpha') ?
' checked' : (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ?
' checked' :
'')).
'>';
1147 $helpcontent .=
'<b>'.$langs->trans(
"MailFrom").
'</b>: '.$conf->global->ADHERENT_MAIL_FROM.
'<br>'.
"\n";
1148 $helpcontent .=
'<b>'.$langs->trans(
"MailRecipient").
'</b>: '.$object->email.
'<br>'.
"\n";
1149 $helpcontent .=
'<b>'.$langs->trans(
"MailTopic").
'</b>:<br>'.
"\n";
1150 if ($subjecttosend) {
1151 $helpcontent .= $subjecttosend.
"\n";
1153 $langs->load(
"errors");
1154 $helpcontent .=
'<span class="error">'.$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Module310Name")).
'</span>'.
"\n";
1156 $helpcontent .=
"<br>";
1157 $helpcontent .=
'<b>'.$langs->trans(
"MailText").
'</b>:<br>';
1161 $langs->load(
"errors");
1162 $helpcontent .=
'<span class="error">'.$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Module310Name")).
'</span>'.
"\n";
1164 print
$form->textwithpicto($tmp, $helpcontent, 1,
'help',
'', 0, 2,
'helpemailtosend');
1172 print
'<div class="center">';
1173 $parameters = array();
1174 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1175 if (empty($reshook)) {
1176 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"AddSubscription").
'">';
1177 print
' ';
1178 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1184 print
"\n<!-- End form subscription -->\n\n";
1190 $langs->load(
"errors");
1191 print $langs->trans(
"ErrorRecordNotFound");
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bank accounts.
Class to manage accounting accounts.
Class to manage members of a foundation.
const STATUS_VALIDATED
Validated status.
Class to manage members type.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage subscriptions of foundation members.
Class to manage translations.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_most_recent_file($dir, $regexfilter='', $excludefilter=array('(\.meta|_preview.*\.png)$', '^\.'), $nohook=false, $mode='')
Return file(s) into a directory (by default most recent)
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_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...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
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_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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...
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...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessage($mesgs, $style='mesgs')
Set event message in dol_events session object.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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...
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
member_prepare_head(Adherent $object)
Return array head with list of tabs to view object informations.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.