card_subscriptions.php 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187
  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-2014 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2012 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. /**
  22. * \file htdocs/adherents/card_subscriptions.php
  23. * \ingroup member
  24. * \brief Onglet d'ajout, edition, suppression des adhesions d'un adherent
  25. */
  26. require '../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/adherents/class/cotisation.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  35. $langs->load("companies");
  36. $langs->load("bills");
  37. $langs->load("members");
  38. $langs->load("users");
  39. $langs->load("mails");
  40. $langs->load('other');
  41. $action=GETPOST('action','alpha');
  42. $confirm=GETPOST('confirm','alpha');
  43. $rowid=GETPOST('rowid','int');
  44. $typeid=GETPOST('typeid','int');
  45. // Security check
  46. $result=restrictedArea($user,'adherent',$rowid,'','cotisation');
  47. $object = new Adherent($db);
  48. $extrafields = new ExtraFields($db);
  49. $adht = new AdherentType($db);
  50. // fetch optionals attributes and labels
  51. $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
  52. $errmsg='';
  53. $errmsgs=array();
  54. $defaultdelay=1;
  55. $defaultdelayunit='y';
  56. if ($rowid)
  57. {
  58. // Load member
  59. $result = $object->fetch($rowid);
  60. // Define variables to know what current user can do on users
  61. $canadduser=($user->admin || $user->rights->user->user->creer);
  62. // Define variables to know what current user can do on properties of user linked to edited member
  63. if ($object->user_id)
  64. {
  65. // $user est le user qui edite, $object->user_id est l'id de l'utilisateur lies au membre edite
  66. $caneditfielduser=( (($user->id == $object->user_id) && $user->rights->user->self->creer)
  67. || (($user->id != $object->user_id) && $user->rights->user->user->creer) );
  68. $caneditpassworduser=( (($user->id == $object->user_id) && $user->rights->user->self->password)
  69. || (($user->id != $object->user_id) && $user->rights->user->user->password) );
  70. }
  71. }
  72. // Define variables to know what current user can do on members
  73. $canaddmember=$user->rights->adherent->creer;
  74. // Define variables to know what current user can do on properties of a member
  75. if ($rowid)
  76. {
  77. $caneditfieldmember=$user->rights->adherent->creer;
  78. }
  79. // PDF
  80. $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
  81. $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
  82. $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
  83. /*
  84. * Actions
  85. */
  86. // Create third party from a member
  87. if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer)
  88. {
  89. if ($result > 0)
  90. {
  91. // Creation user
  92. $company = new Societe($db);
  93. $result=$company->create_from_member($object,$_POST["companyname"]);
  94. if ($result < 0)
  95. {
  96. $langs->load("errors");
  97. $errmsg=$langs->trans($company->error);
  98. setEventMessages($company->error, $company->errors, 'errors');
  99. }
  100. else
  101. {
  102. $action='addsubscription';
  103. }
  104. }
  105. else
  106. {
  107. $errmsg=$object->error;
  108. }
  109. }
  110. if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
  111. {
  112. $error=0;
  113. if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only
  114. {
  115. if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id)
  116. {
  117. $error++;
  118. setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors');
  119. }
  120. }
  121. if (! $error)
  122. {
  123. if ($_POST["userid"] != $object->user_id) // If link differs from currently in database
  124. {
  125. $result=$object->setUserId($_POST["userid"]);
  126. if ($result < 0) dol_print_error('',$object->error);
  127. $_POST['action']='';
  128. $action='';
  129. }
  130. }
  131. }
  132. if ($action == 'setsocid')
  133. {
  134. $error=0;
  135. if (! $error)
  136. {
  137. if (GETPOST('socid','int') != $object->fk_soc) // If link differs from currently in database
  138. {
  139. $sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
  140. $sql.=" WHERE fk_soc = '".GETPOST('socid','int')."'";
  141. $resql = $db->query($sql);
  142. if ($resql)
  143. {
  144. $obj = $db->fetch_object($resql);
  145. if ($obj && $obj->rowid > 0)
  146. {
  147. $othermember=new Adherent($db);
  148. $othermember->fetch($obj->rowid);
  149. $thirdparty=new Societe($db);
  150. $thirdparty->fetch(GETPOST('socid','int'));
  151. $error++;
  152. setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name), null, 'errors');
  153. }
  154. }
  155. if (! $error)
  156. {
  157. $result=$object->setThirdPartyId(GETPOST('socid','int'));
  158. if ($result < 0) dol_print_error('',$object->error);
  159. $_POST['action']='';
  160. $action='';
  161. }
  162. }
  163. }
  164. }
  165. if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $_POST["cancel"])
  166. {
  167. $error=0;
  168. $langs->load("banks");
  169. $result=$object->fetch($rowid);
  170. $result=$adht->fetch($object->typeid);
  171. // Subscription informations
  172. $datecotisation=0;
  173. $datesubend=0;
  174. $paymentdate=0;
  175. if ($_POST["reyear"] && $_POST["remonth"] && $_POST["reday"])
  176. {
  177. $datecotisation=dol_mktime(0, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
  178. }
  179. if ($_POST["endyear"] && $_POST["endmonth"] && $_POST["endday"])
  180. {
  181. $datesubend=dol_mktime(0, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]);
  182. }
  183. if ($_POST["paymentyear"] && $_POST["paymentmonth"] && $_POST["paymentday"])
  184. {
  185. $paymentdate=dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]);
  186. }
  187. $cotisation=$_POST["cotisation"]; // Amount of subscription
  188. $label=$_POST["label"];
  189. // Payment informations
  190. $accountid=$_POST["accountid"];
  191. $operation=$_POST["operation"]; // Payment mode
  192. $num_chq=$_POST["num_chq"];
  193. $emetteur_nom=$_POST["chqemetteur"];
  194. $emetteur_banque=$_POST["chqbank"];
  195. $option=$_POST["paymentsave"];
  196. if (empty($option)) $option='none';
  197. // Check parameters
  198. if (! $datecotisation)
  199. {
  200. $error++;
  201. $langs->load("errors");
  202. $errmsg=$langs->trans("ErrorBadDateFormat",$langs->transnoentitiesnoconv("DateSubscription"));
  203. $action='addsubscription';
  204. }
  205. if (GETPOST('end') && ! $datesubend)
  206. {
  207. $error++;
  208. $langs->load("errors");
  209. $errmsg=$langs->trans("ErrorBadDateFormat",$langs->transnoentitiesnoconv("DateEndSubscription"));
  210. $action='addsubscription';
  211. }
  212. if (! $datesubend)
  213. {
  214. $datesubend=dol_time_plus_duree(dol_time_plus_duree($datecotisation,$defaultdelay,$defaultdelayunit),-1,'d');
  215. }
  216. if (($option == 'bankviainvoice' || $option == 'bankdirect') && ! $paymentdate)
  217. {
  218. $error++;
  219. $errmsg=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment"));
  220. $action='addsubscription';
  221. }
  222. // Check if a payment is mandatory or not
  223. if (! $error && $adht->cotisation) // Type adherent soumis a cotisation
  224. {
  225. if (! is_numeric($_POST["cotisation"]))
  226. {
  227. // If field is '' or not a numeric value
  228. $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount"));
  229. $error++;
  230. $action='addsubscription';
  231. }
  232. else
  233. {
  234. if (! empty($conf->banque->enabled) && $_POST["paymentsave"] != 'none')
  235. {
  236. if ($_POST["cotisation"])
  237. {
  238. if (! $_POST["label"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label"));
  239. if ($_POST["paymentsave"] != 'invoiceonly' && ! $_POST["operation"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
  240. if ($_POST["paymentsave"] != 'invoiceonly' && ! $_POST["accountid"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("FinancialAccount"));
  241. }
  242. else
  243. {
  244. if ($_POST["accountid"]) $errmsg=$langs->trans("ErrorDoNotProvideAccountsIfNullAmount");
  245. }
  246. if ($errmsg) $action='addsubscription';
  247. }
  248. }
  249. }
  250. if (! $error && $action=='cotisation')
  251. {
  252. $db->begin();
  253. // Create subscription
  254. $crowid=$object->cotisation($datecotisation, $cotisation, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend);
  255. if ($crowid <= 0)
  256. {
  257. $error++;
  258. $errmsg=$object->error;
  259. setEventMessages($object->error,$object->errors, 'errors');
  260. }
  261. if (! $error)
  262. {
  263. // Insert into bank account directlty (if option choosed for) + link to llx_cotisation if option is 'bankdirect'
  264. if ($option == 'bankdirect' && $accountid)
  265. {
  266. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  267. $acct=new Account($db);
  268. $result=$acct->fetch($accountid);
  269. $dateop=$paymentdate;
  270. $insertid=$acct->addline($dateop, $operation, $label, $cotisation, $num_chq, '', $user, $emetteur_nom, $emetteur_banque);
  271. if ($insertid > 0)
  272. {
  273. $inserturlid=$acct->add_url_line($insertid, $object->id, DOL_URL_ROOT.'/adherents/card.php?rowid=', $object->getFullname($langs), 'member');
  274. if ($inserturlid > 0)
  275. {
  276. // Met a jour la table cotisation
  277. $sql ="UPDATE ".MAIN_DB_PREFIX."cotisation SET fk_bank=".$insertid;
  278. $sql.=" WHERE rowid=".$crowid;
  279. dol_syslog("card_subscriptions::cotisation", LOG_DEBUG);
  280. $resql = $db->query($sql);
  281. if (! $resql)
  282. {
  283. $error++;
  284. $errmsg=$db->lasterror();
  285. }
  286. }
  287. else
  288. {
  289. $error++;
  290. $errmsg=$acct->error;
  291. $errmsgs=$acct->errors;
  292. }
  293. }
  294. else
  295. {
  296. $error++;
  297. $errmsg=$acct->error;
  298. $errmsgs=$acct->errors;
  299. }
  300. }
  301. // If option choosed, we create invoice
  302. if (($option == 'bankviainvoice' && $accountid) || $option == 'invoiceonly')
  303. {
  304. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  305. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php';
  306. $invoice=new Facture($db);
  307. $customer=new Societe($db);
  308. if (! $error)
  309. {
  310. if (! ($object->fk_soc > 0))
  311. {
  312. $langs->load("errors");
  313. $errmsg=$langs->trans("ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst");
  314. $error++;
  315. }
  316. }
  317. if (! $error)
  318. {
  319. $result=$customer->fetch($object->fk_soc);
  320. if ($result <= 0)
  321. {
  322. $errmsg=$customer->error;
  323. $errmsgs=$acct->errors;
  324. $error++;
  325. }
  326. }
  327. if (! $error)
  328. {
  329. // Create draft invoice
  330. $invoice->type= Facture::TYPE_STANDARD;
  331. $invoice->cond_reglement_id=$customer->cond_reglement_id;
  332. if (empty($invoice->cond_reglement_id))
  333. {
  334. $paymenttermstatic=new PaymentTerm($db);
  335. $invoice->cond_reglement_id=$paymenttermstatic->getDefaultId();
  336. if (empty($invoice->cond_reglement_id))
  337. {
  338. $error++;
  339. $errmsg='ErrorNoPaymentTermRECEPFound';
  340. }
  341. }
  342. $invoice->socid=$object->fk_soc;
  343. $invoice->date=$datecotisation;
  344. // Possibility to add external linked objects with hooks
  345. $invoice->linked_objects['subscription'] = $crowid;
  346. if (! empty($_POST['other_linked_objects']) && is_array($_POST['other_linked_objects']))
  347. {
  348. $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST['other_linked_objects']);
  349. }
  350. $result=$invoice->create($user);
  351. if ($result <= 0)
  352. {
  353. $errmsg=$invoice->error;
  354. $errmsgs=$invoice->errors;
  355. $error++;
  356. }
  357. }
  358. if (! $error)
  359. {
  360. // Add line to draft invoice
  361. $idprodsubscription=0;
  362. 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;
  363. $vattouse=0;
  364. if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS == 'defaultforfoundationcountry')
  365. {
  366. $vattouse=get_default_tva($mysoc, $mysoc, $idprodsubscription);
  367. }
  368. //print xx".$vattouse." - ".$mysoc." - ".$customer;exit;
  369. $result=$invoice->addline($label,0,1,$vattouse,0,0,$idprodsubscription,0,$datecotisation,$datesubend,0,0,'','TTC',$cotisation,1);
  370. if ($result <= 0)
  371. {
  372. $errmsg=$invoice->error;
  373. $error++;
  374. }
  375. }
  376. if (! $error)
  377. {
  378. // Validate invoice
  379. $result=$invoice->validate($user);
  380. if ($result <= 0)
  381. {
  382. $errmsg=$invoice->error;
  383. $errmsgs=$invoice->errors;
  384. $error++;
  385. }
  386. }
  387. // Add payment onto invoice
  388. if ($option == 'bankviainvoice' && $accountid)
  389. {
  390. require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
  391. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  392. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
  393. $amounts[$invoice->id] = price2num($cotisation);
  394. $paiement = new Paiement($db);
  395. $paiement->datepaye = $paymentdate;
  396. $paiement->amounts = $amounts;
  397. $paiement->paiementid = dol_getIdFromCode($db,$operation,'c_paiement');
  398. $paiement->num_paiement = $num_chq;
  399. $paiement->note = $label;
  400. if (! $error)
  401. {
  402. // Create payment line for invoice
  403. $paiement_id = $paiement->create($user);
  404. if (! $paiement_id > 0)
  405. {
  406. $errmsg=$paiement->error;
  407. $errmsgs=$paiement->errors;
  408. $error++;
  409. }
  410. }
  411. if (! $error)
  412. {
  413. // Add transaction into bank account
  414. $bank_line_id=$paiement->addPaymentToBank($user,'payment','(SubscriptionPayment)',$accountid,$emetteur_nom,$emetteur_banque);
  415. if (! ($bank_line_id > 0))
  416. {
  417. $errmsg=$paiement->error;
  418. $errmsgs=$paiement->errors;
  419. setEventMessages($paiement->error, $paiement->errors, 'errors');
  420. $error++;
  421. }
  422. }
  423. if (! $error)
  424. {
  425. // Update fk_bank into subscription table
  426. $sql = 'UPDATE '.MAIN_DB_PREFIX.'cotisation SET fk_bank='.$bank_line_id;
  427. $sql.= ' WHERE rowid='.$crowid;
  428. $result = $db->query($sql);
  429. if (! $result)
  430. {
  431. $error++;
  432. }
  433. }
  434. if (! $error)
  435. {
  436. // Set invoice as paid
  437. $invoice->set_paid($user);
  438. }
  439. if (! $error)
  440. {
  441. // Define output language
  442. $outputlangs = $langs;
  443. $newlang = '';
  444. if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
  445. $newlang = $_REQUEST['lang_id'];
  446. if ($conf->global->MAIN_MULTILANGS && empty($newlang))
  447. $newlang = $customer->default_lang;
  448. if (! empty($newlang)) {
  449. $outputlangs = new Translate("", $conf);
  450. $outputlangs->setDefaultLang($newlang);
  451. }
  452. // Generate PDF (whatever is option MAIN_DISABLE_PDF_AUTOUPDATE) so we can include it into email
  453. //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
  454. $invoice->generateDocument($invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
  455. }
  456. }
  457. }
  458. }
  459. if (! $error)
  460. {
  461. $db->commit();
  462. }
  463. else
  464. {
  465. $db->rollback();
  466. $action = 'addsubscription';
  467. }
  468. // Send email
  469. if (! $error)
  470. {
  471. // Send confirmation Email
  472. if ($object->email && $_POST["sendmail"])
  473. {
  474. $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
  475. $texttosend=$object->makeSubstitution($adht->getMailOnSubscription());
  476. $result=$object->send_an_email($texttosend,$subjecttosend,array(),array(),array(),"","",0,-1);
  477. if ($result < 0)
  478. {
  479. $errmsg=$object->error;
  480. }
  481. }
  482. $_POST["cotisation"]='';
  483. $_POST["accountid"]='';
  484. $_POST["operation"]='';
  485. $_POST["label"]='';
  486. $_POST["num_chq"]='';
  487. }
  488. }
  489. }
  490. /*
  491. * View
  492. */
  493. $form = new Form($db);
  494. $now=dol_now();
  495. llxHeader('',$langs->trans("Subscriptions"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
  496. if ($rowid > 0)
  497. {
  498. $res=$object->fetch($rowid);
  499. if ($res < 0) { dol_print_error($db,$object->error); exit; }
  500. $adht->fetch($object->typeid);
  501. $head = member_prepare_head($object);
  502. $rowspan=10;
  503. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++;
  504. if (! empty($conf->societe->enabled)) $rowspan++;
  505. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  506. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  507. print '<input type="hidden" name="rowid" value="'.$object->id.'">';
  508. dol_fiche_head($head, 'subscription', $langs->trans("Member"), 0, 'user');
  509. $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php">'.$langs->trans("BackToList").'</a>';
  510. dol_banner_tab($object, 'rowid', $linkback);
  511. print '<div class="fichecenter">';
  512. print '<div class="fichehalfleft">';
  513. print '<div class="underbanner clearboth"></div>';
  514. print '<table class="border" width="100%">';
  515. // Login
  516. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
  517. {
  518. print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
  519. }
  520. // Type
  521. print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
  522. // Morphy
  523. print '<tr><td>'.$langs->trans("Nature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
  524. print '</tr>';
  525. // Company
  526. print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->societe.'</td></tr>';
  527. // Civility
  528. print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
  529. print '</tr>';
  530. // Password
  531. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
  532. {
  533. print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i','*',$object->pass);
  534. if ((! empty($object->pass) || ! empty($object->pass_crypted)) && empty($object->user_id))
  535. {
  536. $langs->load("errors");
  537. $htmltext=$langs->trans("WarningPasswordSetWithNoAccount");
  538. print ' '.$form->textwithpicto('', $htmltext,1,'warning');
  539. }
  540. print '</td></tr>';
  541. }
  542. print '</table>';
  543. print '</div>';
  544. print '<div class="fichehalfright"><div class="ficheaddleft">';
  545. print '<div class="underbanner clearboth"></div>';
  546. print '<table class="border tableforfield" width="100%">';
  547. // Birthday
  548. print '<tr><td class="titlefield">'.$langs->trans("Birthday").'</td><td class="valeur">'.dol_print_date($object->birth,'day').'</td></tr>';
  549. // Public
  550. print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>';
  551. // Categories
  552. if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
  553. {
  554. print '<tr><td>' . $langs->trans("Categories") . '</td>';
  555. print '<td colspan="2">';
  556. print $form->showCategories($object->id, 'member', 1);
  557. print '</td></tr>';
  558. }
  559. // Other attributes
  560. $parameters=array('colspan'=>2);
  561. $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
  562. if (empty($reshook) && ! empty($extrafields->attribute_label))
  563. {
  564. print $object->showOptionals($extrafields, 'view', $parameters);
  565. }
  566. // Date end subscription
  567. print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
  568. if ($object->datefin)
  569. {
  570. print dol_print_date($object->datefin,'day');
  571. if ($object->hasDelay()) {
  572. print " ".img_warning($langs->trans("Late"));
  573. }
  574. }
  575. else
  576. {
  577. if (! $adht->cotisation)
  578. {
  579. print $langs->trans("SubscriptionNotRecorded");
  580. if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
  581. }
  582. else
  583. {
  584. print $langs->trans("SubscriptionNotReceived");
  585. if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
  586. }
  587. }
  588. print '</td></tr>';
  589. // Third party Dolibarr
  590. if (! empty($conf->societe->enabled))
  591. {
  592. print '<tr><td>';
  593. print '<table class="nobordernopadding" width="100%"><tr><td>';
  594. print $langs->trans("LinkedToDolibarrThirdParty");
  595. print '</td>';
  596. 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>';
  597. print '</tr></table>';
  598. print '</td><td colspan="2" class="valeur">';
  599. if ($action == 'editthirdparty')
  600. {
  601. $htmlname='socid';
  602. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">';
  603. print '<input type="hidden" name="rowid" value="'.$object->id.'">';
  604. print '<input type="hidden" name="action" value="set'.$htmlname.'">';
  605. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  606. print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
  607. print '<tr><td>';
  608. print $form->select_company($object->fk_soc,'socid','',1);
  609. print '</td>';
  610. print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
  611. print '</tr></table></form>';
  612. }
  613. else
  614. {
  615. if ($object->fk_soc)
  616. {
  617. $company=new Societe($db);
  618. $result=$company->fetch($object->fk_soc);
  619. print $company->getNomUrl(1);
  620. }
  621. else
  622. {
  623. print $langs->trans("NoThirdPartyAssociatedToMember");
  624. }
  625. }
  626. print '</td></tr>';
  627. }
  628. // Login Dolibarr
  629. print '<tr><td>';
  630. print '<table class="nobordernopadding" width="100%"><tr><td>';
  631. print $langs->trans("LinkedToDolibarrUser");
  632. print '</td>';
  633. if ($action != 'editlogin' && $user->rights->adherent->creer)
  634. {
  635. print '<td align="right">';
  636. if ($user->rights->user->user->creer)
  637. {
  638. print '<a href="'.$_SERVER["PHP_SELF"].'?action=editlogin&amp;rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToUser'),1).'</a>';
  639. }
  640. print '</td>';
  641. }
  642. print '</tr></table>';
  643. print '</td><td colspan="2" class="valeur">';
  644. if ($action == 'editlogin')
  645. {
  646. $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'userid','');
  647. }
  648. else
  649. {
  650. if ($object->user_id)
  651. {
  652. $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none');
  653. }
  654. else print $langs->trans("NoDolibarrAccess");
  655. }
  656. print '</td></tr>';
  657. print "</table>\n";
  658. print "</div></div></div>\n";
  659. print '<div style="clear:both"></div>';
  660. dol_fiche_end();
  661. print '</form>';
  662. /*
  663. * Hotbar
  664. */
  665. // Lien nouvelle cotisation si non brouillon et non resilie
  666. if ($user->rights->adherent->cotisation->creer)
  667. {
  668. if ($action != 'addsubscription' && $action != 'create_thirdparty')
  669. {
  670. print '<div class="tabsAction">';
  671. 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>";
  672. else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("AddSubscription").'</a></div>';
  673. print "<br>\n";
  674. print '</div>';
  675. print '<br>';
  676. }
  677. }
  678. /*
  679. * List of subscriptions
  680. */
  681. if ($action != 'addsubscription' && $action != 'create_thirdparty')
  682. {
  683. $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe,";
  684. $sql.= " c.rowid as crowid, c.cotisation,";
  685. $sql.= " c.datec,";
  686. $sql.= " c.dateadh as dateh,";
  687. $sql.= " c.datef,";
  688. $sql.= " c.fk_bank,";
  689. $sql.= " b.rowid as bid,";
  690. $sql.= " ba.rowid as baid, ba.label, ba.bank";
  691. $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."cotisation as c";
  692. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid";
  693. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
  694. $sql.= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid;
  695. $result = $db->query($sql);
  696. if ($result)
  697. {
  698. $cotisationstatic=new Cotisation($db);
  699. $accountstatic=new Account($db);
  700. $num = $db->num_rows($result);
  701. $i = 0;
  702. print "<table class=\"noborder\" width=\"100%\">\n";
  703. print '<tr class="liste_titre">';
  704. print '<td>'.$langs->trans("Ref").'</td>';
  705. print '<td align="center">'.$langs->trans("DateCreation").'</td>';
  706. print '<td align="center">'.$langs->trans("DateStart").'</td>';
  707. print '<td align="center">'.$langs->trans("DateEnd").'</td>';
  708. print '<td align="right">'.$langs->trans("Amount").'</td>';
  709. if (! empty($conf->banque->enabled))
  710. {
  711. print '<td align="right">'.$langs->trans("Account").'</td>';
  712. }
  713. print "</tr>\n";
  714. $var=True;
  715. while ($i < $num)
  716. {
  717. $objp = $db->fetch_object($result);
  718. $var=!$var;
  719. print "<tr ".$bc[$var].">";
  720. $cotisationstatic->ref=$objp->crowid;
  721. $cotisationstatic->id=$objp->crowid;
  722. print '<td>'.$cotisationstatic->getNomUrl(1).'</td>';
  723. print '<td align="center">'.dol_print_date($db->jdate($objp->datec),'dayhour')."</td>\n";
  724. print '<td align="center">'.dol_print_date($db->jdate($objp->dateh),'day')."</td>\n";
  725. print '<td align="center">'.dol_print_date($db->jdate($objp->datef),'day')."</td>\n";
  726. print '<td align="right">'.price($objp->cotisation).'</td>';
  727. if (! empty($conf->banque->enabled))
  728. {
  729. print '<td align="right">';
  730. if ($objp->bid)
  731. {
  732. $accountstatic->label=$objp->label;
  733. $accountstatic->id=$objp->baid;
  734. print $accountstatic->getNomUrl(1);
  735. }
  736. else
  737. {
  738. print '&nbsp;';
  739. }
  740. print '</td>';
  741. }
  742. print "</tr>";
  743. $i++;
  744. }
  745. print "</table>";
  746. }
  747. else
  748. {
  749. dol_print_error($db);
  750. }
  751. // Link for paypal payment
  752. if (! empty($conf->paypal->enabled))
  753. {
  754. include_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
  755. print showPaypalPaymentUrl('membersubscription',$object->ref);
  756. }
  757. }
  758. /*
  759. * Add new subscription form
  760. */
  761. if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer)
  762. {
  763. print '<br>';
  764. print load_fiche_titre($langs->trans("NewCotisation"));
  765. // Define default choice to select
  766. $bankdirect=0; // 1 means option by default is write to bank direct with no invoice
  767. $invoiceonly=0; // 1 means option by default is invoice only
  768. $bankviainvoice=0; // 1 means option by default is write to bank via invoice
  769. if (GETPOST('paymentsave'))
  770. {
  771. if (GETPOST('paymentsave') == 'bankdirect') $bankdirect=1;
  772. if (GETPOST('paymentsave') == 'invoiceonly') $invoiceonly=1;
  773. if (GETPOST('paymentsave') == 'bankviainvoice') $bankviainvoice=1;
  774. }
  775. else
  776. {
  777. 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;
  778. else if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && ! empty($conf->banque->enabled)) $bankdirect=1;
  779. 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;
  780. }
  781. print "\n\n<!-- Form add subscription -->\n";
  782. if ($conf->use_javascript_ajax)
  783. {
  784. //var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly.'-'.empty($conf->global->ADHERENT_BANK_USE));
  785. print "\n".'<script type="text/javascript" language="javascript">';
  786. print '$(document).ready(function () {
  787. $(".bankswitchclass, .bankswitchclass2").'.(($bankdirect||$bankviainvoice)?'show()':'hide()').';
  788. $("#none, #invoiceonly").click(function() {
  789. $(".bankswitchclass").hide();
  790. $(".bankswitchclass2").hide();
  791. });
  792. $("#bankdirect, #bankviainvoice").click(function() {
  793. $(".bankswitchclass").show();
  794. $(".bankswitchclass2").show();
  795. });
  796. $("#selectoperation").change(function() {
  797. var code = $(this).val();
  798. if (code == "CHQ")
  799. {
  800. $(".fieldrequireddyn").addClass("fieldrequired");
  801. if ($("#fieldchqemetteur").val() == "")
  802. {
  803. $("#fieldchqemetteur").val($("#memberlabel").val());
  804. }
  805. }
  806. else
  807. {
  808. $(".fieldrequireddyn").removeClass("fieldrequired");
  809. }
  810. });
  811. ';
  812. if (GETPOST('paymentsave')) print '$("#'.GETPOST('paymentsave').'").prop("checked",true);';
  813. print '});';
  814. print '</script>'."\n";
  815. }
  816. // Confirm create third party
  817. if ($action == 'create_thirdparty')
  818. {
  819. $name = $object->getFullName($langs);
  820. if (! empty($name))
  821. {
  822. if ($object->morphy == 'mor' && ! empty($object->societe)) $name=$object->societe.' ('.$name.')';
  823. else if ($object->societe) $name.=' ('.$object->societe.')';
  824. }
  825. else
  826. {
  827. $name=$object->societe;
  828. }
  829. // Create a form array
  830. $formquestion=array(array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name));
  831. print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1);
  832. }
  833. print '<form name="cotisation" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  834. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  835. print '<input type="hidden" name="action" value="cotisation">';
  836. print '<input type="hidden" name="rowid" value="'.$rowid.'">';
  837. print '<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).'">';
  838. print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($object->societe).'">';
  839. dol_fiche_head('');
  840. print "<table class=\"border\" width=\"100%\">\n";
  841. print '<tbody>';
  842. $today=dol_now();
  843. $datefrom=0;
  844. $dateto=0;
  845. $paymentdate=-1;
  846. // Date payment
  847. if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday'))
  848. {
  849. $paymentdate=dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear'));
  850. }
  851. // Date start subscription
  852. print '<tr><td width="30%" class="fieldrequired">'.$langs->trans("DateSubscription").'</td><td>';
  853. if (GETPOST('reday'))
  854. {
  855. $datefrom=dol_mktime(0,0,0,GETPOST('remonth'),GETPOST('reday'),GETPOST('reyear'));
  856. }
  857. if (! $datefrom)
  858. {
  859. if ($object->datefin > 0)
  860. {
  861. $datefrom=dol_time_plus_duree($object->datefin,1,'d');
  862. }
  863. else
  864. {
  865. //$datefrom=dol_now();
  866. $datefrom=$object->datevalid;
  867. }
  868. }
  869. print $form->select_date($datefrom,'','','','',"cotisation",1,1,1);
  870. print "</td></tr>";
  871. // Date end subscription
  872. if (GETPOST('endday'))
  873. {
  874. $dateto=dol_mktime(0,0,0,GETPOST('endmonth'),GETPOST('endday'),GETPOST('endyear'));
  875. }
  876. if (! $dateto)
  877. {
  878. $dateto=-1; // By default, no date is suggested
  879. }
  880. print '<tr><td>'.$langs->trans("DateEndSubscription").'</td><td>';
  881. print $form->select_date($dateto,'end','','','',"cotisation",1,0,1);
  882. print "</td></tr>";
  883. if ($adht->cotisation)
  884. {
  885. // Amount
  886. print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="cotisation" size="6" value="'.GETPOST('cotisation').'"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
  887. // Label
  888. print '<tr><td>'.$langs->trans("Label").'</td>';
  889. print '<td><input name="label" type="text" size="32" value="';
  890. if (empty($conf->global->MEMBER_NO_DEFAULT_LABEL)) print $langs->trans("Subscription").' '.dol_print_date(($datefrom?$datefrom:time()),"%Y");
  891. print '"></td></tr>';
  892. // Complementary action
  893. if (! empty($conf->banque->enabled) || ! empty($conf->facture->enabled))
  894. {
  895. $company=new Societe($db);
  896. if ($object->fk_soc)
  897. {
  898. $result=$company->fetch($object->fk_soc);
  899. }
  900. // Title payments
  901. //print '<tr><td colspan="2"><b>'.$langs->trans("Payment").'</b></td></tr>';
  902. // No more action
  903. print '<tr><td valign="top" class="fieldrequired">'.$langs->trans('MoreActions');
  904. print '</td>';
  905. print '<td>';
  906. print '<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"'.(empty($bankdirect) && empty($invoiceonly) && empty($bankviainvoice)?' checked':'').'> '.$langs->trans("None").'<br>';
  907. // Add entry into bank accoun
  908. if (! empty($conf->banque->enabled))
  909. {
  910. print '<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"'.(! empty($bankdirect)?' checked':'');
  911. print '> '.$langs->trans("MoreActionBankDirect").'<br>';
  912. }
  913. // Add invoice with no payments
  914. if (! empty($conf->societe->enabled) && ! empty($conf->facture->enabled))
  915. {
  916. print '<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(! empty($invoiceonly)?' checked':'');
  917. //if (empty($object->fk_soc)) print ' disabled';
  918. print '> '.$langs->trans("MoreActionInvoiceOnly");
  919. if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
  920. else
  921. {
  922. print ' (';
  923. if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
  924. print $langs->trans("NoThirdPartyAssociatedToMember");
  925. print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&amp;action=create_thirdparty">';
  926. print $langs->trans("CreateDolibarrThirdParty");
  927. print '</a>)';
  928. }
  929. if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription",0);
  930. if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled)))
  931. {
  932. $prodtmp=new Product($db);
  933. $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
  934. print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
  935. }
  936. print '<br>';
  937. }
  938. // Add invoice with payments
  939. if (! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled))
  940. {
  941. print '<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(! empty($bankviainvoice)?' checked':'');
  942. //if (empty($object->fk_soc)) print ' disabled';
  943. print '> '.$langs->trans("MoreActionBankViaInvoice");
  944. if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
  945. else
  946. {
  947. print ' (';
  948. if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
  949. print $langs->trans("NoThirdPartyAssociatedToMember");
  950. print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&amp;action=create_thirdparty">';
  951. print $langs->trans("CreateDolibarrThirdParty");
  952. print '</a>)';
  953. }
  954. if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription",0);
  955. if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled)))
  956. {
  957. $prodtmp=new Product($db);
  958. $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
  959. print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
  960. }
  961. print '<br>';
  962. }
  963. print '</td></tr>';
  964. // Bank account
  965. print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("FinancialAccount").'</td><td>';
  966. $form->select_comptes(GETPOST('accountid'),'accountid',0,'',1);
  967. print "</td></tr>\n";
  968. // Payment mode
  969. print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
  970. $form->select_types_paiements(GETPOST('operation'),'operation','',2);
  971. print "</td></tr>\n";
  972. // Date of payment
  973. print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("DatePayment").'</td><td>';
  974. print $form->select_date(isset($paymentdate)?$paymentdate:-1,'payment',0,0,1,'cotisation',1,1,1);
  975. print "</td></tr>\n";
  976. print '<tr class="bankswitchclass2"><td>'.$langs->trans('Numero');
  977. print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
  978. print '</td>';
  979. print '<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(! GETPOST('num_chq')?'':GETPOST('num_chq')).'"></td></tr>';
  980. print '<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans('CheckTransmitter');
  981. print ' <em>('.$langs->trans("ChequeMaker").')</em>';
  982. print '</td>';
  983. print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(! GETPOST('chqemetteur')?'':GETPOST('chqemetteur')).'"></td></tr>';
  984. print '<tr class="bankswitchclass2"><td>'.$langs->trans('Bank');
  985. print ' <em>('.$langs->trans("ChequeBank").')</em>';
  986. print '</td>';
  987. print '<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(! GETPOST('chqbank')?'':GETPOST('chqbank')).'"></td></tr>';
  988. }
  989. }
  990. print '<tr><td colspan="2">&nbsp;</td>';
  991. print '<tr><td width="30%">'.$langs->trans("SendAcknowledgementByMail").'</td>';
  992. print '<td>';
  993. if (! $object->email)
  994. {
  995. print $langs->trans("NoEMail");
  996. }
  997. else
  998. {
  999. $adht = new AdherentType($db);
  1000. $adht->fetch($object->typeid);
  1001. $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
  1002. $texttosend=$object->makeSubstitution($adht->getMailOnSubscription());
  1003. $tmp='<input name="sendmail" type="checkbox"'.(GETPOST('sendmail')?GETPOST('sendmail'):(! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?' checked':'')).'>';
  1004. $helpcontent='';
  1005. $helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
  1006. $helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
  1007. $helpcontent.='<b>'.$langs->trans("MailTopic").'</b>:<br>'."\n";
  1008. $helpcontent.=$subjecttosend."\n";
  1009. $helpcontent.="<br>";
  1010. $helpcontent.='<b>'.$langs->trans("MailText").'</b>:<br>';
  1011. $helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
  1012. print $form->textwithpicto($tmp,$helpcontent,1,'help');
  1013. }
  1014. print '</td></tr>';
  1015. print '</tbody>';
  1016. print '</table>';
  1017. dol_fiche_end();
  1018. print '<div class="center">';
  1019. print '<input type="submit" class="button" name="add" value="'.$langs->trans("AddSubscription").'">';
  1020. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  1021. print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
  1022. print '</div>';
  1023. print '</form>';
  1024. print "\n<!-- End form subscription -->\n\n";
  1025. }
  1026. //print '</td></tr>';
  1027. //print '</table>';
  1028. }
  1029. else
  1030. {
  1031. $langs->load("errors");
  1032. print $langs->trans("ErrorRecordNotFound");
  1033. }
  1034. llxFooter();
  1035. $db->close();