36require
'../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/societe/class/companypaymentmode.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
57$langs->loadLangs(array(
"companies",
"commercial",
"banks",
"bills",
'paypal',
'stripe',
'withdrawals'));
61$action =
GETPOST(
"action",
'alpha', 3);
62$cancel =
GETPOST(
'cancel',
'alpha');
63$backtopage =
GETPOST(
'backtopage');
66$source =
GETPOST(
"source",
"alpha");
72 $socid = $user->socid;
86$extrafields->fetch_name_optionals_label(
$object->table_element);
89$hookmanager->initHooks(array(
'thirdpartybancard',
'globalcard'));
92$permissiontoread = $user->hasRight(
'societe',
'lire');
93$permissiontoadd = $user->hasRight(
'societe',
'creer');
95$permissiontoaddupdatepaymentinformation = $user->hasRight(
'societe',
'thirdparty_paymentinformation',
'write');
106$site_account =
'UnknownSiteAccount';
110 $service =
'StripeTest';
112 $service =
'StripeLive';
117 global $stripearrayofkeysbyenv;
118 $site_account = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
120 $stripe =
new Stripe($db);
121 $stripeacc = $stripe->getStripeAccount($service);
122 $stripecu = $stripe->getStripeCustomerAccount(
$object->id, $servicestatus, $site_account);
137$parameters = array(
'id' => $socid);
138$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
140 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
143if (empty($reshook)) {
146 if (!empty($backtopage)) {
147 header(
"Location: ".$backtopage);
155 if (in_array($action, [
'update',
'updatecard',
'edit',
'editcard',
'setasbankdefault',
'confirm_deletecard',
'confirm_deletebank',
'synccardtostripe',
'syncsepatostripe'])) {
156 $idtocheckowner = ($ribid > 0 ? $ribid :
$id);
157 if ($idtocheckowner > 0) {
159 if ($tmppaymentinfo->fetch($idtocheckowner) <= 0 || $tmppaymentinfo->socid !=
$object->id) {
165 if ($action ==
'update' && $permissiontoaddupdatepaymentinformation) {
168 if (!
GETPOST(
'label',
'alpha')) {
169 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
172 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankName")),
null,
'errors');
177 $companybankaccount->fetch($id);
178 $companybankaccount->fk_country =
GETPOSTINT(
'account_country_id');
179 $companybankaccount->country_code =
getCountry($companybankaccount->fk_country,
'2');
180 if ($companybankaccount->needIBAN() == 1) {
182 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
187 if ($companybankaccount->needBIC() == 1) {
189 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
196 $companybankaccount->oldcopy =
dol_clone($companybankaccount, 2);
198 $companybankaccount->socid =
$object->id;
200 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
201 $companybankaccount->label =
GETPOST(
'label',
'alpha');
202 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
203 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
204 $companybankaccount->number =
GETPOST(
'number',
'alpha');
205 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
206 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
207 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
208 $companybankaccount->payment_reference =
GETPOST(
'payment_reference',
'alphanohtml');
210 $companybankaccount->currency_code =
GETPOST(
'account_currency_code',
'alpha');
211 $companybankaccount->state_id =
GETPOSTINT(
'account_state_id');
212 $companybankaccount->address =
GETPOST(
'address',
'alpha');
214 $companybankaccount->owner_name =
GETPOST(
'proprio',
'alpha');
215 $companybankaccount->proprio = $companybankaccount->owner_name;
216 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
217 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
218 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
219 $companybankaccount->date_rum =
GETPOSTDATE(
'date_rum',
'00:00:00');
220 if (empty($companybankaccount->rum)) {
221 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
224 $companybankaccount->status =
GETPOSTINT(
'clos');
226 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
228 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
230 $companybankaccount->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
232 $result = $companybankaccount->update($user);
235 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
239 if ($companybankaccount->default_rib) {
240 $companybankaccount->setAsDefault($id);
243 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
244 if ($companybankaccount->oldcopy->iban != $companybankaccount->iban) {
249 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
250 header(
'Location: '.$url);
256 if ($action ==
'updatecard' && $permissiontoaddupdatepaymentinformation) {
258 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
259 if (!
GETPOST(
'label',
'alpha')) {
260 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
262 if (!
GETPOST(
'proprio',
'alpha')) {
263 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
266 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
267 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
270 $action =
'createcard';
274 $companypaymentmode->fetch($id);
276 $companypaymentmode->oldcopy =
dol_clone($companypaymentmode, 2);
278 $companypaymentmode->fk_soc =
$object->id;
280 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
281 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
282 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
283 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
284 $companypaymentmode->owner_name =
GETPOST(
'proprio',
'alpha');
285 $companypaymentmode->proprio = $companypaymentmode->owner_name;
286 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
287 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
288 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
289 $companypaymentmode->country_code =
$object->country_code;
291 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
293 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
295 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
297 $result = $companypaymentmode->update($user);
299 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
302 if ($companypaymentmode->default_rib) {
303 $companypaymentmode->setAsDefault($id);
306 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
307 if ($companybankaccount->oldcopy->number != $companybankaccount->number) {
312 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
313 header(
'Location: '.$url);
320 if ($action ==
'add' && $permissiontoaddupdatepaymentinformation) {
323 if (!
GETPOST(
'label',
'alpha')) {
324 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
333 $companybankaccount->socid =
$object->id;
335 $companybankaccount->fetch_thirdparty();
337 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
338 $companybankaccount->label =
GETPOST(
'label',
'alpha');
339 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
340 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
341 $companybankaccount->number =
GETPOST(
'number',
'alpha');
342 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
343 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
344 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
345 $companybankaccount->payment_reference =
GETPOST(
'payment_reference',
'alphanohtml');
347 $companybankaccount->currency_code =
GETPOST(
'account_currency_code',
'alpha');
348 $companybankaccount->fk_country =
GETPOSTINT(
'account_country_id');
349 $companybankaccount->country_code =
getCountry($companybankaccount->fk_country,
'2');
350 $companybankaccount->state_id =
GETPOSTINT(
'account_state_id');
351 $companybankaccount->address =
GETPOST(
'address',
'alpha');
353 $companybankaccount->owner_name =
GETPOST(
'proprio',
'alpha');
354 $companybankaccount->proprio = $companybankaccount->owner_name;
355 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
356 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
357 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
358 $companybankaccount->date_rum =
GETPOSTDATE(
'date_rum',
'00:00:00');
359 $companybankaccount->datec =
dol_now();
361 $companybankaccount->status =
GETPOSTINT(
'clos');
363 $companybankaccount->bank = trim($companybankaccount->bank);
364 if (empty($companybankaccount->bank) && !empty($companybankaccount->thirdparty)) {
365 $companybankaccount->bank = $langs->trans(
"Bank").
' '.$companybankaccount->thirdparty->name;
367 $companybankaccount->bic = str_replace(
' ',
'', $companybankaccount->bic);
372 if ($companybankaccount->needIBAN() == 1) {
374 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
379 if ($companybankaccount->needBIC() == 1) {
381 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
388 $result = $companybankaccount->create($user);
391 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
395 if (empty($companybankaccount->rum)) {
396 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
401 $result = $companybankaccount->update($user);
404 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
412 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
413 header(
'Location: '.$url);
422 if ($action ==
'addcard' && $permissiontoaddupdatepaymentinformation) {
425 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
426 if (!
GETPOST(
'label',
'alpha')) {
427 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
429 if (!
GETPOST(
'proprio',
'alpha')) {
430 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
433 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
434 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
437 $action =
'createcard';
445 $companypaymentmode->fk_soc =
$object->id;
446 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
447 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
448 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
449 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
450 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
451 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
452 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
453 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
454 $companypaymentmode->datec =
dol_now();
455 $companypaymentmode->default_rib = 0;
456 $companypaymentmode->type =
'card';
457 $companypaymentmode->country_code =
$object->country_code;
458 $companypaymentmode->status = $servicestatus;
460 if (
GETPOST(
'stripe_card_ref',
'alpha')) {
462 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
464 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
469 $result = $companypaymentmode->create($user);
472 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
473 $action =
'createcard';
480 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
481 header(
'Location: '.$url);
489 if ($action ==
'setasbankdefault' &&
GETPOSTINT(
'ribid') > 0 && $permissiontoaddupdatepaymentinformation) {
491 $res = $companybankaccount->setAsDefault(
GETPOSTINT(
'ribid'));
493 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
494 header(
'Location: '.$url);
497 setEventMessages($db->lasterror,
null,
'errors');
501 if ($action ==
'confirm_deletecard' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoaddupdatepaymentinformation) {
504 if ($companypaymentmode->fetch($ribid ? $ribid :
$id)) {
515 $result = $companypaymentmode->delete($user);
517 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
519 header(
'Location: '.$url);
522 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
525 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
528 if ($action ==
'confirm_deletebank' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoaddupdatepaymentinformation) {
531 if ($companybankaccount->fetch($ribid ? $ribid :
$id) > 0) {
542 $result = $companybankaccount->delete($user);
545 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
547 header(
'Location: '.$url);
550 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
553 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
560 if ($action ==
'builddocrib' && $permissiontoread) {
561 $action =
'builddoc';
563 'use_companybankid' =>
GETPOST(
'companybankid'),
566 $_POST[
'lang_id'] =
GETPOST(
'lang_idrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
567 $_POST[
'model'] =
GETPOST(
'modelrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
572 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
578 if (($action ==
'synccustomertostripe' || $action ==
'synccustomertostripetest') && $permissiontoaddupdatepaymentinformation) {
581 setEventMessages(
'ThisThirdpartyIsNotACustomer',
null,
'errors');
583 if ($action ==
'synccustomertostripe') {
584 $tmpservicestatus = 1;
585 $tmpservice =
'StripeLive';
587 $tmpservicestatus = 0;
588 $tmpservice =
'StripeTest';
591 $stripe =
new Stripe($db);
592 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
595 $tmpcu = $stripe->customerStripe($object, $tmpstripeacc, $tmpservicestatus, 1);
599 setEventMessages($stripe->error, $stripe->errors,
'errors');
601 if ($tmpservicestatus == $servicestatus) {
602 $stripecu = $tmpcu->id;
607 if ($action ==
'synccardtostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
610 $companypaymentmode->fetch($id);
612 if ($companypaymentmode->type !=
'card') {
614 setEventMessages(
'ThisPaymentModeIsNotACard',
null,
'errors');
617 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
620 setEventMessages($stripe->error, $stripe->errors,
'errors');
624 '@phan-var-force \Stripe\Customer $cu';
628 $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
631 setEventMessages($stripe->error, $stripe->errors,
'errors');
636 if ($action ==
'syncsepatostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
639 $companypaymentmode->fetch($id);
641 if ($companypaymentmode->type !=
'ban') {
643 $langs->load(
"errors");
644 setEventMessages(
'ThisPaymentModeIsNotABan',
null,
'errors');
647 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
651 $langs->load(
"errors");
652 setEventMessages($langs->trans(
"ErrorStripeCustomerNotFoundCreateFirst"),
null,
'errors');
655 '@phan-var-force \Stripe\Customer $cu';
657 $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
660 setEventMessages($stripe->error, $stripe->errors,
'errors');
662 setEventMessages(
"", array(
"Bank Account on Stripe",
"BAN is now linked to the Stripe customer account !"));
669 if (($action ==
'setkey_account' || $action ==
'setkey_accounttest') && $permissiontoaddupdatepaymentinformation) {
672 $tmpservice =
'StripeTest';
673 $tmpservicestatus = 0;
674 if ($action ==
'setkey_account') {
675 $tmpservice =
'StripeLive';
676 $tmpservicestatus = 1;
680 global $stripearrayofkeysbyenv;
681 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
683 if ($action ==
'setkey_account') {
684 $newcu =
GETPOST(
'key_account',
'alpha');
686 $newcu =
GETPOST(
'key_accounttest',
'alpha');
692 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_account";
693 $sql .=
" WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($tmpsite_account).
"') AND fk_soc = ".((int)
$object->id).
" AND status = ".((int) $tmpservicestatus).
" AND entity = ".((int)
$conf->entity);
695 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_account";
696 $sql .=
" WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($tmpsite_account).
"') AND fk_soc = ".((int)
$object->id).
" AND status = ".((int) $tmpservicestatus).
" AND entity = ".((int)
$conf->entity);
699 $resql = $db->query($sql);
700 $num = $db->num_rows($resql);
702 if (!empty($newcu)) {
705 $societeaccount->fk_soc =
$object->id;
706 $societeaccount->login =
'';
707 $societeaccount->pass_encoding =
'';
708 $societeaccount->site =
'stripe';
709 $societeaccount->status = $servicestatus;
710 $societeaccount->key_account = $newcu;
711 $societeaccount->site_account = $tmpsite_account;
712 $result = $societeaccount->create($user);
717 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"societe_account";
718 $sql .=
" SET key_account = '".$db->escape($newcu).
"', site_account = '".$db->escape($tmpsite_account).
"'";
719 $sql .=
" WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($tmpsite_account).
"') AND fk_soc = ".((int)
$object->id).
" AND status = ".((int) $tmpservicestatus).
" AND entity = ".((int)
$conf->entity);
720 $resql = $db->query($sql);
728 if ($tmpservicestatus == $servicestatus) {
738 if (($action ==
'setkey_account_supplier' || $action ==
'setkey_account_suppliertest') && $permissiontoaddupdatepaymentinformation) {
741 $tmpservice =
'StripeTest';
742 $tmpservicestatus = 0;
743 if ($action ==
'setkey_account_supplier') {
744 $tmpservice =
'StripeLive';
745 $tmpservicestatus = 1;
749 global $stripearrayofkeysbyenv;
750 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
752 if ($action ==
'setkey_account_supplier') {
753 $newsup =
GETPOST(
'key_account_supplier',
'alpha');
755 $newsup =
GETPOST(
'key_account_suppliertest',
'alpha');
761 if (empty($newsup)) {
762 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"oauth_token WHERE fk_soc = ".((int)
$object->id).
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".((int)
$conf->entity);
767 $stripesup = \Stripe\Account::retrieve($newsup);
768 $tokenstring = array();
769 $tokenstring[
'stripe_user_id'] = $stripesup->id;
770 $tokenstring[
'type'] = $stripesup->type;
771 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"oauth_token";
772 $sql .=
" SET tokenstring = '".$db->escape(json_encode($tokenstring)).
"'";
773 $sql .=
" WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($tmpsite_account).
"') AND fk_soc = ".((int)
$object->id).
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".((int)
$conf->entity);
775 $sql .=
" WHERE fk_soc = ".((int)
$object->id).
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".((int)
$conf->entity);
778 setEventMessages($e->getMessage(),
null,
'errors');
782 $resql = $db->query($sql);
783 $num = $db->num_rows($resql);
784 if (empty($num) && !empty($newsup)) {
786 $stripesup = \Stripe\Account::retrieve($newsup);
787 $tokenstring[
'stripe_user_id'] = $stripesup->id;
788 $tokenstring[
'type'] = $stripesup->type;
789 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"oauth_token (service, fk_soc, entity, tokenstring)";
790 $sql .=
" VALUES ('".$db->escape($tmpservice).
"', ".((int)
$object->id).
", ".((int)
$conf->entity).
", '".$db->escape(json_encode($tokenstring)).
"')";
794 setEventMessages($e->getMessage(),
null,
'errors');
796 $resql = $db->query($sql);
800 if ($tmpservicestatus == $servicestatus) {
801 $stripesupplieracc = $newsup;
809 if ($action ==
'setlocalassourcedefault' && $permissiontoaddupdatepaymentinformation) {
811 $companypaymentmode->setAsDefault($id);
813 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
814 header(
'Location: '.$url);
818 setEventMessages($e->getMessage(),
null,
'errors');
820 } elseif ($action ==
'setassourcedefault' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
822 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
823 if (preg_match(
'/pm_|src_/', $source)) {
824 $cu->invoice_settings->default_payment_method = (string) $source;
826 $cu->default_source = (string) $source;
829 $result = $cu->save();
831 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
832 header(
'Location: '.$url);
836 setEventMessages($e->getMessage(),
null,
'errors');
838 } elseif ($action ==
'deletecard' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
841 if (preg_match(
'/pm_/', $source)) {
842 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
843 if ($payment_method) {
844 $payment_method->detach();
847 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
848 $card = $cu->sources->retrieve(
"$source");
851 if (method_exists($card,
'detach')) {
853 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
854 $sql .=
" SET stripe_card_ref = null";
855 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
857 $resql = $db->query($sql);
864 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
865 header(
'Location: '.$url);
869 setEventMessages($e->getMessage(),
null,
'errors');
871 } elseif ($action ==
'deletebank' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
874 if (preg_match(
'/pm_/', $source)) {
875 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
876 if ($payment_method) {
877 $payment_method->detach();
880 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
881 $card = $cu->sources->retrieve((
string) $source);
884 if (method_exists($card,
'detach')) {
886 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
887 $sql .=
" SET stripe_card_ref = null";
888 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
890 $resql = $db->query($sql);
897 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
899 $url .=
'&page_y='.GETPOSTINT(
'page_y');
902 header(
'Location: '.$url);
906 setEventMessages($e->getMessage(),
null,
'errors');
918$form =
new Form($db);
923$countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
925$title = $langs->trans(
"ThirdParty");
927 $title =
$object->name.
" - ".$langs->trans(
'PaymentInformation');
940 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'), [],
'warning');
945 $companybankaccount->fetch($id);
946 $companypaymentmode->fetch($id);
947} elseif (!in_array($action, array(
'create',
'createcard'))) {
949 $companybankaccount->fetch(0,
'',
$object->id);
951 $companypaymentmode->fetch(0,
'',
$object->id,
'card');
953if (empty($companybankaccount->socid)) {
954 $companybankaccount->socid =
$object->id;
957if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
958 if ($action ==
'edit' &&
$conf->use_javascript_ajax) {
960 print
"\n".
'<script type="text/javascript">';
961 print
'jQuery(document).ready(function () {
962 jQuery("#selectaccount_country_id").change(function() {
963 document.formbank.action.value="edit";
964 document.formbank.submit();
967 print
'</script>'.
"\n";
969 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post" name="formbank" spellcheck="false">';
970 print
'<input type="hidden" name="token" value="'.newToken().
'">';
971 $actionforadd =
'update';
972 if ($action ==
'editcard') {
973 $actionforadd =
'updatecard';
975 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
976 print
'<input type="hidden" name="id" value="'.GETPOSTINT(
"id").
'">';
978if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
979 if ($action ==
'create' &&
$conf->use_javascript_ajax) {
981 print
"\n".
'<script type="text/javascript">';
982 print
'jQuery(document).ready(function () {
983 jQuery("#selectaccount_country_id").change(function() {
984 document.formbank.action.value="create";
985 document.formbank.submit();
988 print
'</script>'.
"\n";
990 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post" name="formbank" spellcheck="false">';
991 print
'<input type="hidden" name="token" value="'.newToken().
'">';
992 $actionforadd =
'add';
993 if ($action ==
'createcard') {
994 $actionforadd =
'addcard';
996 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
1000if ($socid && $action !=
'edit' && $action !=
'create' && $action !=
'editcard' && $action !=
'createcard') {
1004 if ($action ==
'deletebank') {
1005 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".
$object->id.
"&ribid=".($ribid ? $ribid :
$id), $langs->trans(
"DeleteARib"), $langs->trans(
"ConfirmDeleteRib", $companybankaccount->getRibLabel()),
"confirm_deletebank",
'', 0, 1);
1008 if ($action ==
'deletecard') {
1009 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);
1012 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1014 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
1016 print
'<div class="fichecenter">';
1018 print
'<div class="underbanner clearboth"></div>';
1019 print
'<table class="border tableforfield centpercent">';
1022 print
'<tr><td class="titlefield">';
1023 print $langs->trans(
'NatureOfThirdParty');
1029 print
'<tr><td class="titlefield">';
1030 print $langs->trans(
'CustomerCode');
1033 $tmpcheck =
$object->check_codeclient();
1034 if ($tmpcheck != 0 && $tmpcheck != -5) {
1035 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
1038 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
1039 $resql = $db->query($sql);
1041 dol_print_error($db);
1044 $obj = $db->fetch_object($resql);
1045 $nbFactsClient = $obj->nb;
1046 $thirdTypeArray = array();
1047 $elementTypeArray = array();
1048 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
1049 if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
1050 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
1052 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
1053 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1055 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1056 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1058 if (
isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1059 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1064 global $stripearrayofkeysbyenv;
1067 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1068 $tmpstripeacc = $stripe->getStripeAccount((
string) $tmpservice);
1069 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1072 print
'<tr><td class="titlefield">';
1073 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1074 print
'</td><td'.(empty($tmpstripecu) ?
' class="right"' :
'').
'>';
1075 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu,
$object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1076 if ($tmpstripecu && $action !=
'editkey_accounttest') {
1078 if (!empty($stripeacc)) {
1079 $connect = $stripeacc.
'/';
1081 $url =
'https://dashboard.stripe.com/'.$connect.
'test/customers/'.$tmpstripecu;
1082 print
' <a href="'.$url.
'" target="_stripe">'.img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1084 if (empty($tmpstripecu)) {
1085 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" class="nowraponall" spellcheck="false">';
1086 print
'<input type="hidden" name="action" value="synccustomertostripetest">';
1087 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1088 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1089 print img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1090 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomertest" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1096 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1097 $tmpstripeacc = $stripe->getStripeAccount((
string) $tmpservice);
1098 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1101 print
'<tr><td class="titlefield">';
1102 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1103 print
'</td><td'.(empty($tmpstripecu) ?
' class="right"' :
'').
'>';
1104 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu,
$object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1105 if ($tmpstripecu && $action !=
'editkey_account') {
1107 if (!empty($stripeacc)) {
1108 $connect = $stripeacc.
'/';
1110 $url =
'https://dashboard.stripe.com/'.$connect.
'customers/'.$tmpstripecu;
1111 print
' <a href="'.$url.
'" target="_stripe">'.img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1113 if (empty($tmpstripecu)) {
1114 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" class="nowraponall" spellcheck="false">';
1115 print
'<input type="hidden" name="action" value="synccustomertostripe">';
1116 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1117 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1118 print img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1119 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomer" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1127 print
'<tr><td class="titlefield">';
1128 print $langs->trans(
'SupplierCode');
1131 $tmpcheck =
$object->check_codefournisseur();
1132 if ($tmpcheck != 0 && $tmpcheck != -5) {
1133 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
1136 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
1137 $resql = $db->query($sql);
1139 dol_print_error($db);
1141 $obj = $db->fetch_object($resql);
1142 $nbFactsClient = $obj->nb;
1143 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
1144 if (
isModEnabled(
'propal') && $user->hasRight(
'propal',
'lire')) {
1145 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
1147 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
1148 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1150 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1151 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1153 if (
isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1154 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1160 $stripesupplieracc = $stripe->getStripeAccount($service,
$object->id);
1163 print
'<tr><td class="titlefield">';
1164 print $form->editfieldkey(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1165 print
'</td><td'.(empty($stripesupplieracc) ?
' class="right"' :
'').
'>';
1166 print $form->editfieldval(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1167 if ($stripesupplieracc && $action !=
'editkey_account_supplier') {
1170 $url =
'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc;
1171 if ($servicestatus) {
1172 $url =
'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc;
1174 print
' <a href="'.$url.
'" target="_stripe">'.img_picto($langs->trans(
'ShowInStripe').
' - Publishable key '.$site_account,
'globe').
'</a>';
1176 if (empty($stripesupplieracc)) {
1177 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" class="nowraponall" spellcheck="false">';
1178 print
'<input type="hidden" name="action" value="syncsuppliertostripe">';
1179 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1180 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1181 print
'<input type="hidden" name="companybankid" value="'.$ribid.
'">';
1195 $showcardpaymentmode = 0;
1197 $showcardpaymentmode++;
1201 $listofsources = array();
1203 $customerstripe =
null;
1204 if (isset($stripe) && is_object($stripe) && $stripeacc !==
null) {
1206 $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus);
1207 if (!empty($customerstripe->id)) {
1210 $listofsources = $customerstripe->sources->data;
1212 $service =
'StripeTest';
1215 $service =
'StripeLive';
1220 global $stripearrayofkeysbyenv;
1221 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
1224 if (empty($stripeacc)) {
1225 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"));
1226 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"));
1228 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"), array(
"stripe_account" => $stripeacc));
1229 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"), array(
"stripe_account" => $stripeacc));
1232 if ($paymentmethodobjsA->data !=
null && $paymentmethodobjsB->data !=
null) {
1233 $listofsources = array_merge((array) $paymentmethodobjsA->data, (array) $paymentmethodobjsB->data);
1234 } elseif ($paymentmethodobjsB->data !=
null) {
1235 $listofsources = $paymentmethodobjsB->data;
1237 $listofsources = $paymentmethodobjsA->data;
1241 setEventMessages($e->getMessage(),
null,
'errors');
1246 dol_syslog(
"Error when searching/loading Stripe customer for thirdparty id =".
$object->id);
1252 if ($showcardpaymentmode &&
$object->client) {
1253 $morehtmlright =
'';
1255 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=createcard');
1257 print
load_fiche_titre($langs->trans(
'CreditCard'), $morehtmlright,
'fa-credit-card');
1260 print
'<!-- List of card payments -->'.
"\n";
1261 print
'<div class="div-table-responsive-no-min">';
1262 print
'<table class="liste centpercent noborder">'.
"\n";
1263 print
'<tr class="liste_titre">';
1264 print
'<td>'.$langs->trans(
'Label').
'</td>';
1265 print
'<td>'.$form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")).
'</td>';
1266 print
'<td>'.$langs->trans(
'Type').
'</td>';
1267 print
'<td>'.$langs->trans(
'Informations').
'</td>';
1269 print
'<td class="center">'.$langs->trans(
'Default').
'</td>';
1270 print
'<td>'.$langs->trans(
'Note').
'</td>';
1271 print
'<td>'.$langs->trans(
'DateModification').
'</td>';
1273 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'stripetitle');
1274 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
1275 print $hookmanager->resPrint;
1282 $arrayofremotecard = array();
1289 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_rib";
1290 $sql .=
" WHERE type in ('card')";
1291 $sql .=
" AND fk_soc = ".((int)
$object->id);
1292 $sql .=
" AND status = ".((int) $servicestatus);
1294 $resql = $db->query($sql);
1296 $num_rows = $db->num_rows($resql);
1299 while ($i < $num_rows) {
1302 $obj = $db->fetch_object($resql);
1304 $companypaymentmodetemp->fetch($obj->rowid);
1306 $arrayofremotecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref;
1308 print
'<tr class="oddeven" data-rowid="'.((int) $companypaymentmodetemp->id).
'">';
1310 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->label).
'">';
1314 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->stripe_card_ref.(empty($companypaymentmodetemp->stripe_account) ?
'' :
' - '.$companypaymentmodetemp->stripe_account)).
'">';
1315 if (!empty($companypaymentmodetemp->stripe_card_ref) && !empty($companypaymentmodetemp->ext_payment_site)) {
1316 if (
isModEnabled(
'stripe') && in_array($companypaymentmodetemp->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1318 if (!empty($stripeacc)) {
1319 $connect = $stripeacc.
'/';
1321 if ($companypaymentmodetemp->ext_payment_site ==
'StripeLive') {
1322 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$companypaymentmodetemp->stripe_card_ref;
1324 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
1326 print
"<a href='".$url.
"' target='_stripe'>".img_picto($langs->trans(
'ShowInStripe').
' - '.$companypaymentmodetemp->stripe_account,
'globe').
"</a> ";
1337 print
'<td class="minwidth100">';
1338 if ($companypaymentmodetemp->owner_name) {
1339 print
'<span class="opacitymedium">'.$companypaymentmodetemp->owner_name.
'</span><br>';
1341 if ($companypaymentmodetemp->last_four) {
1342 print
'....'.$companypaymentmodetemp->last_four;
1344 if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) {
1345 print
' - '.sprintf(
"%02d", $companypaymentmodetemp->exp_date_month).
'/'.$companypaymentmodetemp->exp_date_year;
1349 print
'<td class="tdoverflowmax100">';
1350 if ($companypaymentmodetemp->country_code) {
1352 print $img ? $img.
' ' :
'';
1353 print
getCountry($companypaymentmodetemp->country_code,
'1');
1355 print img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1359 print
'<td class="center">';
1360 if (empty($companypaymentmodetemp->default_rib)) {
1361 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=setlocalassourcedefault&token='.
newToken().
'">';
1362 print img_picto($langs->trans(
"Default"),
'off');
1365 print img_picto($langs->trans(
"Default"),
'on');
1368 if (empty($companypaymentmodetemp->stripe_card_ref)) {
1369 $s = $langs->trans(
"Local");
1371 $s = $langs->trans(
"LocalAndRemote");
1373 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1377 print
dol_print_date($companypaymentmodetemp->date_modification,
'dayhour',
'tzuserrel');
1380 $parameters = array(
'arrayfields' => array(),
'obj' => $obj,
'linetype' =>
'stripecard');
1381 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1382 print $hookmanager->resPrint;
1384 print
'<td class="right minwidth50 nowraponall">';
1385 if ($permissiontoaddupdatepaymentinformation) {
1386 if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) {
1387 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=synccardtostripe&token='.
newToken().
'&socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'" class="paddingrightonly marginrightonly">'.$langs->trans(
"CreateCardOnStripe").
'</a>';
1390 print
'<a class="editfielda marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=editcard&token='.
newToken().
'">';
1391 print img_picto($langs->trans(
"Modify"),
'edit');
1393 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=deletecard&token='.
newToken().
'">';
1394 print img_picto($langs->trans(
"Delete"),
'delete');
1404 dol_print_error($db);
1409 if (is_array($listofsources) && count($listofsources)) {
1410 foreach ($listofsources as $src) {
1411 if (!empty($arrayofremotecard[$src->id])) {
1418 if ($src->object ==
'card') {
1420 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1422 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1424 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1426 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1430 print
'<tr class="oddeven">';
1434 print
'<td class="tdoverflowmax150">';
1436 if (!empty($stripeacc)) {
1437 $connect = $stripeacc.
'/';
1440 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1441 if ($servicestatus) {
1443 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1445 print
"<a href='".$url.
"' target='_stripe'>".img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1453 print
'<td valign="middle">';
1454 if ($src->object ==
'card') {
1455 print
'....'.$src->last4.
' - '.$src->exp_month.
'/'.$src->exp_year;
1457 if ($src->country) {
1459 print $img ? $img.
' ' :
'';
1462 print img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1464 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1465 print
'<span class="opacitymedium">'.$src->owner->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1468 if ($src->card->country) {
1470 print $img ? $img.
' ' :
'';
1473 print img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1475 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1476 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1478 if ($src->sepa_debit->country) {
1480 print $img ? $img.
' ' :
'';
1481 print
getCountry($src->sepa_debit->country,
'1');
1483 print img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1485 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1486 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1489 if ($src->card->country) {
1491 print $img ? $img.
' ' :
'';
1494 print img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1496 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1497 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1499 if ($src->sepa_debit->country) {
1501 print $img ? $img.
' ' :
'';
1502 print
getCountry($src->sepa_debit->country,
'1');
1504 print img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1511 print
'<td class="center" width="50">';
1512 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1513 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1514 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1515 print img_picto($langs->trans(
"Default"),
'off');
1518 print img_picto($langs->trans(
"Default"),
'on');
1522 print $langs->trans(
"Remote");
1531 $parameters = array(
'arrayfields' => array(),
'stripesource' => $src,
'linetype' =>
'stripecardremoteonly');
1532 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1533 print $hookmanager->resPrint;
1536 print
'<td class="right nowraponall">';
1537 if ($permissiontoaddupdatepaymentinformation) {
1538 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletecard&token='.
newToken().
'">';
1539 print img_picto($langs->trans(
"Delete"),
'delete');
1548 if ($nbremote == 0 && $nblocal == 0) {
1550 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1558 if (
isModEnabled(
'stripe') && !empty(
$conf->stripeconnect->enabled) && !empty($stripesupplieracc)) {
1559 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');
1560 $balance = \Stripe\Balance::retrieve(array(
"stripe_account" => $stripesupplieracc));
1561 print
'<!-- List of Stripe connected accounts -->'.
"\n";
1562 print
'<table class="liste centpercent noborder">'.
"\n";
1563 print
'<tr class="liste_titre">';
1564 print
'<td>'.$langs->trans(
'Currency').
'</td>';
1565 print
'<td>'.$langs->trans(
'Available').
'</td>';
1566 print
'<td>'.$langs->trans(
'Pending').
'</td>';
1567 print
'<td>'.$langs->trans(
'Total').
'</td>';
1570 $currencybalance = array();
1571 if (is_array($balance->available) && count($balance->available)) {
1572 foreach ($balance->available as $cpt) {
1573 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1574 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1575 $currencybalance[$cpt->currency][
'available'] = $cpt->amount / 100;
1577 $currencybalance[$cpt->currency][
'available'] = $cpt->amount;
1579 $currencybalance[$cpt->currency][
'currency'] = $cpt->currency;
1583 if (is_array($balance->pending) && count($balance->pending)) {
1584 foreach ($balance->pending as $cpt) {
1585 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1586 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1587 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount / 100;
1589 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount;
1594 if (is_array($currencybalance)) {
1595 foreach ($currencybalance as $cpt_arr) {
1596 print
'<tr><td>'.$langs->trans(
"Currency".strtoupper($cpt_arr[
'currency'])).
'</td><td>'.
price($cpt_arr[
'available'], 0,
'', 1, - 1, - 1, strtoupper($cpt_arr[
'currency'])).
'</td><td>'.
price(isset($cpt_arr[
'pending']) ? $cpt_arr[
'pending'] : 0, 0,
'', 1, - 1, - 1, strtoupper($cpt_arr[
'currency'])).
'</td><td>'.
price($cpt_arr[
'available'] + (isset($cpt_arr[
'pending']) ? $cpt_arr[
'pending'] : 0), 0,
'', 1, - 1, - 1, strtoupper($cpt_arr[
'currency'])).
'</td></tr>';
1606 if ($permissiontoaddupdatepaymentinformation) {
1607 $morehtmlright =
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"] .
'?socid=' .
$object->id .
'&action=create');
1610 print
load_fiche_titre($langs->trans(
"BankAccounts"), $morehtmlright,
'bank');
1614 $arrayofremoteban = array();
1616 $rib_list =
$object->get_all_rib();
1618 if (is_array($rib_list)) {
1619 print
'<!-- List of bank accounts -->'.
"\n";
1620 print
'<div class="div-table-responsive-no-min">';
1621 print
'<table class="liste centpercent noborder">';
1623 print
'<tr class="liste_titre">';
1625 print_liste_field_titre($form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")));
1630 print_liste_field_titre($form->textwithpicto($langs->trans(
'PaymentReferenceOfAccount'), $langs->trans(
'PaymentReferenceOfAccountHelp')));
1641 $parameters = array(
'arrayfields' => array(),
'linetype' =>
'stripebantitle');
1642 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1643 print $hookmanager->resPrint;
1648 foreach ($rib_list as $rib) {
1649 $arrayofremoteban[$rib->stripe_card_ref] = $rib->stripe_card_ref;
1653 print
'<tr class="oddeven">';
1655 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($rib->label).
'">'.dolPrintHTML($rib->label);
1656 print
'<br><span class="opacitymedium">'.dolPrintHTML($rib->bank).
'</span>';
1660 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->stripe_card_ref.(empty($rib->stripe_account) ?
'' :
' - '.$rib->stripe_account)).
'">';
1661 if (!empty($rib->stripe_card_ref) && !empty($rib->ext_payment_site)) {
1662 if (
isModEnabled(
'stripe') && in_array($rib->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1664 if (!empty($stripeacc)) {
1665 $connect = $stripeacc.
'/';
1667 if ($rib->ext_payment_site ==
'StripeLive') {
1668 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$rib->stripe_card_ref;
1670 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$rib->stripe_card_ref;
1672 print
"<a href='".$url.
"' target='_stripe'>".img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1684 foreach ($rib->getFieldsToShow() as $val) {
1685 if ($val ==
'BankCode') {
1686 $string .= $rib->code_banque.
' ';
1687 } elseif ($val ==
'BankAccountNumber') {
1688 $string .= $rib->number.
' ';
1689 } elseif ($val ==
'DeskCode') {
1690 $string .= $rib->code_guichet.
' ';
1691 } elseif ($val ==
'BankAccountNumberKey') {
1692 $string .= $rib->cle_rib.
' ';
1701 if (!empty($rib->label) && $rib->number) {
1703 $label = $isValid ?
"ValueIsValid" :
"ValueIsNotValid";
1704 $picto = $isValid ?
'info' :
'warning';
1705 $string = img_picto($langs->trans($label), $picto,
'class="pictofixedwidth"').$string;
1707 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($string).
'">';
1712 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->iban).
'">';
1713 if (!empty($rib->iban)) {
1715 print img_picto($langs->trans(
"IbanNotValid"),
'warning').
' ';
1722 if (!empty($rib->bic)) {
1724 print img_picto($langs->trans(
"SwiftNotValid"),
'warning').
' ';
1731 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute((
string) $rib->payment_reference).
'">'.dolPrintHTML((
string) $rib->payment_reference).
'</td>';
1735 print
'<td class="tdoverflowmax100 small" title="'.dolPrintHTMLForAttribute($rib->rum).
'">'.dolPrintHTML($rib->rum);
1736 print
'<br><span class="opacitymedium">'.dolPrintHTML($rib->frstrecur).
'</span>';
1740 print
'<td>'.dol_print_date($rib->date_rum,
'day').
'</td>';
1744 print
'<td class="center" width="70">';
1745 if (!$rib->default_rib) {
1746 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?socid='.((int)
$object->id).
'&ribid='.((int) $rib->id).
'&action=setasbankdefault&token='.
newToken().
'">';
1747 print img_picto($langs->trans(
"Disabled"),
'off');
1750 print img_picto($langs->trans(
"Enabled"),
'on');
1755 print
'<td class="center">';
1757 $buttonlabel = $langs->trans(
"BuildDoc");
1758 $forname =
'builddocrib'.$rib->id;
1760 include_once DOL_DOCUMENT_ROOT.
'/core/modules/bank/modules_bank.php';
1764 if (is_array($modellist) && count($modellist)) {
1765 $out .=
'<form action="'.$_SERVER[
"PHP_SELF"].(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#builddoc').
'" name="'.$forname.
'" id="'.$forname.
'_form" method="post" autocomplete="off" spellcheck="false">';
1766 $out .=
'<input type="hidden" name="action" value="builddocrib">';
1767 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1768 $out .=
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1769 $out .=
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1771 $modelselected =
'';
1772 if (count($modellist) == 1) {
1773 $arraykeys = array_keys($modellist);
1774 $modelselected = $arraykeys[0];
1780 $morecss =
'maxwidth125';
1781 if (
$conf->browser->layout ==
'phone') {
1782 $morecss =
'maxwidth100';
1785 $out .= $form->selectarray(
'modelrib'.$rib->id, $modellist, $modelselected, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 '.$morecss);
1790 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
1792 $defaultlang = $langs->getDefaultLang();
1793 $out .= $formadmin->select_language($defaultlang,
'lang_idrib'.$rib->id, 0, array(), 0, 0, 0, $morecss);
1796 $out .=
'<input class="button buttongen reposition nomargintop nomarginbottom small '.$morecss.
'" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
1797 $out .=
' type="submit" value="'.$buttonlabel.
'"';
1805 $parameters = array(
'arrayfields' => array(),
'stripe_card_ref' => $rib->stripe_card_ref,
'stripe_account' => $rib->stripe_account,
'linetype' =>
'stripeban');
1806 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1807 print $hookmanager->resPrint;
1811 print
'<td class="minwidth200 width200">';
1812 $useonlinesignature = 1;
1813 if ($useonlinesignature) {
1814 $rib->entity =
$object->entity;
1815 require_once DOL_DOCUMENT_ROOT .
'/core/lib/signature.lib.php';
1816 print showOnlineSignatureUrl($companybankaccount->element, (
string) $rib->id, $rib,
'short');
1822 print
'<td class="right nowraponall">';
1823 if ($permissiontoaddupdatepaymentinformation) {
1825 if (empty($rib->stripe_card_ref)) {
1828 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=syncsepatostripe&token='.
newToken().
'">';
1829 print img_picto($langs->trans(
"CreateBANOnStripe"),
'stripe');
1832 print
'<span class="opacitymedium marginrightonly marginleftonly">';
1833 print img_picto($langs->trans(
"ThirdPartyMustBeACustomerToCreateBANOnStripe"),
'stripe');
1839 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=edit">';
1840 print img_picto($langs->trans(
"Modify"),
'edit');
1843 print
'<a class="marginrightonly marginleftonly reposition" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=deletebank&token='.
newToken().
'">';
1844 print img_picto($langs->trans(
"Delete"),
'delete');
1854 foreach ($listofsources as $src) {
1855 if (!empty($arrayofremoteban[$src->id])) {
1860 if ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1861 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1862 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1863 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1870 print
'<tr class="oddeven">';
1875 print
'<td class="tdoverflowmax150">';
1877 if (!empty($stripeacc)) {
1878 $connect = $stripeacc.
'/';
1881 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1882 if ($servicestatus) {
1884 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1886 print
"<a href='".$url.
"' target='_stripe'>".img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1917 print
'<td class="center" width="50">';
1918 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1919 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1920 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1921 print img_picto($langs->trans(
"Default"),
'off');
1924 print img_picto($langs->trans(
"Default"),
'on');
1939 $parameters = array(
'arrayfields' => array(),
'src' => $src,
'linetype' =>
'stripebanremoteonly');
1940 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1941 print $hookmanager->resPrint;
1944 print
'<td class="right nowraponall">';
1945 if ($permissiontoaddupdatepaymentinformation) {
1946 print
'<a class="marginleftonly marginrightonly reposition" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletebank&token='.
newToken().
'">';
1947 print img_picto($langs->trans(
"Delete"),
'delete');
1955 if ($nbremote == 0 && $nblocal == 0) {
1963 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoBANRecord").
'</span></td></tr>';
1969 dol_print_error($db);
1973 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'');
1974 $reshook = $hookmanager->executeHooks(
'printNewTable', $parameters, $object);
1975 print $hookmanager->resPrint;
1980 print
'<div class="fichecenter"><div class="fichehalfleft">';
1981 print
'<a name="builddoc"></a>';
1987 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".
$object->id;
1989 print $formfile->showdocuments(
'company', (
string)
$object->id, $filedir, $urlsource, $permissiontoread, (
int) $permissiontoaddupdatepaymentinformation,
$object->model_pdf, 0, 0, 0, 28, 0,
'entity='.$object->entity,
'',
'',
$object->default_lang);
1996 $result = $companypaymentmodetemp->fetch(0,
'',
$object->id,
'ban');
1998 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
2001 $result = $ecmfile->fetch(0,
'',
'',
'',
'', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
2003 $companybankaccounttemp->last_main_doc = $ecmfile->filepath.
'/'.$ecmfile->filename;
2004 print
'<br><!-- Link to download main doc -->'.
"\n";
2009 print
'</div><div class="fichehalfright">';
2012 print
'</div></div>';
2038if ($socid && $action ==
'edit' && $permissiontoaddupdatepaymentinformation) {
2041 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2043 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2045 print
'<div class="underbanner clearboth"></div>';
2049 print
'<div class="div-table-responsive-no-min">';
2050 print
'<table class="border tableforfield centpercent">';
2052 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Label").
'</td>';
2053 print
'<td><input class="minwidth300" type="text" name="label" value="'.dol_escape_htmltag(
GETPOSTISSET(
'label') ?
GETPOST(
'label',
'alpha') : $companybankaccount->label).
'" spellcheck="false"></td></tr>';
2055 print
'<tr><td>'.$langs->trans(
"BankName").
'</td>';
2056 print
'<td><input class="minwidth200" type="text" name="bank" value="'.dol_escape_htmltag(
GETPOSTISSET(
'bank') ?
GETPOST(
'bank',
'alpha') : $companybankaccount->bank).
'" spellcheck="false"></td></tr>';
2059 $companybankaccount->fetch($id);
2060 $bankaccount = $companybankaccount;
2061 $country_codeid =
GETPOSTINT(
"account_country_id");
2062 if (empty($country_codeid)) {
2063 $country_codeid = $bankaccount->fk_country;
2065 if (empty($country_codeid)) {
2066 $default_country_code = $bankaccount->country_code ? $bankaccount->country_code : (
$object->country_code ?
$object->country_code :
$mysoc->country_code);
2067 $country_codeid =
getCountry($default_country_code,
'3');
2069 $country_codeid = (int) $country_codeid;
2070 $bankaccount->fk_country = $country_codeid;
2071 $bankaccount->country_code =
getCountry($country_codeid,
'2');
2073 foreach ($bankaccount->getFieldsToShow(1) as $val) {
2078 $content =
'NoContent';
2079 if ($val ==
'BankCode') {
2080 $name =
'code_banque';
2082 $content = $bankaccount->code_banque;
2083 } elseif ($val ==
'DeskCode') {
2084 $name =
'code_guichet';
2086 $content = $bankaccount->code_guichet;
2087 } elseif ($val ==
'BankAccountNumber') {
2090 $content = $bankaccount->number;
2091 } elseif ($val ==
'BankAccountNumberKey') {
2094 $content = $bankaccount->cle_rib;
2095 } elseif ($val ==
'IBAN') {
2098 $content = $bankaccount->iban;
2099 if ($bankaccount->needIBAN()) {
2102 $tooltip = $langs->trans(
"Example").
':<br>CH93 0076 2011 6238 5295 7<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';
2103 } elseif ($val ==
'BIC') {
2106 $content = $bankaccount->bic;
2107 if ($bankaccount->needBIC() && (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0)) {
2110 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2113 $content =
GETPOST($name,
'alpha');
2117 print
'<td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2120 print $form->textwithpicto($langs->trans($bankaccount->getBankFieldLabel($val)), $tooltip, 4,
'help',
'', 0, 3, $name);
2122 print $langs->trans($bankaccount->getBankFieldLabel($val));
2125 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.
dol_escape_htmltag($content).
'"></td>';
2130 print
'<tr><td>'.$form->textwithpicto($langs->trans(
'PaymentReferenceOfAccount'), $langs->trans(
'PaymentReferenceOfAccountHelp')).
'</td>';
2131 print
'<td><input class="minwidth200" type="text" name="payment_reference" maxlength="40" value="'.dol_escape_htmltag(
GETPOSTISSET(
'payment_reference') ?
GETPOST(
'payment_reference',
'alphanohtml') : (string) $bankaccount->payment_reference).
'" spellcheck="false"></td></tr>';
2134 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Currency").
'</td>';
2136 $selectedcode = $bankaccount->currency_code;
2137 if (!$selectedcode) {
2138 $selectedcode =
$conf->currency;
2140 print $form->selectCurrency((
GETPOSTISSET(
"account_currency_code") ?
GETPOST(
"account_currency_code") : $selectedcode),
'account_currency_code');
2147 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
'</td>';
2149 print $form->selectarray(
"clos", $bankaccount->labelStatus, $account_status, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth150onsmartphone');
2153 print
'<tr><td class="fieldrequired">'.$langs->trans(
"BankAccountCountry").
'</td>';
2155 print img_picto(
'',
'country',
'class="pictofixedwidth"');
2156 print $form->select_country($country_codeid,
'account_country_id');
2158 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2163 $selected_state_id =
GETPOSTISSET(
"account_state_id") ?
GETPOSTINT(
"account_state_id") : $bankaccount->state_id;
2164 print
'<tr><td>'.$langs->trans(
'State').
'</td><td>';
2165 if ($country_codeid) {
2166 print img_picto(
'',
'state',
'class="pictofixedwidth"');
2167 print $formcompany->select_state($selected_state_id, $country_codeid,
'account_state_id');
2169 print $countrynotdefined;
2173 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2174 print
'<textarea name="address" rows="'.ROWS_4.
'" cols="40" maxlength="255" spellcheck="false">';
2176 print
"</textarea></td></tr>";
2178 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2179 print
'<td><input class="minwidth300" type="text" name="proprio" value="'.dol_escape_htmltag(
GETPOSTISSET(
'proprio') ?
GETPOST(
'proprio',
'alpha') : $companybankaccount->owner_name).
'" spellcheck="false"></td></tr>';
2180 print
"</td></tr>\n";
2182 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2183 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" cols="40" maxlength="255" spellcheck="false">';
2184 print dolPrintHTMLForTextArea(
GETPOSTISSET(
'owner_address') ?
GETPOST(
'owner_address',
'alpha') : $companybankaccount->owner_address);
2185 print
"</textarea></td></tr>";
2193 print
'<div class="div-table-responsive-no-min">';
2194 print
'<table class="border tableforfield centpercent">';
2196 if (empty($companybankaccount->rum)) {
2197 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
2201 print
'<tr><td class="titlefieldcreate" colspan="5">'.$langs->trans(
"WithdrawalsSetup").
'</td></tr>';
2204 print
'<tr><td class="titlefield">'.$langs->trans(
"RUM").
'</td>';
2205 print
'<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag(
GETPOSTISSET(
'rum') ?
GETPOST(
'rum',
'alpha') : $companybankaccount->rum).
'" spellcheck="false"></td></tr>';
2209 print
'<tr><td class="titlefield">'.$langs->trans(
"DateRUM").
'</td>';
2210 print
'<td>'.$form->selectDate($date_rum ? $date_rum : $companybankaccount->date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2212 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2213 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2214 print $form->selectarray(
"frstrecur", $tblArraychoice,
dol_escape_htmltag(
GETPOST(
'frstrecur',
'alpha') ?
GETPOST(
'frstrecur',
'alpha') : $companybankaccount->frstrecur), 0);
2217 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_...' or 'src_...')</td>";
2218 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.dol_escape_htmltag(
GETPOSTISSET(
'stripe_card_ref') ?
GETPOST(
'stripe_card_ref',
'alpha') : $companypaymentmode->stripe_card_ref).
'" spellcheck="false"></td></tr>';
2227 print $form->buttonsSaveCancel(
"Modify");
2231if ($socid && $action ==
'editcard' && $permissiontoaddupdatepaymentinformation) {
2234 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2236 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2238 print
'<div class="nofichecenter">';
2240 print
'<div class="underbanner clearboth"></div>';
2244 print
'<div class="div-table-responsive-no-min">';
2245 print
'<table class="border centpercent">';
2247 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2248 print
'<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.
'" spellcheck="false"></td></tr>';
2250 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2251 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->owner_name.
'" spellcheck="false"></td></tr>';
2253 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2254 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.
'" spellcheck="false"></td></tr>';
2256 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2258 print $formother->select_month((
string) $companypaymentmode->exp_date_month,
'exp_date_month', 1);
2259 print $formother->selectyear((
string) $companypaymentmode->exp_date_year,
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2262 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2263 print
'<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.
'"></td></tr>';
2265 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_... ".$langs->trans(
"or").
" card_....')</td>";
2266 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'" spellcheck="false"></td></tr>';
2274 print $form->buttonsSaveCancel(
"Modify");
2279if ($socid && $action ==
'create' && $permissiontoaddupdatepaymentinformation) {
2282 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2284 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2286 print
'<div class="nofichecenter">';
2288 print
'<div class="underbanner clearboth"></div>';
2292 print
'<div class="div-table-responsive-no-min">';
2293 print
'<table class="border tableforfield centpercent">';
2295 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2296 print
'<td><input class="minwidth250" type="text" id="label" name="label" value="'.dol_escape_htmltag(
GETPOSTISSET(
'label') ?
GETPOST(
'label',
'alpha') : $langs->trans(
"Bank").
' '.
$object->
name).
'" spellcheck="false"></td></tr>';
2298 print
'<tr><td>'.$langs->trans(
"Bank").
'</td>';
2299 print
'<td><input class="minwidth250" type="text" id="bank" name="bank" value="'.dol_escape_htmltag(
GETPOST(
'bank',
'alpha')).
'" spellcheck="false"></td></tr>';
2302 $selected_country_id =
GETPOSTINT(
'account_country_id');
2303 if (empty($selected_country_id)) {
2306 $selected_country_id = (int) $selected_country_id;
2307 $companybankaccount->fk_country = $selected_country_id;
2308 $companybankaccount->country_code =
getCountry($selected_country_id,
'2');
2309 foreach ($companybankaccount->getFieldsToShow(1) as $val) {
2314 $content =
'NoContent';
2316 if ($val ==
'BankCode') {
2317 $name =
'code_banque';
2319 $content = $companybankaccount->code_banque;
2320 } elseif ($val ==
'DeskCode') {
2321 $name =
'code_guichet';
2323 $content = $companybankaccount->code_guichet;
2324 } elseif ($val ==
'BankAccountNumber') {
2327 $content = $companybankaccount->number;
2328 } elseif ($val ==
'BankAccountNumberKey') {
2331 $content = $companybankaccount->cle_rib;
2332 } elseif ($val ==
'IBAN') {
2335 $content = $companybankaccount->iban;
2336 if ($companybankaccount->needIBAN()) {
2339 $tooltip = $langs->trans(
"Example").
':<br>CH93 0076 2011 6238 5295 7<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';
2340 } elseif ($val ==
'BIC') {
2343 $content = $companybankaccount->bic;
2344 if ($companybankaccount->needBIC() && (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0)) {
2347 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2350 $content =
GETPOST($name,
'alpha');
2353 print
'<tr><td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2356 print $form->textwithpicto($langs->trans($companybankaccount->getBankFieldLabel($val)), $tooltip, 4,
'help',
'', 0, 3, $name);
2358 print $langs->trans($companybankaccount->getBankFieldLabel($val));
2361 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" id="'.$name.
'" value="'.
dol_escape_htmltag($content).
'" spellcheck="false"></td>';
2366 print
'<tr><td>'.$form->textwithpicto($langs->trans(
'PaymentReferenceOfAccount'), $langs->trans(
'PaymentReferenceOfAccountHelp')).
'</td>';
2367 print
'<td><input class="minwidth200" type="text" name="payment_reference" maxlength="40" value="'.dol_escape_htmltag(
GETPOSTISSET(
'payment_reference') ?
GETPOST(
'payment_reference',
'alphanohtml') :
'').
'" spellcheck="false"></td></tr>';
2370 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Currency").
'</td>';
2372 $selectedcode =
$object->currency_code;
2373 if (!$selectedcode) {
2374 $selectedcode =
$conf->currency;
2376 print $form->selectCurrency((
GETPOSTISSET(
"account_currency_code") ?
GETPOST(
"account_currency_code") : $selectedcode),
'account_currency_code');
2382 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
'</td>';
2384 print $form->selectarray(
"clos", $companybankaccount->labelStatus, (
GETPOSTISSET(
'clos') ?
GETPOSTINT(
'clos') : $companybankaccount::STATUS_OPEN), 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth150onsmartphone');
2388 print
'<tr><td class="fieldrequired">'.$langs->trans(
"BankAccountCountry").
'</td>';
2390 print img_picto(
'',
'country',
'class="pictofixedwidth"');
2391 print $form->select_country($selected_country_id,
'account_country_id');
2393 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2398 print
'<tr><td>'.$langs->trans(
'State').
'</td><td>';
2399 if ($selected_country_id) {
2400 print img_picto(
'',
'state',
'class="pictofixedwidth"');
2401 print $formcompany->select_state(
GETPOSTISSET(
"account_state_id") ?
GETPOSTINT(
"account_state_id") : 0, $selected_country_id,
'account_state_id');
2403 print $countrynotdefined;
2407 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2408 print
'<textarea name="address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2409 print dolPrintHTMLForTextArea(
GETPOST(
'address'));
2410 print
"</textarea></td></tr>";
2412 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2413 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.dol_escape_htmltag(
GETPOST(
'proprio',
'alpha')).
'" spellcheck="false"></td></tr>';
2414 print
"</td></tr>\n";
2416 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2417 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2418 print dolPrintHTMLForTextArea(
GETPOST(
'owner_address'));
2419 print
"</textarea></td></tr>";
2427 print
'<div class="div-table-responsive-no-min">';
2428 print
'<table class="border tableforfield centpercent">';
2431 print
'<tr><td class="titlefieldcreate" colspan="5">'.$langs->trans(
"WithdrawalsSetup").
'</td></tr>';
2434 print
'<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans(
"RUM"), $langs->trans(
"RUMLong").
'<br>'.$langs->trans(
"RUMWillBeGenerated")).
'</td>';
2435 print
'<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST(
'rum',
'alpha').
'" spellcheck="false"></td></tr>';
2439 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DateRUM").
'</td>';
2440 print
'<td colspan="4">'.$form->selectDate($date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2442 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2443 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2444 print $form->selectarray(
"frstrecur", $tblArraychoice, (
GETPOSTISSET(
'frstrecur') ?
GETPOST(
'frstrecur') :
'FRST'), 0);
2447 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('src_....')</td>";
2448 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'" spellcheck="false"></td></tr>';
2460 print $form->buttonsSaveCancel(
"Add");
2464if ($socid && $action ==
'createcard' && $permissiontoaddupdatepaymentinformation) {
2467 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2469 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2471 print
'<div class="nofichecenter">';
2473 print
'<div class="underbanner clearboth"></div>';
2477 print
'<div class="div-table-responsive-no-min">';
2478 print
'<table class="border centpercent">';
2480 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2481 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST(
'label',
'alpha').
'" spellcheck="false"></td></tr>';
2483 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2484 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio',
'alpha').
'" spellcheck="false"></td></tr>';
2486 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2487 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST(
'cardnumber',
'alpha').
'" spellcheck="false"></td></tr>';
2489 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2491 print $formother->select_month((
string)
GETPOSTINT(
'exp_date_month'),
'exp_date_month', 1);
2492 print $formother->selectyear((
string)
GETPOSTINT(
'exp_date_year'),
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2495 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2496 print
'<td><input class="width50" type="text" name="cvn" value="'.GETPOST(
'cvn',
'alpha').
'" spellcheck="false"></td></tr>';
2498 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('card_....')</td>";
2499 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'" spellcheck="false"></td></tr>';
2510 print $form->buttonsSaveCancel(
"Add");
2513if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
2516if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='', $placeholder='')
Convert a html select field into an ajax combobox.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
checkIbanForAccount($account=null, $ibantocheck=null)
Check IBAN number information for a bank account.
checkBanForAccount($account)
Check account number information for a bank account.
checkSwiftForAccount($account=null, $swift=null)
Check SWIFT information for a bank account.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage withdrawal receipts.
Class to manage bank accounts description of third parties.
Class for CompanyPaymentMode.
Class to manage ECM files.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class for SocieteAccount.
Class to manage third parties objects (customers, suppliers, prospects...)
Stripe class @TODO No reason to extend CommonObject.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
societe_prepare_head(Societe $object, $subtabs='')
Return array of tabs to used on pages for third parties cards.
dol_now($mode='gmt')
Return date for now.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
img_credit_card($brand, $morecss='fa-2x inline-block valignmiddle')
Return image of a credit card according to its brand name.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
showDirectDownloadLink($object)
Return string with full Url.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_set_focus($selector, $nooutput=0)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
$conf db name
Only used if Module[ID]Name translation string is not found.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
div refaddress div address