dolibarr  7.0.0-beta
subscription.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
4  * Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2012-2017 Regis Houssin <regis.houssin@capnetworks.com>
6  * Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
28 require '../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
38 
39 $langs->loadLangs(array("companies","bills","members","users","mails",'other'));
40 
41 $action=GETPOST('action','alpha');
42 $confirm=GETPOST('confirm','alpha');
43 $rowid=GETPOST('rowid','int')?GETPOST('rowid','int'):GETPOST('id','int');
44 $typeid=GETPOST('typeid','int');
45 
46 // Load variable for pagination
47 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
48 $sortfield = GETPOST('sortfield','alpha');
49 $sortorder = GETPOST('sortorder','alpha');
50 $page = GETPOST('page','int');
51 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
52 $offset = $limit * $page;
53 $pageprev = $page - 1;
54 $pagenext = $page + 1;
55 
56 // Default sort order (if not yet defined by previous GETPOST)
57 if (! $sortfield) $sortfield="c.rowid";
58 if (! $sortorder) $sortorder="DESC";
59 
60 
61 // Security check
62 $result=restrictedArea($user,'adherent',$rowid,'','cotisation');
63 
64 $object = new Adherent($db);
65 $extrafields = new ExtraFields($db);
66 $adht = new AdherentType($db);
67 
68 // fetch optionals attributes and labels
69 $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
70 
71 $errmsg='';
72 $errmsgs=array();
73 
74 $defaultdelay=1;
75 $defaultdelayunit='y';
76 
77 if ($rowid)
78 {
79  // Load member
80  $result = $object->fetch($rowid);
81 
82  // Define variables to know what current user can do on users
83  $canadduser=($user->admin || $user->rights->user->user->creer);
84  // Define variables to know what current user can do on properties of user linked to edited member
85  if ($object->user_id)
86  {
87  // $user est le user qui edite, $object->user_id est l'id de l'utilisateur lies au membre edite
88  $caneditfielduser=( (($user->id == $object->user_id) && $user->rights->user->self->creer)
89  || (($user->id != $object->user_id) && $user->rights->user->user->creer) );
90  $caneditpassworduser=( (($user->id == $object->user_id) && $user->rights->user->self->password)
91  || (($user->id != $object->user_id) && $user->rights->user->user->password) );
92  }
93 }
94 
95 // Define variables to know what current user can do on members
96 $canaddmember=$user->rights->adherent->creer;
97 // Define variables to know what current user can do on properties of a member
98 if ($rowid)
99 {
100  $caneditfieldmember=$user->rights->adherent->creer;
101 }
102 
103 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
104 $hookmanager->initHooks(array('subscription'));
105 
106 // PDF
107 $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
108 $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
109 $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
110 
111 
112 /*
113  * Actions
114  */
115 
116 // Create third party from a member
117 if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer)
118 {
119  if ($result > 0)
120  {
121  // Creation user
122  $company = new Societe($db);
123  $result=$company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha'));
124 
125  if ($result < 0)
126  {
127  $langs->load("errors");
128  setEventMessages($company->error, $company->errors, 'errors');
129  }
130  else
131  {
132  $action='addsubscription';
133  }
134  }
135  else
136  {
137  setEventMessages($object->error, $object->errors, 'errors');
138  }
139 }
140 
141 if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
142 {
143  $error=0;
144  if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only
145  {
146  if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id)
147  {
148  $error++;
149  setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors');
150  }
151  }
152 
153  if (! $error)
154  {
155  if ($_POST["userid"] != $object->user_id) // If link differs from currently in database
156  {
157  $result=$object->setUserId($_POST["userid"]);
158  if ($result < 0) dol_print_error('',$object->error);
159  $_POST['action']='';
160  $action='';
161  }
162  }
163 }
164 
165 if ($action == 'setsocid')
166 {
167  $error=0;
168  if (! $error)
169  {
170  if (GETPOST('socid','int') != $object->fk_soc) // If link differs from currently in database
171  {
172  $sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
173  $sql.=" WHERE fk_soc = '".GETPOST('socid','int')."'";
174  $resql = $db->query($sql);
175  if ($resql)
176  {
177  $obj = $db->fetch_object($resql);
178  if ($obj && $obj->rowid > 0)
179  {
180  $othermember=new Adherent($db);
181  $othermember->fetch($obj->rowid);
182  $thirdparty=new Societe($db);
183  $thirdparty->fetch(GETPOST('socid','int'));
184  $error++;
185  setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name), null, 'errors');
186  }
187  }
188 
189  if (! $error)
190  {
191  $result=$object->setThirdPartyId(GETPOST('socid','int'));
192  if ($result < 0) dol_print_error('',$object->error);
193  $_POST['action']='';
194  $action='';
195  }
196  }
197  }
198 }
199 
200 if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $_POST["cancel"])
201 {
202  $error=0;
203 
204  $langs->load("banks");
205 
206  $result=$object->fetch($rowid);
207  $result=$adht->fetch($object->typeid);
208 
209  // Subscription informations
210  $datesubscription=0;
211  $datesubend=0;
212  $paymentdate=0;
213  if ($_POST["reyear"] && $_POST["remonth"] && $_POST["reday"])
214  {
215  $datesubscription=dol_mktime(0, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
216  }
217  if ($_POST["endyear"] && $_POST["endmonth"] && $_POST["endday"])
218  {
219  $datesubend=dol_mktime(0, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]);
220  }
221  if ($_POST["paymentyear"] && $_POST["paymentmonth"] && $_POST["paymentday"])
222  {
223  $paymentdate=dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]);
224  }
225  $subscription=price2num(GETPOST("subscription",'alpha')); // Amount of subscription
226  $label=$_POST["label"];
227 
228  // Payment informations
229  $accountid=$_POST["accountid"];
230  $operation=$_POST["operation"]; // Payment mode
231  $num_chq=$_POST["num_chq"];
232  $emetteur_nom=$_POST["chqemetteur"];
233  $emetteur_banque=$_POST["chqbank"];
234  $option=$_POST["paymentsave"];
235  if (empty($option)) $option='none';
236 
237  // Check parameters
238  if (! $datesubscription)
239  {
240  $error++;
241  $langs->load("errors");
242  $errmsg=$langs->trans("ErrorBadDateFormat",$langs->transnoentitiesnoconv("DateSubscription"));
243  setEventMessages($errmsg, null, 'errors');
244  $action='addsubscription';
245  }
246  if (GETPOST('end') && ! $datesubend)
247  {
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  {
256  $datesubend=dol_time_plus_duree(dol_time_plus_duree($datesubscription,$defaultdelay,$defaultdelayunit),-1,'d');
257  }
258  if (($option == 'bankviainvoice' || $option == 'bankdirect') && ! $paymentdate)
259  {
260  $error++;
261  $errmsg=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment"));
262  setEventMessages($errmsg, null, 'errors');
263  $action='addsubscription';
264  }
265 
266  $amount = price2num(GETPOST("subscription",'alpha'));
267 
268  // Check if a payment is mandatory or not
269  if (! $error && $adht->subscription) // Member type need subscriptions
270  {
271  if (! is_numeric($amount))
272  {
273  // If field is '' or not a numeric value
274  $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount"));
275  setEventMessages($errmsg, null, 'errors');
276  $error++;
277  $action='addsubscription';
278  }
279  else
280  {
281  if (! empty($conf->banque->enabled) && $_POST["paymentsave"] != 'none')
282  {
283  if ($_POST["subscription"])
284  {
285  if (! $_POST["label"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label"));
286  if ($_POST["paymentsave"] != 'invoiceonly' && ! $_POST["operation"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
287  if ($_POST["paymentsave"] != 'invoiceonly' && ! $_POST["accountid"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("FinancialAccount"));
288  }
289  else
290  {
291  if ($_POST["accountid"]) $errmsg=$langs->trans("ErrorDoNotProvideAccountsIfNullAmount");
292  }
293  if ($errmsg)
294  {
295  setEventMessages($errmsg, null, 'errors');
296  $action='addsubscription';
297  }
298  }
299  }
300  }
301 
302  if (! $error && $action=='subscription')
303  {
304  $db->begin();
305 
306  // Create subscription
307  $crowid=$object->subscription($datesubscription, $subscription, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend);
308  if ($crowid <= 0)
309  {
310  $error++;
311  $errmsg=$object->error;
312  setEventMessages($object->error,$object->errors, 'errors');
313  }
314 
315  if (! $error)
316  {
317  // Insert into bank account directlty (if option choosed for) + link to llx_subscription if option is 'bankdirect'
318  if ($option == 'bankdirect' && $accountid)
319  {
320  require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
321 
322  $acct=new Account($db);
323  $result=$acct->fetch($accountid);
324 
325  $dateop=$paymentdate;
326 
327  $insertid=$acct->addline($dateop, $operation, $label, $subscription, $num_chq, '', $user, $emetteur_nom, $emetteur_banque);
328  if ($insertid > 0)
329  {
330  $inserturlid=$acct->add_url_line($insertid, $object->id, DOL_URL_ROOT.'/adherents/card.php?rowid=', $object->getFullname($langs), 'member');
331  if ($inserturlid > 0)
332  {
333  // Update table subscription
334  $sql ="UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".$insertid;
335  $sql.=" WHERE rowid=".$crowid;
336 
337  dol_syslog("subscription::subscription", LOG_DEBUG);
338  $resql = $db->query($sql);
339  if (! $resql)
340  {
341  $error++;
342  $errmsg=$db->lasterror();
343  setEventMessages($errmsg, null, 'errors');
344  }
345  }
346  else
347  {
348  $error++;
349  $errmsg=$acct->error;
350  $errmsgs=$acct->errors;
351  setEventMessages($errmsg, $errmsgs, 'errors');
352  }
353  }
354  else
355  {
356  $error++;
357  $errmsg=$acct->error;
358  $errmsgs=$acct->errors;
359  setEventMessages($errmsg, $errmsgs, 'errors');
360  }
361  }
362 
363  // If option choosed, we create invoice
364  if (($option == 'bankviainvoice' && $accountid) || $option == 'invoiceonly')
365  {
366  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
367  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php';
368 
369  $invoice=new Facture($db);
370  $customer=new Societe($db);
371 
372  if (! $error)
373  {
374  if (! ($object->fk_soc > 0))
375  {
376  $langs->load("errors");
377  $errmsg=$langs->trans("ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst");
378  setEventMessages($errmsg, null, 'errors');
379  $error++;
380  }
381  }
382  if (! $error)
383  {
384  $result=$customer->fetch($object->fk_soc);
385  if ($result <= 0)
386  {
387  $errmsg=$customer->error;
388  $errmsgs=$acct->errors;
389  setEventMessages($errmsg, $errmsgs, 'errors');
390  $error++;
391  }
392  }
393 
394  if (! $error)
395  {
396  // Create draft invoice
397  $invoice->type= Facture::TYPE_STANDARD;
398  $invoice->cond_reglement_id=$customer->cond_reglement_id;
399  if (empty($invoice->cond_reglement_id))
400  {
401  $paymenttermstatic=new PaymentTerm($db);
402  $invoice->cond_reglement_id=$paymenttermstatic->getDefaultId();
403  if (empty($invoice->cond_reglement_id))
404  {
405  $error++;
406  $errmsg='ErrorNoPaymentTermRECEPFound';
407  setEventMessages($errmsg, null, 'errors');
408  }
409  }
410  $invoice->socid=$object->fk_soc;
411  $invoice->date=$datesubscription;
412 
413  // Possibility to add external linked objects with hooks
414  $invoice->linked_objects['subscription'] = $crowid;
415  if (! empty($_POST['other_linked_objects']) && is_array($_POST['other_linked_objects']))
416  {
417  $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST['other_linked_objects']);
418  }
419 
420  $result=$invoice->create($user);
421  if ($result <= 0)
422  {
423  $errmsg=$invoice->error;
424  $errmsgs=$invoice->errors;
425  setEventMessages($errmsg, $errmsgs, 'errors');
426  $error++;
427  }
428  }
429 
430  if (! $error)
431  {
432  // Add line to draft invoice
433  $idprodsubscription=0;
434  if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) $idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS;
435 
436  $vattouse=0;
437  if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS == 'defaultforfoundationcountry')
438  {
439  $vattouse=get_default_tva($mysoc, $mysoc, $idprodsubscription);
440  }
441  //print xx".$vattouse." - ".$mysoc." - ".$customer;exit;
442  $result=$invoice->addline($label,0,1,$vattouse,0,0,$idprodsubscription,0,$datesubscription,$datesubend,0,0,'','TTC',$subscription,1);
443  if ($result <= 0)
444  {
445  $errmsg=$invoice->error;
446  setEventMessages($errmsg, null, 'errors');
447  $error++;
448  }
449  }
450 
451  if (! $error)
452  {
453  // Validate invoice
454  $result=$invoice->validate($user);
455  if ($result <= 0)
456  {
457  $errmsg=$invoice->error;
458  $errmsgs=$invoice->errors;
459  setEventMessages($errmsg, $errmsgs, 'errors');
460  $error++;
461  }
462  }
463 
464  // Add payment onto invoice
465  if ($option == 'bankviainvoice' && $accountid)
466  {
467  require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
468  require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
469  require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
470 
471  $amounts[$invoice->id] = price2num($subscription);
472  $paiement = new Paiement($db);
473  $paiement->datepaye = $paymentdate;
474  $paiement->amounts = $amounts;
475  $paiement->paiementid = dol_getIdFromCode($db,$operation,'c_paiement','code','id',1);
476  $paiement->num_paiement = $num_chq;
477  $paiement->note = $label;
478 
479  if (! $error)
480  {
481  // Create payment line for invoice
482  $paiement_id = $paiement->create($user);
483  if (! $paiement_id > 0)
484  {
485  $errmsg=$paiement->error;
486  $errmsgs=$paiement->errors;
487  setEventMessages($errmsg, $errmsgs, 'errors');
488  $error++;
489  }
490  }
491 
492  if (! $error)
493  {
494  // Add transaction into bank account
495  $bank_line_id=$paiement->addPaymentToBank($user,'payment','(SubscriptionPayment)',$accountid,$emetteur_nom,$emetteur_banque);
496  if (! ($bank_line_id > 0))
497  {
498  $errmsg=$paiement->error;
499  $errmsgs=$paiement->errors;
500  setEventMessages($paiement->error, $paiement->errors, 'errors');
501  $error++;
502  }
503  }
504 
505  if (! $error)
506  {
507  // Update fk_bank into subscription table
508  $sql = 'UPDATE '.MAIN_DB_PREFIX.'subscription SET fk_bank='.$bank_line_id;
509  $sql.= ' WHERE rowid='.$crowid;
510 
511  $result = $db->query($sql);
512  if (! $result)
513  {
514  $error++;
515  }
516  }
517 
518  if (! $error)
519  {
520  // Set invoice as paid
521  $invoice->set_paid($user);
522  }
523 
524  if (! $error)
525  {
526  // Define output language
527  $outputlangs = $langs;
528  $newlang = '';
529  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
530  $newlang = $_REQUEST['lang_id'];
531  if ($conf->global->MAIN_MULTILANGS && empty($newlang))
532  $newlang = $customer->default_lang;
533  if (! empty($newlang)) {
534  $outputlangs = new Translate("", $conf);
535  $outputlangs->setDefaultLang($newlang);
536  }
537  // Generate PDF (whatever is option MAIN_DISABLE_PDF_AUTOUPDATE) so we can include it into email
538  //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
539 
540  $invoice->generateDocument($invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
541  }
542  }
543  }
544  }
545 
546  if (! $error)
547  {
548  $db->commit();
549  }
550  else
551  {
552  $db->rollback();
553  $action = 'addsubscription';
554  }
555 
556  // Send email
557  if (! $error)
558  {
559  // Send confirmation Email
560  if ($object->email && $_POST["sendmail"])
561  {
562  $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
563  $texttosend=$object->makeSubstitution($adht->getMailOnSubscription());
564 
565  $result=$object->send_an_email($texttosend,$subjecttosend,array(),array(),array(),"","",0,-1);
566  if ($result < 0)
567  {
568  $errmsg=$object->error;
569  setEventMessages($errmsg, null, 'errors');
570  }
571  }
572 
573  $_POST["subscription"]='';
574  $_POST["accountid"]='';
575  $_POST["operation"]='';
576  $_POST["label"]='';
577  $_POST["num_chq"]='';
578  }
579  }
580 }
581 
582 
583 
584 /*
585  * View
586  */
587 
588 $form = new Form($db);
589 
590 $now=dol_now();
591 
592 $title=$langs->trans("Member") . " - " . $langs->trans("Subscriptions");
593 $helpurl="EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros";
594 llxHeader("",$title,$helpurl);
595 
596 
597 $param='';
598 if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
599 if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
600 $param.= '&id='.$rowid;
601 if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
602 // Add $param from extra fields
603 //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
604 
605 
606 if ($rowid > 0)
607 {
608  $res=$object->fetch($rowid);
609  if ($res < 0) { dol_print_error($db,$object->error); exit; }
610 
611  $adht->fetch($object->typeid);
612 
613  $head = member_prepare_head($object);
614 
615  $rowspan=10;
616  if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++;
617  if (! empty($conf->societe->enabled)) $rowspan++;
618 
619  print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
620  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
621  print '<input type="hidden" name="rowid" value="'.$object->id.'">';
622 
623  dol_fiche_head($head, 'subscription', $langs->trans("Member"), -1, 'user');
624 
625  $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
626 
627  dol_banner_tab($object, 'rowid', $linkback);
628 
629  print '<div class="fichecenter">';
630  print '<div class="fichehalfleft">';
631 
632  print '<div class="underbanner clearboth"></div>';
633  print '<table class="border" width="100%">';
634 
635  // Login
636  if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
637  {
638  print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
639  }
640 
641  // Type
642  print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
643 
644  // Morphy
645  print '<tr><td>'.$langs->trans("Nature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
646  print '</tr>';
647 
648  // Company
649  print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->societe.'</td></tr>';
650 
651  // Civility
652  print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
653  print '</tr>';
654 
655  // Password
656  if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
657  {
658  print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i','*',$object->pass);
659  if ((! empty($object->pass) || ! empty($object->pass_crypted)) && empty($object->user_id))
660  {
661  $langs->load("errors");
662  $htmltext=$langs->trans("WarningPasswordSetWithNoAccount");
663  print ' '.$form->textwithpicto('', $htmltext,1,'warning');
664  }
665  print '</td></tr>';
666  }
667 
668  print '</table>';
669 
670  print '</div>';
671  print '<div class="fichehalfright"><div class="ficheaddleft">';
672 
673  print '<div class="underbanner clearboth"></div>';
674  print '<table class="border tableforfield" width="100%">';
675 
676  // Birthday
677  print '<tr><td class="titlefield">'.$langs->trans("Birthday").'</td><td class="valeur">'.dol_print_date($object->birth,'day').'</td></tr>';
678 
679  // Public
680  print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>';
681 
682  // Categories
683  if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
684  {
685  print '<tr><td>' . $langs->trans("Categories") . '</td>';
686  print '<td colspan="2">';
687  print $form->showCategories($object->id, 'member', 1);
688  print '</td></tr>';
689  }
690 
691  // Other attributes
692  $cols=2;
693  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
694 
695  // Date end subscription
696  print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
697  if ($object->datefin)
698  {
699  print dol_print_date($object->datefin,'day');
700  if ($object->hasDelay()) {
701  print " ".img_warning($langs->trans("Late"));
702  }
703  }
704  else
705  {
706  if (! $adht->subscription)
707  {
708  print $langs->trans("SubscriptionNotRecorded");
709  if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
710  }
711  else
712  {
713  print $langs->trans("SubscriptionNotReceived");
714  if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
715  }
716  }
717  print '</td></tr>';
718 
719  // Third party Dolibarr
720  if (! empty($conf->societe->enabled))
721  {
722  print '<tr><td>';
723  print '<table class="nobordernopadding" width="100%"><tr><td>';
724  print $langs->trans("LinkedToDolibarrThirdParty");
725  print '</td>';
726  if ($action != 'editthirdparty' && $user->rights->adherent->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editthirdparty&amp;rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'</a></td>';
727  print '</tr></table>';
728  print '</td><td colspan="2" class="valeur">';
729  if ($action == 'editthirdparty')
730  {
731  $htmlname='socid';
732  print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">';
733  print '<input type="hidden" name="rowid" value="'.$object->id.'">';
734  print '<input type="hidden" name="action" value="set'.$htmlname.'">';
735  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
736  print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
737  print '<tr><td>';
738  print $form->select_company($object->fk_soc,'socid','',1);
739  print '</td>';
740  print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
741  print '</tr></table></form>';
742  }
743  else
744  {
745  if ($object->fk_soc)
746  {
747  $company=new Societe($db);
748  $result=$company->fetch($object->fk_soc);
749  print $company->getNomUrl(1);
750  }
751  else
752  {
753  print $langs->trans("NoThirdPartyAssociatedToMember");
754  }
755  }
756  print '</td></tr>';
757  }
758 
759  // Login Dolibarr
760  print '<tr><td>';
761  print '<table class="nobordernopadding" width="100%"><tr><td>';
762  print $langs->trans("LinkedToDolibarrUser");
763  print '</td>';
764  if ($action != 'editlogin' && $user->rights->adherent->creer)
765  {
766  print '<td align="right">';
767  if ($user->rights->user->user->creer)
768  {
769  print '<a href="'.$_SERVER["PHP_SELF"].'?action=editlogin&amp;rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToUser'),1).'</a>';
770  }
771  print '</td>';
772  }
773  print '</tr></table>';
774  print '</td><td colspan="2" class="valeur">';
775  if ($action == 'editlogin')
776  {
777  $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'userid','');
778  }
779  else
780  {
781  if ($object->user_id)
782  {
783  $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none');
784  }
785  else print $langs->trans("NoDolibarrAccess");
786  }
787  print '</td></tr>';
788 
789  print "</table>\n";
790 
791  print "</div></div></div>\n";
792  print '<div style="clear:both"></div>';
793 
794  dol_fiche_end();
795 
796  print '</form>';
797 
798 
799  /*
800  * Action buttons
801  */
802 
803  // Button to create a new subscription if member no draft neither resiliated
804  if ($user->rights->adherent->cotisation->creer)
805  {
806  if ($action != 'addsubscription' && $action != 'create_thirdparty')
807  {
808  print '<div class="tabsAction">';
809 
810  if ($object->statut > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'&action=addsubscription">'.$langs->trans("AddSubscription")."</a></div>";
811  else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("AddSubscription").'</a></div>';
812 
813  print '</div>';
814  }
815  }
816 
817  /*
818  * List of subscriptions
819  */
820  if ($action != 'addsubscription' && $action != 'create_thirdparty')
821  {
822  $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe,";
823  $sql.= " c.rowid as crowid, c.subscription,";
824  $sql.= " c.datec,";
825  $sql.= " c.dateadh as dateh,";
826  $sql.= " c.datef,";
827  $sql.= " c.fk_bank,";
828  $sql.= " b.rowid as bid,";
829  $sql.= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number";
830  $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
831  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid";
832  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
833  $sql.= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid;
834  $sql.= $db->order($sortfield, $sortorder);
835 
836  $result = $db->query($sql);
837  if ($result)
838  {
839  $subscriptionstatic=new Subscription($db);
840 
841  $num = $db->num_rows($result);
842  $i = 0;
843 
844  print '<table class="noborder" width="100%">'."\n";
845 
846  print '<tr class="liste_titre">';
847  print_liste_field_titre('Ref',$_SERVER["PHP_SELF"],'c.rowid','',$param,'',$sortfield,$sortorder);
848  print '<td align="center">'.$langs->trans("DateCreation").'</td>';
849  print '<td align="center">'.$langs->trans("DateStart").'</td>';
850  print '<td align="center">'.$langs->trans("DateEnd").'</td>';
851  print '<td align="right">'.$langs->trans("Amount").'</td>';
852  if (! empty($conf->banque->enabled))
853  {
854  print '<td align="right">'.$langs->trans("Account").'</td>';
855  }
856  print "</tr>\n";
857 
858  $accountstatic=new Account($db);
859 
860  while ($i < $num)
861  {
862  $objp = $db->fetch_object($result);
863 
864  $subscriptionstatic->ref=$objp->crowid;
865  $subscriptionstatic->id=$objp->crowid;
866 
867  print '<tr class="oddeven">';
868  print '<td>'.$subscriptionstatic->getNomUrl(1).'</td>';
869  print '<td align="center">'.dol_print_date($db->jdate($objp->datec),'dayhour')."</td>\n";
870  print '<td align="center">'.dol_print_date($db->jdate($objp->dateh),'day')."</td>\n";
871  print '<td align="center">'.dol_print_date($db->jdate($objp->datef),'day')."</td>\n";
872  print '<td align="right">'.price($objp->subscription).'</td>';
873  if (! empty($conf->banque->enabled))
874  {
875  print '<td align="right">';
876  if ($objp->bid)
877  {
878  $accountstatic->label=$objp->label;
879  $accountstatic->id=$objp->baid;
880  $accountstatic->number=$objp->number;
881  $accountstatic->account_number=$objp->account_number;
882 
883  if (! empty($conf->accounting->enabled))
884  {
885  $accountingjournal = new AccountingJournal($db);
886  $accountingjournal->fetch($objp->fk_accountancy_journal);
887 
888  $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1);
889  }
890 
891  $accountstatic->ref=$objp->ref;
892  print $accountstatic->getNomUrl(1);
893  }
894  else
895  {
896  print '&nbsp;';
897  }
898  print '</td>';
899  }
900  print "</tr>";
901  $i++;
902  }
903  print "</table>";
904  }
905  else
906  {
907  dol_print_error($db);
908  }
909  }
910 
911 
912  if (($action != 'addsubscription' && $action != 'create_thirdparty'))
913  {
914  // Shon online payment link
915  $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled));
916 
917  if ($useonlinepayment)
918  {
919  print '<br>';
920 
921  require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
922  print showOnlinePaymentUrl('membersubscription', $object->ref);
923  print '<br>';
924  }
925  }
926 
927  /*
928  * Add new subscription form
929  */
930  if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer)
931  {
932  print '<br>';
933 
934  print load_fiche_titre($langs->trans("NewCotisation"));
935 
936  // Define default choice to select
937  $bankdirect=0; // 1 means option by default is write to bank direct with no invoice
938  $invoiceonly=0; // 1 means option by default is invoice only
939  $bankviainvoice=0; // 1 means option by default is write to bank via invoice
940  if (GETPOST('paymentsave'))
941  {
942  if (GETPOST('paymentsave') == 'bankdirect') $bankdirect=1;
943  if (GETPOST('paymentsave') == 'invoiceonly') $invoiceonly=1;
944  if (GETPOST('paymentsave') == 'bankviainvoice') $bankviainvoice=1;
945  }
946  else
947  {
948  if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && ! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) $bankviainvoice=1;
949  else if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && ! empty($conf->banque->enabled)) $bankdirect=1;
950  else if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && ! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) $invoiceonly=1;
951  }
952 
953  print "\n\n<!-- Form add subscription -->\n";
954 
955  if ($conf->use_javascript_ajax)
956  {
957  //var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly.'-'.empty($conf->global->ADHERENT_BANK_USE));
958  print "\n".'<script type="text/javascript" language="javascript">';
959  print '$(document).ready(function () {
960  $(".bankswitchclass, .bankswitchclass2").'.(($bankdirect||$bankviainvoice)?'show()':'hide()').';
961  $("#none, #invoiceonly").click(function() {
962  $(".bankswitchclass").hide();
963  $(".bankswitchclass2").hide();
964  });
965  $("#bankdirect, #bankviainvoice").click(function() {
966  $(".bankswitchclass").show();
967  $(".bankswitchclass2").show();
968  });
969  $("#selectoperation").change(function() {
970  var code = $(this).val();
971  if (code == "CHQ")
972  {
973  $(".fieldrequireddyn").addClass("fieldrequired");
974  if ($("#fieldchqemetteur").val() == "")
975  {
976  $("#fieldchqemetteur").val($("#memberlabel").val());
977  }
978  }
979  else
980  {
981  $(".fieldrequireddyn").removeClass("fieldrequired");
982  }
983  });
984  ';
985  if (GETPOST('paymentsave')) print '$("#'.GETPOST('paymentsave').'").prop("checked",true);';
986  print '});';
987  print '</script>'."\n";
988  }
989 
990 
991  // Confirm create third party
992  if ($action == 'create_thirdparty')
993  {
994  $companyalias='';
995  $fullname = $object->getFullName($langs);
996 
997  if ($object->morphy == 'mor')
998  {
999  $companyname=$object->societe;
1000  if (! empty($fullname)) $companyalias=$fullname;
1001  }
1002  else
1003  {
1004  $companyname=$fullname;
1005  if (! empty($object->societe)) $companyalias=$object->societe;
1006  }
1007 
1008  // Create a form array
1009  $formquestion=array(
1010  array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'),
1011  array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"')
1012  );
1013 
1014  print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1);
1015  }
1016 
1017 
1018  print '<form name="subscription" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
1019  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1020  print '<input type="hidden" name="action" value="subscription">';
1021  print '<input type="hidden" name="rowid" value="'.$rowid.'">';
1022  print '<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).'">';
1023  print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($object->societe).'">';
1024 
1025  dol_fiche_head('');
1026 
1027  print "<table class=\"border\" width=\"100%\">\n";
1028  print '<tbody>';
1029 
1030  $today=dol_now();
1031  $datefrom=0;
1032  $dateto=0;
1033  $paymentdate=-1;
1034 
1035  // Date payment
1036  if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday'))
1037  {
1038  $paymentdate=dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear'));
1039  }
1040 
1041  print '<tr>';
1042  // Date start subscription
1043  print '<td class="fieldrequired">'.$langs->trans("DateSubscription").'</td><td>';
1044  if (GETPOST('reday'))
1045  {
1046  $datefrom=dol_mktime(0,0,0,GETPOST('remonth'),GETPOST('reday'),GETPOST('reyear'));
1047  }
1048  if (! $datefrom)
1049  {
1050  if ($object->datefin > 0)
1051  {
1052  $datefrom=dol_time_plus_duree($object->datefin,1,'d');
1053  }
1054  else
1055  {
1056  //$datefrom=dol_now();
1057  $datefrom=$object->datevalid;
1058  }
1059  }
1060  print $form->select_date($datefrom,'','','','',"subscription",1,1,1);
1061  print "</td></tr>";
1062 
1063  // Date end subscription
1064  if (GETPOST('endday'))
1065  {
1066  $dateto=dol_mktime(0,0,0,GETPOST('endmonth'),GETPOST('endday'),GETPOST('endyear'));
1067  }
1068  if (! $dateto)
1069  {
1070  $dateto=-1; // By default, no date is suggested
1071  }
1072  print '<tr><td>'.$langs->trans("DateEndSubscription").'</td><td>';
1073  print $form->select_date($dateto,'end','','','',"subscription",1,0,1);
1074  print "</td></tr>";
1075 
1076  if ($adht->subscription)
1077  {
1078  // Amount
1079  print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="subscription" size="6" value="'.GETPOST('subscription').'"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
1080 
1081  // Label
1082  print '<tr><td>'.$langs->trans("Label").'</td>';
1083  print '<td><input name="label" type="text" size="32" value="';
1084  if (empty($conf->global->MEMBER_NO_DEFAULT_LABEL)) print $langs->trans("Subscription").' '.dol_print_date(($datefrom?$datefrom:time()),"%Y");
1085  print '"></td></tr>';
1086 
1087  // Complementary action
1088  if (! empty($conf->banque->enabled) || ! empty($conf->facture->enabled))
1089  {
1090  $company=new Societe($db);
1091  if ($object->fk_soc)
1092  {
1093  $result=$company->fetch($object->fk_soc);
1094  }
1095 
1096  // Title payments
1097  //print '<tr><td colspan="2"><b>'.$langs->trans("Payment").'</b></td></tr>';
1098 
1099  // No more action
1100  print '<tr><td class="tdtop fieldrequired">'.$langs->trans('MoreActions');
1101  print '</td>';
1102  print '<td>';
1103  print '<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"'.(empty($bankdirect) && empty($invoiceonly) && empty($bankviainvoice)?' checked':'').'> '.$langs->trans("None").'<br>';
1104  // Add entry into bank accoun
1105  if (! empty($conf->banque->enabled))
1106  {
1107  print '<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"'.(! empty($bankdirect)?' checked':'');
1108  print '> '.$langs->trans("MoreActionBankDirect").'<br>';
1109  }
1110  // Add invoice with no payments
1111  if (! empty($conf->societe->enabled) && ! empty($conf->facture->enabled))
1112  {
1113  print '<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(! empty($invoiceonly)?' checked':'');
1114  //if (empty($object->fk_soc)) print ' disabled';
1115  print '> '.$langs->trans("MoreActionInvoiceOnly");
1116  if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
1117  else
1118  {
1119  print ' (';
1120  if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
1121  print $langs->trans("NoThirdPartyAssociatedToMember");
1122  print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&amp;action=create_thirdparty">';
1123  print $langs->trans("CreateDolibarrThirdParty");
1124  print '</a>)';
1125  }
1126  if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription",0);
1127  if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled)))
1128  {
1129  $prodtmp=new Product($db);
1130  $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
1131  print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
1132  }
1133  print '<br>';
1134  }
1135  // Add invoice with payments
1136  if (! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled))
1137  {
1138  print '<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(! empty($bankviainvoice)?' checked':'');
1139  //if (empty($object->fk_soc)) print ' disabled';
1140  print '> '.$langs->trans("MoreActionBankViaInvoice");
1141  if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
1142  else
1143  {
1144  print ' (';
1145  if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
1146  print $langs->trans("NoThirdPartyAssociatedToMember");
1147  print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&amp;action=create_thirdparty">';
1148  print $langs->trans("CreateDolibarrThirdParty");
1149  print '</a>)';
1150  }
1151  if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription",0);
1152  if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled)))
1153  {
1154  $prodtmp=new Product($db);
1155  $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
1156  print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
1157  }
1158  print '<br>';
1159  }
1160  print '</td></tr>';
1161 
1162  // Bank account
1163  print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("FinancialAccount").'</td><td>';
1164  $form->select_comptes(GETPOST('accountid'),'accountid',0,'',1);
1165  print "</td></tr>\n";
1166 
1167  // Payment mode
1168  print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
1169  $form->select_types_paiements(GETPOST('operation'),'operation','',2);
1170  print "</td></tr>\n";
1171 
1172  // Date of payment
1173  print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("DatePayment").'</td><td>';
1174  print $form->select_date(isset($paymentdate)?$paymentdate:-1,'payment',0,0,1,'subscription',1,1,1);
1175  print "</td></tr>\n";
1176 
1177  print '<tr class="bankswitchclass2"><td>'.$langs->trans('Numero');
1178  print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
1179  print '</td>';
1180  print '<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(! GETPOST('num_chq')?'':GETPOST('num_chq')).'"></td></tr>';
1181 
1182  print '<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans('CheckTransmitter');
1183  print ' <em>('.$langs->trans("ChequeMaker").')</em>';
1184  print '</td>';
1185  print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(! GETPOST('chqemetteur')?'':GETPOST('chqemetteur')).'"></td></tr>';
1186 
1187  print '<tr class="bankswitchclass2"><td>'.$langs->trans('Bank');
1188  print ' <em>('.$langs->trans("ChequeBank").')</em>';
1189  print '</td>';
1190  print '<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(! GETPOST('chqbank')?'':GETPOST('chqbank')).'"></td></tr>';
1191  }
1192  }
1193 
1194  print '<tr><td colspan="2">&nbsp;</td>';
1195 
1196  print '<tr><td width="30%">'.$langs->trans("SendAcknowledgementByMail").'</td>';
1197  print '<td>';
1198  if (! $object->email)
1199  {
1200  print $langs->trans("NoEMail");
1201  }
1202  else
1203  {
1204  $adht = new AdherentType($db);
1205  $adht->fetch($object->typeid);
1206 
1207  $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
1208  $texttosend=$object->makeSubstitution($adht->getMailOnSubscription());
1209 
1210  $tmp='<input name="sendmail" type="checkbox"'.(GETPOST('sendmail')?GETPOST('sendmail'):(! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?' checked':'')).'>';
1211  $helpcontent='';
1212  $helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
1213  $helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
1214  $helpcontent.='<b>'.$langs->trans("MailTopic").'</b>:<br>'."\n";
1215  $helpcontent.=$subjecttosend."\n";
1216  $helpcontent.="<br>";
1217  $helpcontent.='<b>'.$langs->trans("MailText").'</b>:<br>';
1218  $helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
1219 
1220  print $form->textwithpicto($tmp,$helpcontent,1,'help');
1221  }
1222  print '</td></tr>';
1223  print '</tbody>';
1224  print '</table>';
1225 
1226  dol_fiche_end();
1227 
1228  print '<div class="center">';
1229  print '<input type="submit" class="button" name="add" value="'.$langs->trans("AddSubscription").'">';
1230  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1231  print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
1232  print '</div>';
1233 
1234  print '</form>';
1235 
1236  print "\n<!-- End form subscription -->\n\n";
1237  }
1238 
1239  //print '</td></tr>';
1240  //print '</table>';
1241 }
1242 else
1243 {
1244  $langs->load("errors");
1245  print $langs->trans("ErrorRecordNotFound");
1246 }
1247 
1248 
1249 llxFooter();
1250 
1251 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
const TYPE_STANDARD
Standard invoice.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
Class to manage products or services.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0)
Return an id or code from a code or id.
member_prepare_head(Adherent $object)
Return array head with list of tabs to view object informations.
Definition: member.lib.php:33
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
Class to manage bank accounts.
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
Class to manage third parties objects (customers, suppliers, prospects...)
img_warning($titlealt= 'default', $moreatt= '')
Show warning logo.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
dol_fiche_end($notab=0)
Show tab footer of a card.
Class to manage payments of customer invoices.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Class to manage members of a foundation.
llxHeader()
Empty header.
Definition: wrapper.php:46
Class to manage translations.
dol_now($mode='gmt')
Return date for now.
Class to manage members type.
Class to manage subscriptions of foundation members.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print
Draft customers invoices.
Definition: index.php:91
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) Si ...
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
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...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
Class to manage accounting accounts.
Class to manage invoices.
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
Definition: date.lib.php:116
img_edit($titlealt= 'default', $float=0, $other= 'class="pictoedit"')
Show logo editer/modifier fiche.
price2num($amount, $rounding='', $alreadysqlnb=0)
Function that return a number with universal decimal format (decimal separator is '...
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.
Class to manage payment terms records in dictionary.