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