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 $defaultdelayunit =
'y';
86 $hookmanager->initHooks(array(
'subscription'));
89 $hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
90 $hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
91 $hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
98 if ($id > 0 || !empty($ref)) {
100 $result = $object->fetch($id, $ref);
103 $canadduser = ($user->admin || $user->rights->user->user->creer);
105 if ($object->user_id) {
107 $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer)
108 || (($user->id != $object->user_id) && $user->rights->user->user->creer));
109 $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password)
110 || (($user->id != $object->user_id) && $user->rights->user->user->password));
115 $canaddmember = $user->rights->adherent->creer;
118 $caneditfieldmember = $user->rights->adherent->creer;
122 $result =
restrictedArea($user,
'adherent', $object->id,
'',
'',
'socid',
'rowid', 0);
129 $parameters = array();
130 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
136 if (empty($reshook) && $action ==
'confirm_create_thirdparty' && $confirm ==
'yes' && $user->rights->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';
153 if (empty($reshook) && $action ==
'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) {
155 if (empty($user->rights->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'));
173 if (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'));
203 if ($user->rights->adherent->cotisation->creer && $action ==
'subscription' && !$cancel) {
206 $langs->load(
"banks");
208 $result = $object->fetch($rowid);
209 $result = $adht->fetch($object->typeid);
212 $datesubscription = 0;
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';
274 if (!empty($conf->banque->enabled) &&
GETPOST(
"paymentsave") !=
'none') {
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);
475 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
478 if (!empty($conf->societe->enabled)) {
482 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
483 print
'<input type="hidden" name="token" value="'.newToken().
'">';
484 print
'<input type="hidden" name="rowid" value="'.$object->id.
'">';
488 $linkback =
'<a href="'.DOL_URL_ROOT.
'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
490 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/adherents/vcard.php?id='.$object->id.
'" class="refid">';
491 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
492 $morehtmlref .=
'</a>';
494 dol_banner_tab($object,
'rowid', $linkback, 1,
'rowid',
'ref', $morehtmlref);
496 print
'<div class="fichecenter">';
497 print
'<div class="fichehalfleft">';
499 print
'<div class="underbanner clearboth"></div>';
500 print
'<table class="border centpercent tableforfield">';
503 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
504 print
'<tr><td class="titlefield">'.$langs->trans(
"Login").
' / '.$langs->trans(
"Id").
'</td><td class="valeur">'.
dol_escape_htmltag($object->login).
'</td></tr>';
508 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td class="valeur">'.$adht->getNomUrl(1).
"</td></tr>\n";
511 print
'<tr><td>'.$langs->trans(
"MemberNature").
'</td><td class="valeur" >'.$object->getmorphylib().
'</td>';
515 print
'<tr><td>'.$langs->trans(
"Company").
'</td><td class="valeur">'.
dol_escape_htmltag($object->company).
'</td></tr>';
518 print
'<tr><td>'.$langs->trans(
"UserTitle").
'</td><td class="valeur">'.$object->getCivilityLabel().
'</td>';
522 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
523 print
'<tr><td>'.$langs->trans(
"Password").
'</td><td>';
525 print preg_replace(
'/./i',
'*', $object->pass);
528 print
'<!-- '.$langs->trans(
"Crypted").
': '.$object->pass_indatabase_crypted.
' -->';
530 print
'<span class="opacitymedium">'.$langs->trans(
"Hidden").
'</span>';
532 if (!empty($object->pass_indatabase) && empty($object->user_id)) {
533 $langs->load(
"errors");
534 $htmltext = $langs->trans(
"WarningPasswordSetWithNoAccount");
535 print
' '.$form->textwithpicto(
'', $htmltext, 1,
'warning');
541 print
'<tr><td>'.$langs->trans(
"SubscriptionEndDate").
'</td><td class="valeur">';
542 if ($object->datefin) {
544 if ($object->hasDelay()) {
545 print
" ".img_warning($langs->trans(
"Late"));
548 if ($object->need_subscription == 0) {
549 print $langs->trans(
"SubscriptionNotNeeded");
550 } elseif (!$adht->subscription) {
551 print $langs->trans(
"SubscriptionNotRecorded");
553 print
" ".img_warning($langs->trans(
"Late"));
556 print $langs->trans(
"SubscriptionNotReceived");
558 print
" ".img_warning($langs->trans(
"Late"));
568 print
'<div class="fichehalfright">';
569 print
'<div class="underbanner clearboth"></div>';
571 print
'<table class="border tableforfield centpercent">';
574 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
575 print
'<tr><td>'.$langs->trans(
"Categories").
'</td>';
576 print
'<td colspan="2">';
577 print
$form->showCategories($object->id, Categorie::TYPE_MEMBER, 1);
582 print
'<tr><td class="titlefield">'.$langs->trans(
"DateOfBirth").
'</td><td class="valeur">'.
dol_print_date($object->birth,
'day').
'</td></tr>';
585 print
'<tr><td>'.$langs->trans(
"Public").
'</td><td class="valeur">'.
yn($object->public).
'</td></tr>';
589 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
592 if (!empty($conf->societe->enabled)) {
594 print
'<table class="nobordernopadding" width="100%"><tr><td>';
595 print $langs->trans(
"LinkedToDolibarrThirdParty");
597 if ($action !=
'editthirdparty' && $user->rights->adherent->creer) {
598 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>';
600 print
'</tr></table>';
601 print
'</td><td colspan="2" class="valeur">';
602 if ($action ==
'editthirdparty') {
604 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'" name="form'.$htmlname.
'">';
605 print
'<input type="hidden" name="rowid" value="'.$object->id.
'">';
606 print
'<input type="hidden" name="action" value="set'.$htmlname.
'">';
607 print
'<input type="hidden" name="token" value="'.newToken().
'">';
608 print
'<table class="nobordernopadding">';
610 print
$form->select_company($object->fk_soc,
'socid',
'', 1);
612 print
'<td class="left"><input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
613 print
'</tr></table></form>';
615 if ($object->fk_soc) {
617 $result = $company->fetch($object->fk_soc);
618 print $company->getNomUrl(1);
621 $tmparray = $company->getOutstandingBills(
'customer');
622 if (!empty($tmparray[
'refs'])) {
623 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']).
')';
628 print
'<span class="opacitymedium">'.$langs->trans(
"NoThirdPartyAssociatedToMember").
'</span>';
636 print
'<table class="nobordernopadding" width="100%"><tr><td>';
637 print $langs->trans(
"LinkedToDolibarrUser");
639 if ($action !=
'editlogin' && $user->rights->adherent->creer) {
640 print
'<td class="right">';
641 if ($user->rights->user->user->creer) {
642 print
'<a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editlogin&token='.
newToken().
'&rowid='.$object->id.
'">'.
img_edit($langs->trans(
'SetLinkToUser'), 1).
'</a>';
646 print
'</tr></table>';
647 print
'</td><td colspan="2" class="valeur">';
648 if ($action ==
'editlogin') {
649 $form->form_users($_SERVER[
'PHP_SELF'].
'?rowid='.$object->id, $object->user_id,
'userid',
'');
651 if ($object->user_id) {
652 $linkeduser =
new User($db);
653 $linkeduser->fetch($object->user_id);
654 print $linkeduser->getNomUrl(-1);
656 print
'<span class="opacitymedium">'.$langs->trans(
"NoDolibarrAccess").
'</span>';
663 print
"</div></div>\n";
664 print
'<div style="clear:both"></div>';
674 if ($user->rights->adherent->cotisation->creer) {
675 if ($action !=
'addsubscription' && $action !=
'create_thirdparty') {
676 print
'<div class="tabsAction">';
678 if ($object->statut > 0) {
679 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$rowid.
'&action=addsubscription&token='.
newToken().
'">'.$langs->trans(
"AddSubscription").
"</a></div>";
681 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"ValidateBefore")).
'">'.$langs->trans(
"AddSubscription").
'</a></div>';
691 if ($action !=
'addsubscription' && $action !=
'create_thirdparty') {
692 $sql =
"SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,";
693 $sql .=
" c.rowid as crowid, c.subscription,";
694 $sql .=
" c.datec, c.fk_type as cfk_type,";
695 $sql .=
" c.dateadh as dateh,";
697 $sql .=
" c.fk_bank,";
698 $sql .=
" b.rowid as bid,";
699 $sql .=
" ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code";
700 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as d, ".MAIN_DB_PREFIX.
"subscription as c";
701 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON c.fk_bank = b.rowid";
702 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account as ba ON b.fk_account = ba.rowid";
703 $sql .=
" WHERE d.rowid = c.fk_adherent AND d.rowid=".((int) $rowid);
704 $sql .= $db->order($sortfield, $sortorder);
706 $result = $db->query($sql);
710 $num = $db->num_rows($result);
712 print
'<table class="noborder centpercent">'.
"\n";
714 print
'<tr class="liste_titre">';
716 print_liste_field_titre(
'DateCreation', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
718 print_liste_field_titre(
'DateStart', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
719 print_liste_field_titre(
'DateEnd', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
721 if (!empty($conf->banque->enabled)) {
722 print_liste_field_titre(
'Account', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
726 $accountstatic =
new Account($db);
732 $objp = $db->fetch_object($result);
734 $adh->id = $objp->rowid;
735 $adh->typeid = $objp->type;
737 $subscriptionstatic->ref = $objp->crowid;
738 $subscriptionstatic->id = $objp->crowid;
740 $typeid = $objp->cfk_type;
742 $adht->fetch($typeid);
745 print
'<tr class="oddeven">';
746 print
'<td>'.$subscriptionstatic->getNomUrl(1).
'</td>';
747 print
'<td class="center">'.dol_print_date($db->jdate($objp->datec),
'dayhour').
"</td>\n";
748 print
'<td class="center">';
750 print $adht->getNomUrl(1);
753 print
'<td class="center">'.dol_print_date($db->jdate($objp->dateh),
'day').
"</td>\n";
754 print
'<td class="center">'.dol_print_date($db->jdate($objp->datef),
'day').
"</td>\n";
755 print
'<td class="right">'.price($objp->subscription).
'</td>';
756 if (!empty($conf->banque->enabled)) {
757 print
'<td class="right">';
759 $accountstatic->label = $objp->label;
760 $accountstatic->id = $objp->baid;
761 $accountstatic->number = $objp->number;
762 $accountstatic->account_number = $objp->account_number;
763 $accountstatic->currency_code = $objp->currency_code;
765 if (!empty($conf->accounting->enabled) && $objp->fk_accountancy_journal > 0) {
767 $accountingjournal->fetch($objp->fk_accountancy_journal);
769 $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
772 $accountstatic->ref = $objp->ref;
773 print $accountstatic->getNomUrl(1);
785 if (!empty($conf->banque->enabled)) {
788 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
798 if (($action !=
'addsubscription' && $action !=
'create_thirdparty')) {
800 $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled));
802 if ($useonlinepayment) {
805 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
806 print showOnlinePaymentUrl(
'membersubscription', $object->ref);
814 if (($action ==
'addsubscription' || $action ==
'create_thirdparty') && $user->rights->adherent->cotisation->creer) {
824 if (
GETPOST(
'paymentsave') ==
'bankdirect') {
827 if (
GETPOST(
'paymentsave') ==
'invoiceonly') {
830 if (
GETPOST(
'paymentsave') ==
'bankviainvoice') {
834 if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'bankviainvoice' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) &&
isModEnabled(
'facture')) {
836 } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'bankdirect' && !empty($conf->banque->enabled)) {
838 } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'invoiceonly' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) &&
isModEnabled(
'facture')) {
843 print
"\n\n<!-- Form add subscription -->\n";
845 if ($conf->use_javascript_ajax) {
847 print
"\n".
'<script type="text/javascript">';
848 print
'$(document).ready(function () {
849 $(".bankswitchclass, .bankswitchclass2").'.(($bankdirect || $bankviainvoice) ?
'show()' :
'hide()').
';
850 $("#none, #invoiceonly").click(function() {
851 $(".bankswitchclass").hide();
852 $(".bankswitchclass2").hide();
854 $("#bankdirect, #bankviainvoice").click(function() {
855 $(".bankswitchclass").show();
856 $(".bankswitchclass2").show();
858 $("#selectoperation").change(function() {
859 var code = $(this).val();
862 $(".fieldrequireddyn").addClass("fieldrequired");
863 if ($("#fieldchqemetteur").val() == "")
865 $("#fieldchqemetteur").val($("#memberlabel").val());
870 $(".fieldrequireddyn").removeClass("fieldrequired");
875 print
'$("#'.GETPOST(
'paymentsave',
'aZ09').
'").prop("checked", true);';
878 print
'</script>'.
"\n";
883 if ($action ==
'create_thirdparty') {
885 $fullname = $object->getFullName($langs);
887 if ($object->morphy ==
'mor') {
888 $companyname = $object->company;
889 if (!empty($fullname)) {
890 $companyalias = $fullname;
893 $companyname = $fullname;
894 if (!empty($object->company)) {
895 $companyalias = $object->company;
900 $formquestion = array(
901 array(
'label' => $langs->trans(
"NameToCreate"),
'type' =>
'text',
'name' =>
'companyname',
'value' => $companyname,
'morecss' =>
'minwidth300',
'moreattr' =>
'maxlength="128"'),
902 array(
'label' => $langs->trans(
"AliasNames"),
'type' =>
'text',
'name' =>
'companyalias',
'value' => $companyalias,
'morecss' =>
'minwidth300',
'moreattr' =>
'maxlength="128"')
905 if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) {
906 $tmpcompany =
new Societe($db);
907 $tmpcompany->name = $companyname;
908 $tmpcompany->get_codeclient($tmpcompany, 0);
909 $customercode = $tmpcompany->code_client;
910 $formquestion[] = array(
911 'label' => $langs->trans(
"CustomerCode"),
913 'name' =>
'customercode',
914 'value' => $customercode,
915 'morecss' =>
'minwidth300',
916 'moreattr' =>
'maxlength="128"',
921 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?rowid=".$object->id, $langs->trans(
"CreateDolibarrThirdParty"), $langs->trans(
"ConfirmCreateThirdParty"),
"confirm_create_thirdparty", $formquestion, 1);
925 print
'<form name="subscription" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
926 print
'<input type="hidden" name="token" value="'.newToken().
'">';
927 print
'<input type="hidden" name="action" value="subscription">';
928 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
929 print
'<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).
'">';
930 print
'<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($object->company).
'">';
934 print
"<table class=\"border\" width=\"100%\">\n";
946 print
'<td class="fieldrequired">'.$langs->trans(
"DateSubscription").
'</td><td>';
951 $datefrom = $object->datevalid;
958 print
$form->selectDate($datefrom,
'',
'',
'',
'',
"subscription", 1, 1);
968 print
'<tr><td>'.$langs->trans(
"DateEndSubscription").
'</td><td>';
969 print
$form->selectDate($dateto,
'end',
'',
'',
'',
"subscription", 1, 0);
972 if ($adht->subscription) {
974 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>';
977 print
'<tr><td>'.$langs->trans(
"Label").
'</td>';
978 print
'<td><input name="label" type="text" size="32" value="';
979 if (empty($conf->global->MEMBER_NO_DEFAULT_LABEL)) {
980 print $langs->trans(
"Subscription").
' '.
dol_print_date(($datefrom ? $datefrom : time()),
"%Y");
982 print
'"></td></tr>';
985 if ((!empty($conf->banque->enabled) ||
isModEnabled(
'facture')) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) {
987 if ($object->fk_soc) {
988 $result = $company->fetch($object->fk_soc);
995 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'MoreActions');
998 print
'<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"'.(empty($bankdirect) && empty($invoiceonly) && empty($bankviainvoice) ?
' checked' :
'').
'>';
999 print
'<label for="none"> '.$langs->trans(
"None").
'</label><br>';
1001 if (!empty($conf->banque->enabled)) {
1002 print
'<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"'.(!empty($bankdirect) ?
' checked' :
'');
1003 print
'><label for="bankdirect"> '.$langs->trans(
"MoreActionBankDirect").
'</label><br>';
1006 if (!empty($conf->societe->enabled) &&
isModEnabled(
'facture')) {
1007 print
'<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(!empty($invoiceonly) ?
' checked' :
'');
1009 print
'><label for="invoiceonly"> '.$langs->trans(
"MoreActionInvoiceOnly");
1010 if ($object->fk_soc) {
1011 print
' ('.$langs->trans(
"ThirdParty").
': '.$company->getNomUrl(1).
')';
1014 if (empty($object->fk_soc)) {
1015 print
img_warning($langs->trans(
"NoThirdPartyAssociatedToMember"));
1017 print $langs->trans(
"NoThirdPartyAssociatedToMember");
1018 print
' - <a href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$object->id.
'&action=create_thirdparty">';
1019 print $langs->trans(
"CreateDolibarrThirdParty");
1022 if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS !=
'defaultforfoundationcountry') {
1023 print
'. <span class="opacitymedium">'.$langs->trans(
"NoVatOnSubscription", 0).
'</span>';
1025 if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
1027 $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
1031 print
'. '.$langs->transnoentitiesnoconv(
"ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1));
1033 print
'</label><br>';
1036 if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) &&
isModEnabled(
'facture')) {
1037 print
'<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(!empty($bankviainvoice) ?
' checked' :
'');
1039 print
'><label for="bankviainvoice"> '.$langs->trans(
"MoreActionBankViaInvoice");
1040 if ($object->fk_soc) {
1041 print
' ('.$langs->trans(
"ThirdParty").
': '.$company->getNomUrl(1).
')';
1044 if (empty($object->fk_soc)) {
1045 print
img_warning($langs->trans(
"NoThirdPartyAssociatedToMember"));
1047 print $langs->trans(
"NoThirdPartyAssociatedToMember");
1048 print
' - <a href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$object->id.
'&action=create_thirdparty">';
1049 print $langs->trans(
"CreateDolibarrThirdParty");
1052 if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS !=
'defaultforfoundationcountry') {
1053 print
'. <span class="opacitymedium">'.$langs->trans(
"NoVatOnSubscription", 0).
'</span>';
1055 if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
1057 $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
1061 print
'. '.$langs->transnoentitiesnoconv(
"ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1));
1063 print
'</label><br>';
1068 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"FinancialAccount").
'</td><td>';
1070 $form->select_comptes(
GETPOST(
'accountid'),
'accountid', 0,
'', 2,
'', 0,
'minwidth200');
1071 print
"</td></tr>\n";
1074 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
1075 $form->select_types_paiements(
GETPOST(
'operation'),
'operation',
'', 2, 1, 0, 0, 1,
'minwidth200');
1076 print
"</td></tr>\n";
1079 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"DatePayment").
'</td><td>';
1080 print
$form->selectDate(isset($paymentdate) ? $paymentdate : -1,
'payment', 0, 0, 1,
'subscription', 1, 1);
1081 print
"</td></tr>\n";
1083 print
'<tr class="bankswitchclass2"><td>'.$langs->trans(
'Numero');
1084 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
1086 print
'<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(!
GETPOST(
'num_chq') ?
'' :
GETPOST(
'num_chq')).
'"></td></tr>';
1088 print
'<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans(
'CheckTransmitter');
1089 print
' <em>('.$langs->trans(
"ChequeMaker").
')</em>';
1091 print
'<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(!
GETPOST(
'chqemetteur') ?
'' :
GETPOST(
'chqemetteur')).
'"></td></tr>';
1093 print
'<tr class="bankswitchclass2"><td>'.$langs->trans(
'Bank');
1094 print
' <em>('.$langs->trans(
"ChequeBank").
')</em>';
1096 print
'<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(!
GETPOST(
'chqbank') ?
'' :
GETPOST(
'chqbank')).
'"></td></tr>';
1100 print
'<tr><td></td><td></td></tr>';
1102 print
'<tr><td>'.$langs->trans(
"SendAcknowledgementByMail").
'</td>';
1104 if (!$object->email) {
1105 print $langs->trans(
"NoEMail");
1108 $adht->fetch($object->typeid);
1115 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1118 $outputlangs =
new Translate(
'', $conf);
1119 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
1121 $outputlangs->loadLangs(array(
"main",
"members"));
1123 $arraydefaultmessage =
null;
1124 $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
1126 if (!empty($labeltouse)) {
1127 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
1130 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1131 $subject = $arraydefaultmessage->topic;
1132 $msg = $arraydefaultmessage->content;
1140 $tmp =
'<input name="sendmail" type="checkbox"'.(GETPOST(
'sendmail',
'alpha') ?
' checked' : (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ?
' checked' :
'')).
'>';
1142 $helpcontent .=
'<b>'.$langs->trans(
"MailFrom").
'</b>: '.$conf->global->ADHERENT_MAIL_FROM.
'<br>'.
"\n";
1143 $helpcontent .=
'<b>'.$langs->trans(
"MailRecipient").
'</b>: '.$object->email.
'<br>'.
"\n";
1144 $helpcontent .=
'<b>'.$langs->trans(
"MailTopic").
'</b>:<br>'.
"\n";
1145 if ($subjecttosend) {
1146 $helpcontent .= $subjecttosend.
"\n";
1148 $langs->load(
"errors");
1149 $helpcontent .=
'<span class="error">'.$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Module310Name")).
'</span>'.
"\n";
1151 $helpcontent .=
"<br>";
1152 $helpcontent .=
'<b>'.$langs->trans(
"MailText").
'</b>:<br>';
1156 $langs->load(
"errors");
1157 $helpcontent .=
'<span class="error">'.$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Module310Name")).
'</span>'.
"\n";
1159 print
$form->textwithpicto($tmp, $helpcontent, 1,
'help',
'', 0, 2,
'helpemailtosend');
1167 print
'<div class="center">';
1168 $parameters = array();
1169 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1170 if (empty($reshook)) {
1171 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"AddSubscription").
'">';
1172 print
' ';
1173 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1179 print
"\n<!-- End form subscription -->\n\n";
1185 $langs->load(
"errors");
1186 print $langs->trans(
"ErrorRecordNotFound");