32require
'../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/member.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
43$langs->loadLangs(array(
"companies",
"bills",
"members",
"users",
"mails",
'other'));
45$action =
GETPOST(
'action',
'aZ09');
46$confirm =
GETPOST(
'confirm',
'alpha');
47$contextpage =
GETPOST(
'contextpage',
'aZ09');
48$optioncss =
GETPOST(
'optioncss',
'aZ');
52$ref =
GETPOST(
'ref',
'alphanohtml');
53$typeid =
GETPOST(
'typeid',
'int');
57$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
58$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
59$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
60$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
61if (empty($page) || $page == -1) {
64$offset = $limit * $page;
70 $sortfield =
"c.rowid";
81$extrafields->fetch_name_optionals_label($object->table_element);
86$hookmanager->initHooks(array(
'subscription'));
98if ($id > 0 || !empty($ref)) {
100 $result = $object->fetch($id, $ref);
103 $canadduser = ($user->admin || $user->hasRight(
"user",
"user",
"creer"));
105 if ($object->user_id) {
107 $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight(
"user",
"self",
"creer"))
108 || (($user->id != $object->user_id) && $user->hasRight(
"user",
"user",
"creer")));
109 $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight(
"user",
"self",
"password"))
110 || (($user->id != $object->user_id) && $user->hasRight(
"user",
"user",
"password")));
115$canaddmember = $user->hasRight(
'adherent',
'creer');
118 $caneditfieldmember = $user->hasRight(
'adherent',
'creer');
122$result =
restrictedArea($user,
'adherent', $object->id,
'',
'',
'socid',
'rowid', 0);
129$parameters = array();
130$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
136if (empty($reshook) && $action ==
'confirm_create_thirdparty' && $confirm ==
'yes' && $user->hasRight(
'societe',
'creer')) {
140 $result = $company->create_from_member($object,
GETPOST(
'companyname',
'alpha'),
GETPOST(
'companyalias',
'alpha'),
GETPOST(
'customercode',
'alpha'));
143 $langs->load(
"errors");
146 $action =
'addsubscription';
153if (empty($reshook) && $action ==
'setuserid' && ($user->hasRight(
'user',
'self',
'creer') || $user->hasRight(
'user',
'user',
'creer'))) {
155 if (!$user->hasRight(
'user',
'user',
'creer')) {
156 if (
GETPOST(
"userid",
'int') != $user->id &&
GETPOST(
"userid",
'int') != $object->user_id) {
158 setEventMessages($langs->trans(
"ErrorUserPermissionAllowsToLinksToItselfOnly"),
null,
'errors');
163 if (
GETPOST(
"userid",
'int') != $object->user_id) {
164 $result = $object->setUserId(
GETPOST(
"userid",
'int'));
173if (empty($reshook) && $action ==
'setsocid') {
176 if (
GETPOST(
'socid',
'int') != $object->fk_soc) {
177 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
178 $sql .=
" WHERE fk_soc = '".GETPOST(
'socid',
'int').
"'";
179 $resql = $db->query($sql);
181 $obj = $db->fetch_object($resql);
182 if ($obj && $obj->rowid > 0) {
184 $othermember->fetch($obj->rowid);
185 $thirdparty =
new Societe($db);
186 $thirdparty->fetch(
GETPOST(
'socid',
'int'));
188 setEventMessages($langs->trans(
"ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name),
null,
'errors');
193 $result = $object->setThirdPartyId(
GETPOST(
'socid',
'int'));
203if ($user->hasRight(
'adherent',
'cotisation',
'creer') && $action ==
'subscription' && !$cancel) {
206 $langs->load(
"banks");
208 $result = $object->fetch($rowid);
209 $result = $adht->fetch($object->typeid);
212 $datesubscription = 0;
214 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
215 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
223 if (
GETPOST(
"paymentyear",
'int') &&
GETPOST(
"paymentmonth",
'int') &&
GETPOST(
"paymentday",
'int')) {
230 $accountid =
GETPOST(
"accountid",
'int');
231 $operation =
GETPOST(
"operation",
"alphanohtml");
232 $num_chq =
GETPOST(
"num_chq",
"alphanohtml");
233 $emetteur_nom =
GETPOST(
"chqemetteur");
234 $emetteur_banque =
GETPOST(
"chqbank");
235 $option =
GETPOST(
"paymentsave");
236 if (empty($option)) {
239 $sendalsoemail =
GETPOST(
"sendmail",
'alpha');
242 if (!$datesubscription) {
244 $langs->load(
"errors");
245 $errmsg = $langs->trans(
"ErrorBadDateFormat", $langs->transnoentitiesnoconv(
"DateSubscription"));
247 $action =
'addsubscription';
249 if (
GETPOST(
'end') && !$datesubend) {
251 $langs->load(
"errors");
252 $errmsg = $langs->trans(
"ErrorBadDateFormat", $langs->transnoentitiesnoconv(
"DateEndSubscription"));
254 $action =
'addsubscription';
259 if (($option ==
'bankviainvoice' || $option ==
'bankdirect') && !$paymentdate) {
261 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DatePayment"));
263 $action =
'addsubscription';
267 if ($adht->subscription) {
268 if (!is_numeric($amount)) {
270 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount"));
273 $action =
'addsubscription';
276 if (isModEnabled(
'banque') &&
GETPOST(
"paymentsave") !=
'none') {
279 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label"));
282 $action =
'addsubscription';
284 if (
GETPOST(
"paymentsave") !=
'invoiceonly' && !
GETPOST(
"operation")) {
285 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode"));
288 $action =
'addsubscription';
290 if (
GETPOST(
"paymentsave") !=
'invoiceonly' && !(
GETPOST(
"accountid",
'int') > 0)) {
291 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"FinancialAccount"));
294 $action =
'addsubscription';
297 if (
GETPOST(
"accountid",
'int')) {
298 $errmsg = $langs->trans(
"ErrorDoNotProvideAccountsIfNullAmount");
301 $action =
'addsubscription';
309 if (!$error && $action ==
'subscription') {
313 $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend);
316 $errmsg = $object->error;
321 $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque);
334 $action =
'addsubscription';
344 if ($object->email && $sendalsoemail) {
346 'datesubscription' => $datesubscription,
348 'ccountid' => $accountid,
349 'operation' => $operation,
351 'num_chq' => $num_chq,
352 'emetteur_nom' => $emetteur_nom,
353 'emetteur_banque' => $emetteur_banque,
354 'datesubend' => $datesubend
356 $reshook = $hookmanager->executeHooks(
'sendMail', $parameters, $object, $action);
361 if (empty($reshook)) {
366 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
370 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
372 $outputlangs->loadLangs(array(
"main",
"members"));
375 $arraydefaultmessage =
null;
376 $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
378 if (!empty($labeltouse)) {
379 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
382 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
383 $subject = $arraydefaultmessage->topic;
384 $msg = $arraydefaultmessage->content;
394 $listofpaths = array();
395 $listofnames = array();
396 $listofmimes = array();
397 if (is_object($object->invoice) && (!is_object($arraydefaultmessage) || intval($arraydefaultmessage->joinfiles))) {
398 $invoicediroutput = $conf->facture->dir_output;
399 $fileparams =
dol_most_recent_file($invoicediroutput.
'/'.$object->invoice->ref, preg_quote($object->invoice->ref,
'/').
'[^\-]+');
400 $file = $fileparams[
'fullname'];
402 $listofpaths = array($file);
403 $listofnames = array(basename($file));
407 $moreinheader =
'X-Dolibarr-Info: send_an_email by adherents/subscription.php'.
"\r\n";
409 $result = $object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
'', $moreinheader);
411 $errmsg = $object->error;
414 setEventMessages($langs->trans(
"EmailSentToMember", $object->email),
null,
'mesgs');
424 $_POST[
"subscription"] =
'';
425 $_POST[
"accountid"] =
'';
426 $_POST[
"operation"] =
'';
427 $_POST[
"label"] =
'';
428 $_POST[
"num_chq"] =
'';
439$form =
new Form($db);
443$title = $langs->trans(
"Member").
" - ".$langs->trans(
"Subscriptions");
445$help_url =
"EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder";
451if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
452 $param .=
'&contextpage='.urlencode($contextpage);
454if ($limit > 0 && $limit != $conf->liste_limit) {
455 $param .=
'&limit='.((int) $limit);
457$param .=
'&id='.$rowid;
458if ($optioncss !=
'') {
459 $param .=
'&optioncss='.urlencode($optioncss);
465if (! ($object->id > 0)) {
466 $langs->load(
"errors");
467 print $langs->trans(
"ErrorRecordNotFound");
477$adht->fetch($object->typeid);
479$defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
480$defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
488if (isModEnabled(
'societe')) {
492print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
493print
'<input type="hidden" name="token" value="'.newToken().
'">';
494print
'<input type="hidden" name="rowid" value="'.$object->id.
'">';
498$linkback =
'<a href="'.DOL_URL_ROOT.
'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
500$morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/adherents/vcard.php?id='.$object->id.
'" class="refid">';
501$morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
502$morehtmlref .=
'</a>';
504dol_banner_tab($object,
'rowid', $linkback, 1,
'rowid',
'ref', $morehtmlref);
506print
'<div class="fichecenter">';
507print
'<div class="fichehalfleft">';
509print
'<div class="underbanner clearboth"></div>';
510print
'<table class="border centpercent tableforfield">';
514 print
'<tr><td class="titlefield">'.$langs->trans(
"Login").
' / '.$langs->trans(
"Id").
'</td><td class="valeur">'.
dol_escape_htmltag($object->login).
'</td></tr>';
518print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td>';
519print
'<td class="valeur">'.$adht->getNomUrl(1).
"</td></tr>\n";
522print
'<tr><td>'.$langs->trans(
"MemberNature").
'</td>';
523print
'<td class="valeur" >'.$object->getmorphylib(
'', 1).
'</td>';
527print
'<tr><td>'.$langs->trans(
"Company").
'</td><td class="valeur">'.
dol_escape_htmltag($object->company).
'</td></tr>';
530print
'<tr><td>'.$langs->trans(
"UserTitle").
'</td><td class="valeur">'.$object->getCivilityLabel().
'</td>';
535 print
'<tr><td>'.$langs->trans(
"Password").
'</td><td>';
537 print preg_replace(
'/./i',
'*', $object->pass);
540 print
'<!-- '.$langs->trans(
"Crypted").
': '.$object->pass_indatabase_crypted.
' -->';
542 print
'<span class="opacitymedium">'.$langs->trans(
"Hidden").
'</span>';
544 if (!empty($object->pass_indatabase) && empty($object->user_id)) {
545 $langs->load(
"errors");
546 $htmltext = $langs->trans(
"WarningPasswordSetWithNoAccount");
547 print
' '.$form->textwithpicto(
'', $htmltext, 1,
'warning');
553print
'<tr><td>'.$langs->trans(
"SubscriptionEndDate").
'</td><td class="valeur">';
554if ($object->datefin) {
556 if ($object->hasDelay()) {
557 print
" ".img_warning($langs->trans(
"Late"));
560 if ($object->need_subscription == 0) {
561 print $langs->trans(
"SubscriptionNotNeeded");
562 } elseif (!$adht->subscription) {
563 print $langs->trans(
"SubscriptionNotRecorded");
565 print
" ".img_warning($langs->trans(
"Late"));
568 print $langs->trans(
"SubscriptionNotReceived");
570 print
" ".img_warning($langs->trans(
"Late"));
580print
'<div class="fichehalfright">';
581print
'<div class="underbanner clearboth"></div>';
583print
'<table class="border tableforfield centpercent">';
586if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
587 print
'<tr><td>'.$langs->trans(
"Categories").
'</td>';
588 print
'<td colspan="2">';
589 print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1);
594print
'<tr><td class="titlefield">'.$langs->trans(
"DateOfBirth").
'</td><td class="valeur">'.
dol_print_date($object->birth,
'day').
'</td></tr>';
598 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
599 print
'<tr><td>'.$langs->trans(
"DefaultLang").
'</td><td>';
602 $langs->load(
"languages");
603 $labellang = ($object->default_lang ? $langs->trans(
'Language_'.$object->default_lang) :
'');
604 print
picto_from_langcode($object->default_lang,
'class="paddingrightonly saturatemedium opacitylow"');
610$linkofpubliclist = DOL_MAIN_URL_ROOT.
'/public/members/public_list.php'.((isModEnabled(
'multicompany')) ?
'?entity='.$conf->entity :
'');
611print
'<tr><td>'.$langs->trans(
"Public",
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist).
'</td><td class="valeur">'.
yn($object->public).
'</td></tr>';
615include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
618if (isModEnabled(
'societe')) {
620 print
'<table class="nobordernopadding" width="100%"><tr><td>';
621 print $langs->trans(
"LinkedToDolibarrThirdParty");
623 if ($action !=
'editthirdparty' && $user->hasRight(
'adherent',
'creer')) {
624 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>';
626 print
'</tr></table>';
627 print
'</td><td colspan="2" class="valeur">';
628 if ($action ==
'editthirdparty') {
630 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'" name="form'.$htmlname.
'">';
631 print
'<input type="hidden" name="rowid" value="'.$object->id.
'">';
632 print
'<input type="hidden" name="action" value="set'.$htmlname.
'">';
633 print
'<input type="hidden" name="token" value="'.newToken().
'">';
634 print
'<table class="nobordernopadding">';
636 print $form->select_company($object->fk_soc,
'socid',
'', 1);
638 print
'<td class="left"><input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
639 print
'</tr></table></form>';
641 if ($object->fk_soc) {
643 $result = $company->fetch($object->fk_soc);
644 print $company->getNomUrl(1);
647 $tmparray = $company->getOutstandingBills(
'customer');
648 if (!empty($tmparray[
'refs'])) {
649 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']).
')';
654 print
'<span class="opacitymedium">'.$langs->trans(
"NoThirdPartyAssociatedToMember").
'</span>';
662print
'<table class="nobordernopadding" width="100%"><tr><td>';
663print $langs->trans(
"LinkedToDolibarrUser");
665if ($action !=
'editlogin' && $user->hasRight(
'adherent',
'creer')) {
666 print
'<td class="right">';
667 if ($user->hasRight(
"user",
"user",
"creer")) {
668 print
'<a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editlogin&token='.newToken().
'&rowid='.$object->id.
'">'.
img_edit($langs->trans(
'SetLinkToUser'), 1).
'</a>';
672print
'</tr></table>';
673print
'</td><td colspan="2" class="valeur">';
674if ($action ==
'editlogin') {
675 $form->form_users($_SERVER[
'PHP_SELF'].
'?rowid='.$object->id, $object->user_id,
'userid',
'');
677 if ($object->user_id) {
678 $linkeduser =
new User($db);
679 $linkeduser->fetch($object->user_id);
680 print $linkeduser->getNomUrl(-1);
682 print
'<span class="opacitymedium">'.$langs->trans(
"NoDolibarrAccess").
'</span>';
689print
"</div></div>\n";
690print
'<div class="clearboth"></div>';
700if ($user->hasRight(
'adherent',
'cotisation',
'creer')) {
701 if ($action !=
'addsubscription' && $action !=
'create_thirdparty') {
702 print
'<div class="tabsAction">';
704 if ($object->statut > 0) {
705 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$rowid.
'&action=addsubscription&token='.newToken().
'">'.$langs->trans(
"AddSubscription").
"</a></div>";
707 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"ValidateBefore")).
'">'.$langs->trans(
"AddSubscription").
'</a></div>';
717if ($action !=
'addsubscription' && $action !=
'create_thirdparty') {
718 $sql =
"SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,";
719 $sql .=
" c.rowid as crowid, c.subscription,";
720 $sql .=
" c.datec, c.fk_type as cfk_type,";
721 $sql .=
" c.dateadh as dateh,";
723 $sql .=
" c.fk_bank,";
724 $sql .=
" b.rowid as bid,";
725 $sql .=
" ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code";
726 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as d, ".MAIN_DB_PREFIX.
"subscription as c";
727 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON c.fk_bank = b.rowid";
728 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account as ba ON b.fk_account = ba.rowid";
729 $sql .=
" WHERE d.rowid = c.fk_adherent AND d.rowid=".((int) $rowid);
730 $sql .= $db->order($sortfield, $sortorder);
732 $result = $db->query($sql);
736 $num = $db->num_rows($result);
738 print
'<table class="noborder centpercent">'.
"\n";
740 print
'<tr class="liste_titre">';
742 print_liste_field_titre(
'DateCreation', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
744 print_liste_field_titre(
'DateStart', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
745 print_liste_field_titre(
'DateEnd', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
747 if (isModEnabled(
'banque')) {
748 print_liste_field_titre(
'Account', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
752 $accountstatic =
new Account($db);
758 $objp = $db->fetch_object($result);
760 $adh->id = $objp->rowid;
761 $adh->typeid = $objp->type;
763 $subscriptionstatic->ref = $objp->crowid;
764 $subscriptionstatic->id = $objp->crowid;
766 $typeid = $objp->cfk_type;
768 $adht->fetch($typeid);
771 print
'<tr class="oddeven">';
772 print
'<td>'.$subscriptionstatic->getNomUrl(1).
'</td>';
773 print
'<td class="center">'.dol_print_date($db->jdate($objp->datec),
'dayhour').
"</td>\n";
774 print
'<td class="center">';
776 print $adht->getNomUrl(1);
779 print
'<td class="center">'.dol_print_date($db->jdate($objp->dateh),
'day').
"</td>\n";
780 print
'<td class="center">'.dol_print_date($db->jdate($objp->datef),
'day').
"</td>\n";
781 print
'<td class="right amount">'.price($objp->subscription).
'</td>';
782 if (isModEnabled(
'banque')) {
783 print
'<td class="right">';
785 $accountstatic->label = $objp->label;
786 $accountstatic->id = $objp->baid;
787 $accountstatic->number = $objp->number;
788 $accountstatic->account_number = $objp->account_number;
789 $accountstatic->currency_code = $objp->currency_code;
791 if (isModEnabled(
'accounting') && $objp->fk_accountancy_journal > 0) {
793 $accountingjournal->fetch($objp->fk_accountancy_journal);
795 $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
798 $accountstatic->ref = $objp->ref;
799 print $accountstatic->getNomUrl(1);
811 if (isModEnabled(
'banque')) {
814 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
824if (($action !=
'addsubscription' && $action !=
'create_thirdparty')) {
826 $useonlinepayment = (isModEnabled(
'paypal') || isModEnabled(
'stripe') || isModEnabled(
'paybox'));
828 if ($useonlinepayment) {
831 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
832 print showOnlinePaymentUrl(
'membersubscription', $object->ref);
840if (($action ==
'addsubscription' || $action ==
'create_thirdparty') && $user->hasRight(
'adherent',
'cotisation',
'creer')) {
850 if (
GETPOST(
'paymentsave') ==
'bankdirect') {
853 if (
GETPOST(
'paymentsave') ==
'invoiceonly') {
856 if (
GETPOST(
'paymentsave') ==
'bankviainvoice') {
860 if (
getDolGlobalString(
'ADHERENT_BANK_USE') ==
'bankviainvoice' && isModEnabled(
'banque') && isModEnabled(
'societe') && isModEnabled(
'facture')) {
862 } elseif (
getDolGlobalString(
'ADHERENT_BANK_USE') ==
'bankdirect' && isModEnabled(
'banque')) {
864 } elseif (
getDolGlobalString(
'ADHERENT_BANK_USE') ==
'invoiceonly' && isModEnabled(
'banque') && isModEnabled(
'societe') && isModEnabled(
'facture')) {
869 print
"\n\n<!-- Form add subscription -->\n";
871 if ($conf->use_javascript_ajax) {
873 print
"\n".
'<script type="text/javascript">';
874 print
'$(document).ready(function () {
875 $(".bankswitchclass, .bankswitchclass2").'.(($bankdirect || $bankviainvoice) ?
'show()' :
'hide()').
';
876 $("#none, #invoiceonly").click(function() {
877 $(".bankswitchclass").hide();
878 $(".bankswitchclass2").hide();
880 $("#bankdirect, #bankviainvoice").click(function() {
881 $(".bankswitchclass").show();
882 $(".bankswitchclass2").show();
884 $("#selectoperation").change(function() {
885 var code = $(this).val();
888 $(".fieldrequireddyn").addClass("fieldrequired");
889 if ($("#fieldchqemetteur").val() == "")
891 $("#fieldchqemetteur").val($("#memberlabel").val());
896 $(".fieldrequireddyn").removeClass("fieldrequired");
901 print
'$("#'.GETPOST(
'paymentsave',
'aZ09').
'").prop("checked", true);';
904 print
'</script>'.
"\n";
909 if ($action ==
'create_thirdparty') {
911 $fullname = $object->getFullName($langs);
913 if ($object->morphy ==
'mor') {
914 $companyname = $object->company;
915 if (!empty($fullname)) {
916 $companyalias = $fullname;
919 $companyname = $fullname;
920 if (!empty($object->company)) {
921 $companyalias = $object->company;
926 $formquestion = array(
927 array(
'label' => $langs->trans(
"NameToCreate"),
'type' =>
'text',
'name' =>
'companyname',
'value' => $companyname,
'morecss' =>
'minwidth300',
'moreattr' =>
'maxlength="128"'),
928 array(
'label' => $langs->trans(
"AliasNames"),
'type' =>
'text',
'name' =>
'companyalias',
'value' => $companyalias,
'morecss' =>
'minwidth300',
'moreattr' =>
'maxlength="128"')
932 $tmpcompany =
new Societe($db);
933 $tmpcompany->name = $companyname;
934 $tmpcompany->get_codeclient($tmpcompany, 0);
935 $customercode = $tmpcompany->code_client;
936 $formquestion[] = array(
937 'label' => $langs->trans(
"CustomerCode"),
939 'name' =>
'customercode',
940 'value' => $customercode,
941 'morecss' =>
'minwidth300',
942 'moreattr' =>
'maxlength="128"',
947 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?rowid=".$object->id, $langs->trans(
"CreateDolibarrThirdParty"), $langs->trans(
"ConfirmCreateThirdParty"),
"confirm_create_thirdparty", $formquestion, 1);
951 print
'<form name="subscription" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
952 print
'<input type="hidden" name="token" value="'.newToken().
'">';
953 print
'<input type="hidden" name="action" value="subscription">';
954 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
955 print
'<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).
'">';
956 print
'<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($object->company).
'">';
960 print
'<div class="div-table-responsive">';
961 print
'<table class="border centpercent">'.
"\n";
973 print
'<td class="fieldrequired">'.$langs->trans(
"DateSubscription").
'</td><td>';
978 $datefrom = $object->datevalid;
981 } elseif ($object->datefin > 0 &&
dol_time_plus_duree($object->datefin, $defaultdelay, $defaultdelayunit) > $now) {
991 print $form->selectDate($datefrom,
'',
'',
'',
'',
"subscription", 1, 1);
1001 } elseif (
getDolGlobalInt(
'MEMBER_SUBSCRIPTION_SUGGEST_END_OF_YEAR')) {
1007 print
'<tr><td>'.$langs->trans(
"DateEndSubscription").
'</td><td>';
1008 print $form->selectDate($dateto,
'end',
'',
'',
'',
"subscription", 1, 0);
1011 if ($adht->subscription) {
1013 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Amount").
'</td><td><input type="text" name="subscription" size="6" value="'.(GETPOSTISSET(
'subscription') ?
GETPOST(
'subscription') :
price($adht->amount, 0,
'', 0)).
'"> '.$langs->trans(
"Currency".$conf->currency) .
'</td></tr>';
1016 print
'<tr><td>'.$langs->trans(
"Label").
'</td>';
1017 print
'<td><input name="label" type="text" size="32" value="';
1019 print $langs->trans(
"Subscription").
' '.
dol_print_date(($datefrom ? $datefrom : time()),
"%Y");
1021 print
'"></td></tr>';
1024 if ((isModEnabled(
'banque') || isModEnabled(
'facture')) && !
getDolGlobalString(
'ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS')) {
1026 if ($object->socid) {
1027 $result = $company->fetch($object->socid);
1031 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'MoreActions');
1033 print
'<td class="line-height-large">';
1035 print
'<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"'.(empty($bankdirect) && empty($invoiceonly) && empty($bankviainvoice) ?
' checked' :
'').
'>';
1036 print
'<label for="none"> '.$langs->trans(
"None").
'</label><br>';
1038 if (isModEnabled(
'banque')) {
1039 print
'<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"'.(!empty($bankdirect) ?
' checked' :
'');
1040 print
'><label for="bankdirect"> '.$langs->trans(
"MoreActionBankDirect").
'</label><br>';
1043 if (isModEnabled(
'societe') && isModEnabled(
'facture')) {
1044 print
'<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(!empty($invoiceonly) ?
' checked' :
'');
1046 print
'><label for="invoiceonly"> '.$langs->trans(
"MoreActionInvoiceOnly");
1047 if ($object->fk_soc) {
1048 print
' ('.$langs->trans(
"ThirdParty").
': '.$company->getNomUrl(1).
')';
1051 if (empty($object->fk_soc)) {
1052 print
img_warning($langs->trans(
"NoThirdPartyAssociatedToMember"));
1054 print $langs->trans(
"NoThirdPartyAssociatedToMember");
1055 print
' - <a href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$object->id.
'&action=create_thirdparty">';
1056 print $langs->trans(
"CreateDolibarrThirdParty");
1060 print
'. <span class="opacitymedium">'.$langs->trans(
"NoVatOnSubscription", 0).
'</span>';
1062 if (
getDolGlobalString(
'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && (isModEnabled(
'product') || isModEnabled(
'service'))) {
1064 $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
1068 print
'. '.$langs->transnoentitiesnoconv(
"ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1));
1070 print
'</label><br>';
1073 if (isModEnabled(
'banque') && isModEnabled(
'societe') && isModEnabled(
'facture')) {
1074 print
'<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(!empty($bankviainvoice) ?
' checked' :
'');
1076 print
'><label for="bankviainvoice"> '.$langs->trans(
"MoreActionBankViaInvoice");
1077 if ($object->socid) {
1078 print
' ('.$langs->trans(
"ThirdParty").
': '.$company->getNomUrl(1).
')';
1081 if (empty($object->socid)) {
1082 print
img_warning($langs->trans(
"NoThirdPartyAssociatedToMember"));
1084 print $langs->trans(
"NoThirdPartyAssociatedToMember");
1085 print
' - <a href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$object->id.
'&action=create_thirdparty">';
1086 print $langs->trans(
"CreateDolibarrThirdParty");
1090 print
'. <span class="opacitymedium">'.$langs->trans(
"NoVatOnSubscription", 0).
'</span>';
1092 if (
getDolGlobalString(
'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && (isModEnabled(
'product')|| isModEnabled(
'service'))) {
1094 $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
1098 print
'. '.$langs->transnoentitiesnoconv(
"ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1));
1100 print
'</label><br>';
1105 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"FinancialAccount").
'</td><td>';
1107 $form->select_comptes(
GETPOST(
'accountid'),
'accountid', 0,
'', 2,
'', 0,
'minwidth200');
1108 print
"</td></tr>\n";
1111 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
1112 print $form->select_types_paiements(
GETPOST(
'operation'),
'operation',
'', 2, 1, 0, 0, 1,
'minwidth200', 1);
1113 print
"</td></tr>\n";
1116 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"DatePayment").
'</td><td>';
1117 print $form->selectDate(isset($paymentdate) ? $paymentdate : -1,
'payment', 0, 0, 1,
'subscription', 1, 1);
1118 print
"</td></tr>\n";
1120 print
'<tr class="bankswitchclass2"><td>'.$langs->trans(
'Numero');
1121 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
1123 print
'<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(!
GETPOST(
'num_chq') ?
'' :
GETPOST(
'num_chq')).
'"></td></tr>';
1125 print
'<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans(
'CheckTransmitter');
1126 print
' <em>('.$langs->trans(
"ChequeMaker").
')</em>';
1128 print
'<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(!
GETPOST(
'chqemetteur') ?
'' :
GETPOST(
'chqemetteur')).
'"></td></tr>';
1130 print
'<tr class="bankswitchclass2"><td>'.$langs->trans(
'Bank');
1131 print
' <em>('.$langs->trans(
"ChequeBank").
')</em>';
1133 print
'<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(!
GETPOST(
'chqbank') ?
'' :
GETPOST(
'chqbank')).
'"></td></tr>';
1137 print
'<tr><td></td><td></td></tr>';
1139 print
'<tr><td>'.$langs->trans(
"SendAcknowledgementByMail").
'</td>';
1141 if (!$object->email) {
1142 print $langs->trans(
"NoEMail");
1145 $adht->fetch($object->typeid);
1152 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1155 $outputlangs =
new Translate(
'', $conf);
1156 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
1158 $outputlangs->loadLangs(array(
"main",
"members"));
1160 $arraydefaultmessage =
null;
1161 $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
1163 if (!empty($labeltouse)) {
1164 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
1167 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1168 $subject = $arraydefaultmessage->topic;
1169 $msg = $arraydefaultmessage->content;
1177 $tmp =
'<input name="sendmail" type="checkbox"'.(GETPOST(
'sendmail',
'alpha') ?
' checked' : (
getDolGlobalString(
'ADHERENT_DEFAULT_SENDINFOBYMAIL') ?
' checked' :
'')).
'>';
1179 $helpcontent .=
'<b>'.$langs->trans(
"MailFrom").
'</b>: '.
getDolGlobalString(
'ADHERENT_MAIL_FROM').
'<br>'.
"\n";
1180 $helpcontent .=
'<b>'.$langs->trans(
"MailRecipient").
'</b>: '.$object->email.
'<br>'.
"\n";
1181 $helpcontent .=
'<b>'.$langs->trans(
"MailTopic").
'</b>:<br>'.
"\n";
1182 if ($subjecttosend) {
1183 $helpcontent .= $subjecttosend.
"\n";
1185 $langs->load(
"errors");
1186 $helpcontent .=
'<span class="error">'.$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Module310Name")).
'</span>'.
"\n";
1188 $helpcontent .=
"<br>";
1189 $helpcontent .=
'<b>'.$langs->trans(
"MailText").
'</b>:<br>';
1193 $langs->load(
"errors");
1194 $helpcontent .=
'<span class="error">'.$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Module310Name")).
'</span>'.
"\n";
1196 print $form->textwithpicto($tmp, $helpcontent, 1,
'help',
'', 0, 2,
'helpemailtosend');
1205 print
'<div class="center">';
1206 $parameters = array();
1207 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1208 if (empty($reshook)) {
1209 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"AddSubscription").
'">';
1210 print
' ';
1211 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1217 print
"\n<!-- End form subscription -->\n\n";
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 journals.
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.
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_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
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...
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
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.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message 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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages 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...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.