paymentmodes.php 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638
  1. <?php
  2. /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
  4. * Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2013 Peter Fontaine <contact@peterfontaine.fr>
  7. * Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
  8. * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
  9. * Copyright (C) 2018 ptibogxiv <support@ptibogxiv.net>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. */
  24. /**
  25. * \file htdocs/societe/paymentmodes.php
  26. * \ingroup societe
  27. * \brief Tab of payment modes for the customer
  28. */
  29. require '../main.inc.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/societe/class/companypaymentmode.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
  39. $langs->loadLangs(array("companies","commercial","banks","bills",'paypal','stripe','withdrawals'));
  40. // Security check
  41. $socid = GETPOST("socid","int");
  42. if ($user->societe_id) $socid=$user->societe_id;
  43. $result = restrictedArea($user, 'societe','','');
  44. $id=GETPOST("id","int");
  45. $source=GETPOST("source","alpha");
  46. $ribid=GETPOST("ribid","int");
  47. $action=GETPOST("action", 'alpha', 3);
  48. $cancel=GETPOST('cancel', 'alpha');
  49. $object = new Societe($db);
  50. $object->fetch($socid);
  51. $companybankaccount = new CompanyBankAccount($db);
  52. $companypaymentmode = new CompanyPaymentMode($db);
  53. $prelevement = new BonPrelevement($db);
  54. $extrafields = new ExtraFields($db);
  55. // fetch optionals attributes and labels
  56. $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
  57. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  58. $hookmanager->initHooks(array('thirdpartybancard','globalcard'));
  59. if (! empty($conf->stripe->enabled))
  60. {
  61. $service = 'StripeTest';
  62. $servicestatus = 0;
  63. if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha'))
  64. {
  65. $service = 'StripeLive';
  66. $servicestatus = 1;
  67. }
  68. $stripe = new Stripe($db);
  69. $stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account (no network access here)
  70. $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus); // Get remote Stripe customer 'cus_...' (no network access here)
  71. }
  72. /*
  73. * Actions
  74. */
  75. if ($cancel)
  76. {
  77. $action='';
  78. }
  79. $parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas);
  80. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  81. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  82. if (empty($reshook))
  83. {
  84. if ($cancel)
  85. {
  86. $action='';
  87. if (! empty($backtopage))
  88. {
  89. header("Location: ".$backtopage);
  90. exit;
  91. }
  92. }
  93. if ($action == 'update')
  94. {
  95. // Modification
  96. if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha'))
  97. {
  98. if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
  99. if (! GETPOST('bank','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors');
  100. $action='edit';
  101. $error++;
  102. }
  103. if ($companybankaccount->needIBAN() == 1)
  104. {
  105. if (! GETPOST('iban'))
  106. {
  107. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
  108. $action='edit';
  109. $error++;
  110. }
  111. if (! GETPOST('bic'))
  112. {
  113. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
  114. $action='edit';
  115. $error++;
  116. }
  117. }
  118. $companybankaccount->fetch($id);
  119. if (! $error)
  120. {
  121. $companybankaccount->socid = $object->id;
  122. $companybankaccount->bank = GETPOST('bank','alpha');
  123. $companybankaccount->label = GETPOST('label','alpha');
  124. $companybankaccount->courant = GETPOST('courant','alpha');
  125. $companybankaccount->clos = GETPOST('clos','alpha');
  126. $companybankaccount->code_banque = GETPOST('code_banque','alpha');
  127. $companybankaccount->code_guichet = GETPOST('code_guichet','alpha');
  128. $companybankaccount->number = GETPOST('number','alpha');
  129. $companybankaccount->cle_rib = GETPOST('cle_rib','alpha');
  130. $companybankaccount->bic = GETPOST('bic','alpha');
  131. $companybankaccount->iban = GETPOST('iban','alpha');
  132. $companybankaccount->domiciliation = GETPOST('domiciliation','alpha');
  133. $companybankaccount->proprio = GETPOST('proprio','alpha');
  134. $companybankaccount->owner_address = GETPOST('owner_address','alpha');
  135. $companybankaccount->frstrecur = GETPOST('frstrecur','alpha');
  136. $companybankaccount->rum = GETPOST('rum','alpha');
  137. if (empty($companybankaccount->rum))
  138. {
  139. $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
  140. $companybankaccount->date_rum = dol_now();
  141. }
  142. $result = $companybankaccount->update($user);
  143. if (! $result)
  144. {
  145. setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
  146. }
  147. else
  148. {
  149. // If this account is the default bank account, we disable others
  150. if ($companybankaccount->default_rib)
  151. {
  152. $companybankaccount->setAsDefault($id); // This will make sure there is only one default rib
  153. }
  154. $url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
  155. header('Location: '.$url);
  156. exit;
  157. }
  158. }
  159. }
  160. if ($action == 'updatecard')
  161. {
  162. // Modification
  163. if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha'))
  164. {
  165. if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
  166. if (! GETPOST('proprio','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors');
  167. if (! GETPOST('cardnumber','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors');
  168. if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors');
  169. if (! GETPOST('cvn','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors');
  170. $action='createcard';
  171. $error++;
  172. }
  173. $companypaymentmode->fetch($id);
  174. if (! $error)
  175. {
  176. $companypaymentmode->fk_soc = $object->id;
  177. $companypaymentmode->bank = GETPOST('bank','alpha');
  178. $companypaymentmode->label = GETPOST('label','alpha');
  179. $companypaymentmode->number = GETPOST('cardnumber','alpha');
  180. $companypaymentmode->last_four = substr(GETPOST('cardnumber','alpha'), -4);
  181. $companypaymentmode->proprio = GETPOST('proprio','alpha');
  182. $companypaymentmode->exp_date_month = GETPOST('exp_date_month','int');
  183. $companypaymentmode->exp_date_year = GETPOST('exp_date_year','int');
  184. $companypaymentmode->cvn = GETPOST('cvn','alpha');
  185. $companypaymentmode->country_code = $object->country_code;
  186. $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref','alpha');
  187. $result = $companypaymentmode->update($user);
  188. if (! $result)
  189. {
  190. setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
  191. }
  192. else
  193. {
  194. // If this account is the default bank account, we disable others
  195. if ($companypaymentmode->default_rib)
  196. {
  197. $companypaymentmode->setAsDefault($id); // This will make sure there is only one default rib
  198. }
  199. $url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
  200. header('Location: '.$url);
  201. exit;
  202. }
  203. }
  204. }
  205. if ($action == 'add')
  206. {
  207. $error=0;
  208. if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha'))
  209. {
  210. if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
  211. if (! GETPOST('bank','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors');
  212. $action='create';
  213. $error++;
  214. }
  215. if (! $error)
  216. {
  217. // Ajout
  218. $companybankaccount = new CompanyBankAccount($db);
  219. $companybankaccount->socid = $object->id;
  220. $companybankaccount->bank = GETPOST('bank','alpha');
  221. $companybankaccount->label = GETPOST('label','alpha');
  222. $companybankaccount->courant = GETPOST('courant','alpha');
  223. $companybankaccount->clos = GETPOST('clos','alpha');
  224. $companybankaccount->code_banque = GETPOST('code_banque','alpha');
  225. $companybankaccount->code_guichet = GETPOST('code_guichet','alpha');
  226. $companybankaccount->number = GETPOST('number','alpha');
  227. $companybankaccount->cle_rib = GETPOST('cle_rib','alpha');
  228. $companybankaccount->bic = GETPOST('bic','alpha');
  229. $companybankaccount->iban = GETPOST('iban','alpha');
  230. $companybankaccount->domiciliation = GETPOST('domiciliation','alpha');
  231. $companybankaccount->proprio = GETPOST('proprio','alpha');
  232. $companybankaccount->owner_address = GETPOST('owner_address','alpha');
  233. $companybankaccount->frstrecur = GETPOST('frstrecur');
  234. $companybankaccount->rum = GETPOST('rum','alpha');
  235. $companybankaccount->datec = dol_now();
  236. $companybankaccount->status = 1;
  237. $db->begin();
  238. // This test can be done only once properties were set
  239. if ($companybankaccount->needIBAN() == 1)
  240. {
  241. if (! GETPOST('iban'))
  242. {
  243. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
  244. $action='create';
  245. $error++;
  246. }
  247. if (! GETPOST('bic'))
  248. {
  249. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
  250. $action='create';
  251. $error++;
  252. }
  253. }
  254. if (! $error)
  255. {
  256. $result = $companybankaccount->create($user);
  257. if ($result < 0)
  258. {
  259. $error++;
  260. setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
  261. $action='create'; // Force chargement page création
  262. }
  263. if (empty($companybankaccount->rum))
  264. {
  265. $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
  266. $companybankaccount->date_rum = dol_now();
  267. }
  268. }
  269. if (! $error)
  270. {
  271. $result = $companybankaccount->update($user); // This will set the UMR number.
  272. if ($result < 0)
  273. {
  274. $error++;
  275. setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
  276. $action='create';
  277. }
  278. }
  279. if (! $error)
  280. {
  281. $db->commit();
  282. $url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
  283. header('Location: '.$url);
  284. exit;
  285. }
  286. else
  287. {
  288. $db->rollback();
  289. }
  290. }
  291. }
  292. if ($action == 'addcard')
  293. {
  294. $error=0;
  295. if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha'))
  296. {
  297. if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
  298. if (! GETPOST('proprio','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors');
  299. if (! GETPOST('cardnumber','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors');
  300. if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors');
  301. if (! GETPOST('cvn','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors');
  302. $action='createcard';
  303. $error++;
  304. }
  305. if (! $error)
  306. {
  307. // Ajout
  308. $companypaymentmode = new CompanyPaymentMode($db);
  309. $companypaymentmode->fk_soc = $object->id;
  310. $companypaymentmode->bank = GETPOST('bank','alpha');
  311. $companypaymentmode->label = GETPOST('label','alpha');
  312. $companypaymentmode->number = GETPOST('cardnumber','alpha');
  313. $companypaymentmode->last_four = substr(GETPOST('cardnumber','alpha'), -4);
  314. $companypaymentmode->proprio = GETPOST('proprio','alpha');
  315. $companypaymentmode->exp_date_month = GETPOST('exp_date_month','int');
  316. $companypaymentmode->exp_date_year = GETPOST('exp_date_year','int');
  317. $companypaymentmode->cvn = GETPOST('cvn','alpha');
  318. $companypaymentmode->datec = dol_now();
  319. $companypaymentmode->default_rib = 0;
  320. $companypaymentmode->type = 'card';
  321. $companypaymentmode->country_code = $object->country_code;
  322. $companypaymentmode->status = $servicestatus;
  323. $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref','alpha');
  324. $db->begin();
  325. if (! $error)
  326. {
  327. $result = $companypaymentmode->create($user);
  328. if ($result < 0)
  329. {
  330. $error++;
  331. setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
  332. $action='createcard'; // Force chargement page création
  333. }
  334. }
  335. if (! $error)
  336. {
  337. $db->commit();
  338. $url=$_SERVER["PHP_SELF"].'?socid='.$object->id;
  339. header('Location: '.$url);
  340. exit;
  341. }
  342. else
  343. {
  344. $db->rollback();
  345. }
  346. }
  347. }
  348. if ($action == 'setasbankdefault' && GETPOST('ribid','int') > 0)
  349. {
  350. $companybankaccount = new CompanyBankAccount($db);
  351. $res = $companybankaccount->setAsDefault(GETPOST('ribid','int'));
  352. if ($res)
  353. {
  354. $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
  355. header('Location: '.$url);
  356. exit;
  357. }
  358. else
  359. {
  360. setEventMessages($db->lasterror, null, 'errors');
  361. }
  362. }
  363. if ($action == 'confirm_deletecard' && GETPOST('confirm','alpha') == 'yes')
  364. {
  365. $companypaymentmode = new CompanyPaymentMode($db);
  366. if ($companypaymentmode->fetch($ribid?$ribid:$id))
  367. {
  368. $result = $companypaymentmode->delete($user);
  369. if ($result > 0)
  370. {
  371. $url = $_SERVER['PHP_SELF']."?socid=".$object->id;
  372. header('Location: '.$url);
  373. exit;
  374. }
  375. else
  376. {
  377. setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
  378. }
  379. }
  380. else
  381. {
  382. setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
  383. }
  384. }
  385. if ($action == 'confirm_delete' && GETPOST('confirm','alpha') == 'yes')
  386. {
  387. $companybankaccount = new CompanyBankAccount($db);
  388. if ($companybankaccount->fetch($ribid?$ribid:$id))
  389. {
  390. $result = $companybankaccount->delete($user);
  391. if ($result > 0)
  392. {
  393. $url = $_SERVER['PHP_SELF']."?socid=".$object->id;
  394. header('Location: '.$url);
  395. exit;
  396. }
  397. else
  398. {
  399. setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
  400. }
  401. }
  402. else
  403. {
  404. setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
  405. }
  406. }
  407. $savid=$id;
  408. // Actions to build doc
  409. if ($action == 'builddocrib')
  410. {
  411. $action = 'builddoc';
  412. $moreparams = array(
  413. 'use_companybankid'=>GETPOST('companybankid'),
  414. 'force_dir_output'=>$conf->societe->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->id)
  415. );
  416. $_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid','int'), 'alpha');
  417. $_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid','int'), 'alpha');
  418. }
  419. $id = $socid;
  420. $upload_dir = $conf->societe->multidir_output[$object->entity];
  421. $permissioncreate=$user->rights->societe->creer;
  422. include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
  423. $id = $savid;
  424. // Action for stripe
  425. if (! empty($conf->stripe->enabled) && class_exists('Stripe'))
  426. {
  427. if ($action == 'synccustomertostripe')
  428. {
  429. if ($object->client == 0)
  430. {
  431. $error++;
  432. setEventMessages('ThisThirdpartyIsNotACustomer', null, 'errors');
  433. }
  434. else
  435. {
  436. // Creation of Stripe customer + update of societe_account
  437. $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1);
  438. if (! $cu)
  439. {
  440. $error++;
  441. setEventMessages($stripe->error, $stripe->errors, 'errors');
  442. }
  443. else
  444. {
  445. $stripecu = $cu->id;
  446. }
  447. }
  448. }
  449. if ($action == 'synccardtostripe')
  450. {
  451. $companypaymentmode = new CompanyPaymentMode($db);
  452. $companypaymentmode->fetch($id);
  453. if ($companypaymentmode->type != 'card')
  454. {
  455. $error++;
  456. setEventMessages('ThisPaymentModeIsNotACard', null, 'errors');
  457. }
  458. else
  459. {
  460. // Get the Stripe customer
  461. $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
  462. if (! $cu)
  463. {
  464. $error++;
  465. setEventMessages($stripe->error, $stripe->errors, 'errors');
  466. }
  467. if (! $error)
  468. {
  469. // Creation of Stripe card + update of societe_account
  470. $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
  471. if (! $card)
  472. {
  473. $error++;
  474. setEventMessages($stripe->error, $stripe->errors, 'errors');
  475. }
  476. else
  477. {
  478. $stripecard = $card->id;
  479. }
  480. }
  481. }
  482. }
  483. if ($action == 'setkey_account')
  484. {
  485. $error = 0;
  486. $newcu = GETPOST('key_account', 'alpha');
  487. $db->begin();
  488. if (empty($newcu)) {
  489. $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity;
  490. } else {
  491. $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account";
  492. $sql.= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'";
  493. $sql.= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
  494. }
  495. $resql = $db->query($sql);
  496. $num = $db->num_rows($resql);
  497. if (empty($num) && !empty($newcu))
  498. {
  499. $societeaccount = new SocieteAccount($db);
  500. $societeaccount->fk_soc = $object->id;
  501. $societeaccount->login = '';
  502. $societeaccount->pass_encoding = '';
  503. $societeaccount->site = 'stripe';
  504. $societeaccount->status = $servicestatus;
  505. $societeaccount->key_account = $newcu;
  506. $result = $societeaccount->create($user);
  507. if ($result < 0)
  508. {
  509. $error++;
  510. }
  511. }
  512. if (! $error)
  513. {
  514. $stripecu = $newcu;
  515. $db->commit();
  516. }
  517. else
  518. {
  519. $db->rollback();
  520. }
  521. }
  522. if ($action == 'setlocalassourcedefault')
  523. {
  524. try {
  525. $companypaymentmode->setAsDefault($id);
  526. $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
  527. header('Location: '.$url);
  528. exit;
  529. }
  530. catch(Exception $e)
  531. {
  532. $error++;
  533. setEventMessages($e->getMessage(), null, 'errors');
  534. }
  535. }
  536. elseif ($action == 'setassourcedefault')
  537. {
  538. try {
  539. $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus);
  540. $cu->default_source = (string) $source;
  541. $result = $cu->save();
  542. $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
  543. header('Location: '.$url);
  544. exit;
  545. }
  546. catch(Exception $e)
  547. {
  548. $error++;
  549. setEventMessages($e->getMessage(), null, 'errors');
  550. }
  551. }
  552. elseif ($action == 'deletecard' && $source)
  553. {
  554. try {
  555. $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus);
  556. $card=$cu->sources->retrieve("$source");
  557. if ($card)
  558. {
  559. // $card->detach(); Does not work with card_, only with src_
  560. if (method_exists($card, 'detach')) $card->detach();
  561. else $card->delete();
  562. }
  563. $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
  564. header('Location: '.$url);
  565. exit;
  566. }
  567. catch(Exception $e)
  568. {
  569. $error++;
  570. setEventMessages($e->getMessage(), null, 'errors');
  571. }
  572. }
  573. }
  574. }
  575. /*
  576. * View
  577. */
  578. $form = new Form($db);
  579. $formother = new FormOther($db);
  580. $formfile = new FormFile($db);
  581. llxHeader();
  582. $head=societe_prepare_head($object);
  583. // Show sandbox warning
  584. /*if (! empty($conf->paypal->enabled) && (! empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha'))) // We can force sand box with param 'forcesandbox'
  585. {
  586. dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Paypal'),'','warning');
  587. }*/
  588. if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox','alpha')))
  589. {
  590. dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning');
  591. }
  592. // Load Bank account
  593. if (! $id)
  594. {
  595. $companybankaccount->fetch(0, $object->id);
  596. $companypaymentmode->fetch(0, null, $object->id, 'card');
  597. }
  598. else
  599. {
  600. $companybankaccount->fetch($id);
  601. $companypaymentmode->fetch($id);
  602. }
  603. if (empty($companybankaccount->socid)) $companybankaccount->socid=$object->id;
  604. if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->societe->creer)
  605. {
  606. print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">';
  607. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  608. $actionforadd='update';
  609. if ($action == 'editcard') $actionforadd='updatecard';
  610. print '<input type="hidden" name="action" value="'.$actionforadd.'">';
  611. print '<input type="hidden" name="id" value="'.GETPOST("id","int").'">';
  612. }
  613. if ($socid && ($action == 'create' || $action == 'createcard') && $user->rights->societe->creer)
  614. {
  615. print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">';
  616. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  617. $actionforadd='add';
  618. if ($action == 'createcard') $actionforadd='addcard';
  619. print '<input type="hidden" name="action" value="'.$actionforadd.'">';
  620. }
  621. // View
  622. if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' && $action != 'createcard')
  623. {
  624. dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company');
  625. // Confirm delete ban
  626. if ($action == 'delete')
  627. {
  628. print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $companybankaccount->getRibLabel()), "confirm_delete", '', 0, 1);
  629. }
  630. // Confirm delete card
  631. if ($action == 'deletecard')
  632. {
  633. print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteACard"), $langs->trans("ConfirmDeleteCard", $companybankaccount->getRibLabel()), "confirm_deletecard", '', 0, 1);
  634. }
  635. $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  636. dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
  637. if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
  638. {
  639. print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
  640. }
  641. //if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events');
  642. print '<div class="fichecenter">';
  643. print '<div class="underbanner clearboth"></div>';
  644. print '<table class="border tableforfield" width="100%">';
  645. if ($object->client)
  646. {
  647. print '<tr><td class="titlefield">';
  648. print $langs->trans('CustomerCode').'</td><td colspan="2">';
  649. print $object->code_client;
  650. if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
  651. print '</td></tr>';
  652. $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid;
  653. $resql=$db->query($sql);
  654. if (!$resql) dol_print_error($db);
  655. $obj = $db->fetch_object($resql);
  656. $nbFactsClient = $obj->nb;
  657. $thirdTypeArray['customer']=$langs->trans("customer");
  658. if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals');
  659. if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders');
  660. if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices');
  661. if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts');
  662. }
  663. if (! empty($conf->stripe->enabled))
  664. {
  665. $permissiontowrite = $user->rights->societe->creer;
  666. // Stripe customer key 'cu_....' stored into llx_societe_account
  667. print '<tr><td class="titlefield">';
  668. //print $langs->trans('StripeCustomerId');
  669. print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', 0, 2, 'socid');
  670. print '</td><td>';
  671. //print $stripecu;
  672. print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid');
  673. if ($stripecu && $action != 'editkey_account')
  674. {
  675. if (! empty($conf->stripe->enabled) && !empty($stripeacc)) $connect=$stripeacc.'/';
  676. $url='https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu;
  677. if ($servicestatus)
  678. {
  679. $url='https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu;
  680. }
  681. print ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'object_globe').'</a>';
  682. }
  683. print '</td><td align="right">';
  684. if (empty($stripecu))
  685. {
  686. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  687. print '<input type="hidden" name="action" value="synccustomertostripe">';
  688. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  689. print '<input type="hidden" name="socid" value="'.$object->id.'">';
  690. print '<input type="hidden" name="companybankid" value="'.$rib->id.'">';
  691. print '<input type="submit" class="button" name="syncstripecustomer" value="'.$langs->trans("CreateCustomerOnStripe").'">';
  692. print '</form>';
  693. }
  694. print '</td></tr>';
  695. }
  696. print '</table>';
  697. print '</div>';
  698. dol_fiche_end();
  699. print '<br>';
  700. // List of Stripe payment modes
  701. if (! (empty($conf->stripe->enabled)))
  702. {
  703. $morehtmlright='';
  704. if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
  705. {
  706. $morehtmlright='<a class="butActionNew" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=createcard">'.$langs->trans("Add").' <span class="fa fa-plus-circle valignmiddle"></span></a>';
  707. }
  708. print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc?' (Stripe connection with StripeConnect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, '');
  709. $listofsources = array();
  710. if (is_object($stripe))
  711. {
  712. try {
  713. $customerstripe=$stripe->customerStripe($object, $stripeacc, $servicestatus);
  714. if ($customerstripe->id) {
  715. $listofsources=$customerstripe->sources->data;
  716. }
  717. }
  718. catch(Exception $e)
  719. {
  720. dol_syslog("Error when searching/loading Stripe customer for thirdparty id =".$object->id);
  721. }
  722. }
  723. print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  724. print '<table class="liste" width="100%">'."\n";
  725. print '<tr class="liste_titre">';
  726. if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
  727. {
  728. print '<td>'.$langs->trans('LocalID').'</td>';
  729. }
  730. print '<td>'.$langs->trans('StripeID').'</td>';
  731. print '<td>'.$langs->trans('Type').'</td>';
  732. print '<td>'.$langs->trans('Informations').'</td>';
  733. print '<td></td>';
  734. print '<td align="center">'.$langs->trans('Default').'</td>';
  735. print '<td>'.$langs->trans('Note').'</td>';
  736. print '<td>'.$langs->trans('DateModification').'</td>';
  737. print "<td></td>";
  738. print "</tr>\n";
  739. $nbremote = 0;
  740. $nblocal = 0;
  741. $arrayofstripecard = array();
  742. // Show local sources
  743. if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
  744. {
  745. //$societeaccount = new SocieteAccount($db);
  746. $companypaymentmodetemp = new CompanyPaymentMode($db);
  747. $sql='SELECT rowid FROM '.MAIN_DB_PREFIX."societe_rib";
  748. $sql.=" WHERE type in ('card', 'paypal')";
  749. $sql.=" AND fk_soc = ".$object->id;
  750. $sql.=" AND status = ".$servicestatus;
  751. $resql = $db->query($sql);
  752. if ($resql)
  753. {
  754. $num_rows = $db->num_rows($resql);
  755. if ($num_rows)
  756. {
  757. $i=0;
  758. while ($i < $num_rows)
  759. {
  760. $nblocal++;
  761. $obj = $db->fetch_object($resql);
  762. if ($obj)
  763. {
  764. $companypaymentmodetemp->fetch($obj->rowid);
  765. $arrayofstripecard[$companypaymentmodetemp->stripe_card_ref]=$companypaymentmodetemp->stripe_card_ref;
  766. print '<tr>';
  767. print '<td>';
  768. print $companypaymentmodetemp->id;
  769. print '</td>';
  770. print '<td>';
  771. print $companypaymentmodetemp->stripe_card_ref;
  772. /*if ($companypaymentmodetemp->stripe_card_ref)
  773. {
  774. $url='https://dashboard.stripe.com/test/card/'.$companypaymentmodetemp->stripe_card_ref;
  775. if ($servicestatus)
  776. {
  777. $url='https://dashboard.stripe.com/card/'.$companypaymentmodetemp->stripe_card_ref;
  778. }
  779. print ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'object_globe').'</a>';
  780. }*/
  781. print '</td>';
  782. print '<td>';
  783. print img_credit_card($companypaymentmodetemp->type);
  784. print '</td>';
  785. print '<td>';
  786. if ($companypaymentmodetemp->last_four) print '....'.$companypaymentmodetemp->last_four;
  787. if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) print ' - '.sprintf("%02d", $companypaymentmodetemp->exp_date_month).'/'.$companypaymentmodetemp->exp_date_year.'';
  788. print '</td><td>';
  789. if ($companypaymentmodetemp->country_code)
  790. {
  791. $img=picto_from_langcode($companypaymentmodetemp->country_code);
  792. print $img?$img.' ':'';
  793. print getCountry($companypaymentmodetemp->country_code,1);
  794. }
  795. else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
  796. print '</td>';
  797. // Default
  798. print '<td align="center">';
  799. if (empty($companypaymentmodetemp->default_rib))
  800. {
  801. print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=setlocalassourcedefault">';
  802. print img_picto($langs->trans("Default"),'off');
  803. print '</a>';
  804. } else {
  805. print img_picto($langs->trans("Default"),'on');
  806. }
  807. print '</td>';
  808. print '<td>';
  809. if (empty($companypaymentmodetemp->stripe_card_ref)) print $langs->trans("Local");
  810. else print $langs->trans("LocalAndRemote");
  811. print '</td>';
  812. print '<td>';
  813. print dol_print_date($companypaymentmodetemp->tms, 'dayhour');
  814. print '</td>';
  815. print '<td align="right" class="nowraponall">';
  816. if ($user->rights->societe->creer)
  817. {
  818. if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref))
  819. {
  820. print '<a href="'.$_SERVER['PHP_SELF'].'?action=synccardtostripe&socid='.$object->id.'&id='.$companypaymentmodetemp->id.'" class="button">'.$langs->trans("CreateCardOnStripe").'</a>';
  821. }
  822. print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=editcard">';
  823. print img_picto($langs->trans("Modify"),'edit');
  824. print '</a>';
  825. print '&nbsp;';
  826. print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=deletecard">'; // source='.$companypaymentmodetemp->stripe_card_ref.'&
  827. print img_picto($langs->trans("Delete"), 'delete');
  828. print '</a>';
  829. }
  830. print '</td>';
  831. print '</tr>';
  832. }
  833. $i++;
  834. }
  835. }
  836. }
  837. else dol_print_error($db);
  838. }
  839. // Show remote sources (not already shown as local source)
  840. if (is_array($listofsources) && count($listofsources))
  841. {
  842. foreach ($listofsources as $src)
  843. {
  844. if (! empty($arrayofstripecard[$src->id])) continue; // Already in previous list
  845. $nbremote++;
  846. print '<tr class="oddeven">';
  847. // Local ID
  848. if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
  849. {
  850. print '<td>';
  851. print '</td>';
  852. }
  853. // Src ID
  854. print '<td>';
  855. if (!empty($stripeacc)) $connect=$stripeacc.'/';
  856. $url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id;
  857. if ($servicestatus)
  858. {
  859. $url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id;
  860. }
  861. print $src->id." <a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'object_globe')."</a>";
  862. print '</td>';
  863. // Img of credit card
  864. print '<td>';
  865. if ($src->object=='card')
  866. {
  867. print img_credit_card($src->brand);
  868. }
  869. elseif ($src->object=='source' && $src->type=='card')
  870. {
  871. print img_credit_card($src->card->brand);
  872. }
  873. elseif ($src->object=='source' && $src->type=='sepa_debit')
  874. {
  875. print '<span class="fa fa-university fa-2x fa-fw"></span>';
  876. }
  877. print'</td>';
  878. print '<td valign="middle">';
  879. if ($src->object=='card')
  880. {
  881. print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.'';
  882. print '</td><td>';
  883. if ($src->country)
  884. {
  885. $img=picto_from_langcode($src->country);
  886. print $img?$img.' ':'';
  887. print getCountry($src->country,1);
  888. }
  889. else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
  890. }
  891. elseif ($src->object=='source' && $src->type=='card')
  892. {
  893. print $src->owner->name.'<br>....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.'';
  894. print '</td><td>';
  895. if ($src->card->country)
  896. {
  897. $img=picto_from_langcode($src->card->country);
  898. print $img?$img.' ':'';
  899. print getCountry($src->card->country,1);
  900. }
  901. else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
  902. }
  903. elseif ($src->object=='source' && $src->type=='sepa_debit')
  904. {
  905. print 'info sepa';
  906. print '</td><td>';
  907. if ($src->sepa_debit->country)
  908. {
  909. $img=picto_from_langcode($src->sepa_debit->country);
  910. print $img?$img.' ':'';
  911. print getCountry($src->sepa_debit->country,1);
  912. }
  913. else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
  914. }
  915. print '</td>';
  916. // Default
  917. print '<td align="center" width="50">';
  918. if (($customerstripe->default_source != $src->id))
  919. {
  920. print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=setassourcedefault">';
  921. print img_picto($langs->trans("Default"),'off');
  922. print '</a>';
  923. } else {
  924. print img_picto($langs->trans("Default"),'on');
  925. }
  926. print '</td>';
  927. print '<td>';
  928. print $langs->trans("Remote");
  929. //if ($src->cvc_check == 'fail') print ' - CVC check fail';
  930. print '</td>';
  931. print '<td>';
  932. //var_dump($src);
  933. print '';
  934. print '</td>';
  935. print '<td align="right" class="nowraponall">';
  936. if ($user->rights->societe->creer)
  937. {
  938. print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=deletecard">';
  939. print img_picto($langs->trans("Delete"), 'delete');
  940. print '</a>';
  941. }
  942. print '</td>';
  943. print '</tr>';
  944. }
  945. }
  946. if ($nbremote == 0 && $nblocal == 0)
  947. {
  948. print '<tr><td class="opacitymedium" colspan="7">'.$langs->trans("None").'</td></tr>';
  949. }
  950. print "</table>";
  951. print "</div>";
  952. }
  953. // List of bank accounts
  954. print '<br>';
  955. $morehtmlright='<a class="butActionNew" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=create">'.$langs->trans("Add").' <span class="fa fa-plus-circle valignmiddle"></span></a>';
  956. print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, '');
  957. $rib_list = $object->get_all_rib();
  958. if (is_array($rib_list))
  959. {
  960. print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  961. print '<table class="liste" width="100%">';
  962. print '<tr class="liste_titre">';
  963. print_liste_field_titre("LabelRIB");
  964. print_liste_field_titre("Bank");
  965. print_liste_field_titre("RIB");
  966. print_liste_field_titre("IBAN");
  967. print_liste_field_titre("BIC");
  968. if (! empty($conf->prelevement->enabled))
  969. {
  970. print print_liste_field_titre("RUM");
  971. print print_liste_field_titre("WithdrawMode");
  972. }
  973. print_liste_field_titre("DefaultRIB", '', '', '', '', 'align="center"');
  974. print_liste_field_titre('', '', '', '', '', 'align="center"');
  975. print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
  976. print "</tr>\n";
  977. foreach ($rib_list as $rib)
  978. {
  979. print '<tr class="oddeven">';
  980. // Label
  981. print '<td>'.$rib->label.'</td>';
  982. // Bank name
  983. print '<td>'.$rib->bank.'</td>';
  984. // Account number
  985. print '<td>';
  986. $string='';
  987. foreach ($rib->getFieldsToShow() as $val) {
  988. if ($val == 'BankCode') {
  989. $string .= $rib->code_banque.' ';
  990. } elseif ($val == 'BankAccountNumber') {
  991. $string .= $rib->number.' ';
  992. } elseif ($val == 'DeskCode') {
  993. $string .= $rib->code_guichet.' ';
  994. } elseif ($val == 'BankAccountNumberKey') {
  995. $string .= $rib->cle_rib.' ';
  996. /* Already output after
  997. }elseif ($val == 'BIC') {
  998. $string .= $rib->bic.' ';
  999. }elseif ($val == 'IBAN') {
  1000. $string .= $rib->iban.' ';*/
  1001. }
  1002. }
  1003. if (! empty($rib->label) && $rib->number) {
  1004. if (! checkBanForAccount($rib)) {
  1005. $string.= ' '.img_picto($langs->trans("ValueIsNotValid"),'warning');
  1006. } else {
  1007. $string.= ' '.img_picto($langs->trans("ValueIsValid"),'info');
  1008. }
  1009. }
  1010. print $string;
  1011. print '</td>';
  1012. // IBAN
  1013. print '<td>'.$rib->iban;
  1014. if (! empty($rib->iban)) {
  1015. if (! checkIbanForAccount($rib)) {
  1016. print ' '.img_picto($langs->trans("IbanNotValid"),'warning');
  1017. } else {
  1018. print ' '.img_picto($langs->trans("IbanValid"),'info');
  1019. }
  1020. }
  1021. print '</td>';
  1022. // BIC
  1023. print '<td>'.$rib->bic;
  1024. if (! empty($rib->bic)) {
  1025. if (! checkSwiftForAccount($rib)) {
  1026. print ' '.img_picto($langs->trans("SwiftNotValid"),'warning');
  1027. } else {
  1028. print ' '.img_picto($langs->trans("SwiftValid"),'info');
  1029. }
  1030. }
  1031. print '</td>';
  1032. if (! empty($conf->prelevement->enabled))
  1033. {
  1034. // RUM
  1035. //print '<td>'.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).'</td>';
  1036. print '<td>'.$rib->rum.'</td>';
  1037. // FRSTRECUR
  1038. print '<td>'.$rib->frstrecur.'</td>';
  1039. }
  1040. // Default
  1041. print '<td align="center" width="70">';
  1042. if (!$rib->default_rib) {
  1043. print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&ribid='.$rib->id.'&action=setasbankdefault">';
  1044. print img_picto($langs->trans("Disabled"),'off');
  1045. print '</a>';
  1046. } else {
  1047. print img_picto($langs->trans("Enabled"),'on');
  1048. }
  1049. print '</td>';
  1050. // Generate doc
  1051. print '<td align="center">';
  1052. $buttonlabel = $langs->trans("BuildDoc");
  1053. $forname='builddocrib'.$rib->id;
  1054. include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php';
  1055. $modellist=ModeleBankAccountDoc::liste_modeles($db);
  1056. $out = '';
  1057. if (is_array($modellist) && count($modellist))
  1058. {
  1059. $out.= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc').'" name="'.$forname.'" id="'.$forname.'_form" method="post">';
  1060. $out.= '<input type="hidden" name="action" value="builddocrib">';
  1061. $out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  1062. $out.= '<input type="hidden" name="socid" value="'.$object->id.'">';
  1063. $out.= '<input type="hidden" name="companybankid" value="'.$rib->id.'">';
  1064. if (is_array($modellist) && count($modellist) == 1) // If there is only one element
  1065. {
  1066. $arraykeys=array_keys($modellist);
  1067. $modelselected=$arraykeys[0];
  1068. }
  1069. if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF;
  1070. $out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100');
  1071. $out.= ajax_combobox('modelrib'.$rib->id);
  1072. // Language code (if multilang)
  1073. if ($conf->global->MAIN_MULTILANGS)
  1074. {
  1075. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
  1076. $formadmin=new FormAdmin($db);
  1077. $defaultlang=$codelang?$codelang:$langs->getDefaultLang();
  1078. $morecss='maxwidth150';
  1079. if ($conf->browser->layout == 'phone') $morecss='maxwidth100';
  1080. $out.= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss);
  1081. }
  1082. // Button
  1083. $genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"';
  1084. $genbutton.= ' type="submit" value="'.$buttonlabel.'"';
  1085. if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) $genbutton.= ' disabled';
  1086. $genbutton.= '>';
  1087. if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid')
  1088. {
  1089. $langs->load("errors");
  1090. $genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated"));
  1091. }
  1092. if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton='';
  1093. if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton='';
  1094. $out.= $genbutton;
  1095. $out.= '</form>';
  1096. }
  1097. print $out;
  1098. print '</td>';
  1099. // Edit/Delete
  1100. print '<td align="right" class="nowraponall">';
  1101. if ($user->rights->societe->creer)
  1102. {
  1103. print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=edit">';
  1104. print img_picto($langs->trans("Modify"),'edit');
  1105. print '</a>';
  1106. print '&nbsp;';
  1107. print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=delete">';
  1108. print img_picto($langs->trans("Delete"),'delete');
  1109. print '</a>';
  1110. }
  1111. print '</td>';
  1112. print '</tr>';
  1113. }
  1114. if (count($rib_list) == 0)
  1115. {
  1116. $colspan=8;
  1117. if (! empty($conf->prelevement->enabled)) $colspan+=2;
  1118. print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>';
  1119. }
  1120. print '</table>';
  1121. print '</div>';
  1122. } else {
  1123. dol_print_error($db);
  1124. }
  1125. if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC))
  1126. {
  1127. print '<br>';
  1128. print '<div class="fichecenter"><div class="fichehalfleft">';
  1129. print '<a name="builddoc"></a>'; // ancre
  1130. /*
  1131. * Documents generes
  1132. */
  1133. $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id;
  1134. $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id;
  1135. $genallowed=$user->rights->societe->lire;
  1136. $delallowed=$user->rights->societe->creer;
  1137. print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang);
  1138. // Show direct download link
  1139. if (! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD))
  1140. {
  1141. $companybankaccounttemp = new CompanyBankAccount($db);
  1142. $companypaymentmodetemp = new CompanyPaymentMode($db);
  1143. $result = $companypaymentmodetemp->fetch(0, null, $object->id, 'ban');
  1144. include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
  1145. $ecmfile = new EcmFiles($db);
  1146. $result = $ecmfile->fetch(0, '', '', '', '', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
  1147. if ($result > 0)
  1148. {
  1149. $companybankaccounttemp->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename;
  1150. print '<br><!-- Link to download main doc -->'."\n";
  1151. print showDirectDownloadLink($companybankaccounttemp).'<br>';
  1152. }
  1153. }
  1154. print '</div><div class="fichehalfright"><div class="ficheaddleft">';
  1155. print '</div></div></div>';
  1156. print '<br>';
  1157. }
  1158. /*
  1159. include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php';
  1160. $modellist=ModeleBankAccountDoc::liste_modeles($db);
  1161. //print '<td>';
  1162. if (is_array($modellist) && count($modellist) == 1) // If there is only one element
  1163. {
  1164. $arraykeys=array_keys($modellist);
  1165. $modelselected=$arraykeys[0];
  1166. }
  1167. $out.= $form->selectarray('model', $modellist, $modelselected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100');
  1168. $out.= ajax_combobox('model');
  1169. //print $out;
  1170. $buttonlabel=$langs->trans("Generate");
  1171. $genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"';
  1172. $genbutton.= ' type="submit" value="'.$buttonlabel.'"';
  1173. $genbutton.= '>';
  1174. print $genbutton;
  1175. //print '</td>'; // TODO Add link to generate doc
  1176. */
  1177. }
  1178. // Edit BAN
  1179. if ($socid && $action == 'edit' && $user->rights->societe->creer)
  1180. {
  1181. dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
  1182. $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
  1183. dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
  1184. print '<div class="fichecenter">';
  1185. print '<div class="underbanner clearboth"></div>';
  1186. print '<table class="border centpercent">';
  1187. print '<tr><td class="titlefield fieldrequired">'.$langs->trans("LabelRIB").'</td>';
  1188. print '<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.'"></td></tr>';
  1189. print '<tr><td class="fieldrequired">'.$langs->trans("BankName").'</td>';
  1190. print '<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.'"></td></tr>';
  1191. // Show fields of bank account
  1192. foreach ($companybankaccount->getFieldsToShow(1) as $val) {
  1193. $require=false;
  1194. if ($val == 'BankCode') {
  1195. $name = 'code_banque';
  1196. $size = 8;
  1197. $content = $companybankaccount->code_banque;
  1198. } elseif ($val == 'DeskCode') {
  1199. $name = 'code_guichet';
  1200. $size = 8;
  1201. $content = $companybankaccount->code_guichet;
  1202. } elseif ($val == 'BankAccountNumber') {
  1203. $name = 'number';
  1204. $size = 18;
  1205. $content = $companybankaccount->number;
  1206. } elseif ($val == 'BankAccountNumberKey') {
  1207. $name = 'cle_rib';
  1208. $size = 3;
  1209. $content = $companybankaccount->cle_rib;
  1210. } elseif ($val == 'IBAN') {
  1211. $name = 'iban';
  1212. $size = 30;
  1213. $content = $companybankaccount->iban;
  1214. if ($companybankaccount->needIBAN()) $require=true;
  1215. } elseif ($val == 'BIC') {
  1216. $name = 'bic';
  1217. $size = 12;
  1218. $content = $companybankaccount->bic;
  1219. if ($companybankaccount->needIBAN()) $require=true;
  1220. }
  1221. print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>';
  1222. print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>';
  1223. print '</tr>';
  1224. }
  1225. print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
  1226. print '<textarea name="domiciliation" rows="4" cols="40" maxlength="255">';
  1227. print $companybankaccount->domiciliation;
  1228. print "</textarea></td></tr>";
  1229. print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
  1230. print '<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->proprio.'"></td></tr>';
  1231. print "</td></tr>\n";
  1232. print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
  1233. print '<textarea name="owner_address" rows="'.ROWS_4.'" cols="40" maxlength="255">';
  1234. print $companybankaccount->owner_address;
  1235. print "</textarea></td></tr>";
  1236. print '</table>';
  1237. if ($conf->prelevement->enabled)
  1238. {
  1239. print '<br>';
  1240. print '<table class="border" width="100%">';
  1241. if (empty($companybankaccount->rum)) $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
  1242. // RUM
  1243. print '<tr><td class="titlefield">'.$langs->trans("RUM").'</td>';
  1244. print '<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).'"></td></tr>';
  1245. print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
  1246. $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
  1247. print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur','alpha')?GETPOST('frstrecur','alpha'):$companybankaccount->frstrecur), 0);
  1248. print '</td></tr>';
  1249. print '</table>';
  1250. }
  1251. print '</div>';
  1252. dol_fiche_end();
  1253. print '<div align="center">';
  1254. print '<input class="button" value="'.$langs->trans("Modify").'" type="submit">';
  1255. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  1256. print '<input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
  1257. print '</div>';
  1258. }
  1259. // Edit Card
  1260. if ($socid && $action == 'editcard' && $user->rights->societe->creer)
  1261. {
  1262. dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
  1263. $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
  1264. dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
  1265. print '<div class="fichecenter">';
  1266. print '<div class="underbanner clearboth"></div>';
  1267. print '<table class="border centpercent">';
  1268. print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td>';
  1269. print '<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.'"></td></tr>';
  1270. print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>';
  1271. print '<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->proprio.'"></td></tr>';
  1272. print '<tr><td class="fieldrequired">'.$langs->trans("CardNumber").'</td>';
  1273. print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.'"></td></tr>';
  1274. print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>';
  1275. print '<td>';
  1276. print $formother->select_month($companypaymentmode->exp_date_month, 'exp_date_month', 1);
  1277. print $formother->select_year($companypaymentmode->exp_date_year, 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly');
  1278. print '</td></tr>';
  1279. print '<tr><td class="fieldrequired">'.$langs->trans("CVN").'</td>';
  1280. print '<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.'"></td></tr>';
  1281. print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>";
  1282. print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.'"></td></tr>';
  1283. print '</table>';
  1284. print '</div>';
  1285. dol_fiche_end();
  1286. print '<div align="center">';
  1287. print '<input class="button" value="'.$langs->trans("Modify").'" type="submit">';
  1288. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  1289. print '<input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
  1290. print '</div>';
  1291. }
  1292. // Create BAN
  1293. if ($socid && $action == 'create' && $user->rights->societe->creer)
  1294. {
  1295. dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
  1296. $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
  1297. dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
  1298. print '<div class="nofichecenter">';
  1299. print '<div class="underbanner clearboth"></div>';
  1300. print '<table class="border centpercent">';
  1301. print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("LabelRIB").'</td>';
  1302. print '<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST('label').'"></td></tr>';
  1303. print '<tr><td class="fieldrequired">'.$langs->trans("Bank").'</td>';
  1304. print '<td><input class="minwidth200" type="text" name="bank" value="'.GETPOST('bank').'"></td></tr>';
  1305. // Show fields of bank account
  1306. foreach ($companybankaccount->getFieldsToShow(1) as $val) {
  1307. $require=false;
  1308. if ($val == 'BankCode') {
  1309. $name = 'code_banque';
  1310. $size = 8;
  1311. } elseif ($val == 'DeskCode') {
  1312. $name = 'code_guichet';
  1313. $size = 8;
  1314. } elseif ($val == 'BankAccountNumber') {
  1315. $name = 'number';
  1316. $size = 18;
  1317. } elseif ($val == 'BankAccountNumberKey') {
  1318. $name = 'cle_rib';
  1319. $size = 3;
  1320. } elseif ($val == 'IBAN') {
  1321. $name = 'iban';
  1322. $size = 30;
  1323. if ($companybankaccount->needIBAN()) $require=true;
  1324. } elseif ($val == 'BIC') {
  1325. $name = 'bic';
  1326. $size = 12;
  1327. if ($companybankaccount->needIBAN()) $require=true;
  1328. }
  1329. print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>';
  1330. print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.GETPOST($name).'"></td>';
  1331. print '</tr>';
  1332. }
  1333. print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
  1334. print '<textarea name="domiciliation" rows="'.ROWS_4.'" class="quatrevingtpercent" maxlength="255">';
  1335. print GETPOST('domiciliation');
  1336. print "</textarea></td></tr>";
  1337. print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
  1338. print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio').'"></td></tr>';
  1339. print "</td></tr>\n";
  1340. print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
  1341. print '<textarea name="owner_address" rows="'.ROWS_4.'" class="quatrevingtpercent" maxlength="255">';
  1342. print GETPOST('owner_address');
  1343. print "</textarea></td></tr>";
  1344. print '</table>';
  1345. if ($conf->prelevement->enabled)
  1346. {
  1347. print '<br>';
  1348. print '<table class="border" width="100%">';
  1349. // RUM
  1350. print '<tr><td class="titlefieldcreate">'.$langs->trans("RUM").'</td>';
  1351. print '<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST('rum','alpha').'"> <div class="opacitymedium">'.$langs->trans("RUMWillBeGenerated").'</div></td></tr>';
  1352. print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
  1353. $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
  1354. print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST'), 0);
  1355. print '</td></tr>';
  1356. print '</table>';
  1357. }
  1358. print '</div>';
  1359. dol_fiche_end();
  1360. dol_set_focus('#label');
  1361. print '<div class="center">';
  1362. print '<input class="button" value="'.$langs->trans("Add").'" type="submit">';
  1363. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  1364. print '<input name="cancel" class="button" value="'.$langs->trans("Cancel").'" type="submit">';
  1365. print '</div>';
  1366. }
  1367. // Create Card
  1368. if ($socid && $action == 'createcard' && $user->rights->societe->creer)
  1369. {
  1370. dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
  1371. $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
  1372. dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
  1373. print '<div class="nofichecenter">';
  1374. print '<div class="underbanner clearboth"></div>';
  1375. print '<table class="border centpercent">';
  1376. print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td>';
  1377. print '<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST('label','alpha').'"></td></tr>';
  1378. print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>';
  1379. print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio','alpha').'"></td></tr>';
  1380. print '<tr><td class="fieldrequired">'.$langs->trans("CardNumber").'</td>';
  1381. print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST('cardnumber','alpha').'"></td></tr>';
  1382. print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>';
  1383. print '<td>';
  1384. print $formother->select_month(GETPOST('exp_date_month','int'), 'exp_date_month', 1);
  1385. print $formother->select_year(GETPOST('exp_date_year','int'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly');
  1386. print '</td></tr>';
  1387. print '<tr><td class="fieldrequired">'.$langs->trans("CVN").'</td>';
  1388. print '<td><input size="8" type="text" name="cvn" value="'.GETPOST('cvn','alpha').'"></td></tr>';
  1389. print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>";
  1390. print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST('stripe_card_ref','alpha').'"></td></tr>';
  1391. print '</table>';
  1392. print '</div>';
  1393. dol_fiche_end();
  1394. dol_set_focus('#label');
  1395. print '<div class="center">';
  1396. print '<input class="button" value="'.$langs->trans("Add").'" type="submit">';
  1397. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  1398. print '<input name="cancel" class="button" value="'.$langs->trans("Cancel").'" type="submit">';
  1399. print '</div>';
  1400. }
  1401. if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->societe->creer)
  1402. {
  1403. print '</form>';
  1404. }
  1405. if ($socid && ($action == 'create' || $action == 'createcard') && $user->rights->societe->creer)
  1406. {
  1407. print '</form>';
  1408. }
  1409. // End of page
  1410. llxFooter();
  1411. $db->close();