dolibarr  16.0.5
paymentmodes.php
Go to the documentation of this file.
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-2022 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-2021 Thibault FOUCART <support@ptibogxiv.net>
10  * Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <https://www.gnu.org/licenses/>.
24  */
25 
32 require '../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/societe/class/companypaymentmode.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
42 
43 $langs->loadLangs(array("companies", "commercial", "banks", "bills", 'paypal', 'stripe', 'withdrawals'));
44 
45 // Security check
46 $socid = GETPOST("socid", "int");
47 if ($user->socid) {
48  $socid = $user->socid;
49 }
50 $result = restrictedArea($user, 'societe', '', '');
51 
52 $id = GETPOST("id", "int");
53 $source = GETPOST("source", "alpha"); // source can be a source or a paymentmode
54 $ribid = GETPOST("ribid", "int");
55 $action = GETPOST("action", 'alpha', 3);
56 $cancel = GETPOST('cancel', 'alpha');
57 
58 $object = new Societe($db);
59 $object->fetch($socid);
60 
61 $companybankaccount = new CompanyBankAccount($db);
62 $companypaymentmode = new CompanyPaymentMode($db);
63 $prelevement = new BonPrelevement($db);
64 
65 $extrafields = new ExtraFields($db);
66 
67 // fetch optionals attributes and labels
68 $extrafields->fetch_name_optionals_label($object->table_element);
69 
70 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
71 $hookmanager->initHooks(array('thirdpartybancard', 'globalcard'));
72 
73 $permissiontoread = $user->rights->societe->lire;
74 $permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_builddoc.inc.php
75 
76 $permissiontoaddupdatepaymentinformation = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $permissiontoadd) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->societe->thirdparty_paymentinformation_advance->write)));
77 
78 if (!empty($conf->stripe->enabled)) {
79  $service = 'StripeTest';
80  $servicestatus = 0;
81  if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) {
82  $service = 'StripeLive';
83  $servicestatus = 1;
84  }
85 
86  // Force to use the correct API key
87  global $stripearrayofkeysbyenv;
88  $site_account = $stripearrayofkeysbyenv[$servicestatus]['publishable_key'];
89 
90  $stripe = new Stripe($db);
91  $stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account (no remote access to Stripe here)
92  $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus, $site_account); // Get remote Stripe customer 'cus_...' (no remote access to Stripe here)
93 }
94 
95 
96 
97 /*
98  * Actions
99  */
100 
101 if ($cancel) {
102  $action = '';
103 }
104 
105 $parameters = array('id'=>$socid);
106 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
107 if ($reshook < 0) {
108  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
109 }
110 
111 if (empty($reshook)) {
112  if ($cancel) {
113  $action = '';
114  if (!empty($backtopage)) {
115  header("Location: ".$backtopage);
116  exit;
117  }
118  }
119 
120  if ($action == 'update') {
121  // Modification
122  if (!GETPOST('label', 'alpha') || !GETPOST('bank', 'alpha')) {
123  if (!GETPOST('label', 'alpha')) {
124  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
125  }
126  if (!GETPOST('bank', 'alpha')) {
127  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors');
128  }
129  $action = 'edit';
130  $error++;
131  }
132  $companybankaccount->fetch($id);
133  if ($companybankaccount->needIBAN() == 1) {
134  if (!GETPOST('iban')) {
135  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
136  $action = 'edit';
137  $error++;
138  }
139  if (!GETPOST('bic')) {
140  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
141  $action = 'edit';
142  $error++;
143  }
144  }
145 
146  if (!$error) {
147  $companybankaccount->socid = $object->id;
148 
149  $companybankaccount->bank = GETPOST('bank', 'alpha');
150  $companybankaccount->label = GETPOST('label', 'alpha');
151  $companybankaccount->courant = GETPOST('courant', 'alpha');
152  $companybankaccount->clos = GETPOST('clos', 'alpha');
153  $companybankaccount->code_banque = GETPOST('code_banque', 'alpha');
154  $companybankaccount->code_guichet = GETPOST('code_guichet', 'alpha');
155  $companybankaccount->number = GETPOST('number', 'alpha');
156  $companybankaccount->cle_rib = GETPOST('cle_rib', 'alpha');
157  $companybankaccount->bic = GETPOST('bic', 'alpha');
158  $companybankaccount->iban = GETPOST('iban', 'alpha');
159  $companybankaccount->domiciliation = GETPOST('domiciliation', 'alpha');
160  $companybankaccount->proprio = GETPOST('proprio', 'alpha');
161  $companybankaccount->owner_address = GETPOST('owner_address', 'alpha');
162  $companybankaccount->frstrecur = GETPOST('frstrecur', 'alpha');
163  $companybankaccount->rum = GETPOST('rum', 'alpha');
164  $companybankaccount->date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth'), GETPOST('date_rumday'), GETPOST('date_rumyear'));
165  if (empty($companybankaccount->rum)) {
166  $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
167  }
168 
169  $result = $companybankaccount->update($user);
170  if (!$result) {
171  setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
172  } else {
173  // If this account is the default bank account, we disable others
174  if ($companybankaccount->default_rib) {
175  $companybankaccount->setAsDefault($id); // This will make sure there is only one default rib
176  }
177 
178  $url = $_SERVER["PHP_SELF"].'?socid='.$object->id;
179  header('Location: '.$url);
180  exit;
181  }
182  }
183  }
184 
185  if ($action == 'updatecard') {
186  // Modification
187  if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha')) {
188  if (!GETPOST('label', 'alpha')) {
189  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
190  }
191  if (!GETPOST('proprio', 'alpha')) {
192  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors');
193  }
194  //if (!GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors');
195  if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) {
196  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors');
197  }
198  //if (!GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors');
199  $action = 'createcard';
200  $error++;
201  }
202 
203  $companypaymentmode->fetch($id);
204  if (!$error) {
205  $companypaymentmode->fk_soc = $object->id;
206 
207  $companypaymentmode->bank = GETPOST('bank', 'alpha');
208  $companypaymentmode->label = GETPOST('label', 'alpha');
209  $companypaymentmode->number = GETPOST('cardnumber', 'alpha');
210  $companypaymentmode->last_four = substr(GETPOST('cardnumber', 'alpha'), -4);
211  $companypaymentmode->proprio = GETPOST('proprio', 'alpha');
212  $companypaymentmode->exp_date_month = GETPOST('exp_date_month', 'int');
213  $companypaymentmode->exp_date_year = GETPOST('exp_date_year', 'int');
214  $companypaymentmode->cvn = GETPOST('cvn', 'alpha');
215  $companypaymentmode->country_code = $object->country_code;
216 
217  if (GETPOST('stripe_card_ref', 'alpha') && GETPOST('stripe_card_ref', 'alpha') != $companypaymentmode->stripe_card_ref) {
218  // If we set a stripe value that is different than previous one, we also set the stripe account
219  $companypaymentmode->stripe_account = $stripecu.'@'.$site_account;
220  }
221  $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha');
222 
223  $result = $companypaymentmode->update($user);
224  if (!$result) {
225  setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
226  } else {
227  // If this account is the default bank account, we disable others
228  if ($companypaymentmode->default_rib) {
229  $companypaymentmode->setAsDefault($id); // This will make sure there is only one default rib
230  }
231 
232  $url = $_SERVER["PHP_SELF"].'?socid='.$object->id;
233  header('Location: '.$url);
234  exit;
235  }
236  }
237  }
238 
239  if ($action == 'add') {
240  $error = 0;
241 
242  if (!GETPOST('label', 'alpha') || !GETPOST('bank', 'alpha')) {
243  if (!GETPOST('label', 'alpha')) {
244  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
245  }
246  if (!GETPOST('bank', 'alpha')) {
247  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors');
248  }
249  $action = 'create';
250  $error++;
251  }
252 
253  if (!$error) {
254  // Ajout
255  $companybankaccount = new CompanyBankAccount($db);
256 
257  $companybankaccount->socid = $object->id;
258 
259  $companybankaccount->bank = GETPOST('bank', 'alpha');
260  $companybankaccount->label = GETPOST('label', 'alpha');
261  $companybankaccount->courant = GETPOST('courant', 'alpha');
262  $companybankaccount->clos = GETPOST('clos', 'alpha');
263  $companybankaccount->code_banque = GETPOST('code_banque', 'alpha');
264  $companybankaccount->code_guichet = GETPOST('code_guichet', 'alpha');
265  $companybankaccount->number = GETPOST('number', 'alpha');
266  $companybankaccount->cle_rib = GETPOST('cle_rib', 'alpha');
267  $companybankaccount->bic = GETPOST('bic', 'alpha');
268  $companybankaccount->iban = GETPOST('iban', 'alpha');
269  $companybankaccount->domiciliation = GETPOST('domiciliation', 'alpha');
270  $companybankaccount->proprio = GETPOST('proprio', 'alpha');
271  $companybankaccount->owner_address = GETPOST('owner_address', 'alpha');
272  $companybankaccount->frstrecur = GETPOST('frstrecur', 'alpha');
273  $companybankaccount->rum = GETPOST('rum', 'alpha');
274  $companybankaccount->date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth', 'int'), GETPOST('date_rumday', 'int'), GETPOST('date_rumyear', 'int'));
275  $companybankaccount->datec = dol_now();
276  $companybankaccount->status = 1;
277 
278  $db->begin();
279 
280  // This test can be done only once properties were set
281  if ($companybankaccount->needIBAN() == 1) {
282  if (!GETPOST('iban')) {
283  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
284  $action = 'create';
285  $error++;
286  }
287  if (!GETPOST('bic')) {
288  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
289  $action = 'create';
290  $error++;
291  }
292  }
293 
294  if (!$error) {
295  $result = $companybankaccount->create($user);
296  if ($result < 0) {
297  $error++;
298  setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
299  $action = 'create'; // Force chargement page création
300  }
301 
302  if (empty($companybankaccount->rum)) {
303  $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
304  }
305  }
306 
307  if (!$error) {
308  $result = $companybankaccount->update($user); // This will set the UMR number.
309  if ($result < 0) {
310  $error++;
311  setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
312  $action = 'create';
313  }
314  }
315 
316  if (!$error) {
317  $db->commit();
318 
319  $url = $_SERVER["PHP_SELF"].'?socid='.$object->id;
320  header('Location: '.$url);
321  exit;
322  } else {
323  $db->rollback();
324  }
325  }
326  }
327 
328  if ($action == 'addcard') {
329  $error = 0;
330 
331  if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha')) {
332  if (!GETPOST('label', 'alpha')) {
333  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
334  }
335  if (!GETPOST('proprio', 'alpha')) {
336  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors');
337  }
338  //if (!GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors');
339  if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) {
340  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors');
341  }
342  //if (!GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors');
343  $action = 'createcard';
344  $error++;
345  }
346 
347  if (!$error) {
348  // Ajout
349  $companypaymentmode = new CompanyPaymentMode($db);
350 
351  $companypaymentmode->fk_soc = $object->id;
352  $companypaymentmode->bank = GETPOST('bank', 'alpha');
353  $companypaymentmode->label = GETPOST('label', 'alpha');
354  $companypaymentmode->number = GETPOST('cardnumber', 'alpha');
355  $companypaymentmode->last_four = substr(GETPOST('cardnumber', 'alpha'), -4);
356  $companypaymentmode->proprio = GETPOST('proprio', 'alpha');
357  $companypaymentmode->exp_date_month = GETPOST('exp_date_month', 'int');
358  $companypaymentmode->exp_date_year = GETPOST('exp_date_year', 'int');
359  $companypaymentmode->cvn = GETPOST('cvn', 'alpha');
360  $companypaymentmode->datec = dol_now();
361  $companypaymentmode->default_rib = 0;
362  $companypaymentmode->type = 'card';
363  $companypaymentmode->country_code = $object->country_code;
364  $companypaymentmode->status = $servicestatus;
365 
366  if (GETPOST('stripe_card_ref', 'alpha')) {
367  // If we set a stripe value, we also set the stripe account
368  $companypaymentmode->stripe_account = $stripecu.'@'.$site_account;
369  }
370  $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha');
371 
372  $db->begin();
373 
374  if (!$error) {
375  $result = $companypaymentmode->create($user);
376  if ($result < 0) {
377  $error++;
378  setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
379  $action = 'createcard'; // Force chargement page création
380  }
381  }
382 
383  if (!$error) {
384  $db->commit();
385 
386  $url = $_SERVER["PHP_SELF"].'?socid='.$object->id;
387  header('Location: '.$url);
388  exit;
389  } else {
390  $db->rollback();
391  }
392  }
393  }
394 
395  if ($action == 'setasbankdefault' && GETPOST('ribid', 'int') > 0) {
396  $companybankaccount = new CompanyBankAccount($db);
397  $res = $companybankaccount->setAsDefault(GETPOST('ribid', 'int'));
398  if ($res) {
399  $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
400  header('Location: '.$url);
401  exit;
402  } else {
403  setEventMessages($db->lasterror, null, 'errors');
404  }
405  }
406 
407  if ($action == 'confirm_deletecard' && GETPOST('confirm', 'alpha') == 'yes') {
408  $companypaymentmode = new CompanyPaymentMode($db);
409  if ($companypaymentmode->fetch($ribid ? $ribid : $id)) {
410  /*if ($companypaymentmode->stripe_card_ref && preg_match('/pm_/', $companypaymentmode->stripe_card_ref))
411  {
412  $payment_method = \Stripe\PaymentMethod::retrieve($companypaymentmode->stripe_card_ref);
413  if ($payment_method)
414  {
415  $payment_method->detach();
416  }
417  }*/
418 
419  $result = $companypaymentmode->delete($user);
420  if ($result > 0) {
421  $url = $_SERVER['PHP_SELF']."?socid=".$object->id;
422  header('Location: '.$url);
423  exit;
424  } else {
425  setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
426  }
427  } else {
428  setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors');
429  }
430  }
431  if ($action == 'confirm_delete' && GETPOST('confirm', 'alpha') == 'yes') {
432  $companybankaccount = new CompanyBankAccount($db);
433  if ($companybankaccount->fetch($ribid ? $ribid : $id)) {
434  $result = $companybankaccount->delete($user);
435  if ($result > 0) {
436  $url = $_SERVER['PHP_SELF']."?socid=".$object->id;
437  header('Location: '.$url);
438  exit;
439  } else {
440  setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
441  }
442  } else {
443  setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors');
444  }
445  }
446 
447  $savid = $id;
448 
449  // Actions to build doc
450  if ($action == 'builddocrib') {
451  $action = 'builddoc';
452  $moreparams = array(
453  'use_companybankid'=>GETPOST('companybankid'),
454  'force_dir_output'=>$conf->societe->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->id)
455  );
456  $_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid', 'int'), 'alpha');
457  $_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid', 'int'), 'alpha');
458  }
459 
460  $id = $socid;
461  $upload_dir = $conf->societe->multidir_output[$object->entity];
462  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
463 
464  $id = $savid;
465 
466  // Action for stripe
467  if (!empty($conf->stripe->enabled) && class_exists('Stripe')) {
468  if ($action == 'synccustomertostripe') {
469  if ($object->client == 0) {
470  $error++;
471  setEventMessages('ThisThirdpartyIsNotACustomer', null, 'errors');
472  } else {
473  // Creation of Stripe customer + update of societe_account
474  $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1);
475  if (!$cu) {
476  $error++;
477  setEventMessages($stripe->error, $stripe->errors, 'errors');
478  } else {
479  $stripecu = $cu->id;
480  }
481  }
482  }
483  if ($action == 'synccardtostripe') {
484  $companypaymentmode = new CompanyPaymentMode($db);
485  $companypaymentmode->fetch($id);
486 
487  if ($companypaymentmode->type != 'card') {
488  $error++;
489  setEventMessages('ThisPaymentModeIsNotACard', null, 'errors');
490  } else {
491  // Get the Stripe customer
492  $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
493  if (!$cu) {
494  $error++;
495  setEventMessages($stripe->error, $stripe->errors, 'errors');
496  }
497 
498  if (!$error) {
499  // Creation of Stripe card + update of societe_account
500  // Note that with the new Stripe API, option to create a card is no more available, instead an error message will be returned to
501  // ask to create the crdit card from Stripe backoffice.
502  $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
503  if (!$card) {
504  $error++;
505  setEventMessages($stripe->error, $stripe->errors, 'errors');
506  }
507  }
508  }
509  }
510 
511  if ($action == 'setkey_account') {
512  $error = 0;
513 
514  $newcu = GETPOST('key_account', 'alpha');
515 
516  $db->begin();
517 
518  if (empty($newcu)) {
519  $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".((int) $servicestatus)." AND entity = ".$conf->entity;
520  } else {
521  $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."societe_account";
522  $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".((int) $object->id)." AND status = ".((int) $servicestatus)." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
523  }
524 
525  $resql = $db->query($sql);
526  $num = $db->num_rows($resql); // Note: $num is always 0 on an update and delete, it is defined for select only.
527  if (!empty($newcu)) {
528  if (empty($num)) {
529  $societeaccount = new SocieteAccount($db);
530  $societeaccount->fk_soc = $object->id;
531  $societeaccount->login = '';
532  $societeaccount->pass_encoding = '';
533  $societeaccount->site = 'stripe';
534  $societeaccount->status = $servicestatus;
535  $societeaccount->key_account = $newcu;
536  $societeaccount->site_account = $site_account;
537  $result = $societeaccount->create($user);
538  if ($result < 0) {
539  $error++;
540  }
541  } else {
542  $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account";
543  $sql .= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."', site_account = '".$db->escape($site_account)."'";
544  $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".((int) $object->id)." AND status = ".((int) $servicestatus)." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
545  $resql = $db->query($sql);
546  }
547  }
548  //var_dump($sql);
549  //var_dump($newcu);
550  //var_dump($num); exit;
551 
552  if (!$error) {
553  $stripecu = $newcu;
554  $db->commit();
555  } else {
556  $db->rollback();
557  }
558  }
559 
560  if ($action == 'setkey_account_supplier') {
561  $error = 0;
562 
563  $newsup = GETPOST('key_account_supplier', 'alpha');
564 
565  $db->begin();
566 
567  if (empty($newsup)) {
568  $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity;
569  // TODO Add site and site_account on oauth_token table
570  //$sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($site_account)."') AND fk_soc = ".((int) $object->id)." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity;
571  } else {
572  try {
573  $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha')));
574  $tokenstring['stripe_user_id'] = $stripesup->id;
575  $tokenstring['type'] = $stripesup->type;
576  $sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token";
577  $sql .= " SET tokenstring = '".$db->escape(json_encode($tokenstring))."'";
578  $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($site_account)."') AND fk_soc = ".((int) $object->id)." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
579  // TODO Add site and site_account on oauth_token table
580  $sql .= " WHERE fk_soc = ".$object->id." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
581  } catch (Exception $e) {
582  $error++;
583  setEventMessages($e->getMessage(), null, 'errors');
584  }
585  }
586 
587  $resql = $db->query($sql);
588  $num = $db->num_rows($resql);
589  if (empty($num) && !empty($newsup)) {
590  try {
591  $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha')));
592  $tokenstring['stripe_user_id'] = $stripesup->id;
593  $tokenstring['type'] = $stripesup->type;
594  $sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_token (service, fk_soc, entity, tokenstring)";
595  $sql .= " VALUES ('".$db->escape($service)."', ".((int) $object->id).", ".((int) $conf->entity).", '".$db->escape(json_encode($tokenstring))."')";
596  // TODO Add site and site_account on oauth_token table
597  } catch (Exception $e) {
598  $error++;
599  setEventMessages($e->getMessage(), null, 'errors');
600  }
601  $resql = $db->query($sql);
602  }
603 
604  if (!$error) {
605  $stripesupplieracc = $newsup;
606  $db->commit();
607  } else {
608  $db->rollback();
609  }
610  }
611 
612  if ($action == 'setlocalassourcedefault') { // Set as default when payment mode defined locally (and may be also remotely)
613  try {
614  $companypaymentmode->setAsDefault($id);
615 
616  $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
617  header('Location: '.$url);
618  exit;
619  } catch (Exception $e) {
620  $error++;
621  setEventMessages($e->getMessage(), null, 'errors');
622  }
623  } elseif ($action == 'setassourcedefault') { // Set as default when payment mode defined remotely only
624  try {
625  $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
626  if (preg_match('/pm_/', $source)) {
627  $cu->invoice_settings->default_payment_method = (string) $source; // New
628  } else {
629  $cu->default_source = (string) $source; // Old
630  }
631  $result = $cu->save();
632 
633  $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
634  header('Location: '.$url);
635  exit;
636  } catch (Exception $e) {
637  $error++;
638  setEventMessages($e->getMessage(), null, 'errors');
639  }
640  } elseif ($action == 'deletecard' && $source) {
641  try {
642  if (preg_match('/pm_/', $source)) {
643  $payment_method = \Stripe\PaymentMethod::retrieve($source, array("stripe_account" => $stripeacc));
644  if ($payment_method) {
645  $payment_method->detach();
646  }
647  } else {
648  $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
649  $card = $cu->sources->retrieve("$source");
650  if ($card) {
651  // $card->detach(); Does not work with card_, only with src_
652  if (method_exists($card, 'detach')) {
653  $card->detach();
654  } else {
655  $card->delete();
656  }
657  }
658  }
659 
660  $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
661  header('Location: '.$url);
662  exit;
663  } catch (Exception $e) {
664  $error++;
665  setEventMessages($e->getMessage(), null, 'errors');
666  }
667  }
668  }
669 }
670 
671 
672 
673 /*
674  * View
675  */
676 
677 $form = new Form($db);
678 $formother = new FormOther($db);
679 $formfile = new FormFile($db);
680 
681 $title = $langs->trans("ThirdParty");
682 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
683  $title = $object->name." - ".$langs->trans('PaymentInformation');
684 }
685 
686 llxHeader();
687 
688 $head = societe_prepare_head($object);
689 
690 // Show sandbox warning
691 /*if (! empty($conf->paypal->enabled) && (! empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha'))) // We can force sand box with param 'forcesandbox'
692 {
693  dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Paypal'),'','warning');
694 }*/
695 if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) {
696  dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
697 }
698 
699 // Load Bank account
700 if (!$id) {
701  $companybankaccount->fetch(0, $object->id);
702  $companypaymentmode->fetch(0, null, $object->id, 'card');
703 } else {
704  $companybankaccount->fetch($id);
705  $companypaymentmode->fetch($id);
706 }
707 if (empty($companybankaccount->socid)) {
708  $companybankaccount->socid = $object->id;
709 }
710 
711 if ($socid && ($action == 'edit' || $action == 'editcard') && $permissiontoaddupdatepaymentinformation) {
712  print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">';
713  print '<input type="hidden" name="token" value="'.newToken().'">';
714  $actionforadd = 'update';
715  if ($action == 'editcard') {
716  $actionforadd = 'updatecard';
717  }
718  print '<input type="hidden" name="action" value="'.$actionforadd.'">';
719  print '<input type="hidden" name="id" value="'.GETPOST("id", "int").'">';
720 }
721 if ($socid && ($action == 'create' || $action == 'createcard') && $permissiontoaddupdatepaymentinformation) {
722  print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">';
723  print '<input type="hidden" name="token" value="'.newToken().'">';
724  $actionforadd = 'add';
725  if ($action == 'createcard') {
726  $actionforadd = 'addcard';
727  }
728  print '<input type="hidden" name="action" value="'.$actionforadd.'">';
729 }
730 
731 
732 // View
733 if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' && $action != 'createcard') {
734  print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company');
735 
736  // Confirm delete ban
737  if ($action == 'delete') {
738  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);
739  }
740  // Confirm delete card
741  if ($action == 'deletecard') {
742  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);
743  }
744 
745  $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
746 
747  dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
748 
749  print '<div class="fichecenter">';
750 
751  print '<div class="underbanner clearboth"></div>';
752  print '<table class="border tableforfield centpercent">';
753 
754  // Type Prospect/Customer/Supplier
755  print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td colspan="2">';
756  print $object->getTypeUrl(1);
757  print '</td></tr>';
758 
759  if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
760  print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="2">'.$object->prefix_comm.'</td></tr>';
761  }
762 
763  if ($object->client) {
764  print '<tr><td class="titlefield">';
765  print $langs->trans('CustomerCode').'</td><td colspan="2">';
766  print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
767  $tmpcheck = $object->check_codeclient();
768  if ($tmpcheck != 0 && $tmpcheck != -5) {
769  print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
770  }
771  print '</td></tr>';
772  $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".((int) $socid);
773  $resql = $db->query($sql);
774  if (!$resql) {
775  dol_print_error($db);
776  }
777 
778  $obj = $db->fetch_object($resql);
779  $nbFactsClient = $obj->nb;
780  $thirdTypeArray['customer'] = $langs->trans("customer");
781  if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
782  $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals');
783  }
784  if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
785  $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders');
786  }
787  if (isModEnabled('facture') && $user->rights->facture->lire) {
788  $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices');
789  }
790  if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) {
791  $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts');
792  }
793 
794  if (!empty($conf->stripe->enabled)) {
795  // Stripe customer key 'cu_....' stored into llx_societe_account
796  print '<tr><td class="titlefield">';
797  print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid');
798  print '</td><td>';
799  print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid');
800  if (!empty($conf->stripe->enabled) && $stripecu && $action != 'editkey_account') {
801  $connect = '';
802  if (!empty($stripeacc)) {
803  $connect = $stripeacc.'/';
804  }
805  $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu;
806  if ($servicestatus) {
807  $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu;
808  }
809  print ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe').' - Publishable key = '.$site_account, 'globe').'</a>';
810  }
811  print '</td><td class="right">';
812  if (empty($stripecu)) {
813  print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
814  print '<input type="hidden" name="action" value="synccustomertostripe">';
815  print '<input type="hidden" name="token" value="'.newToken().'">';
816  print '<input type="hidden" name="socid" value="'.$object->id.'">';
817  print '<input type="submit" class="button buttongen" name="syncstripecustomer" value="'.$langs->trans("CreateCustomerOnStripe").'">';
818  print '</form>';
819  }
820  print '</td></tr>';
821  }
822  }
823 
824  if ($object->fournisseur) {
825  print '<tr><td class="titlefield">';
826  print $langs->trans('SupplierCode').'</td><td colspan="2">';
827  print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
828  $tmpcheck = $object->check_codefournisseur();
829  if ($tmpcheck != 0 && $tmpcheck != -5) {
830  print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
831  }
832  print '</td></tr>';
833  $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".((int) $socid);
834  $resql = $db->query($sql);
835  if (!$resql) {
836  dol_print_error($db);
837  }
838  $obj = $db->fetch_object($resql);
839  $nbFactsClient = $obj->nb;
840  $thirdTypeArray['customer'] = $langs->trans("customer");
841  if (isModEnabled('propal') && $user->rights->propal->lire) {
842  $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals');
843  }
844  if (isModEnabled('commande') && $user->rights->commande->lire) {
845  $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders');
846  }
847  if (isModEnabled('facture') && $user->rights->facture->lire) {
848  $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices');
849  }
850  if (isModEnabled('contrat') && $user->rights->contrat->lire) {
851  $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts');
852  }
853  }
854 
855  if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
856  $stripesupplieracc = $stripe->getStripeAccount($service, $object->id); // Get Stripe OAuth connect account (no network access here)
857 
858  // Stripe customer key 'cu_....' stored into llx_societe_account
859  print '<tr><td class="titlefield">';
860  print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid');
861  print '</td><td>';
862  print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid');
863  if (!empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account_supplier') {
864  $connect = '';
865 
866  $url = 'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc;
867  if ($servicestatus) {
868  $url = 'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc;
869  }
870  print ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe').' - Publishable key '.$site_account, 'globe').'</a>';
871  }
872  print '</td><td class="right">';
873  if (empty($stripesupplieracc)) {
874  print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
875  print '<input type="hidden" name="action" value="syncsuppliertostripe">';
876  print '<input type="hidden" name="token" value="'.newToken().'">';
877  print '<input type="hidden" name="socid" value="'.$object->id.'">';
878  print '<input type="hidden" name="companybankid" value="'.$rib->id.'">';
879  //print '<input type="submit" class="button buttongen" name="syncstripecustomer" value="'.$langs->trans("CreateSupplierOnStripe").'">';
880  print '</form>';
881  }
882  print '</td></tr>';
883  }
884 
885  print '</table>';
886  print '</div>';
887 
888  print dol_get_fiche_end();
889 
890  print '<br>';
891 
892  // List of Stripe payment modes
893  if (!(empty($conf->stripe->enabled)) && $object->client) {
894  $morehtmlright = '';
895  if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) {
896  $morehtmlright .= dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=createcard');
897  }
898  print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc ? ' (Stripe connection with StripeConnect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'stripe-s');
899 
900  $listofsources = array();
901  if (is_object($stripe)) {
902  try {
903  $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus);
904  if (!empty($customerstripe->id)) {
905  // When using the Charge API architecture
906  if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
907  $listofsources = $customerstripe->sources->data;
908  } else {
909  $service = 'StripeTest';
910  $servicestatus = 0;
911  if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) {
912  $service = 'StripeLive';
913  $servicestatus = 1;
914  }
915 
916  // Force to use the correct API key
917  global $stripearrayofkeysbyenv;
918  \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus]['secret_key']);
919 
920  try {
921  if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
922  $paymentmethodobjsA = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "card"));
923  $paymentmethodobjsB = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "sepa_debit"));
924  } else {
925  $paymentmethodobjsA = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "card"), array("stripe_account" => $stripeacc));
926  $paymentmethodobjsB = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "sepa_debit"), array("stripe_account" => $stripeacc));
927  }
928 
929  if ($paymentmethodobjsA->data != null && $paymentmethodobjsB->data != null) {
930  $listofsources = array_merge((array) $paymentmethodobjsA->data, (array) $paymentmethodobjsB->data);
931  } elseif ($paymentmethodobjsB->data != null) {
932  $listofsources = $paymentmethodobjsB->data;
933  } else {
934  $listofsources = $paymentmethodobjsA->data;
935  }
936  } catch (Exception $e) {
937  $error++;
938  setEventMessages($e->getMessage(), null, 'errors');
939  }
940  }
941  }
942  } catch (Exception $e) {
943  dol_syslog("Error when searching/loading Stripe customer for thirdparty id =".$object->id);
944  }
945  }
946 
947  print '<!-- List of stripe payments -->'."\n";
948  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
949  print '<table class="liste centpercent">'."\n";
950  print '<tr class="liste_titre">';
951  if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) {
952  print '<td>'.$langs->trans('LocalID').'</td>';
953  }
954  print '<td>'.$langs->trans('Label').'</td>';
955  print '<td>'.$langs->trans('StripeID').'</td>';
956  print '<td>'.$langs->trans('Type').'</td>';
957  print '<td>'.$langs->trans('Informations').'</td>';
958  print '<td></td>';
959  print '<td class="center">'.$langs->trans('Default').'</td>';
960  print '<td>'.$langs->trans('Note').'</td>';
961  print '<td>'.$langs->trans('DateModification').'</td>';
962  // Hook fields
963  $parameters = array('arrayfields'=>array(), 'param'=>'', 'sortfield'=>'', 'sortorder'=>'', 'linetype'=>'stripetitle');
964  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
965  print $hookmanager->resPrint;
966  // Action column
967  print "<td></td>";
968  print "</tr>\n";
969 
970  $nbremote = 0;
971  $nblocal = 0;
972  $arrayofstripecard = array();
973 
974  // Show local sources
975  if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) {
976  //$societeaccount = new SocieteAccount($db);
977  $companypaymentmodetemp = new CompanyPaymentMode($db);
978 
979  $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."societe_rib";
980  $sql .= " WHERE type in ('card')";
981  $sql .= " AND fk_soc = ".((int) $object->id);
982  $sql .= " AND status = ".((int) $servicestatus);
983 
984  $resql = $db->query($sql);
985  if ($resql) {
986  $num_rows = $db->num_rows($resql);
987  if ($num_rows) {
988  $i = 0;
989  while ($i < $num_rows) {
990  $nblocal++;
991 
992  $obj = $db->fetch_object($resql);
993  if ($obj) {
994  $companypaymentmodetemp->fetch($obj->rowid);
995 
996  $arrayofstripecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref;
997 
998  print '<tr class="oddeven">';
999  print '<td>';
1000  print $companypaymentmodetemp->id;
1001  print '</td>';
1002  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->label).'">';
1003  print dol_escape_htmltag($companypaymentmodetemp->label);
1004  print '</td>';
1005  print '<td>';
1006  print $companypaymentmodetemp->stripe_card_ref;
1007  if ($companypaymentmodetemp->stripe_card_ref) {
1008  $connect = '';
1009  if (!empty($stripeacc)) {
1010  $connect = $stripeacc.'/';
1011  }
1012  $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
1013  if ($servicestatus) {
1014  $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$companypaymentmodetemp->stripe_card_ref;
1015  }
1016  print ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe').' - Customer and Publishable key = '.$companypaymentmodetemp->stripe_account, 'globe').'</a>';
1017  }
1018  print '</td>';
1019  print '<td>';
1020  print img_credit_card($companypaymentmodetemp->type);
1021  print '</td>';
1022  print '<td>';
1023  if ($companypaymentmodetemp->proprio) {
1024  print '<span class="opacitymedium">'.$companypaymentmodetemp->proprio.'</span><br>';
1025  }
1026  if ($companypaymentmodetemp->last_four) {
1027  print '....'.$companypaymentmodetemp->last_four;
1028  }
1029  if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) {
1030  print ' - '.sprintf("%02d", $companypaymentmodetemp->exp_date_month).'/'.$companypaymentmodetemp->exp_date_year.'';
1031  }
1032  print '</td><td>';
1033  if ($companypaymentmodetemp->country_code) {
1034  $img = picto_from_langcode($companypaymentmodetemp->country_code);
1035  print $img ? $img.' ' : '';
1036  print getCountry($companypaymentmodetemp->country_code, 1);
1037  } else {
1038  print img_warning().' <span class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</span>';
1039  }
1040  print '</td>';
1041  // Default
1042  print '<td class="center">';
1043  if (empty($companypaymentmodetemp->default_rib)) {
1044  print '<a href="'.DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=setlocalassourcedefault&token='.newToken().'">';
1045  print img_picto($langs->trans("Default"), 'off');
1046  print '</a>';
1047  } else {
1048  print img_picto($langs->trans("Default"), 'on');
1049  }
1050  print '</td>';
1051  print '<td>';
1052  if (empty($companypaymentmodetemp->stripe_card_ref)) {
1053  print $langs->trans("Local");
1054  } else {
1055  print $langs->trans("LocalAndRemote");
1056  }
1057  print '</td>';
1058  print '<td>';
1059  print dol_print_date($companypaymentmodetemp->tms, 'dayhour');
1060  print '</td>';
1061  // Fields from hook
1062  $parameters = array('arrayfields'=>array(), 'obj'=>$obj, 'linetype'=>'stripecard');
1063  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
1064  print $hookmanager->resPrint;
1065  // Action column
1066  print '<td class="right nowraponall">';
1067  if ($permissiontoaddupdatepaymentinformation) {
1068  if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) {
1069  print '<a href="'.$_SERVER['PHP_SELF'].'?action=synccardtostripe&socid='.$object->id.'&id='.$companypaymentmodetemp->id.'" class="paddingrightonly marginrightonly">'.$langs->trans("CreateCardOnStripe").'</a>';
1070  }
1071 
1072  print '<a class="editfielda marginleftonly marginrightonly" href="'.DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=editcard&token='.newToken().'">';
1073  print img_picto($langs->trans("Modify"), 'edit');
1074  print '</a>';
1075  print '&nbsp;';
1076  print '<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=deletecard&token='.newToken().'">'; // source='.$companypaymentmodetemp->stripe_card_ref.'&
1077  print img_picto($langs->trans("Delete"), 'delete');
1078  print '</a>';
1079  }
1080  print '</td>';
1081  print '</tr>';
1082  }
1083  $i++;
1084  }
1085  }
1086  } else {
1087  dol_print_error($db);
1088  }
1089  }
1090 
1091  // Show remote sources (not already shown as local source)
1092  if (is_array($listofsources) && count($listofsources)) {
1093  foreach ($listofsources as $src) {
1094  if (!empty($arrayofstripecard[$src->id])) {
1095  continue; // Already in previous list
1096  }
1097 
1098  $nbremote++;
1099 
1100  print '<tr class="oddeven">';
1101  // Local ID
1102  if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) {
1103  print '<td>';
1104  print '</td>';
1105  }
1106  print '<td>';
1107  print '</td>';
1108  // Src ID
1109  print '<td>';
1110  $connect = '';
1111  print $src->id;
1112  if (!empty($stripeacc)) {
1113  $connect = $stripeacc.'/';
1114  }
1115  //$url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id;
1116  $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$src->id;
1117  if ($servicestatus) {
1118  //$url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id;
1119  $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$src->id;
1120  }
1121  print " <a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')."</a>";
1122  print '</td>';
1123  // Img of credit card
1124  print '<td>';
1125  if ($src->object == 'card') {
1126  print img_credit_card($src->brand);
1127  } elseif ($src->object == 'source' && $src->type == 'card') {
1128  print img_credit_card($src->card->brand);
1129  } elseif ($src->object == 'source' && $src->type == 'sepa_debit') {
1130  print '<span class="fa fa-university fa-2x fa-fw"></span>';
1131  } elseif ($src->object == 'payment_method' && $src->type == 'card') {
1132  print img_credit_card($src->card->brand);
1133  } elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') {
1134  print '<span class="fa fa-university fa-2x fa-fw"></span>';
1135  }
1136  print'</td>';
1137  // Information
1138  print '<td valign="middle">';
1139  if ($src->object == 'card') {
1140  print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.'';
1141  print '</td><td>';
1142  if ($src->country) {
1143  $img = picto_from_langcode($src->country);
1144  print $img ? $img.' ' : '';
1145  print getCountry($src->country, 1);
1146  } else {
1147  print img_warning().' <span class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</span>';
1148  }
1149  } elseif ($src->object == 'source' && $src->type == 'card') {
1150  print '<span class="opacitymedium">'.$src->owner->name.'</span><br>....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.'';
1151  print '</td><td>';
1152 
1153  if ($src->card->country) {
1154  $img = picto_from_langcode($src->card->country);
1155  print $img ? $img.' ' : '';
1156  print getCountry($src->card->country, 1);
1157  } else {
1158  print img_warning().' <span class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</span>';
1159  }
1160  } elseif ($src->object == 'source' && $src->type == 'sepa_debit') {
1161  print '<span class="opacitymedium">'.$src->billing_details->name.'</span><br>....'.$src->sepa_debit->last4;
1162  print '</td><td>';
1163  if ($src->sepa_debit->country) {
1164  $img = picto_from_langcode($src->sepa_debit->country);
1165  print $img ? $img.' ' : '';
1166  print getCountry($src->sepa_debit->country, 1);
1167  } else {
1168  print img_warning().' <span class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</span>';
1169  }
1170  } elseif ($src->object == 'payment_method' && $src->type == 'card') {
1171  print '<span class="opacitymedium">'.$src->billing_details->name.'</span><br>....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.'';
1172  print '</td><td>';
1173 
1174  if ($src->card->country) {
1175  $img = picto_from_langcode($src->card->country);
1176  print $img ? $img.' ' : '';
1177  print getCountry($src->card->country, 1);
1178  } else {
1179  print img_warning().' <span class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</span>';
1180  }
1181  } elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') {
1182  print '<span class="opacitymedium">'.$src->billing_details->name.'</span><br>....'.$src->sepa_debit->last4;
1183  print '</td><td>';
1184  if ($src->sepa_debit->country) {
1185  $img = picto_from_langcode($src->sepa_debit->country);
1186  print $img ? $img.' ' : '';
1187  print getCountry($src->sepa_debit->country, 1);
1188  } else {
1189  print img_warning().' <span class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</span>';
1190  }
1191  } else {
1192  print '</td><td>';
1193  }
1194  print '</td>';
1195  // Default
1196  print '<td class="center" width="50">';
1197  if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1198  (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1199  print '<a href="'.DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=setassourcedefault&token='.newToken().'">';
1200  print img_picto($langs->trans("Default"), 'off');
1201  print '</a>';
1202  } else {
1203  print img_picto($langs->trans("Default"), 'on');
1204  }
1205  print '</td>';
1206  print '<td>';
1207  print $langs->trans("Remote");
1208  //if ($src->cvc_check == 'fail') print ' - CVC check fail';
1209  print '</td>';
1210  print '<td>';
1211  //var_dump($src);
1212  print '';
1213  print '</td>';
1214  // Fields from hook
1215  $parameters = array('arrayfields'=>array(), 'stripesource'=>$src, 'linetype'=>'stripecardremoteonly');
1216  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
1217  print $hookmanager->resPrint;
1218  // Action column
1219  print '<td class="right nowraponall">';
1220  if ($permissiontoaddupdatepaymentinformation) {
1221  print '<a href="'.DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=deletecard&token='.newToken().'">';
1222  print img_picto($langs->trans("Delete"), 'delete');
1223  print '</a>';
1224  }
1225  print '</td>';
1226 
1227  print '</tr>';
1228  }
1229  }
1230 
1231  if ($nbremote == 0 && $nblocal == 0) {
1232  $colspan = (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD) ? 10 : 9);
1233  print '<tr><td colspan="'.$colspan.'"<span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
1234  }
1235  print "</table>";
1236  print "</div>";
1237  print '<br>';
1238  }
1239 
1240  // List of Stripe payment modes
1241  if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc)) {
1242  print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc ? ' (Stripe connection with StripeConnect account '.$stripesupplieracc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'stripe-s');
1243  $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc));
1244  print '<table class="liste centpercent">'."\n";
1245  print '<tr class="liste_titre">';
1246  print '<td>'.$langs->trans('Currency').'</td>';
1247  print '<td>'.$langs->trans('Available').'</td>';
1248  print '<td>'.$langs->trans('Pending').'</td>';
1249  print '<td>'.$langs->trans('Total').'</td>';
1250  print '</tr>';
1251 
1252  $currencybalance = array();
1253  if (is_array($balance->available) && count($balance->available)) {
1254  foreach ($balance->available as $cpt) {
1255  $arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF');
1256  if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1257  $currencybalance[$cpt->currency]['available'] = $cpt->amount / 100;
1258  } else {
1259  $currencybalance[$cpt->currency]['available'] = $cpt->amount;
1260  }
1261  $currencybalance[$cpt->currency]['currency'] = $cpt->currency;
1262  }
1263  }
1264 
1265  if (is_array($balance->pending) && count($balance->pending)) {
1266  foreach ($balance->pending as $cpt) {
1267  $arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF');
1268  if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1269  $currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available'] + $cpt->amount / 100;
1270  } else {
1271  $currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available'] + $cpt->amount;
1272  }
1273  }
1274  }
1275 
1276  if (is_array($currencybalance)) {
1277  foreach ($currencybalance as $cpt) {
1278  print '<tr><td>'.$langs->trans("Currency".strtoupper($cpt['currency'])).'</td><td>'.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).'</td><td>'.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).'</td><td>'.price($cpt['available'] + $cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).'</td></tr>';
1279  }
1280  }
1281 
1282  print '</table>';
1283  print '<br>';
1284  }
1285 
1286  // List of bank accounts
1287  if ($permissiontoaddupdatepaymentinformation) {
1288  $morehtmlright = dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '&amp;action=create');
1289  }
1290 
1291  print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, 'bank');
1292 
1293  $rib_list = $object->get_all_rib();
1294  if (is_array($rib_list)) {
1295  print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
1296  print '<table class="liste centpercent">';
1297 
1298  print '<tr class="liste_titre">';
1299  print_liste_field_titre("LabelRIB");
1300  print_liste_field_titre("Bank");
1301  print_liste_field_titre("RIB");
1302  print_liste_field_titre("IBAN");
1303  print_liste_field_titre("BIC");
1304  if (!empty($conf->prelevement->enabled)) {
1305  print_liste_field_titre("RUM");
1306  print_liste_field_titre("DateRUM");
1307  print_liste_field_titre("WithdrawMode");
1308  }
1309  print_liste_field_titre("DefaultRIB", '', '', '', '', '', '', '', 'center ');
1310  print_liste_field_titre('', '', '', '', '', '', '', '', 'center ');
1311  print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', '', '', 'maxwidthsearch ');
1312  print "</tr>\n";
1313 
1314  foreach ($rib_list as $rib) {
1315  print '<tr class="oddeven">';
1316  // Label
1317  print '<td>'.$rib->label.'</td>';
1318  // Bank name
1319  print '<td>'.$rib->bank.'</td>';
1320  // Account number
1321  print '<td>';
1322  $string = '';
1323  foreach ($rib->getFieldsToShow() as $val) {
1324  if ($val == 'BankCode') {
1325  $string .= $rib->code_banque.' ';
1326  } elseif ($val == 'BankAccountNumber') {
1327  $string .= $rib->number.' ';
1328  } elseif ($val == 'DeskCode') {
1329  $string .= $rib->code_guichet.' ';
1330  } elseif ($val == 'BankAccountNumberKey') {
1331  $string .= $rib->cle_rib.' ';
1332  }
1333  // Already output after
1334  // } elseif ($val == 'BIC') {
1335  // $string .= $rib->bic.' ';
1336  // } elseif ($val == 'IBAN') {
1337  // $string .= $rib->iban.' ';*/
1338  //}
1339  }
1340  if (!empty($rib->label) && $rib->number) {
1341  if (!checkBanForAccount($rib)) {
1342  $string .= ' '.img_picto($langs->trans("ValueIsNotValid"), 'warning');
1343  } else {
1344  $string .= ' '.img_picto($langs->trans("ValueIsValid"), 'info');
1345  }
1346  }
1347 
1348  print $string;
1349  print '</td>';
1350  // IBAN
1351  print '<td>'.$rib->iban;
1352  if (!empty($rib->iban)) {
1353  if (!checkIbanForAccount($rib)) {
1354  print ' '.img_picto($langs->trans("IbanNotValid"), 'warning');
1355  }
1356  }
1357  print '</td>';
1358  // BIC
1359  print '<td>'.$rib->bic;
1360  if (!empty($rib->bic)) {
1361  if (!checkSwiftForAccount($rib)) {
1362  print ' '.img_picto($langs->trans("SwiftNotValid"), 'warning');
1363  }
1364  }
1365  print '</td>';
1366 
1367  if (!empty($conf->prelevement->enabled)) {
1368  // RUM
1369  //print '<td>'.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).'</td>';
1370  print '<td>'.$rib->rum.'</td>';
1371 
1372  print '<td>'.dol_print_date($rib->date_rum, 'day').'</td>';
1373 
1374  // FRSTRECUR
1375  print '<td>'.$rib->frstrecur.'</td>';
1376  }
1377 
1378  // Default
1379  print '<td class="center" width="70">';
1380  if (!$rib->default_rib) {
1381  print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&ribid='.$rib->id.'&action=setasbankdefault&token='.newToken().'">';
1382  print img_picto($langs->trans("Disabled"), 'off');
1383  print '</a>';
1384  } else {
1385  print img_picto($langs->trans("Enabled"), 'on');
1386  }
1387  print '</td>';
1388 
1389  // Generate doc
1390  print '<td class="center">';
1391 
1392  $buttonlabel = $langs->trans("BuildDoc");
1393  $forname = 'builddocrib'.$rib->id;
1394 
1395  include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php';
1396  $modellist = ModeleBankAccountDoc::liste_modeles($db);
1397 
1398  $out = '';
1399  if (is_array($modellist) && count($modellist)) {
1400  $out .= '<form action="'.$_SERVER["PHP_SELF"].(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc').'" name="'.$forname.'" id="'.$forname.'_form" method="post">';
1401  $out .= '<input type="hidden" name="action" value="builddocrib">';
1402  $out .= '<input type="hidden" name="token" value="'.newToken().'">';
1403  $out .= '<input type="hidden" name="socid" value="'.$object->id.'">';
1404  $out .= '<input type="hidden" name="companybankid" value="'.$rib->id.'">';
1405 
1406  if (is_array($modellist) && count($modellist) == 1) { // If there is only one element
1407  $arraykeys = array_keys($modellist);
1408  $modelselected = $arraykeys[0];
1409  }
1410  if (!empty($conf->global->BANKADDON_PDF)) {
1411  $modelselected = $conf->global->BANKADDON_PDF;
1412  }
1413 
1414  $out .= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100');
1415  $out .= ajax_combobox('modelrib'.$rib->id);
1416 
1417  $allowgenifempty = 0;
1418 
1419  // Language code (if multilang)
1420  if ($conf->global->MAIN_MULTILANGS) {
1421  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
1422  $formadmin = new FormAdmin($db);
1423  $defaultlang = $langs->getDefaultLang();
1424  $morecss = 'maxwidth150';
1425  if ($conf->browser->layout == 'phone') {
1426  $morecss = 'maxwidth100';
1427  }
1428  $out .= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss);
1429  }
1430  // Button
1431  $genbutton = '<input class="button buttongen reposition nomargintop nomarginbottom" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"';
1432  $genbutton .= ' type="submit" value="'.$buttonlabel.'"';
1433  if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) {
1434  $genbutton .= ' disabled';
1435  }
1436  $genbutton .= '>';
1437  if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') {
1438  $langs->load("errors");
1439  $genbutton .= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated"));
1440  }
1441  if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') {
1442  $genbutton = '';
1443  }
1444  if (empty($modellist) && !$showempty && $modulepart != 'unpaid') {
1445  $genbutton = '';
1446  }
1447  $out .= $genbutton;
1448  $out .= '</form>';
1449  }
1450  print $out;
1451  print '</td>';
1452 
1453  // Edit/Delete
1454  print '<td class="right nowraponall">';
1455  if ($permissiontoaddupdatepaymentinformation) {
1456  print '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=edit">';
1457  print img_picto($langs->trans("Modify"), 'edit');
1458  print '</a>';
1459 
1460  print '<a class="marginleftonly" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=delete&token='.newToken().'">';
1461  print img_picto($langs->trans("Delete"), 'delete');
1462  print '</a>';
1463  }
1464  print '</td>';
1465 
1466  print '</tr>';
1467  }
1468 
1469  if (count($rib_list) == 0) {
1470  $colspan = 9;
1471  if (!empty($conf->prelevement->enabled)) {
1472  $colspan += 2;
1473  }
1474  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoBANRecord").'</span></td></tr>';
1475  }
1476 
1477  print '</table>';
1478  print '</div>';
1479  } else {
1480  dol_print_error($db);
1481  }
1482 
1483 
1484  if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) {
1485  print '<br>';
1486 
1487  print '<div class="fichecenter"><div class="fichehalfleft">';
1488  print '<a name="builddoc"></a>'; // ancre
1489 
1490  /*
1491  * Generated documents
1492  */
1493  $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id;
1494  $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id;
1495 
1496  print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $permissiontoread, $permissiontoaddupdatepaymentinformation, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang);
1497 
1498  // Show direct download link
1499  if (!empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) {
1500  $companybankaccounttemp = new CompanyBankAccount($db);
1501  $companypaymentmodetemp = new CompanyPaymentMode($db);
1502  $result = $companypaymentmodetemp->fetch(0, null, $object->id, 'ban');
1503 
1504  include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
1505  $ecmfile = new EcmFiles($db);
1506  $result = $ecmfile->fetch(0, '', '', '', '', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
1507  if ($result > 0) {
1508  $companybankaccounttemp->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename;
1509  print '<br><!-- Link to download main doc -->'."\n";
1510  print showDirectDownloadLink($companybankaccounttemp).'<br>';
1511  }
1512  }
1513 
1514  print '</div><div class="fichehalfright">';
1515 
1516 
1517  print '</div></div>';
1518 
1519  print '<br>';
1520  }
1521  /*
1522  include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php';
1523  $modellist=ModeleBankAccountDoc::liste_modeles($db);
1524  //print '<td>';
1525  if (is_array($modellist) && count($modellist) == 1) // If there is only one element
1526  {
1527  $arraykeys=array_keys($modellist);
1528  $modelselected=$arraykeys[0];
1529  }
1530  $out.= $form->selectarray('model', $modellist, $modelselected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100');
1531  $out.= ajax_combobox('model');
1532  //print $out;
1533  $buttonlabel=$langs->trans("Generate");
1534  $genbutton = '<input class="button buttongen reposition nomargintop nomarginbottom" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"';
1535  $genbutton.= ' type="submit" value="'.$buttonlabel.'"';
1536  $genbutton.= '>';
1537  print $genbutton;
1538  //print '</td>'; // TODO Add link to generate doc
1539  */
1540 }
1541 
1542 // Edit BAN
1543 if ($socid && $action == 'edit' && $permissiontoaddupdatepaymentinformation) {
1544  print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company');
1545 
1546  $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
1547 
1548  dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
1549 
1550  print '<div class="underbanner clearboth"></div>';
1551 
1552  print '<div class="div-table-responsive-no-min">';
1553  print '<table class="border centpercent">';
1554 
1555  print '<tr><td class="titlefield fieldrequired">'.$langs->trans("LabelRIB").'</td>';
1556  print '<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.'"></td></tr>';
1557 
1558  print '<tr><td class="fieldrequired">'.$langs->trans("BankName").'</td>';
1559  print '<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.'"></td></tr>';
1560 
1561  // Show fields of bank account
1562  foreach ($companybankaccount->getFieldsToShow(1) as $val) {
1563  $require = false;
1564  $tooltip = '';
1565  if ($val == 'BankCode') {
1566  $name = 'code_banque';
1567  $size = 8;
1568  $content = $companybankaccount->code_banque;
1569  } elseif ($val == 'DeskCode') {
1570  $name = 'code_guichet';
1571  $size = 8;
1572  $content = $companybankaccount->code_guichet;
1573  } elseif ($val == 'BankAccountNumber') {
1574  $name = 'number';
1575  $size = 18;
1576  $content = $companybankaccount->number;
1577  } elseif ($val == 'BankAccountNumberKey') {
1578  $name = 'cle_rib';
1579  $size = 3;
1580  $content = $companybankaccount->cle_rib;
1581  } elseif ($val == 'IBAN') {
1582  $name = 'iban';
1583  $size = 30;
1584  $content = $companybankaccount->iban;
1585  if ($companybankaccount->needIBAN()) {
1586  $require = true;
1587  }
1588  $tooltip = $langs->trans("Example").':<br>LT12 1000 0111 0100 1000<br>FR14 2004 1010 0505 0001 3M02 606<br>LU28 0019 4006 4475 0000<br>DE89 3704 0044 0532 0130 00';
1589  } elseif ($val == 'BIC') {
1590  $name = 'bic';
1591  $size = 12;
1592  $content = $companybankaccount->bic;
1593  if ($companybankaccount->needIBAN()) {
1594  $require = true;
1595  }
1596  $tooltip = $langs->trans("Example").': LIABLT2XXXX';
1597  }
1598 
1599  print '<tr><td'.($require ? ' class="fieldrequired" ' : '').'>';
1600  if ($tooltip) {
1601  print $form->textwithpicto($langs->trans($val), $tooltip, 4, 'help', '', 0, 3, $name);
1602  } else {
1603  print $langs->trans($val);
1604  }
1605  print '</td>';
1606  print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>';
1607  print '</tr>';
1608  }
1609 
1610  print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
1611  print '<textarea name="domiciliation" rows="4" cols="40" maxlength="255">';
1612  print $companybankaccount->domiciliation;
1613  print "</textarea></td></tr>";
1614 
1615  print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
1616  print '<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->proprio.'"></td></tr>';
1617  print "</td></tr>\n";
1618 
1619  print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
1620  print '<textarea name="owner_address" rows="'.ROWS_4.'" cols="40" maxlength="255">';
1621  print $companybankaccount->owner_address;
1622  print "</textarea></td></tr>";
1623 
1624  print '</table>';
1625  print '</div>';
1626 
1627  if (isModEnabled('prelevement')) {
1628  print '<br>';
1629 
1630  print '<div class="div-table-responsive-no-min">';
1631  print '<table class="border centpercent">';
1632 
1633  if (empty($companybankaccount->rum)) {
1634  $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
1635  }
1636 
1637  // RUM
1638  print '<tr><td class="titlefield">'.$langs->trans("RUM").'</td>';
1639  print '<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).'"></td></tr>';
1640 
1641  $date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth'), GETPOST('date_rumday'), GETPOST('date_rumyear'));
1642 
1643  print '<tr><td class="titlefield">'.$langs->trans("DateRUM").'</td>';
1644  print '<td>'.$form->selectDate($date_rum ? $date_rum : $companybankaccount->date_rum, 'date_rum', 0, 0, 1, 'date_rum', 1, 1).'</td></tr>';
1645 
1646  print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
1647  $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
1648  print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur', 'alpha') ?GETPOST('frstrecur', 'alpha') : $companybankaccount->frstrecur), 0);
1649  print '</td></tr>';
1650 
1651  print '</table>';
1652  print '</div>';
1653  }
1654 
1655 
1656  print dol_get_fiche_end();
1657 
1658  print $form->buttonsSaveCancel("Modify");
1659 }
1660 
1661 // Edit Card
1662 if ($socid && $action == 'editcard' && $permissiontoaddupdatepaymentinformation) {
1663  print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company');
1664 
1665  $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
1666 
1667  dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
1668 
1669  print '<div class="fichecenter">';
1670 
1671  print '<div class="underbanner clearboth"></div>';
1672  print '<table class="border centpercent">';
1673 
1674  print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td>';
1675  print '<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.'"></td></tr>';
1676 
1677  print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>';
1678  print '<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->proprio.'"></td></tr>';
1679 
1680  print '<tr><td>'.$langs->trans("CardNumber").'</td>';
1681  print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.'"></td></tr>';
1682 
1683  print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>';
1684  print '<td>';
1685  print $formother->select_month($companypaymentmode->exp_date_month, 'exp_date_month', 1);
1686  print $formother->selectyear($companypaymentmode->exp_date_year, 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly');
1687  print '</td></tr>';
1688 
1689  print '<tr><td>'.$langs->trans("CVN").'</td>';
1690  print '<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.'"></td></tr>';
1691 
1692  print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>";
1693  print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.'"></td></tr>';
1694 
1695  print '</table>';
1696  print '</div>';
1697 
1698  print dol_get_fiche_end();
1699 
1700  print $form->buttonsSaveCancel("Modify");
1701 }
1702 
1703 
1704 // Create BAN
1705 if ($socid && $action == 'create' && $permissiontoaddupdatepaymentinformation) {
1706  print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company');
1707 
1708  $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
1709 
1710  dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
1711 
1712  print '<div class="nofichecenter">';
1713 
1714  print '<div class="underbanner clearboth"></div>';
1715  print '<table class="border centpercent">';
1716 
1717  print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("LabelRIB").'</td>';
1718  print '<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST('label').'"></td></tr>';
1719 
1720  print '<tr><td class="fieldrequired">'.$langs->trans("Bank").'</td>';
1721  print '<td><input class="minwidth200" type="text" name="bank" value="'.GETPOST('bank').'"></td></tr>';
1722 
1723  // Show fields of bank account
1724  foreach ($companybankaccount->getFieldsToShow(1) as $val) {
1725  $require = false;
1726  $tooltip = '';
1727  if ($val == 'BankCode') {
1728  $name = 'code_banque';
1729  $size = 8;
1730  $content = $companybankaccount->code_banque;
1731  } elseif ($val == 'DeskCode') {
1732  $name = 'code_guichet';
1733  $size = 8;
1734  $content = $companybankaccount->code_guichet;
1735  } elseif ($val == 'BankAccountNumber') {
1736  $name = 'number';
1737  $size = 18;
1738  $content = $companybankaccount->number;
1739  } elseif ($val == 'BankAccountNumberKey') {
1740  $name = 'cle_rib';
1741  $size = 3;
1742  $content = $companybankaccount->cle_rib;
1743  } elseif ($val == 'IBAN') {
1744  $name = 'iban';
1745  $size = 30;
1746  $content = $companybankaccount->iban;
1747  if ($companybankaccount->needIBAN()) {
1748  $require = true;
1749  }
1750  $tooltip = $langs->trans("Example").':<br>LT12 1000 0111 0100 1000<br>FR14 2004 1010 0505 0001 3M02 606<br>LU28 0019 4006 4475 0000<br>DE89 3704 0044 0532 0130 00';
1751  } elseif ($val == 'BIC') {
1752  $name = 'bic';
1753  $size = 12;
1754  $content = $companybankaccount->bic;
1755  if ($companybankaccount->needIBAN()) {
1756  $require = true;
1757  }
1758  $tooltip = $langs->trans("Example").': LIABLT2XXXX';
1759  }
1760 
1761  print '<tr><td'.($require ? ' class="fieldrequired" ' : '').'>';
1762  if ($tooltip) {
1763  print $form->textwithpicto($langs->trans($val), $tooltip, 4, 'help', '', 0, 3, $name);
1764  } else {
1765  print $langs->trans($val);
1766  }
1767  print '</td>';
1768  print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.GETPOST($name).'"></td>';
1769  print '</tr>';
1770  }
1771 
1772  print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
1773  print '<textarea name="domiciliation" rows="'.ROWS_4.'" class="quatrevingtpercent" maxlength="255">';
1774  print GETPOST('domiciliation');
1775  print "</textarea></td></tr>";
1776 
1777  print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
1778  print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio').'"></td></tr>';
1779  print "</td></tr>\n";
1780 
1781  print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
1782  print '<textarea name="owner_address" rows="'.ROWS_4.'" class="quatrevingtpercent" maxlength="255">';
1783  print GETPOST('owner_address');
1784  print "</textarea></td></tr>";
1785 
1786  print '</table>';
1787 
1788  if (isModEnabled('prelevement')) {
1789  print '<br>';
1790 
1791  print '<table class="border centpercent">';
1792 
1793  // RUM
1794  print '<tr><td class="titlefieldcreate">'.$langs->trans("RUM").'</td>';
1795  print '<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST('rum', 'alpha').'"> <div class="opacitymedium">'.$langs->trans("RUMWillBeGenerated").'</div></td></tr>';
1796 
1797  $date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth'), GETPOST('date_rumday'), GETPOST('date_rumyear'));
1798 
1799  print '<tr><td class="titlefieldcreate">'.$langs->trans("DateRUM").'</td>';
1800  print '<td colspan="4">'.$form->selectDate($date_rum, 'date_rum', 0, 0, 1, 'date_rum', 1, 1).'</td></tr>';
1801 
1802  print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
1803  $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
1804  print $form->selectarray("frstrecur", $tblArraychoice, (GETPOSTISSET('frstrecur') ? GETPOST('frstrecur') : 'FRST'), 0);
1805  print '</td></tr>';
1806 
1807  print '</table>';
1808  }
1809 
1810  print '</div>';
1811 
1812  print dol_get_fiche_end();
1813 
1814  dol_set_focus('#label');
1815 
1816  print $form->buttonsSaveCancel("Add");
1817 }
1818 
1819 // Create Card
1820 if ($socid && $action == 'createcard' && $permissiontoaddupdatepaymentinformation) {
1821  print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company');
1822 
1823  $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
1824 
1825  dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
1826 
1827  print '<div class="nofichecenter">';
1828 
1829  print '<div class="underbanner clearboth"></div>';
1830  print '<table class="border centpercent">';
1831 
1832  print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td>';
1833  print '<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST('label', 'alpha').'"></td></tr>';
1834 
1835  print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>';
1836  print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio', 'alpha').'"></td></tr>';
1837 
1838  print '<tr><td>'.$langs->trans("CardNumber").'</td>';
1839  print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST('cardnumber', 'alpha').'"></td></tr>';
1840 
1841  print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>';
1842  print '<td>';
1843  print $formother->select_month(GETPOST('exp_date_month', 'int'), 'exp_date_month', 1);
1844  print $formother->selectyear(GETPOST('exp_date_year', 'int'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly');
1845  print '</td></tr>';
1846 
1847  print '<tr><td>'.$langs->trans("CVN").'</td>';
1848  print '<td><input class="width50" type="text" name="cvn" value="'.GETPOST('cvn', 'alpha').'"></td></tr>';
1849 
1850  print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>";
1851  print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST('stripe_card_ref', 'alpha').'"></td></tr>';
1852 
1853  print '</table>';
1854 
1855  print '</div>';
1856 
1857  print dol_get_fiche_end();
1858 
1859  dol_set_focus('#label');
1860 
1861  print $form->buttonsSaveCancel("Add");
1862 }
1863 
1864 if ($socid && ($action == 'edit' || $action == 'editcard') && $permissiontoaddupdatepaymentinformation) {
1865  print '</form>';
1866 }
1867 if ($socid && ($action == 'create' || $action == 'createcard') && $permissiontoaddupdatepaymentinformation) {
1868  print '</form>';
1869 }
1870 
1871 // End of page
1872 llxFooter();
1873 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
ajax_combobox
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:438
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
restrictedArea
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
SocieteAccount
Class for SocieteAccount.
Definition: societeaccount.class.php:35
checkIbanForAccount
checkIbanForAccount(Account $account)
Check IBAN number informations for a bank account.
Definition: bank.lib.php:277
checkSwiftForAccount
checkSwiftForAccount($account)
Check SWIFT informations for a bank account.
Definition: bank.lib.php:261
showDirectDownloadLink
showDirectDownloadLink($object)
Return string with full Url.
Definition: functions.lib.php:9569
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4521
picto_from_langcode
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
Definition: functions.lib.php:8742
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormOther
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formother.class.php:39
FormAdmin
Class to generate html code for admin pages.
Definition: html.formadmin.class.php:30
CompanyBankAccount
Class to manage bank accounts description of third parties.
Definition: companybankaccount.class.php:34
checkBanForAccount
checkBanForAccount($account)
Check account number informations for a bank account.
Definition: bank.lib.php:299
dol_banner_tab
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Definition: functions.lib.php:2046
img_credit_card
img_credit_card($brand, $morecss=null)
Return image of a credit card according to its brand name.
Definition: functions.lib.php:4693
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
BonPrelevement
Class to manage withdrawal receipts.
Definition: bonprelevement.class.php:43
Exception
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
showValueWithClipboardCPButton
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
Definition: functions.lib.php:11087
dolGetButtonTitle
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Definition: functions.lib.php:10605
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
ModeleBankAccountDoc\liste_modeles
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Definition: modules_bank.php:48
EcmFiles
Class to manage ECM files.
Definition: ecmfiles.class.php:35
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
societe_prepare_head
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
dol_htmloutput_mesg
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
Definition: functions.lib.php:8299
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5026
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_set_focus
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
Definition: functions.lib.php:9379
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
Stripe
Stripe class.
Definition: stripe.class.php:29
price
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
Definition: functions.lib.php:5541
getCountry
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
Definition: company.lib.php:489
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
CompanyPaymentMode
Class for CompanyPaymentMode.
Definition: companypaymentmode.class.php:33
dol_mktime
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Definition: functions.lib.php:2757
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:93
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59