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