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 $optioncss =
GETPOST(
'optioncss',
'aZ');
45 $action =
GETPOST(
'action',
'aZ09');
46 $confirm =
GETPOST(
'confirm',
'alpha');
49 $ref =
GETPOST(
'ref',
'alphanohtml');
50 $typeid =
GETPOST(
'typeid',
'int');
54 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
55 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
56 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
58 if (empty($page) || $page == -1) {
61 $offset = $limit * $page;
62 $pageprev = $page - 1;
63 $pagenext = $page + 1;
67 $sortfield =
"c.rowid";
78 $extrafields->fetch_name_optionals_label($object->table_element);
83 $hookmanager->initHooks(array(
'subscription'));
86 $hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
87 $hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
88 $hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
95 if ($id > 0 || !empty($ref)) {
97 $result = $object->fetch($id, $ref);
100 $canadduser = ($user->admin || $user->rights->user->user->creer);
102 if ($object->user_id) {
104 $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer)
105 || (($user->id != $object->user_id) && $user->rights->user->user->creer));
106 $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password)
107 || (($user->id != $object->user_id) && $user->rights->user->user->password));
112 $canaddmember = $user->rights->adherent->creer;
115 $caneditfieldmember = $user->rights->adherent->creer;
119 $result =
restrictedArea($user,
'adherent', $object->id,
'',
'',
'socid',
'rowid', 0);
126 $parameters = array();
127 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
133 if (empty($reshook) && $action ==
'confirm_create_thirdparty' && $confirm ==
'yes' && $user->rights->societe->creer) {
137 $result = $company->create_from_member($object,
GETPOST(
'companyname',
'alpha'),
GETPOST(
'companyalias',
'alpha'),
GETPOST(
'customercode',
'alpha'));
140 $langs->load(
"errors");
143 $action =
'addsubscription';
150 if (empty($reshook) && $action ==
'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) {
152 if (empty($user->rights->user->user->creer)) {
153 if (
GETPOST(
"userid",
'int') != $user->id &&
GETPOST(
"userid",
'int') != $object->user_id) {
155 setEventMessages($langs->trans(
"ErrorUserPermissionAllowsToLinksToItselfOnly"),
null,
'errors');
160 if (
GETPOST(
"userid",
'int') != $object->user_id) {
161 $result = $object->setUserId(
GETPOST(
"userid",
'int'));
170 if (empty($reshook) && $action ==
'setsocid') {
173 if (
GETPOST(
'socid',
'int') != $object->fk_soc) {
174 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
175 $sql .=
" WHERE fk_soc = '".GETPOST(
'socid',
'int').
"'";
176 $resql = $db->query($sql);
178 $obj = $db->fetch_object(
$resql);
179 if ($obj && $obj->rowid > 0) {
181 $othermember->fetch($obj->rowid);
182 $thirdparty =
new Societe($db);
183 $thirdparty->fetch(
GETPOST(
'socid',
'int'));
185 setEventMessages($langs->trans(
"ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name),
null,
'errors');
190 $result = $object->setThirdPartyId(
GETPOST(
'socid',
'int'));
200 if ($user->rights->adherent->cotisation->creer && $action ==
'subscription' && !$cancel) {
203 $langs->load(
"banks");
205 $result = $object->fetch($rowid);
206 $result = $adht->fetch($object->typeid);
209 $datesubscription = 0;
211 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
212 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
220 if (
GETPOST(
"paymentyear",
'int') &&
GETPOST(
"paymentmonth",
'int') &&
GETPOST(
"paymentday",
'int')) {
227 $accountid =
GETPOST(
"accountid",
'int');
228 $operation =
GETPOST(
"operation",
"alphanohtml");
229 $num_chq =
GETPOST(
"num_chq",
"alphanohtml");
230 $emetteur_nom =
GETPOST(
"chqemetteur");
231 $emetteur_banque =
GETPOST(
"chqbank");
232 $option =
GETPOST(
"paymentsave");
233 if (empty($option)) {
236 $sendalsoemail =
GETPOST(
"sendmail",
'alpha');
239 if (!$datesubscription) {
241 $langs->load(
"errors");
242 $errmsg = $langs->trans(
"ErrorBadDateFormat", $langs->transnoentitiesnoconv(
"DateSubscription"));
244 $action =
'addsubscription';
246 if (
GETPOST(
'end') && !$datesubend) {
248 $langs->load(
"errors");
249 $errmsg = $langs->trans(
"ErrorBadDateFormat", $langs->transnoentitiesnoconv(
"DateEndSubscription"));
251 $action =
'addsubscription';
256 if (($option ==
'bankviainvoice' || $option ==
'bankdirect') && !$paymentdate) {
258 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DatePayment"));
260 $action =
'addsubscription';
264 if ($adht->subscription) {
265 if (!is_numeric($amount)) {
267 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount"));
270 $action =
'addsubscription';
273 if (!empty($conf->banque->enabled) &&
GETPOST(
"paymentsave") !=
'none') {
276 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label"));
279 $action =
'addsubscription';
281 if (
GETPOST(
"paymentsave") !=
'invoiceonly' && !
GETPOST(
"operation")) {
282 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode"));
285 $action =
'addsubscription';
287 if (
GETPOST(
"paymentsave") !=
'invoiceonly' && !(
GETPOST(
"accountid",
'int') > 0)) {
288 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"FinancialAccount"));
291 $action =
'addsubscription';
294 if (
GETPOST(
"accountid",
'int')) {
295 $errmsg = $langs->trans(
"ErrorDoNotProvideAccountsIfNullAmount");
298 $action =
'addsubscription';
306 if (!$error && $action ==
'subscription') {
310 $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend);
313 $errmsg = $object->error;
318 $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque);
331 $action =
'addsubscription';
341 if ($object->email && $sendalsoemail) {
343 'datesubscription' => $datesubscription,
345 'ccountid' => $accountid,
346 'operation' => $operation,
348 'num_chq' => $num_chq,
349 'emetteur_nom' => $emetteur_nom,
350 'emetteur_banque' => $emetteur_banque,
351 'datesubend' => $datesubend
353 $reshook = $hookmanager->executeHooks(
'sendMail', $parameters, $object, $action);
358 if (empty($reshook)) {
363 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
367 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
369 $outputlangs->loadLangs(array(
"main",
"members"));
372 $arraydefaultmessage =
null;
373 $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
375 if (!empty($labeltouse)) {
376 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
379 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
380 $subject = $arraydefaultmessage->topic;
381 $msg = $arraydefaultmessage->content;
391 $listofpaths = array();
392 $listofnames = array();
393 $listofmimes = array();
394 if (is_object($object->invoice) && (!is_object($arraydefaultmessage) || intval($arraydefaultmessage->joinfiles))) {
395 $invoicediroutput = $conf->facture->dir_output;
396 $fileparams =
dol_most_recent_file($invoicediroutput.
'/'.$object->invoice->ref, preg_quote($object->invoice->ref,
'/').
'[^\-]+');
397 $file = $fileparams[
'fullname'];
399 $listofpaths = array($file);
400 $listofnames = array(basename($file));
404 $moreinheader =
'X-Dolibarr-Info: send_an_email by adherents/subscription.php'.
"\r\n";
406 $result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
'', $moreinheader);
408 $errmsg = $object->error;
411 setEventMessages($langs->trans(
"EmailSentToMember", $object->email),
null,
'mesgs');
421 $_POST[
"subscription"] =
'';
422 $_POST[
"accountid"] =
'';
423 $_POST[
"operation"] =
'';
424 $_POST[
"label"] =
'';
425 $_POST[
"num_chq"] =
'';
440 $title = $langs->trans(
"Member").
" - ".$langs->trans(
"Subscriptions");
442 $help_url =
"EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder";
448 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
449 $param .=
'&contextpage='.urlencode($contextpage);
451 if ($limit > 0 && $limit != $conf->liste_limit) {
452 $param .=
'&limit='.urlencode($limit);
454 $param .=
'&id='.$rowid;
455 if ($optioncss !=
'') {
456 $param .=
'&optioncss='.urlencode($optioncss);
463 $res = $object->fetch($rowid);
469 $adht->fetch($object->typeid);
471 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
472 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
477 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
480 if (!empty($conf->societe->enabled)) {
484 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
485 print
'<input type="hidden" name="token" value="'.newToken().
'">';
486 print
'<input type="hidden" name="rowid" value="'.$object->id.
'">';
490 $linkback =
'<a href="'.DOL_URL_ROOT.
'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
492 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/adherents/vcard.php?id='.$object->id.
'" class="refid">';
493 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
494 $morehtmlref .=
'</a>';
496 dol_banner_tab($object,
'rowid', $linkback, 1,
'rowid',
'ref', $morehtmlref);
498 print
'<div class="fichecenter">';
499 print
'<div class="fichehalfleft">';
501 print
'<div class="underbanner clearboth"></div>';
502 print
'<table class="border centpercent tableforfield">';
505 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
506 print
'<tr><td class="titlefield">'.$langs->trans(
"Login").
' / '.$langs->trans(
"Id").
'</td><td class="valeur">'.
dol_escape_htmltag($object->login).
'</td></tr>';
510 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td class="valeur">'.$adht->getNomUrl(1).
"</td></tr>\n";
513 print
'<tr><td>'.$langs->trans(
"MemberNature").
'</td><td class="valeur" >'.$object->getmorphylib().
'</td>';
517 print
'<tr><td>'.$langs->trans(
"Company").
'</td><td class="valeur">'.
dol_escape_htmltag($object->company).
'</td></tr>';
520 print
'<tr><td>'.$langs->trans(
"UserTitle").
'</td><td class="valeur">'.$object->getCivilityLabel().
'</td>';
524 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
525 print
'<tr><td>'.$langs->trans(
"Password").
'</td><td>';
527 print preg_replace(
'/./i',
'*', $object->pass);
530 print
'<!-- '.$langs->trans(
"Crypted").
': '.$object->pass_indatabase_crypted.
' -->';
532 print
'<span class="opacitymedium">'.$langs->trans(
"Hidden").
'</span>';
534 if (!empty($object->pass_indatabase) && empty($object->user_id)) {
535 $langs->load(
"errors");
536 $htmltext = $langs->trans(
"WarningPasswordSetWithNoAccount");
537 print
' '.$form->textwithpicto(
'', $htmltext, 1,
'warning');
543 print
'<tr><td>'.$langs->trans(
"SubscriptionEndDate").
'</td><td class="valeur">';
544 if ($object->datefin) {
546 if ($object->hasDelay()) {
547 print
" ".img_warning($langs->trans(
"Late"));
550 if ($object->need_subscription == 0) {
551 print $langs->trans(
"SubscriptionNotNeeded");
552 } elseif (!$adht->subscription) {
553 print $langs->trans(
"SubscriptionNotRecorded");
555 print
" ".img_warning($langs->trans(
"Late"));
558 print $langs->trans(
"SubscriptionNotReceived");
560 print
" ".img_warning($langs->trans(
"Late"));
570 print
'<div class="fichehalfright">';
571 print
'<div class="underbanner clearboth"></div>';
573 print
'<table class="border tableforfield centpercent">';
576 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
577 print
'<tr><td>'.$langs->trans(
"Categories").
'</td>';
578 print
'<td colspan="2">';
579 print
$form->showCategories($object->id, Categorie::TYPE_MEMBER, 1);
584 print
'<tr><td class="titlefield">'.$langs->trans(
"DateOfBirth").
'</td><td class="valeur">'.
dol_print_date($object->birth,
'day').
'</td></tr>';
587 print
'<tr><td>'.$langs->trans(
"Public").
'</td><td class="valeur">'.
yn($object->public).
'</td></tr>';
591 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
594 if (!empty($conf->societe->enabled)) {
596 print
'<table class="nobordernopadding" width="100%"><tr><td>';
597 print $langs->trans(
"LinkedToDolibarrThirdParty");
599 if ($action !=
'editthirdparty' && $user->rights->adherent->creer) {
600 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>';
602 print
'</tr></table>';
603 print
'</td><td colspan="2" class="valeur">';
604 if ($action ==
'editthirdparty') {
606 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'" name="form'.$htmlname.
'">';
607 print
'<input type="hidden" name="rowid" value="'.$object->id.
'">';
608 print
'<input type="hidden" name="action" value="set'.$htmlname.
'">';
609 print
'<input type="hidden" name="token" value="'.newToken().
'">';
610 print
'<table class="nobordernopadding">';
612 print
$form->select_company($object->fk_soc,
'socid',
'', 1);
614 print
'<td class="left"><input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
615 print
'</tr></table></form>';
617 if ($object->fk_soc) {
619 $result = $company->fetch($object->fk_soc);
620 print $company->getNomUrl(1);
623 $tmparray = $company->getOutstandingBills(
'customer');
624 if (!empty($tmparray[
'refs'])) {
625 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']).
')';
630 print
'<span class="opacitymedium">'.$langs->trans(
"NoThirdPartyAssociatedToMember").
'</span>';
638 print
'<table class="nobordernopadding" width="100%"><tr><td>';
639 print $langs->trans(
"LinkedToDolibarrUser");
641 if ($action !=
'editlogin' && $user->rights->adherent->creer) {
642 print
'<td class="right">';
643 if ($user->rights->user->user->creer) {
644 print
'<a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editlogin&token='.
newToken().
'&rowid='.$object->id.
'">'.
img_edit($langs->trans(
'SetLinkToUser'), 1).
'</a>';
648 print
'</tr></table>';
649 print
'</td><td colspan="2" class="valeur">';
650 if ($action ==
'editlogin') {
651 $form->form_users($_SERVER[
'PHP_SELF'].
'?rowid='.$object->id, $object->user_id,
'userid',
'');
653 if ($object->user_id) {
654 $linkeduser =
new User($db);
655 $linkeduser->fetch($object->user_id);
656 print $linkeduser->getNomUrl(-1);
658 print
'<span class="opacitymedium">'.$langs->trans(
"NoDolibarrAccess").
'</span>';
665 print
"</div></div>\n";
666 print
'<div style="clear:both"></div>';
676 if ($user->rights->adherent->cotisation->creer) {
677 if ($action !=
'addsubscription' && $action !=
'create_thirdparty') {
678 print
'<div class="tabsAction">';
680 if ($object->statut > 0) {
681 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$rowid.
'&action=addsubscription&token='.
newToken().
'">'.$langs->trans(
"AddSubscription").
"</a></div>";
683 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"ValidateBefore")).
'">'.$langs->trans(
"AddSubscription").
'</a></div>';
693 if ($action !=
'addsubscription' && $action !=
'create_thirdparty') {
694 $sql =
"SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,";
695 $sql .=
" c.rowid as crowid, c.subscription,";
696 $sql .=
" c.datec, c.fk_type as cfk_type,";
697 $sql .=
" c.dateadh as dateh,";
699 $sql .=
" c.fk_bank,";
700 $sql .=
" b.rowid as bid,";
701 $sql .=
" ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code";
702 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as d, ".MAIN_DB_PREFIX.
"subscription as c";
703 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON c.fk_bank = b.rowid";
704 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account as ba ON b.fk_account = ba.rowid";
705 $sql .=
" WHERE d.rowid = c.fk_adherent AND d.rowid=".((int) $rowid);
706 $sql .= $db->order($sortfield, $sortorder);
708 $result = $db->query($sql);
712 $num = $db->num_rows($result);
714 print
'<table class="noborder centpercent">'.
"\n";
716 print
'<tr class="liste_titre">';
718 print_liste_field_titre(
'DateCreation', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
720 print_liste_field_titre(
'DateStart', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
721 print_liste_field_titre(
'DateEnd', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
723 if (!empty($conf->banque->enabled)) {
724 print_liste_field_titre(
'Account', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
728 $accountstatic =
new Account($db);
734 $objp = $db->fetch_object($result);
736 $adh->id = $objp->rowid;
737 $adh->typeid = $objp->type;
739 $subscriptionstatic->ref = $objp->crowid;
740 $subscriptionstatic->id = $objp->crowid;
742 $typeid = $objp->cfk_type;
744 $adht->fetch($typeid);
747 print
'<tr class="oddeven">';
748 print
'<td>'.$subscriptionstatic->getNomUrl(1).
'</td>';
749 print
'<td class="center">'.dol_print_date($db->jdate($objp->datec),
'dayhour').
"</td>\n";
750 print
'<td class="center">';
752 print $adht->getNomUrl(1);
755 print
'<td class="center">'.dol_print_date($db->jdate($objp->dateh),
'day').
"</td>\n";
756 print
'<td class="center">'.dol_print_date($db->jdate($objp->datef),
'day').
"</td>\n";
757 print
'<td class="right">'.price($objp->subscription).
'</td>';
758 if (!empty($conf->banque->enabled)) {
759 print
'<td class="right">';
761 $accountstatic->label = $objp->label;
762 $accountstatic->id = $objp->baid;
763 $accountstatic->number = $objp->number;
764 $accountstatic->account_number = $objp->account_number;
765 $accountstatic->currency_code = $objp->currency_code;
767 if (!empty($conf->accounting->enabled) && $objp->fk_accountancy_journal > 0) {
769 $accountingjournal->fetch($objp->fk_accountancy_journal);
771 $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
774 $accountstatic->ref = $objp->ref;
775 print $accountstatic->getNomUrl(1);
787 if (!empty($conf->banque->enabled)) {
790 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
800 if (($action !=
'addsubscription' && $action !=
'create_thirdparty')) {
802 $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled));
804 if ($useonlinepayment) {
807 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
808 print showOnlinePaymentUrl(
'membersubscription', $object->ref);
816 if (($action ==
'addsubscription' || $action ==
'create_thirdparty') && $user->rights->adherent->cotisation->creer) {
826 if (
GETPOST(
'paymentsave') ==
'bankdirect') {
829 if (
GETPOST(
'paymentsave') ==
'invoiceonly') {
832 if (
GETPOST(
'paymentsave') ==
'bankviainvoice') {
836 if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'bankviainvoice' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) &&
isModEnabled(
'facture')) {
838 } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'bankdirect' && !empty($conf->banque->enabled)) {
840 } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'invoiceonly' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) &&
isModEnabled(
'facture')) {
845 print
"\n\n<!-- Form add subscription -->\n";
847 if ($conf->use_javascript_ajax) {
849 print
"\n".
'<script type="text/javascript">';
850 print
'$(document).ready(function () {
851 $(".bankswitchclass, .bankswitchclass2").'.(($bankdirect || $bankviainvoice) ?
'show()' :
'hide()').
';
852 $("#none, #invoiceonly").click(function() {
853 $(".bankswitchclass").hide();
854 $(".bankswitchclass2").hide();
856 $("#bankdirect, #bankviainvoice").click(function() {
857 $(".bankswitchclass").show();
858 $(".bankswitchclass2").show();
860 $("#selectoperation").change(function() {
861 var code = $(this).val();
864 $(".fieldrequireddyn").addClass("fieldrequired");
865 if ($("#fieldchqemetteur").val() == "")
867 $("#fieldchqemetteur").val($("#memberlabel").val());
872 $(".fieldrequireddyn").removeClass("fieldrequired");
877 print
'$("#'.GETPOST(
'paymentsave',
'aZ09').
'").prop("checked", true);';
880 print
'</script>'.
"\n";
885 if ($action ==
'create_thirdparty') {
887 $fullname = $object->getFullName($langs);
889 if ($object->morphy ==
'mor') {
890 $companyname = $object->company;
891 if (!empty($fullname)) {
892 $companyalias = $fullname;
895 $companyname = $fullname;
896 if (!empty($object->company)) {
897 $companyalias = $object->company;
902 $formquestion = array(
903 array(
'label' => $langs->trans(
"NameToCreate"),
'type' =>
'text',
'name' =>
'companyname',
'value' => $companyname,
'morecss' =>
'minwidth300',
'moreattr' =>
'maxlength="128"'),
904 array(
'label' => $langs->trans(
"AliasNames"),
'type' =>
'text',
'name' =>
'companyalias',
'value' => $companyalias,
'morecss' =>
'minwidth300',
'moreattr' =>
'maxlength="128"')
907 if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) {
908 $tmpcompany =
new Societe($db);
909 $tmpcompany->name = $companyname;
910 $tmpcompany->get_codeclient($tmpcompany, 0);
911 $customercode = $tmpcompany->code_client;
912 $formquestion[] = array(
913 'label' => $langs->trans(
"CustomerCode"),
915 'name' =>
'customercode',
916 'value' => $customercode,
917 'morecss' =>
'minwidth300',
918 'moreattr' =>
'maxlength="128"',
923 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?rowid=".$object->id, $langs->trans(
"CreateDolibarrThirdParty"), $langs->trans(
"ConfirmCreateThirdParty"),
"confirm_create_thirdparty", $formquestion, 1);
927 print
'<form name="subscription" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
928 print
'<input type="hidden" name="token" value="'.newToken().
'">';
929 print
'<input type="hidden" name="action" value="subscription">';
930 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
931 print
'<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).
'">';
932 print
'<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($object->company).
'">';
936 print
"<table class=\"border\" width=\"100%\">\n";
948 print
'<td class="fieldrequired">'.$langs->trans(
"DateSubscription").
'</td><td>';
953 $datefrom = $object->datevalid;
960 print
$form->selectDate($datefrom,
'',
'',
'',
'',
"subscription", 1, 1);
970 print
'<tr><td>'.$langs->trans(
"DateEndSubscription").
'</td><td>';
971 print
$form->selectDate($dateto,
'end',
'',
'',
'',
"subscription", 1, 0);
974 if ($adht->subscription) {
976 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>';
979 print
'<tr><td>'.$langs->trans(
"Label").
'</td>';
980 print
'<td><input name="label" type="text" size="32" value="';
981 if (empty($conf->global->MEMBER_NO_DEFAULT_LABEL)) {
982 print $langs->trans(
"Subscription").
' '.
dol_print_date(($datefrom ? $datefrom : time()),
"%Y");
984 print
'"></td></tr>';
987 if ((!empty($conf->banque->enabled) ||
isModEnabled(
'facture')) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) {
989 if ($object->fk_soc) {
990 $result = $company->fetch($object->fk_soc);
997 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'MoreActions');
1000 print
'<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"'.(empty($bankdirect) && empty($invoiceonly) && empty($bankviainvoice) ?
' checked' :
'').
'>';
1001 print
'<label for="none"> '.$langs->trans(
"None").
'</label><br>';
1003 if (!empty($conf->banque->enabled)) {
1004 print
'<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"'.(!empty($bankdirect) ?
' checked' :
'');
1005 print
'><label for="bankdirect"> '.$langs->trans(
"MoreActionBankDirect").
'</label><br>';
1008 if (!empty($conf->societe->enabled) &&
isModEnabled(
'facture')) {
1009 print
'<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(!empty($invoiceonly) ?
' checked' :
'');
1011 print
'><label for="invoiceonly"> '.$langs->trans(
"MoreActionInvoiceOnly");
1012 if ($object->fk_soc) {
1013 print
' ('.$langs->trans(
"ThirdParty").
': '.$company->getNomUrl(1).
')';
1016 if (empty($object->fk_soc)) {
1017 print
img_warning($langs->trans(
"NoThirdPartyAssociatedToMember"));
1019 print $langs->trans(
"NoThirdPartyAssociatedToMember");
1020 print
' - <a href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$object->id.
'&action=create_thirdparty">';
1021 print $langs->trans(
"CreateDolibarrThirdParty");
1024 if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS !=
'defaultforfoundationcountry') {
1025 print
'. <span class="opacitymedium">'.$langs->trans(
"NoVatOnSubscription", 0).
'</span>';
1027 if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
1029 $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
1033 print
'. '.$langs->transnoentitiesnoconv(
"ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1));
1035 print
'</label><br>';
1038 if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) &&
isModEnabled(
'facture')) {
1039 print
'<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(!empty($bankviainvoice) ?
' checked' :
'');
1041 print
'><label for="bankviainvoice"> '.$langs->trans(
"MoreActionBankViaInvoice");
1042 if ($object->fk_soc) {
1043 print
' ('.$langs->trans(
"ThirdParty").
': '.$company->getNomUrl(1).
')';
1046 if (empty($object->fk_soc)) {
1047 print
img_warning($langs->trans(
"NoThirdPartyAssociatedToMember"));
1049 print $langs->trans(
"NoThirdPartyAssociatedToMember");
1050 print
' - <a href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$object->id.
'&action=create_thirdparty">';
1051 print $langs->trans(
"CreateDolibarrThirdParty");
1054 if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS !=
'defaultforfoundationcountry') {
1055 print
'. <span class="opacitymedium">'.$langs->trans(
"NoVatOnSubscription", 0).
'</span>';
1057 if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
1059 $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
1063 print
'. '.$langs->transnoentitiesnoconv(
"ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1));
1065 print
'</label><br>';
1070 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"FinancialAccount").
'</td><td>';
1072 $form->select_comptes(
GETPOST(
'accountid'),
'accountid', 0,
'', 2,
'', 0,
'minwidth200');
1073 print
"</td></tr>\n";
1076 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
1077 $form->select_types_paiements(
GETPOST(
'operation'),
'operation',
'', 2, 1, 0, 0, 1,
'minwidth200');
1078 print
"</td></tr>\n";
1081 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"DatePayment").
'</td><td>';
1082 print
$form->selectDate(isset($paymentdate) ? $paymentdate : -1,
'payment', 0, 0, 1,
'subscription', 1, 1);
1083 print
"</td></tr>\n";
1085 print
'<tr class="bankswitchclass2"><td>'.$langs->trans(
'Numero');
1086 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
1088 print
'<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(!
GETPOST(
'num_chq') ?
'' :
GETPOST(
'num_chq')).
'"></td></tr>';
1090 print
'<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans(
'CheckTransmitter');
1091 print
' <em>('.$langs->trans(
"ChequeMaker").
')</em>';
1093 print
'<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(!
GETPOST(
'chqemetteur') ?
'' :
GETPOST(
'chqemetteur')).
'"></td></tr>';
1095 print
'<tr class="bankswitchclass2"><td>'.$langs->trans(
'Bank');
1096 print
' <em>('.$langs->trans(
"ChequeBank").
')</em>';
1098 print
'<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(!
GETPOST(
'chqbank') ?
'' :
GETPOST(
'chqbank')).
'"></td></tr>';
1102 print
'<tr><td></td><td></td></tr>';
1104 print
'<tr><td>'.$langs->trans(
"SendAcknowledgementByMail").
'</td>';
1106 if (!$object->email) {
1107 print $langs->trans(
"NoEMail");
1110 $adht->fetch($object->typeid);
1117 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1120 $outputlangs =
new Translate(
'', $conf);
1121 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
1123 $outputlangs->loadLangs(array(
"main",
"members"));
1125 $arraydefaultmessage =
null;
1126 $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
1128 if (!empty($labeltouse)) {
1129 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
1132 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1133 $subject = $arraydefaultmessage->topic;
1134 $msg = $arraydefaultmessage->content;
1142 $tmp =
'<input name="sendmail" type="checkbox"'.(GETPOST(
'sendmail',
'alpha') ?
' checked' : (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ?
' checked' :
'')).
'>';
1144 $helpcontent .=
'<b>'.$langs->trans(
"MailFrom").
'</b>: '.$conf->global->ADHERENT_MAIL_FROM.
'<br>'.
"\n";
1145 $helpcontent .=
'<b>'.$langs->trans(
"MailRecipient").
'</b>: '.$object->email.
'<br>'.
"\n";
1146 $helpcontent .=
'<b>'.$langs->trans(
"MailTopic").
'</b>:<br>'.
"\n";
1147 if ($subjecttosend) {
1148 $helpcontent .= $subjecttosend.
"\n";
1150 $langs->load(
"errors");
1151 $helpcontent .=
'<span class="error">'.$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Module310Name")).
'</span>'.
"\n";
1153 $helpcontent .=
"<br>";
1154 $helpcontent .=
'<b>'.$langs->trans(
"MailText").
'</b>:<br>';
1158 $langs->load(
"errors");
1159 $helpcontent .=
'<span class="error">'.$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Module310Name")).
'</span>'.
"\n";
1161 print
$form->textwithpicto($tmp, $helpcontent, 1,
'help',
'', 0, 2,
'helpemailtosend');
1169 print
'<div class="center">';
1170 $parameters = array();
1171 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1172 if (empty($reshook)) {
1173 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"AddSubscription").
'">';
1174 print
' ';
1175 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1181 print
"\n<!-- End form subscription -->\n\n";
1187 $langs->load(
"errors");
1188 print $langs->trans(
"ErrorRecordNotFound");