dolibarr 21.0.0-beta
subscription.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
4 * Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2012-2017 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2015-2024 Alexandre Spangaro <aspangaro@open-dsi.fr>
7 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
9 * Copyright (C) 2023 Waël Almoman <info@almoman.com>
10 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
32// Load Dolibarr environment
33require '../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
37require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
38require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
40require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
41require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
42require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
43
53$langs->loadLangs(array("companies", "bills", "members", "users", "mails", 'other'));
54
55$action = GETPOST('action', 'aZ09');
56$confirm = GETPOST('confirm', 'alpha');
57$contextpage = GETPOST('contextpage', 'aZ09');
58$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
59
60$id = GETPOSTINT('rowid') ? GETPOSTINT('rowid') : GETPOSTINT('id');
61$rowid = $id;
62$ref = GETPOST('ref', 'alphanohtml');
63$typeid = GETPOSTINT('typeid');
64$cancel = GETPOST('cancel');
65
66// Load variable for pagination
67$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
68$sortfield = GETPOST('sortfield', 'aZ09comma');
69$sortorder = GETPOST('sortorder', 'aZ09comma');
70$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
71if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
72 // If $page is not defined, or '' or -1 or if we click on clear filters
73 $page = 0;
74}
75$offset = $limit * $page;
76$pageprev = $page - 1;
77$pagenext = $page + 1;
78
79// Default sort order (if not yet defined by previous GETPOST)
80if (!$sortfield) {
81 $sortfield = "c.rowid";
82}
83if (!$sortorder) {
84 $sortorder = "DESC";
85}
86
87$object = new Adherent($db);
88$extrafields = new ExtraFields($db);
89$adht = new AdherentType($db);
90
91// fetch optionals attributes and labels
92$extrafields->fetch_name_optionals_label($object->table_element);
93
94$errmsg = '';
95
96// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
97$hookmanager->initHooks(array('subscription'));
98
99// PDF
100$hidedetails = (GETPOSTINT('hidedetails') ? GETPOSTINT('hidedetails') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0));
101$hidedesc = (GETPOSTINT('hidedesc') ? GETPOSTINT('hidedesc') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0));
102$hideref = (GETPOSTINT('hideref') ? GETPOSTINT('hideref') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0));
103
104$datefrom = 0;
105$dateto = 0;
106$paymentdate = -1;
107
108// Fetch object
109if ($id > 0 || !empty($ref)) {
110 // Load member
111 $result = $object->fetch($id, $ref);
112
113 // Define variables to know what current user can do on users
114 $canadduser = ($user->admin || $user->hasRight("user", "user", "creer"));
115 // Define variables to know what current user can do on properties of user linked to edited member
116 if ($object->user_id) {
117 // $User is the user who edits, $object->user_id is the id of the related user in the edited member
118 $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight("user", "self", "creer"))
119 || (($user->id != $object->user_id) && $user->hasRight("user", "user", "creer")));
120 $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight("user", "self", "password"))
121 || (($user->id != $object->user_id) && $user->hasRight("user", "user", "password")));
122 }
123}
124
125// Define variables to determine what the current user can do on the members
126$permissiontoaddmember = $user->hasRight('adherent', 'creer');
127
128// Security check
129$result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
130
131
132/*
133 * Actions
134 */
135
136$parameters = array();
137$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
138if ($reshook < 0) {
139 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
140}
141
142// Create third party from a member
143if (empty($reshook) && $action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->hasRight('societe', 'creer')) {
144 if ($result > 0) {
145 // Creation of thirdparty
146 $company = new Societe($db);
147 $result = $company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha'), GETPOST('customercode', 'alpha'));
148
149 if ($result < 0) {
150 $langs->load("errors");
151 setEventMessages($company->error, $company->errors, 'errors');
152 } else {
153 $action = 'addsubscription';
154 }
155 } else {
156 setEventMessages($object->error, $object->errors, 'errors');
157 }
158}
159
160if (empty($reshook) && $action == 'setuserid' && ($user->hasRight('user', 'self', 'creer') || $user->hasRight('user', 'user', 'creer'))) {
161 $error = 0;
162 if (!$user->hasRight('user', 'user', 'creer')) { // If can edit only itself user, we can link to itself only
163 if (GETPOSTINT("userid") != $user->id && GETPOSTINT("userid") != $object->user_id) {
164 $error++;
165 setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors');
166 }
167 }
168
169 if (!$error) {
170 if (GETPOSTINT("userid") != $object->user_id) { // If link differs from currently in database
171 $result = $object->setUserId(GETPOSTINT("userid"));
172 if ($result < 0) {
173 dol_print_error(null, $object->error);
174 }
175 $action = '';
176 }
177 }
178}
179
180if (empty($reshook) && $action == 'setsocid' && $permissiontoaddmember) {
181 $error = 0;
182 if (GETPOSTINT('socid') != $object->socid) { // If link differs from currently in database
183 $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "adherent";
184 $sql .= " WHERE fk_soc = " . ((int) GETPOSTINT('socid'));
185 $resql = $db->query($sql);
186 if ($resql) {
187 $obj = $db->fetch_object($resql);
188 if ($obj && $obj->rowid > 0) {
189 $othermember = new Adherent($db);
190 $othermember->fetch($obj->rowid);
191 $thirdparty = new Societe($db);
192 $thirdparty->fetch(GETPOSTINT('socid'));
193 $error++;
194 setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors');
195 }
196 }
197
198 if (!$error) {
199 $result = $object->setThirdPartyId(GETPOSTINT('socid'));
200 if ($result < 0) {
201 dol_print_error(null, $object->error);
202 }
203 $action = '';
204 }
205 }
206}
207
208if (empty($reshook) && $user->hasRight('adherent', 'cotisation', 'creer') && $action == 'subscription' && !$cancel) {
209 $error = 0;
210
211 $langs->load("banks");
212
213 $result = $object->fetch($rowid);
214 $result = $adht->fetch($object->typeid);
215
216 // Subscription information
217 $datesubscription = 0;
218 $datesubend = 0;
219 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
220 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit : 'y';
221 $paymentdate = ''; // Do not use 0 here, default value is '' that means not filled where 0 means 1970-01-01
222 if (GETPOSTINT("reyear") && GETPOSTINT("remonth") && GETPOSTINT("reday")) {
223 $datesubscription = dol_mktime(0, 0, 0, GETPOSTINT("remonth"), GETPOSTINT("reday"), GETPOSTINT("reyear"));
224 }
225 if (GETPOSTINT("endyear") && GETPOSTINT("endmonth") && GETPOSTINT("endday")) {
226 $datesubend = dol_mktime(0, 0, 0, GETPOSTINT("endmonth"), GETPOSTINT("endday"), GETPOSTINT("endyear"));
227 }
228 if (GETPOSTINT("paymentyear") && GETPOSTINT("paymentmonth") && GETPOSTINT("paymentday")) {
229 $paymentdate = dol_mktime(0, 0, 0, GETPOSTINT("paymentmonth"), GETPOSTINT("paymentday"), GETPOSTINT("paymentyear"));
230 }
231 $amount = price2num(GETPOST("subscription", 'alpha')); // Amount of subscription
232 $label = GETPOST("label");
233
234 // Payment information
235 $accountid = GETPOSTINT("accountid");
236 $operation = GETPOST("operation", "alphanohtml"); // Payment mode
237 $num_chq = GETPOST("num_chq", "alphanohtml");
238 $emetteur_nom = GETPOST("chqemetteur");
239 $emetteur_banque = GETPOST("chqbank");
240 $option = GETPOST("paymentsave");
241 if (empty($option)) {
242 $option = 'none';
243 }
244 $sendalsoemail = GETPOST("sendmail", 'alpha');
245
246 // Check parameters
247 if (!$datesubscription) {
248 $error++;
249 $langs->load("errors");
250 $errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateSubscription"));
251 setEventMessages($errmsg, null, 'errors');
252 $action = 'addsubscription';
253 }
254 if (GETPOST('end') && !$datesubend) {
255 $error++;
256 $langs->load("errors");
257 $errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateEndSubscription"));
258 setEventMessages($errmsg, null, 'errors');
259 $action = 'addsubscription';
260 }
261 if (!$datesubend) {
262 $datesubend = dol_time_plus_duree(dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit), -1, 'd');
263 }
264 if (($option == 'bankviainvoice' || $option == 'bankdirect') && !$paymentdate) {
265 $error++;
266 $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment"));
267 setEventMessages($errmsg, null, 'errors');
268 $action = 'addsubscription';
269 }
270
271 // Check if a payment is mandatory or not
272 if ($adht->subscription) { // Member type need subscriptions
273 if (!is_numeric($amount)) {
274 // If field is '' or not a numeric value
275 $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
276 setEventMessages($errmsg, null, 'errors');
277 $error++;
278 $action = 'addsubscription';
279 } else {
280 // If an amount has been provided, we check also fields that becomes mandatory when amount is not null.
281 if (isModEnabled('bank') && GETPOST("paymentsave") != 'none') {
282 if (GETPOST("subscription")) {
283 if (!GETPOST("label")) {
284 $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
285 setEventMessages($errmsg, null, 'errors');
286 $error++;
287 $action = 'addsubscription';
288 }
289 if (GETPOST("paymentsave") != 'invoiceonly' && !GETPOST("operation")) {
290 $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
291 setEventMessages($errmsg, null, 'errors');
292 $error++;
293 $action = 'addsubscription';
294 }
295 if (GETPOST("paymentsave") != 'invoiceonly' && !(GETPOSTINT("accountid") > 0)) {
296 $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount"));
297 setEventMessages($errmsg, null, 'errors');
298 $error++;
299 $action = 'addsubscription';
300 }
301 } else {
302 if (GETPOSTINT("accountid")) {
303 $errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount");
304 setEventMessages($errmsg, null, 'errors');
305 $error++;
306 $action = 'addsubscription';
307 }
308 }
309 }
310 }
311 }
312
313 // Record the subscription then complementary actions
314 if (!$error && $action == 'subscription') { // Test on permission already done
315 $db->begin();
316
317 // Create subscription
318 $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend);
319 if ($crowid <= 0) {
320 $error++;
321 $errmsg = $object->error;
322 setEventMessages($object->error, $object->errors, 'errors');
323 }
324
325 if (!$error) {
326 $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque);
327 if ($result < 0) {
328 $error++;
329 setEventMessages($object->error, $object->errors, 'errors');
330 } else {
331 // If an invoice was created, it is into $object->invoice
332 }
333 }
334
335 if (!$error) {
336 $db->commit();
337 } else {
338 $db->rollback();
339 $action = 'addsubscription';
340 }
341
342 if (!$error) {
343 setEventMessages("SubscriptionRecorded", null, 'mesgs');
344 }
345
346 // Send email
347 if (!$error) {
348 // Send confirmation Email
349 if ($object->email && $sendalsoemail) { // $object is 'Adherent'
350 $parameters = array(
351 'datesubscription' => $datesubscription,
352 'amount' => $amount,
353 'ccountid' => $accountid,
354 'operation' => $operation,
355 'label' => $label,
356 'num_chq' => $num_chq,
357 'emetteur_nom' => $emetteur_nom,
358 'emetteur_banque' => $emetteur_banque,
359 'datesubend' => $datesubend
360 );
361 $reshook = $hookmanager->executeHooks('sendMail', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
362 if ($reshook < 0) {
363 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
364 }
365
366 if (empty($reshook)) {
367 $subject = '';
368 $msg = '';
369
370 // Send subscription email
371 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
372 $formmail = new FormMail($db);
373 // Set output language
374 $outputlangs = new Translate('', $conf);
375 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
376 // Load traductions files required by page
377 $outputlangs->loadLangs(array("main", "members"));
378
379 // Get email content from template
380 $arraydefaultmessage = null;
381 $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION');
382
383 if (!empty($labeltouse)) {
384 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
385 }
386
387 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
388 $subject = $arraydefaultmessage->topic;
389 $msg = $arraydefaultmessage->content;
390 }
391
392 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
393 complete_substitutions_array($substitutionarray, $outputlangs, $object);
394 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
395 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs);
396
397 // Attach a file ?
398 $file = '';
399 $listofpaths = array();
400 $listofnames = array();
401 $listofmimes = array();
402 if (is_object($object->invoice) && (!is_object($arraydefaultmessage) || intval($arraydefaultmessage->joinfiles))) {
403 $invoicediroutput = $conf->facture->dir_output;
404 $fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+');
405 $file = $fileparams['fullname'];
406
407 $listofpaths = array($file);
408 $listofnames = array(basename($file));
409 $listofmimes = array(dol_mimetype($file));
410 }
411
412 $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/subscription.php'."\r\n";
413
414 $result = $object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, '', $moreinheader);
415 if ($result < 0) {
416 $errmsg = $object->error;
417 setEventMessages($object->error, $object->errors, 'errors');
418 } else {
419 setEventMessages($langs->trans("EmailSentToMember", $object->email), null, 'mesgs');
420 }
421 }
422 } else {
423 setEventMessages($langs->trans("NoEmailSentToMember"), null, 'mesgs');
424 }
425 }
426
427 // Clean some POST vars
428 if (!$error) {
429 $accountid = '';
430 $operation = '';
431 $label = '';
432 $num_chq = '';
433 $option = '';
434 }
435 }
436}
437
438
439
440/*
441 * View
442 */
443
444$form = new Form($db);
445
446$now = dol_now();
447
448$title = $langs->trans("Member")." - ".$langs->trans("Subscriptions");
449$help_url = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder";
450
451llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-member page-card_subscription');
452
453
454$param = '';
455if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
456 $param .= '&contextpage='.urlencode($contextpage);
457}
458if ($limit > 0 && $limit != $conf->liste_limit) {
459 $param .= '&limit='.((int) $limit);
460}
461$param .= '&id='.$rowid;
462if ($optioncss != '') {
463 $param .= '&optioncss='.urlencode($optioncss);
464}
465// Add $param from extra fields
466//include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
467
468
469if (! ($object->id > 0)) {
470 $langs->load("errors");
471 print $langs->trans("ErrorRecordNotFound");
472}
473
474
475$adht->fetch($object->typeid);
476
477$defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
478$defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit : 'y';
479
480$head = member_prepare_head($object);
481
482$rowspan = 10;
483if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
484 $rowspan++;
485}
486if (isModEnabled('societe')) {
487 $rowspan++;
488}
489
490print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
491print '<input type="hidden" name="token" value="'.newToken().'">';
492print '<input type="hidden" name="rowid" value="'.$object->id.'">';
493
494print dol_get_fiche_head($head, 'subscription', $langs->trans("Member"), -1, 'user');
495
496$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
497
498$morehtmlref = '<a href="'.DOL_URL_ROOT.'/adherents/vcard.php?id='.$object->id.'" class="refid">';
499$morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
500$morehtmlref .= '</a>';
501
502dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
503
504print '<div class="fichecenter">';
505print '<div class="fichehalfleft">';
506
507print '<div class="underbanner clearboth"></div>';
508print '<table class="border centpercent tableforfield">';
509
510// Login
511if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
512 print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.dol_escape_htmltag($object->login).'</td></tr>';
513}
514
515// Type
516print '<tr><td class="titlefield">'.$langs->trans("Type").'</td>';
517print '<td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
518
519// Morphy
520print '<tr><td>'.$langs->trans("MemberNature").'</td>';
521print '<td class="valeur" >'.$object->getmorphylib('', 1).'</td>';
522print '</tr>';
523
524// Company
525print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.dol_escape_htmltag($object->company).'</td></tr>';
526
527// Civility
528print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'</td>';
529print '</tr>';
530
531// Password
532if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
533 print '<tr><td>'.$langs->trans("Password").'</td><td>';
534 if ($object->pass) {
535 print preg_replace('/./i', '*', $object->pass);
536 } else {
537 if ($user->admin) {
538 print '<!-- '.$langs->trans("Crypted").': '.$object->pass_indatabase_crypted.' -->';
539 }
540 print '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
541 }
542 if (!empty($object->pass_indatabase) && empty($object->user_id)) { // Show warning only for old password still in clear (does not happen anymore)
543 $langs->load("errors");
544 $htmltext = $langs->trans("WarningPasswordSetWithNoAccount");
545 print ' '.$form->textwithpicto('', $htmltext, 1, 'warning');
546 }
547 print '</td></tr>';
548}
549
550// Date end subscription
551print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
552if ($object->datefin) {
553 print dol_print_date($object->datefin, 'day');
554 if ($object->hasDelay()) {
555 print " ".img_warning($langs->trans("Late"));
556 }
557} else {
558 if ($object->need_subscription == 0) {
559 print $langs->trans("SubscriptionNotNeeded");
560 } elseif (!$adht->subscription) {
561 print $langs->trans("SubscriptionNotRecorded");
562 if (Adherent::STATUS_VALIDATED == $object->statut) {
563 print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft, not excluded and not resiliated
564 }
565 } else {
566 print $langs->trans("SubscriptionNotReceived");
567 if (Adherent::STATUS_VALIDATED == $object->statut) {
568 print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft, not excluded and not resiliated
569 }
570 }
571}
572print '</td></tr>';
573
574print '</table>';
575
576print '</div>';
577
578print '<div class="fichehalfright">';
579print '<div class="underbanner clearboth"></div>';
580
581print '<table class="border tableforfield centpercent">';
582
583// Tags / Categories
584if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
585 print '<tr><td>'.$langs->trans("Categories").'</td>';
586 print '<td colspan="2">';
587 print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1);
588 print '</td></tr>';
589}
590
591// Birth Date
592print '<tr><td class="titlefield">'.$langs->trans("DateOfBirth").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>';
593
594// Default language
595if (getDolGlobalInt('MAIN_MULTILANGS')) {
596 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
597 print '<tr><td>'.$langs->trans("DefaultLang").'</td><td>';
598 //$s=picto_from_langcode($object->default_lang);
599 //print ($s?$s.' ':'');
600 $langs->load("languages");
601 $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : '');
602 print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"');
603 print $labellang;
604 print '</td></tr>';
605}
606
607// Public
608$linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.$conf->entity : '');
609print '<tr><td>'.$form->textwithpicto($langs->trans("MembershipPublic"), $langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist), 1, 'help', '', 0, 3, 'publicfile').'</td><td class="valeur">'.yn($object->public).'</td></tr>';
610
611// Other attributes
612$cols = 2;
613include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
614
615// Third party Dolibarr
616if (isModEnabled('societe')) {
617 print '<tr><td>';
618 print '<table class="nobordernopadding centpercent"><tr><td>';
619 print $langs->trans("LinkedToDolibarrThirdParty");
620 print '</td>';
621 if ($action != 'editthirdparty' && $user->hasRight('adherent', 'creer')) {
622 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>';
623 }
624 print '</tr></table>';
625 print '</td><td colspan="2" class="valeur">';
626 if ($action == 'editthirdparty') {
627 $htmlname = 'socid';
628 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">';
629 print '<input type="hidden" name="rowid" value="'.$object->id.'">';
630 print '<input type="hidden" name="action" value="set'.$htmlname.'">';
631 print '<input type="hidden" name="token" value="'.newToken().'">';
632 print '<table class="nobordernopadding">';
633 print '<tr><td>';
634 print $form->select_company($object->fk_soc, 'socid', '', 1);
635 print '</td>';
636 print '<td class="left"><input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'"></td>';
637 print '</tr></table></form>';
638 } else {
639 if ($object->socid > 0) {
640 $company = new Societe($db);
641 $result = $company->fetch($object->socid);
642 print $company->getNomUrl(1);
643
644 // Show link to invoices
645 $tmparray = $company->getOutstandingBills('customer');
646 if (!empty($tmparray['refs'])) {
647 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']).')';
648 // TODO Add alert if warning on at least one invoice late
649 print '</a>';
650 }
651 } else {
652 print '<span class="opacitymedium">'.$langs->trans("NoThirdPartyAssociatedToMember").'</span>';
653 }
654 }
655 print '</td></tr>';
656}
657
658// Login Dolibarr - Link to user
659print '<tr><td>';
660print '<table class="nobordernopadding centpercent"><tr><td>';
661print $langs->trans("LinkedToDolibarrUser");
662print '</td>';
663if ($action != 'editlogin' && $user->hasRight('adherent', 'creer')) {
664 print '<td class="right">';
665 if ($user->hasRight("user", "user", "creer")) {
666 print '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editlogin&token='.newToken().'&rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToUser'), 1).'</a>';
667 }
668 print '</td>';
669}
670print '</tr></table>';
671print '</td><td colspan="2" class="valeur">';
672if ($action == 'editlogin') {
673 $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'userid', array());
674} else {
675 if ($object->user_id) {
676 $linkeduser = new User($db);
677 $linkeduser->fetch($object->user_id);
678 print $linkeduser->getNomUrl(-1);
679 } else {
680 print '<span class="opacitymedium">'.$langs->trans("NoDolibarrAccess").'</span>';
681 }
682}
683print '</td></tr>';
684
685print "</table>\n";
686
687print "</div></div>\n";
688print '<div class="clearboth"></div>';
689
690print dol_get_fiche_end();
691
692
693/*
694 * Action bar
695 */
696
697// Button to create a new subscription if member no draft (-1) neither resiliated (0) neither excluded (-2)
698if ($user->hasRight('adherent', 'cotisation', 'creer')) {
699 if ($action != 'addsubscription' && $action != 'create_thirdparty') {
700 print '<div class="tabsAction">';
701
702 if ($object->status > 0) {
703 print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'&action=addsubscription&token='.newToken().'">'.$langs->trans("AddSubscription")."</a></div>";
704 } else {
705 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("AddSubscription").'</a></div>';
706 }
707
708 print '</div>';
709 }
710}
711
712/*
713 * List of subscriptions
714 */
715if ($action != 'addsubscription' && $action != 'create_thirdparty') {
716 $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,";
717 $sql .= " c.rowid as crowid, c.subscription,";
718 $sql .= " c.datec, c.fk_type as cfk_type,";
719 $sql .= " c.dateadh as dateh,";
720 $sql .= " c.datef,";
721 $sql .= " c.fk_bank,";
722 $sql .= " b.rowid as bid,";
723 $sql .= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code";
724 $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
725 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid";
726 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
727 $sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".((int) $rowid);
728 $sql .= $db->order($sortfield, $sortorder);
729
730 $result = $db->query($sql);
731 if ($result) {
732 $subscriptionstatic = new Subscription($db);
733
734 $num = $db->num_rows($result);
735
736 print '<table class="noborder centpercent">'."\n";
737
738 print '<tr class="liste_titre">';
739 print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder);
740 print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
741 print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
742 print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
743 print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
744 print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
745 if (isModEnabled('bank')) {
746 print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
747 }
748 print "</tr>\n";
749
750 $accountstatic = new Account($db);
751 $adh = new Adherent($db);
752 $adht = new AdherentType($db);
753
754 $i = 0;
755 while ($i < $num) {
756 $objp = $db->fetch_object($result);
757
758 $adh->id = $objp->rowid;
759 $adh->typeid = $objp->type;
760
761 $subscriptionstatic->ref = $objp->crowid;
762 $subscriptionstatic->id = $objp->crowid;
763
764 $typeid = $objp->cfk_type;
765 if ($typeid > 0) {
766 $adht->fetch($typeid);
767 }
768
769 print '<tr class="oddeven">';
770 print '<td>'.$subscriptionstatic->getNomUrl(1).'</td>';
771 print '<td class="center">'.dol_print_date($db->jdate($objp->datec), 'dayhour')."</td>\n";
772 print '<td class="center">';
773 if ($typeid > 0) {
774 print $adht->getNomUrl(1);
775 }
776 print '</td>';
777 print '<td class="center">'.dol_print_date($db->jdate($objp->dateh), 'day')."</td>\n";
778 print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day')."</td>\n";
779 print '<td class="right amount">'.price($objp->subscription).'</td>';
780 if (isModEnabled('bank')) {
781 print '<td class="right">';
782 if ($objp->bid) {
783 $accountstatic->label = $objp->label;
784 $accountstatic->id = $objp->baid;
785 $accountstatic->number = $objp->number;
786 $accountstatic->account_number = $objp->account_number;
787 $accountstatic->currency_code = $objp->currency_code;
788
789 if (isModEnabled('accounting') && $objp->fk_accountancy_journal > 0) {
790 $accountingjournal = new AccountingJournal($db);
791 $accountingjournal->fetch($objp->fk_accountancy_journal);
792
793 $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
794 }
795
796 $accountstatic->ref = $objp->ref;
797 print $accountstatic->getNomUrl(1);
798 } else {
799 print '&nbsp;';
800 }
801 print '</td>';
802 }
803 print "</tr>";
804 $i++;
805 }
806
807 if (empty($num)) {
808 $colspan = 6;
809 if (isModEnabled('bank')) {
810 $colspan++;
811 }
812 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
813 }
814
815 print "</table>";
816 } else {
817 dol_print_error($db);
818 }
819}
820
821
822if (($action != 'addsubscription' && $action != 'create_thirdparty')) {
823 // Show online payment link
824 // The list can be complete by the hook 'doValidatePayment' executed inside getValidOnlinePaymentMethods()
825 include_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
826 $validpaymentmethod = getValidOnlinePaymentMethods('');
827 $useonlinepayment = count($validpaymentmethod);
828
829 if ($useonlinepayment) {
830 print '<br>';
831
832 require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
833 print showOnlinePaymentUrl('membersubscription', $object->ref);
834 print '<br>';
835 }
836}
837
838/*
839 * Add new subscription form
840 */
841if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->hasRight('adherent', 'cotisation', 'creer')) {
842 print '<br>';
843
844 print load_fiche_titre($langs->trans("NewCotisation"));
845
846 // Define default choice for complementary actions
847 $bankdirect = 0; // 1 means option by default is write to bank direct with no invoice
848 $invoiceonly = 0; // 1 means option by default is invoice only
849 $bankviainvoice = 0; // 1 means option by default is write to bank via invoice
850 if (GETPOST('paymentsave')) {
851 if (GETPOST('paymentsave') == 'bankdirect') {
852 $bankdirect = 1;
853 }
854 if (GETPOST('paymentsave') == 'invoiceonly') {
855 $invoiceonly = 1;
856 }
857 if (GETPOST('paymentsave') == 'bankviainvoice') {
858 $bankviainvoice = 1;
859 }
860 } else {
861 if (getDolGlobalString('ADHERENT_BANK_USE') == 'bankviainvoice' && isModEnabled('bank') && isModEnabled('societe') && isModEnabled('invoice')) {
862 $bankviainvoice = 1;
863 } elseif (getDolGlobalString('ADHERENT_BANK_USE') == 'bankdirect' && isModEnabled('bank')) {
864 $bankdirect = 1;
865 } elseif (getDolGlobalString('ADHERENT_BANK_USE') == 'invoiceonly' && isModEnabled('bank') && isModEnabled('societe') && isModEnabled('invoice')) {
866 $invoiceonly = 1;
867 }
868 }
869
870 print "\n\n<!-- Form add subscription -->\n";
871
872 if ($conf->use_javascript_ajax) {
873 //var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly);
874 print "\n".'<script type="text/javascript">';
875 print '$(document).ready(function () {
876 $(".bankswitchclass, .bankswitchclass2").'.(($bankdirect || $bankviainvoice) ? 'show()' : 'hide()').';
877 $("#none, #invoiceonly").click(function() {
878 $(".bankswitchclass").hide();
879 $(".bankswitchclass2").hide();
880 });
881 $("#bankdirect, #bankviainvoice").click(function() {
882 $(".bankswitchclass").show();
883 $(".bankswitchclass2").show();
884 });
885 $("#selectoperation").change(function() {
886 var code = $(this).val();
887 if (code == "CHQ")
888 {
889 $(".fieldrequireddyn").addClass("fieldrequired");
890 if ($("#fieldchqemetteur").val() == "")
891 {
892 $("#fieldchqemetteur").val($("#memberlabel").val());
893 }
894 }
895 else
896 {
897 $(".fieldrequireddyn").removeClass("fieldrequired");
898 }
899 });
900 ';
901 if (GETPOST('paymentsave')) {
902 print '$("#'.GETPOST('paymentsave', 'aZ09').'").prop("checked", true);';
903 }
904 print '});';
905 print '</script>'."\n";
906 }
907
908
909 // Confirm create third party
910 if ($action == 'create_thirdparty') {
911 $companyalias = '';
912 $fullname = $object->getFullName($langs);
913
914 if ($object->morphy == 'mor') {
915 $companyname = $object->company;
916 if (!empty($fullname)) {
917 $companyalias = $fullname;
918 }
919 } else {
920 $companyname = $fullname;
921 if (!empty($object->company)) {
922 $companyalias = $object->company;
923 }
924 }
925
926 // Create a form array
927 $formquestion = array(
928 array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'),
929 array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"')
930 );
931 // If customer code was forced to "required", we ask it at creation to avoid error later
932 if (getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED')) {
933 $tmpcompany = new Societe($db);
934 $tmpcompany->name = $companyname;
935 $tmpcompany->get_codeclient($tmpcompany, 0);
936 $customercode = $tmpcompany->code_client;
937 $formquestion[] = array(
938 'label' => $langs->trans("CustomerCode"),
939 'type' => 'text',
940 'name' => 'customercode',
941 'value' => $customercode,
942 'morecss' => 'minwidth300',
943 'moreattr' => 'maxlength="128"',
944 );
945 }
946 // @todo Add other extrafields mandatory for thirdparty creation
947
948 print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("CreateDolibarrThirdParty"), $langs->trans("ConfirmCreateThirdParty"), "confirm_create_thirdparty", $formquestion, 1);
949 }
950
951
952 print '<form name="subscription" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
953 print '<input type="hidden" name="token" value="'.newToken().'">';
954 print '<input type="hidden" name="action" value="subscription">';
955 print '<input type="hidden" name="rowid" value="'.$rowid.'">';
956 print '<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).'">';
957 print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($object->company).'">';
958
959 print dol_get_fiche_head(array());
960
961 print '<div class="div-table-responsive">';
962 print '<table class="border centpercent">'."\n";
963 print '<tbody>';
964
965 // Date payment
966 if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) {
967 $paymentdate = dol_mktime(0, 0, 0, GETPOSTINT('paymentmonth'), GETPOSTINT('paymentday'), GETPOSTINT('paymentyear'));
968 }
969
970 print '<tr>';
971 // Date start subscription
972 $currentyear = dol_print_date($now, "%Y");
973 $currentmonth = dol_print_date($now, "%m");
974 print '<td class="fieldrequired">'.$langs->trans("DateSubscription").'</td><td>';
975 if (GETPOST('reday')) {
976 $datefrom = dol_mktime(0, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
977 }
978 if (!$datefrom) {
979 // Guess the subscription start date
980 $datefrom = $object->datevalid; // By default, the subscription start date is the payment date
981 if (getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER')) {
982 $datefrom = dol_time_plus_duree($now, (int) substr(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER'), 0, -1), substr(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER'), -1));
983 } elseif ($object->datefin > 0 && dol_time_plus_duree($object->datefin, $defaultdelay, $defaultdelayunit) > $now) {
984 $datefrom = dol_time_plus_duree($object->datefin, 1, 'd');
985 }
986 // Now do a correction of the suggested date
987 if (getDolGlobalString('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF') === "m") {
988 $datefrom = dol_get_first_day((int) dol_print_date($datefrom, "%Y"), (int) dol_print_date($datefrom, "%m"));
989 } elseif (getDolGlobalString('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF') === "3m") {
990 $datefrom = dol_time_plus_duree($object->datefin, -3, 'm');
991 $datefrom = dol_get_first_day((int) dol_print_date($datefrom, "%Y"), (int) dol_print_date($datefrom, "%m"));
992 } elseif (getDolGlobalString('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF') === "Y") {
993 $datefrom = dol_get_first_day((int) dol_print_date($datefrom, "%Y"));
994 }
995 }
996 print $form->selectDate($datefrom, '', 0, 0, 0, "subscription", 1, 1);
997 print "</td></tr>";
998
999 // Date end subscription
1000 if (GETPOST('endday')) {
1001 $dateto = dol_mktime(0, 0, 0, GETPOSTINT('endmonth'), GETPOSTINT('endday'), GETPOSTINT('endyear'));
1002 }
1003 if (!$dateto) {
1004 if (getDolGlobalInt('MEMBER_SUBSCRIPTION_SUGGEST_END_OF_MONTH')) {
1005 $dateto = dol_get_last_day((int) dol_print_date($datefrom, "%Y"), (int) dol_print_date($datefrom, "%m"));
1006 } elseif (getDolGlobalInt('MEMBER_SUBSCRIPTION_SUGGEST_END_OF_YEAR')) {
1007 $dateto = dol_get_last_day((int) dol_print_date($datefrom, "%Y"));
1008 } else {
1009 $dateto = -1; // By default, no date is suggested
1010 }
1011 }
1012 print '<tr><td>'.$langs->trans("DateEndSubscription").'</td><td>';
1013 print $form->selectDate($dateto, 'end', 0, 0, 0, "subscription", 1, 0);
1014 print "</td></tr>";
1015
1016 if ($adht->subscription) {
1017 // Amount
1018 print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="subscription" size="6" value="'.(GETPOSTISSET('subscription') ? GETPOST('subscription') : price($adht->amount, 0, '', 0)).'"> '.$langs->trans("Currency".$conf->currency) .'</td></tr>';
1019
1020 // Label
1021 print '<tr><td>'.$langs->trans("Label").'</td>';
1022 print '<td><input name="label" type="text" size="32" value="';
1023 if (!getDolGlobalString('MEMBER_NO_DEFAULT_LABEL')) {
1024 print $langs->trans("Subscription").' '.dol_print_date(($datefrom ? $datefrom : time()), "%Y");
1025 }
1026 print '"></td></tr>';
1027
1028 // Complementary action
1029 if ((isModEnabled('bank') || isModEnabled('invoice')) && !getDolGlobalString('ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS')) {
1030 $company = new Societe($db);
1031 if ($object->socid) {
1032 $result = $company->fetch($object->socid);
1033 }
1034
1035 // No more action
1036 print '<tr><td class="tdtop fieldrequired">'.$langs->trans('MoreActions');
1037 print '</td>';
1038 print '<td class="line-height-large">';
1039
1040 print '<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"'.(empty($bankdirect) && empty($invoiceonly) && empty($bankviainvoice) ? ' checked' : '').'>';
1041 print '<label for="none"> '.$langs->trans("None").'</label><br>';
1042 // Add entry into bank account
1043 if (isModEnabled('bank')) {
1044 print '<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"'.(!empty($bankdirect) ? ' checked' : '');
1045 print '><label for="bankdirect"> '.$langs->trans("MoreActionBankDirect").'</label><br>';
1046 }
1047 // Add invoice with no payments
1048 if (isModEnabled('societe') && isModEnabled('invoice')) {
1049 print '<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(!empty($invoiceonly) ? ' checked' : '');
1050 //if (empty($object->fk_soc)) print ' disabled';
1051 print '><label for="invoiceonly"> '.$langs->trans("MoreActionInvoiceOnly");
1052 if ($object->fk_soc) {
1053 print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
1054 } else {
1055 print ' (';
1056 if (empty($object->fk_soc)) {
1057 print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
1058 }
1059 print $langs->trans("NoThirdPartyAssociatedToMember");
1060 print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&amp;action=create_thirdparty">';
1061 print $langs->trans("CreateDolibarrThirdParty");
1062 print '</a>)';
1063 }
1064 if (!getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') || getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') != 'defaultforfoundationcountry') {
1065 print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>';
1066 }
1067 if (getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && (isModEnabled('product') || isModEnabled('service'))) {
1068 $prodtmp = new Product($db);
1069 $result = $prodtmp->fetch(getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS'));
1070 if ($result < 0) {
1071 setEventMessage($prodtmp->error, 'errors');
1072 }
1073 print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
1074 }
1075 print '</label><br>';
1076 }
1077 // Add invoice with payments
1078 if (isModEnabled('bank') && isModEnabled('societe') && isModEnabled('invoice')) {
1079 print '<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(!empty($bankviainvoice) ? ' checked' : '');
1080 //if (empty($object->fk_soc)) print ' disabled';
1081 print '><label for="bankviainvoice"> '.$langs->trans("MoreActionBankViaInvoice");
1082 if ($object->socid) {
1083 print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
1084 } else {
1085 print ' (';
1086 if (empty($object->socid)) {
1087 print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
1088 }
1089 print $langs->trans("NoThirdPartyAssociatedToMember");
1090 print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&amp;action=create_thirdparty">';
1091 print $langs->trans("CreateDolibarrThirdParty");
1092 print '</a>)';
1093 }
1094 if (!getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') || getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') != 'defaultforfoundationcountry') {
1095 print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>';
1096 }
1097 if (getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && (isModEnabled('product') || isModEnabled('service'))) {
1098 $prodtmp = new Product($db);
1099 $result = $prodtmp->fetch(getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS'));
1100 if ($result < 0) {
1101 setEventMessage($prodtmp->error, 'errors');
1102 }
1103 print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
1104 }
1105 print '</label><br>';
1106 }
1107 print '</td></tr>';
1108
1109 // Bank account
1110 print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("FinancialAccount").'</td><td>';
1111 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
1112 $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2, '', 0, 'minwidth200');
1113 print "</td></tr>\n";
1114
1115 // Payment mode
1116 print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
1117 print $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2, 1, 0, 0, 1, 'minwidth200', 1);
1118 print "</td></tr>\n";
1119
1120 // Date of payment
1121 print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("DatePayment").'</td><td>';
1122 print $form->selectDate(isset($paymentdate) ? $paymentdate : -1, 'payment', 0, 0, 1, 'subscription', 1, 1);
1123 print "</td></tr>\n";
1124
1125 print '<tr class="bankswitchclass2"><td>'.$langs->trans('Numero');
1126 print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
1127 print '</td>';
1128 print '<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(!GETPOST('num_chq') ? '' : GETPOST('num_chq')).'"></td></tr>';
1129
1130 print '<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans('CheckTransmitter');
1131 print ' <em>('.$langs->trans("ChequeMaker").')</em>';
1132 print '</td>';
1133 print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(!GETPOST('chqemetteur') ? '' : GETPOST('chqemetteur')).'"></td></tr>';
1134
1135 print '<tr class="bankswitchclass2"><td>'.$langs->trans('Bank');
1136 print ' <em>('.$langs->trans("ChequeBank").')</em>';
1137 print '</td>';
1138 print '<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(!GETPOST('chqbank') ? '' : GETPOST('chqbank')).'"></td></tr>';
1139 }
1140 }
1141
1142 print '<tr><td></td><td></td></tr>';
1143
1144 print '<tr><td>'.$langs->trans("SendAcknowledgementByMail").'</td>';
1145 print '<td>';
1146 if (!$object->email) {
1147 print $langs->trans("NoEMail");
1148 } else {
1149 $adht = new AdherentType($db);
1150 $adht->fetch($object->typeid);
1151
1152 // Send subscription email
1153 $subject = '';
1154 $msg = '';
1155
1156 // Send subscription email
1157 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
1158 $formmail = new FormMail($db);
1159 // Set output language
1160 $outputlangs = new Translate('', $conf);
1161 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
1162 // Load traductions files required by page
1163 $outputlangs->loadLangs(array("main", "members"));
1164 // Get email content from template
1165 $arraydefaultmessage = null;
1166 $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION');
1167
1168 if (!empty($labeltouse)) {
1169 $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
1170 }
1171
1172 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1173 $subject = $arraydefaultmessage->topic;
1174 $msg = $arraydefaultmessage->content;
1175 }
1176
1177 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
1178 complete_substitutions_array($substitutionarray, $outputlangs, $object);
1179 $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
1180 $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs);
1181
1182 $tmp = '<input name="sendmail" type="checkbox"'.(GETPOST('sendmail', 'alpha') ? ' checked' : (getDolGlobalString('ADHERENT_DEFAULT_SENDINFOBYMAIL') ? ' checked' : '')).'>';
1183 $helpcontent = '';
1184 $helpcontent .= '<b>'.$langs->trans("MailFrom").'</b>: '.getDolGlobalString('ADHERENT_MAIL_FROM').'<br>'."\n";
1185 $helpcontent .= '<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
1186 $helpcontent .= '<b>'.$langs->trans("MailTopic").'</b>:<br>'."\n";
1187 if ($subjecttosend) {
1188 $helpcontent .= $subjecttosend."\n";
1189 } else {
1190 $langs->load("errors");
1191 $helpcontent .= '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).'</span>'."\n";
1192 }
1193 $helpcontent .= "<br>";
1194 $helpcontent .= '<b>'.$langs->trans("MailText").'</b>:<br>';
1195 if ($texttosend) {
1196 $helpcontent .= dol_htmlentitiesbr($texttosend)."\n";
1197 } else {
1198 $langs->load("errors");
1199 $helpcontent .= '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).'</span>'."\n";
1200 }
1201 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1202 print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend');
1203 }
1204 print '</td></tr>';
1205 print '</tbody>';
1206 print '</table>';
1207 print '</div>';
1208
1209 print dol_get_fiche_end();
1210
1211 print '<div class="center">';
1212 $parameters = array();
1213 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action);
1214 if (empty($reshook)) {
1215 print '<input type="submit" class="button" name="add" value="'.$langs->trans("AddSubscription").'">';
1216 print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1217 print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
1218 }
1219 print '</div>';
1220
1221 print '</form>';
1222
1223 print "\n<!-- End form subscription -->\n\n";
1224}
1225
1226
1227// End of page
1228llxFooter();
1229$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:87
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage bank accounts.
Class to manage accounting journals.
Class to manage members of a foundation.
const STATUS_VALIDATED
Validated status.
Class to manage members type.
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new Form...
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage subscriptions of foundation members.
Class to manage translations.
Class to manage Dolibarr users.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition date.lib.php:600
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition date.lib.php:125
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:619
dol_most_recent_file($dir, $regexfilter='', $excludefilter=array('(\.meta|_preview.*\.png) $', '^\.'), $nohook=0, $mode=0)
Return file(s) into a directory (by default most recent)
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
member_prepare_head(Adherent $object)
Return array head with list of tabs to view object information.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.