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