31 require
'../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/member.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
42 $langs->loadLangs(array(
"companies",
"bills",
"members",
"users",
"mails",
'other'));
44 $optioncss =
GETPOST(
'optioncss',
'aZ');
46 $action =
GETPOST(
'action',
'aZ09');
47 $confirm =
GETPOST(
'confirm',
'alpha');
50 $ref =
GETPOST(
'ref',
'alphanohtml');
51 $typeid =
GETPOST(
'typeid',
'int');
55 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
56 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
57 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
59 if (empty($page) || $page == -1) {
62 $offset = $limit * $page;
63 $pageprev = $page - 1;
64 $pagenext = $page + 1;
68 $sortfield =
"c.rowid";
79 $extrafields->fetch_name_optionals_label($object->table_element);
84 $defaultdelayunit =
'y';
87 $hookmanager->initHooks(array(
'subscription'));
90 $hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
91 $hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
92 $hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
99 if ($id > 0 || !empty($ref)) {
101 $result = $object->fetch($id, $ref);
104 $canadduser = ($user->admin || $user->hasRight(
"user",
"user",
"creer"));
106 if ($object->user_id) {
108 $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight(
"user",
"self",
"creer"))
109 || (($user->id != $object->user_id) && $user->hasRight(
"user",
"user",
"creer")));
110 $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight(
"user",
"self",
"password"))
111 || (($user->id != $object->user_id) && $user->hasRight(
"user",
"user",
"password")));
116 $canaddmember = $user->hasRight(
'adherent',
'creer');
119 $caneditfieldmember = $user->hasRight(
'adherent',
'creer');
123 $result =
restrictedArea($user,
'adherent', $object->id,
'',
'',
'socid',
'rowid', 0);
130 $parameters = array();
131 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
137 if (empty($reshook) && $action ==
'confirm_create_thirdparty' && $confirm ==
'yes' && $user->rights->societe->creer) {
141 $result = $company->create_from_member($object,
GETPOST(
'companyname',
'alpha'),
GETPOST(
'companyalias',
'alpha'),
GETPOST(
'customercode',
'alpha'));
144 $langs->load(
"errors");
147 $action =
'addsubscription';
154 if (empty($reshook) && $action ==
'setuserid' && ($user->rights->user->self->creer || $user->hasRight(
'user',
'user',
'creer'))) {
156 if (!$user->hasRight(
'user',
'user',
'creer')) {
157 if (
GETPOST(
"userid",
'int') != $user->id &&
GETPOST(
"userid",
'int') != $object->user_id) {
159 setEventMessages($langs->trans(
"ErrorUserPermissionAllowsToLinksToItselfOnly"),
null,
'errors');
164 if (
GETPOST(
"userid",
'int') != $object->user_id) {
165 $result = $object->setUserId(
GETPOST(
"userid",
'int'));
174 if (empty($reshook) && $action ==
'setsocid') {
177 if (
GETPOST(
'socid',
'int') != $object->fk_soc) {
178 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
179 $sql .=
" WHERE fk_soc = '".GETPOST(
'socid',
'int').
"'";
180 $resql = $db->query(
$sql);
182 $obj = $db->fetch_object($resql);
183 if ($obj && $obj->rowid > 0) {
185 $othermember->fetch($obj->rowid);
186 $thirdparty =
new Societe($db);
187 $thirdparty->fetch(
GETPOST(
'socid',
'int'));
189 setEventMessages($langs->trans(
"ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name),
null,
'errors');
194 $result = $object->setThirdPartyId(
GETPOST(
'socid',
'int'));
204 if ($user->hasRight(
'adherent',
'cotisation',
'creer') && $action ==
'subscription' && !$cancel) {
207 $langs->load(
"banks");
209 $result = $object->fetch($rowid);
210 $result = $adht->fetch($object->typeid);
213 $datesubscription = 0;
222 if (
GETPOST(
"paymentyear",
'int') &&
GETPOST(
"paymentmonth",
'int') &&
GETPOST(
"paymentday",
'int')) {
229 $accountid =
GETPOST(
"accountid",
'int');
230 $operation =
GETPOST(
"operation",
"alphanohtml");
231 $num_chq =
GETPOST(
"num_chq",
"alphanohtml");
232 $emetteur_nom =
GETPOST(
"chqemetteur");
233 $emetteur_banque =
GETPOST(
"chqbank");
234 $option =
GETPOST(
"paymentsave");
235 if (empty($option)) {
238 $sendalsoemail =
GETPOST(
"sendmail",
'alpha');
241 if (!$datesubscription) {
243 $langs->load(
"errors");
244 $errmsg = $langs->trans(
"ErrorBadDateFormat", $langs->transnoentitiesnoconv(
"DateSubscription"));
246 $action =
'addsubscription';
248 if (
GETPOST(
'end') && !$datesubend) {
250 $langs->load(
"errors");
251 $errmsg = $langs->trans(
"ErrorBadDateFormat", $langs->transnoentitiesnoconv(
"DateEndSubscription"));
253 $action =
'addsubscription';
258 if (($option ==
'bankviainvoice' || $option ==
'bankdirect') && !$paymentdate) {
260 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DatePayment"));
262 $action =
'addsubscription';
266 if ($adht->subscription) {
267 if (!is_numeric($amount)) {
269 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount"));
272 $action =
'addsubscription';
278 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label"));
281 $action =
'addsubscription';
283 if (
GETPOST(
"paymentsave") !=
'invoiceonly' && !
GETPOST(
"operation")) {
284 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode"));
287 $action =
'addsubscription';
289 if (
GETPOST(
"paymentsave") !=
'invoiceonly' && !(
GETPOST(
"accountid",
'int') > 0)) {
290 $errmsg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"FinancialAccount"));
293 $action =
'addsubscription';
296 if (
GETPOST(
"accountid",
'int')) {
297 $errmsg = $langs->trans(
"ErrorDoNotProvideAccountsIfNullAmount");
300 $action =
'addsubscription';
308 if (!$error && $action ==
'subscription') {
312 $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend);
315 $errmsg = $object->error;
320 $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque);
333 $action =
'addsubscription';
343 if ($object->email && $sendalsoemail) {
345 'datesubscription' => $datesubscription,
347 'ccountid' => $accountid,
348 'operation' => $operation,
350 'num_chq' => $num_chq,
351 'emetteur_nom' => $emetteur_nom,
352 'emetteur_banque' => $emetteur_banque,
353 'datesubend' => $datesubend
355 $reshook = $hookmanager->executeHooks(
'sendMail', $parameters, $object, $action);
360 if (empty($reshook)) {
365 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
369 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
371 $outputlangs->loadLangs(array(
"main",
"members"));
374 $arraydefaultmessage =
null;
375 $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
377 if (!empty($labeltouse)) {
378 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
381 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
382 $subject = $arraydefaultmessage->topic;
383 $msg = $arraydefaultmessage->content;
393 $listofpaths = array();
394 $listofnames = array();
395 $listofmimes = array();
396 if (is_object($object->invoice) && (!is_object($arraydefaultmessage) || intval($arraydefaultmessage->joinfiles))) {
397 $invoicediroutput = $conf->facture->dir_output;
398 $fileparams =
dol_most_recent_file($invoicediroutput.
'/'.$object->invoice->ref, preg_quote($object->invoice->ref,
'/').
'[^\-]+');
399 $file = $fileparams[
'fullname'];
401 $listofpaths = array($file);
402 $listofnames = array(basename($file));
406 $moreinheader =
'X-Dolibarr-Info: send_an_email by adherents/subscription.php'.
"\r\n";
408 $result = $object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
'', $moreinheader);
410 $errmsg = $object->error;
413 setEventMessages($langs->trans(
"EmailSentToMember", $object->email),
null,
'mesgs');
423 $_POST[
"subscription"] =
'';
424 $_POST[
"accountid"] =
'';
425 $_POST[
"operation"] =
'';
426 $_POST[
"label"] =
'';
427 $_POST[
"num_chq"] =
'';
442 $title = $langs->trans(
"Member").
" - ".$langs->trans(
"Subscriptions");
444 $help_url =
"EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder";
450 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
451 $param .=
'&contextpage='.urlencode($contextpage);
453 if ($limit > 0 && $limit != $conf->liste_limit) {
454 $param .=
'&limit='.urlencode($limit);
456 $param .=
'&id='.$rowid;
457 if ($optioncss !=
'') {
458 $param .=
'&optioncss='.urlencode($optioncss);
465 $res = $object->fetch($rowid);
471 $adht->fetch($object->typeid);
476 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
483 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
484 print
'<input type="hidden" name="token" value="'.newToken().
'">';
485 print
'<input type="hidden" name="rowid" value="'.$object->id.
'">';
489 $linkback =
'<a href="'.DOL_URL_ROOT.
'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
491 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/adherents/vcard.php?id='.$object->id.
'" class="refid">';
492 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
493 $morehtmlref .=
'</a>';
495 dol_banner_tab($object,
'rowid', $linkback, 1,
'rowid',
'ref', $morehtmlref);
497 print
'<div class="fichecenter">';
498 print
'<div class="fichehalfleft">';
500 print
'<div class="underbanner clearboth"></div>';
501 print
'<table class="border centpercent tableforfield">';
504 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
505 print
'<tr><td class="titlefield">'.$langs->trans(
"Login").
' / '.$langs->trans(
"Id").
'</td><td class="valeur">'.
dol_escape_htmltag($object->login).
'</td></tr>';
509 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td>';
510 print
'<td class="valeur">'.$adht->getNomUrl(1).
"</td></tr>\n";
513 print
'<tr><td>'.$langs->trans(
"MemberNature").
'</td>';
514 print
'<td class="valeur" >'.$object->getmorphylib(
'', 1).
'</td>';
518 print
'<tr><td>'.$langs->trans(
"Company").
'</td><td class="valeur">'.
dol_escape_htmltag($object->company).
'</td></tr>';
521 print
'<tr><td>'.$langs->trans(
"UserTitle").
'</td><td class="valeur">'.$object->getCivilityLabel().
'</td>';
525 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
526 print
'<tr><td>'.$langs->trans(
"Password").
'</td><td>';
528 print preg_replace(
'/./i',
'*', $object->pass);
531 print
'<!-- '.$langs->trans(
"Crypted").
': '.$object->pass_indatabase_crypted.
' -->';
533 print
'<span class="opacitymedium">'.$langs->trans(
"Hidden").
'</span>';
535 if (!empty($object->pass_indatabase) && empty($object->user_id)) {
536 $langs->load(
"errors");
537 $htmltext = $langs->trans(
"WarningPasswordSetWithNoAccount");
538 print
' '.$form->textwithpicto(
'', $htmltext, 1,
'warning');
544 print
'<tr><td>'.$langs->trans(
"SubscriptionEndDate").
'</td><td class="valeur">';
545 if ($object->datefin) {
547 if ($object->hasDelay()) {
548 print
" ".img_warning($langs->trans(
"Late"));
551 if ($object->need_subscription == 0) {
552 print $langs->trans(
"SubscriptionNotNeeded");
553 } elseif (!$adht->subscription) {
554 print $langs->trans(
"SubscriptionNotRecorded");
556 print
" ".img_warning($langs->trans(
"Late"));
559 print $langs->trans(
"SubscriptionNotReceived");
561 print
" ".img_warning($langs->trans(
"Late"));
571 print
'<div class="fichehalfright">';
572 print
'<div class="underbanner clearboth"></div>';
574 print
'<table class="border tableforfield centpercent">';
577 if (
isModEnabled(
'categorie') && !empty($user->rights->categorie->lire)) {
578 print
'<tr><td>'.$langs->trans(
"Categories").
'</td>';
579 print
'<td colspan="2">';
580 print
$form->showCategories($object->id, Categorie::TYPE_MEMBER, 1);
585 print
'<tr><td class="titlefield">'.$langs->trans(
"DateOfBirth").
'</td><td class="valeur">'.
dol_print_date($object->birth,
'day').
'</td></tr>';
588 print
'<tr><td>'.$langs->trans(
"Public").
'</td><td class="valeur">'.
yn($object->public).
'</td></tr>';
592 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
597 print
'<table class="nobordernopadding" width="100%"><tr><td>';
598 print $langs->trans(
"LinkedToDolibarrThirdParty");
600 if ($action !=
'editthirdparty' && $user->hasRight(
'adherent',
'creer')) {
601 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>';
603 print
'</tr></table>';
604 print
'</td><td colspan="2" class="valeur">';
605 if ($action ==
'editthirdparty') {
607 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'" name="form'.$htmlname.
'">';
608 print
'<input type="hidden" name="rowid" value="'.$object->id.
'">';
609 print
'<input type="hidden" name="action" value="set'.$htmlname.
'">';
610 print
'<input type="hidden" name="token" value="'.newToken().
'">';
611 print
'<table class="nobordernopadding">';
613 print
$form->select_company($object->fk_soc,
'socid',
'', 1);
615 print
'<td class="left"><input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
616 print
'</tr></table></form>';
618 if ($object->fk_soc) {
620 $result = $company->fetch($object->fk_soc);
621 print $company->getNomUrl(1);
624 $tmparray = $company->getOutstandingBills(
'customer');
625 if (!empty($tmparray[
'refs'])) {
626 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']).
')';
631 print
'<span class="opacitymedium">'.$langs->trans(
"NoThirdPartyAssociatedToMember").
'</span>';
639 print
'<table class="nobordernopadding" width="100%"><tr><td>';
640 print $langs->trans(
"LinkedToDolibarrUser");
642 if ($action !=
'editlogin' && $user->hasRight(
'adherent',
'creer')) {
643 print
'<td class="right">';
644 if ($user->hasRight(
"user",
"user",
"creer")) {
645 print
'<a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editlogin&token='.
newToken().
'&rowid='.$object->id.
'">'.
img_edit($langs->trans(
'SetLinkToUser'), 1).
'</a>';
649 print
'</tr></table>';
650 print
'</td><td colspan="2" class="valeur">';
651 if ($action ==
'editlogin') {
652 $form->form_users($_SERVER[
'PHP_SELF'].
'?rowid='.$object->id, $object->user_id,
'userid',
'');
654 if ($object->user_id) {
655 $linkeduser =
new User($db);
656 $linkeduser->fetch($object->user_id);
657 print $linkeduser->getNomUrl(-1);
659 print
'<span class="opacitymedium">'.$langs->trans(
"NoDolibarrAccess").
'</span>';
666 print
"</div></div>\n";
667 print
'<div class="clearboth"></div>';
677 if ($user->hasRight(
'adherent',
'cotisation',
'creer')) {
678 if ($action !=
'addsubscription' && $action !=
'create_thirdparty') {
679 print
'<div class="tabsAction">';
681 if ($object->statut > 0) {
682 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$rowid.
'&action=addsubscription&token='.
newToken().
'">'.$langs->trans(
"AddSubscription").
"</a></div>";
684 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"ValidateBefore")).
'">'.$langs->trans(
"AddSubscription").
'</a></div>';
694 if ($action !=
'addsubscription' && $action !=
'create_thirdparty') {
695 $sql =
"SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,";
696 $sql .=
" c.rowid as crowid, c.subscription,";
697 $sql .=
" c.datec, c.fk_type as cfk_type,";
698 $sql .=
" c.dateadh as dateh,";
700 $sql .=
" c.fk_bank,";
701 $sql .=
" b.rowid as bid,";
702 $sql .=
" ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code";
703 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as d, ".MAIN_DB_PREFIX.
"subscription as c";
704 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON c.fk_bank = b.rowid";
705 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account as ba ON b.fk_account = ba.rowid";
706 $sql .=
" WHERE d.rowid = c.fk_adherent AND d.rowid=".((int) $rowid);
707 $sql .= $db->order($sortfield, $sortorder);
709 $result = $db->query(
$sql);
713 $num = $db->num_rows($result);
715 print
'<table class="noborder centpercent">'.
"\n";
717 print
'<tr class="liste_titre">';
719 print_liste_field_titre(
'DateCreation', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
721 print_liste_field_titre(
'DateStart', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
722 print_liste_field_titre(
'DateEnd', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
725 print_liste_field_titre(
'Account', $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
729 $accountstatic =
new Account($db);
735 $objp = $db->fetch_object($result);
737 $adh->id = $objp->rowid;
738 $adh->typeid = $objp->type;
740 $subscriptionstatic->ref = $objp->crowid;
741 $subscriptionstatic->id = $objp->crowid;
743 $typeid = $objp->cfk_type;
745 $adht->fetch($typeid);
748 print
'<tr class="oddeven">';
749 print
'<td>'.$subscriptionstatic->getNomUrl(1).
'</td>';
750 print
'<td class="center">'.dol_print_date($db->jdate($objp->datec),
'dayhour').
"</td>\n";
751 print
'<td class="center">';
753 print $adht->getNomUrl(1);
756 print
'<td class="center">'.dol_print_date($db->jdate($objp->dateh),
'day').
"</td>\n";
757 print
'<td class="center">'.dol_print_date($db->jdate($objp->datef),
'day').
"</td>\n";
758 print
'<td class="right">'.price($objp->subscription).
'</td>';
760 print
'<td class="right">';
762 $accountstatic->label = $objp->label;
763 $accountstatic->id = $objp->baid;
764 $accountstatic->number = $objp->number;
765 $accountstatic->account_number = $objp->account_number;
766 $accountstatic->currency_code = $objp->currency_code;
768 if (
isModEnabled(
'accounting') && $objp->fk_accountancy_journal > 0) {
770 $accountingjournal->fetch($objp->fk_accountancy_journal);
772 $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
775 $accountstatic->ref = $objp->ref;
776 print $accountstatic->getNomUrl(1);
791 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
801 if (($action !=
'addsubscription' && $action !=
'create_thirdparty')) {
805 if ($useonlinepayment) {
808 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
809 print showOnlinePaymentUrl(
'membersubscription', $object->ref);
817 if (($action ==
'addsubscription' || $action ==
'create_thirdparty') && $user->hasRight(
'adherent',
'cotisation',
'creer')) {
827 if (
GETPOST(
'paymentsave') ==
'bankdirect') {
830 if (
GETPOST(
'paymentsave') ==
'invoiceonly') {
833 if (
GETPOST(
'paymentsave') ==
'bankviainvoice') {
837 if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'bankviainvoice' &&
isModEnabled(
'banque') &&
isModEnabled(
'societe') &&
isModEnabled(
'facture')) {
839 } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'bankdirect' &&
isModEnabled(
'banque')) {
841 } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'invoiceonly' &&
isModEnabled(
'banque') &&
isModEnabled(
'societe') &&
isModEnabled(
'facture')) {
846 print
"\n\n<!-- Form add subscription -->\n";
848 if ($conf->use_javascript_ajax) {
850 print
"\n".
'<script type="text/javascript">';
851 print
'$(document).ready(function () {
852 $(".bankswitchclass, .bankswitchclass2").'.(($bankdirect || $bankviainvoice) ?
'show()' :
'hide()').
';
853 $("#none, #invoiceonly").click(function() {
854 $(".bankswitchclass").hide();
855 $(".bankswitchclass2").hide();
857 $("#bankdirect, #bankviainvoice").click(function() {
858 $(".bankswitchclass").show();
859 $(".bankswitchclass2").show();
861 $("#selectoperation").change(function() {
862 var code = $(this).val();
865 $(".fieldrequireddyn").addClass("fieldrequired");
866 if ($("#fieldchqemetteur").val() == "")
868 $("#fieldchqemetteur").val($("#memberlabel").val());
873 $(".fieldrequireddyn").removeClass("fieldrequired");
878 print
'$("#'.GETPOST(
'paymentsave',
'aZ09').
'").prop("checked", true);';
881 print
'</script>'.
"\n";
886 if ($action ==
'create_thirdparty') {
888 $fullname = $object->getFullName($langs);
890 if ($object->morphy ==
'mor') {
891 $companyname = $object->company;
892 if (!empty($fullname)) {
893 $companyalias = $fullname;
896 $companyname = $fullname;
897 if (!empty($object->company)) {
898 $companyalias = $object->company;
903 $formquestion = array(
904 array(
'label' => $langs->trans(
"NameToCreate"),
'type' =>
'text',
'name' =>
'companyname',
'value' => $companyname,
'morecss' =>
'minwidth300',
'moreattr' =>
'maxlength="128"'),
905 array(
'label' => $langs->trans(
"AliasNames"),
'type' =>
'text',
'name' =>
'companyalias',
'value' => $companyalias,
'morecss' =>
'minwidth300',
'moreattr' =>
'maxlength="128"')
908 if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) {
909 $tmpcompany =
new Societe($db);
910 $tmpcompany->name = $companyname;
911 $tmpcompany->get_codeclient($tmpcompany, 0);
912 $customercode = $tmpcompany->code_client;
913 $formquestion[] = array(
914 'label' => $langs->trans(
"CustomerCode"),
916 'name' =>
'customercode',
917 'value' => $customercode,
918 'morecss' =>
'minwidth300',
919 'moreattr' =>
'maxlength="128"',
924 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?rowid=".$object->id, $langs->trans(
"CreateDolibarrThirdParty"), $langs->trans(
"ConfirmCreateThirdParty"),
"confirm_create_thirdparty", $formquestion, 1);
928 print
'<form name="subscription" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
929 print
'<input type="hidden" name="token" value="'.newToken().
'">';
930 print
'<input type="hidden" name="action" value="subscription">';
931 print
'<input type="hidden" name="rowid" value="'.$rowid.
'">';
932 print
'<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).
'">';
933 print
'<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($object->company).
'">';
937 print
"<table class=\"border\" width=\"100%\">\n";
949 print
'<td class="fieldrequired">'.$langs->trans(
"DateSubscription").
'</td><td>';
954 $datefrom = $object->datevalid;
961 print
$form->selectDate($datefrom,
'',
'',
'',
'',
"subscription", 1, 1);
971 print
'<tr><td>'.$langs->trans(
"DateEndSubscription").
'</td><td>';
972 print
$form->selectDate($dateto,
'end',
'',
'',
'',
"subscription", 1, 0);
975 if ($adht->subscription) {
977 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>';
980 print
'<tr><td>'.$langs->trans(
"Label").
'</td>';
981 print
'<td><input name="label" type="text" size="32" value="';
982 if (empty($conf->global->MEMBER_NO_DEFAULT_LABEL)) {
983 print $langs->trans(
"Subscription").
' '.
dol_print_date(($datefrom ? $datefrom : time()),
"%Y");
985 print
'"></td></tr>';
988 if ((
isModEnabled(
'banque') ||
isModEnabled(
'facture')) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) {
990 if ($object->fk_soc) {
991 $result = $company->fetch($object->fk_soc);
998 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'MoreActions');
1001 print
'<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"'.(empty($bankdirect) && empty($invoiceonly) && empty($bankviainvoice) ?
' checked' :
'').
'>';
1002 print
'<label for="none"> '.$langs->trans(
"None").
'</label><br>';
1005 print
'<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"'.(!empty($bankdirect) ?
' checked' :
'');
1006 print
'><label for="bankdirect"> '.$langs->trans(
"MoreActionBankDirect").
'</label><br>';
1010 print
'<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(!empty($invoiceonly) ?
' checked' :
'');
1012 print
'><label for="invoiceonly"> '.$langs->trans(
"MoreActionInvoiceOnly");
1013 if ($object->fk_soc) {
1014 print
' ('.$langs->trans(
"ThirdParty").
': '.$company->getNomUrl(1).
')';
1017 if (empty($object->fk_soc)) {
1018 print
img_warning($langs->trans(
"NoThirdPartyAssociatedToMember"));
1020 print $langs->trans(
"NoThirdPartyAssociatedToMember");
1021 print
' - <a href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$object->id.
'&action=create_thirdparty">';
1022 print $langs->trans(
"CreateDolibarrThirdParty");
1025 if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS !=
'defaultforfoundationcountry') {
1026 print
'. <span class="opacitymedium">'.$langs->trans(
"NoVatOnSubscription", 0).
'</span>';
1028 if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (
isModEnabled(
'product') ||
isModEnabled(
'service'))) {
1030 $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
1034 print
'. '.$langs->transnoentitiesnoconv(
"ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1));
1036 print
'</label><br>';
1040 print
'<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(!empty($bankviainvoice) ?
' checked' :
'');
1042 print
'><label for="bankviainvoice"> '.$langs->trans(
"MoreActionBankViaInvoice");
1043 if ($object->fk_soc) {
1044 print
' ('.$langs->trans(
"ThirdParty").
': '.$company->getNomUrl(1).
')';
1047 if (empty($object->fk_soc)) {
1048 print
img_warning($langs->trans(
"NoThirdPartyAssociatedToMember"));
1050 print $langs->trans(
"NoThirdPartyAssociatedToMember");
1051 print
' - <a href="'.$_SERVER[
"PHP_SELF"].
'?rowid='.$object->id.
'&action=create_thirdparty">';
1052 print $langs->trans(
"CreateDolibarrThirdParty");
1055 if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS !=
'defaultforfoundationcountry') {
1056 print
'. <span class="opacitymedium">'.$langs->trans(
"NoVatOnSubscription", 0).
'</span>';
1058 if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (
isModEnabled(
'product')||
isModEnabled(
'service'))) {
1060 $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
1064 print
'. '.$langs->transnoentitiesnoconv(
"ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1));
1066 print
'</label><br>';
1071 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"FinancialAccount").
'</td><td>';
1073 $form->select_comptes(
GETPOST(
'accountid'),
'accountid', 0,
'', 2,
'', 0,
'minwidth200');
1074 print
"</td></tr>\n";
1077 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
1078 print
$form->select_types_paiements(
GETPOST(
'operation'),
'operation',
'', 2, 1, 0, 0, 1,
'minwidth200', 1);
1079 print
"</td></tr>\n";
1082 print
'<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans(
"DatePayment").
'</td><td>';
1083 print
$form->selectDate(isset($paymentdate) ? $paymentdate : -1,
'payment', 0, 0, 1,
'subscription', 1, 1);
1084 print
"</td></tr>\n";
1086 print
'<tr class="bankswitchclass2"><td>'.$langs->trans(
'Numero');
1087 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
1089 print
'<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(!
GETPOST(
'num_chq') ?
'' :
GETPOST(
'num_chq')).
'"></td></tr>';
1091 print
'<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans(
'CheckTransmitter');
1092 print
' <em>('.$langs->trans(
"ChequeMaker").
')</em>';
1094 print
'<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(!
GETPOST(
'chqemetteur') ?
'' :
GETPOST(
'chqemetteur')).
'"></td></tr>';
1096 print
'<tr class="bankswitchclass2"><td>'.$langs->trans(
'Bank');
1097 print
' <em>('.$langs->trans(
"ChequeBank").
')</em>';
1099 print
'<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(!
GETPOST(
'chqbank') ?
'' :
GETPOST(
'chqbank')).
'"></td></tr>';
1103 print
'<tr><td></td><td></td></tr>';
1105 print
'<tr><td>'.$langs->trans(
"SendAcknowledgementByMail").
'</td>';
1107 if (!$object->email) {
1108 print $langs->trans(
"NoEMail");
1111 $adht->fetch($object->typeid);
1118 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1121 $outputlangs =
new Translate(
'', $conf);
1122 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
1124 $outputlangs->loadLangs(array(
"main",
"members"));
1126 $arraydefaultmessage =
null;
1127 $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
1129 if (!empty($labeltouse)) {
1130 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
1133 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1134 $subject = $arraydefaultmessage->topic;
1135 $msg = $arraydefaultmessage->content;
1143 $tmp =
'<input name="sendmail" type="checkbox"'.(GETPOST(
'sendmail',
'alpha') ?
' checked' : (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ?
' checked' :
'')).
'>';
1145 $helpcontent .=
'<b>'.$langs->trans(
"MailFrom").
'</b>: '.
getDolGlobalString(
'ADHERENT_MAIL_FROM').
'<br>'.
"\n";
1146 $helpcontent .=
'<b>'.$langs->trans(
"MailRecipient").
'</b>: '.$object->email.
'<br>'.
"\n";
1147 $helpcontent .=
'<b>'.$langs->trans(
"MailTopic").
'</b>:<br>'.
"\n";
1148 if ($subjecttosend) {
1149 $helpcontent .= $subjecttosend.
"\n";
1151 $langs->load(
"errors");
1152 $helpcontent .=
'<span class="error">'.$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Module310Name")).
'</span>'.
"\n";
1154 $helpcontent .=
"<br>";
1155 $helpcontent .=
'<b>'.$langs->trans(
"MailText").
'</b>:<br>';
1159 $langs->load(
"errors");
1160 $helpcontent .=
'<span class="error">'.$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Module310Name")).
'</span>'.
"\n";
1162 print
$form->textwithpicto($tmp, $helpcontent, 1,
'help',
'', 0, 2,
'helpemailtosend');
1170 print
'<div class="center">';
1171 $parameters = array();
1172 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1173 if (empty($reshook)) {
1174 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"AddSubscription").
'">';
1175 print
' ';
1176 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1182 print
"\n<!-- End form subscription -->\n\n";
1188 $langs->load(
"errors");
1189 print $langs->trans(
"ErrorRecordNotFound");