36require
'../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/societe/class/companypaymentmode.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
56$langs->loadLangs(array(
"companies",
"commercial",
"banks",
"bills",
'paypal',
'stripe',
'withdrawals'));
60$action =
GETPOST(
"action",
'alpha', 3);
61$cancel =
GETPOST(
'cancel',
'alpha');
62$backtopage =
GETPOST(
'backtopage');
65$source =
GETPOST(
"source",
"alpha");
71 $socid = $user->socid;
85$extrafields->fetch_name_optionals_label(
$object->table_element);
88$hookmanager->initHooks(array(
'thirdpartybancard',
'globalcard'));
91$permissiontoread = $user->hasRight(
'societe',
'lire');
92$permissiontoadd = $user->hasRight(
'societe',
'creer');
94$permissiontoaddupdatepaymentinformation = $user->hasRight(
'societe',
'thirdparty_paymentinformation',
'write');
104$site_account =
'UnknownSiteAccount';
108 $service =
'StripeTest';
110 $service =
'StripeLive';
115 global $stripearrayofkeysbyenv;
116 $site_account = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
118 $stripe =
new Stripe($db);
119 $stripeacc = $stripe->getStripeAccount($service);
120 $stripecu = $stripe->getStripeCustomerAccount(
$object->id, $servicestatus, $site_account);
135$parameters = array(
'id' => $socid);
136$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
141if (empty($reshook)) {
144 if (!empty($backtopage)) {
145 header(
"Location: ".$backtopage);
153 if (in_array($action, [
'update',
'updatecard',
'edit',
'editcard',
'setasbankdefault',
'confirm_deletecard',
'confirm_deletebank',
'synccardtostripe',
'syncsepatostripe'])) {
154 $idtocheckowner = ($ribid > 0 ? $ribid :
$id);
155 if ($idtocheckowner > 0) {
157 if ($tmppaymentinfo->fetch($idtocheckowner) <= 0 || $tmppaymentinfo->socid !=
$object->id) {
163 if ($action ==
'update' && $permissiontoaddupdatepaymentinformation) {
166 if (!
GETPOST(
'label',
'alpha')) {
167 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
170 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankName")),
null,
'errors');
175 $companybankaccount->fetch($id);
176 if ($companybankaccount->needIBAN() == 1) {
178 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
183 if ($companybankaccount->needBIC() == 1) {
185 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
192 $companybankaccount->oldcopy =
dol_clone($companybankaccount, 2);
194 $companybankaccount->socid =
$object->id;
196 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
197 $companybankaccount->label =
GETPOST(
'label',
'alpha');
198 $companybankaccount->status =
GETPOSTINT(
'clos');
199 $companybankaccount->clos = $companybankaccount->status;
200 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
201 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
202 $companybankaccount->number =
GETPOST(
'number',
'alpha');
203 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
204 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
205 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
207 $companybankaccount->address =
GETPOST(
'address',
'alpha');
209 $companybankaccount->owner_name =
GETPOST(
'proprio',
'alpha');
210 $companybankaccount->proprio = $companybankaccount->owner_name;
211 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
212 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
213 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
214 $companybankaccount->date_rum =
GETPOSTDATE(
'date_rum',
'00:00:00');
215 if (empty($companybankaccount->rum)) {
216 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
219 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
221 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
223 $companybankaccount->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
225 $result = $companybankaccount->update($user);
228 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
232 if ($companybankaccount->default_rib) {
233 $companybankaccount->setAsDefault($id);
236 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
237 if ($companybankaccount->oldcopy->iban != $companybankaccount->iban) {
242 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
243 header(
'Location: '.$url);
249 if ($action ==
'updatecard' && $permissiontoaddupdatepaymentinformation) {
251 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
252 if (!
GETPOST(
'label',
'alpha')) {
253 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
255 if (!
GETPOST(
'proprio',
'alpha')) {
256 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
259 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
260 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
263 $action =
'createcard';
267 $companypaymentmode->fetch($id);
269 $companypaymentmode->oldcopy =
dol_clone($companypaymentmode, 2);
271 $companypaymentmode->fk_soc =
$object->id;
273 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
274 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
275 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
276 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
277 $companypaymentmode->owner_name =
GETPOST(
'proprio',
'alpha');
278 $companypaymentmode->proprio = $companypaymentmode->owner_name;
279 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
280 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
281 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
282 $companypaymentmode->country_code =
$object->country_code;
284 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
286 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
288 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
290 $result = $companypaymentmode->update($user);
292 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
295 if ($companypaymentmode->default_rib) {
296 $companypaymentmode->setAsDefault($id);
299 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
300 if ($companybankaccount->oldcopy->number != $companybankaccount->number) {
305 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
306 header(
'Location: '.$url);
313 if ($action ==
'add' && $permissiontoaddupdatepaymentinformation) {
316 if (!
GETPOST(
'label',
'alpha')) {
317 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
326 $companybankaccount->socid =
$object->id;
328 $companybankaccount->fetch_thirdparty();
330 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
331 $companybankaccount->label =
GETPOST(
'label',
'alpha');
332 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
333 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
334 $companybankaccount->number =
GETPOST(
'number',
'alpha');
335 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
336 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
337 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
339 $companybankaccount->address =
GETPOST(
'address',
'alpha');
341 $companybankaccount->owner_name =
GETPOST(
'proprio',
'alpha');
342 $companybankaccount->proprio = $companybankaccount->owner_name;
343 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
344 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
345 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
346 $companybankaccount->date_rum =
GETPOSTDATE(
'date_rum',
'00:00:00');
347 $companybankaccount->datec =
dol_now();
350 $companybankaccount->status =
GETPOSTINT(
'clos');
352 $companybankaccount->bank = trim($companybankaccount->bank);
353 if (empty($companybankaccount->bank) && !empty($companybankaccount->thirdparty)) {
354 $companybankaccount->bank = $langs->trans(
"Bank").
' '.$companybankaccount->thirdparty->name;
356 $companybankaccount->bic = str_replace(
' ',
'', $companybankaccount->bic);
361 if ($companybankaccount->needIBAN() == 1) {
363 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
368 if ($companybankaccount->needBIC() == 1) {
370 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
377 $result = $companybankaccount->create($user);
380 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
384 if (empty($companybankaccount->rum)) {
385 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
390 $result = $companybankaccount->update($user);
393 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
401 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
402 header(
'Location: '.$url);
411 if ($action ==
'addcard' && $permissiontoaddupdatepaymentinformation) {
414 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
415 if (!
GETPOST(
'label',
'alpha')) {
416 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
418 if (!
GETPOST(
'proprio',
'alpha')) {
419 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
422 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
423 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
426 $action =
'createcard';
434 $companypaymentmode->fk_soc =
$object->id;
435 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
436 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
437 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
438 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
439 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
440 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
441 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
442 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
443 $companypaymentmode->datec =
dol_now();
444 $companypaymentmode->default_rib = 0;
445 $companypaymentmode->type =
'card';
446 $companypaymentmode->country_code =
$object->country_code;
447 $companypaymentmode->status = $servicestatus;
449 if (
GETPOST(
'stripe_card_ref',
'alpha')) {
451 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
453 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
458 $result = $companypaymentmode->create($user);
461 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
462 $action =
'createcard';
469 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
470 header(
'Location: '.$url);
478 if ($action ==
'setasbankdefault' &&
GETPOSTINT(
'ribid') > 0 && $permissiontoaddupdatepaymentinformation) {
480 $res = $companybankaccount->setAsDefault(
GETPOSTINT(
'ribid'));
482 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
483 header(
'Location: '.$url);
490 if ($action ==
'confirm_deletecard' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoaddupdatepaymentinformation) {
493 if ($companypaymentmode->fetch($ribid ? $ribid :
$id)) {
504 $result = $companypaymentmode->delete($user);
506 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
508 header(
'Location: '.$url);
511 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
514 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
517 if ($action ==
'confirm_deletebank' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoaddupdatepaymentinformation) {
520 if ($companybankaccount->fetch($ribid ? $ribid :
$id) > 0) {
531 $result = $companybankaccount->delete($user);
534 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
536 header(
'Location: '.$url);
539 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
542 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
549 if ($action ==
'builddocrib' && $permissiontoread) {
550 $action =
'builddoc';
552 'use_companybankid' =>
GETPOST(
'companybankid'),
555 $_POST[
'lang_id'] =
GETPOST(
'lang_idrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
556 $_POST[
'model'] =
GETPOST(
'modelrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
560 $upload_dir = $conf->societe->multidir_output[
$object->entity ?? $conf->entity];
561 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
567 if (($action ==
'synccustomertostripe' || $action ==
'synccustomertostripetest') && $permissiontoaddupdatepaymentinformation) {
572 if ($action ==
'synccustomertostripe') {
573 $tmpservicestatus = 1;
574 $tmpservice =
'StripeLive';
576 $tmpservicestatus = 0;
577 $tmpservice =
'StripeTest';
580 $stripe =
new Stripe($db);
581 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
584 $tmpcu = $stripe->customerStripe($object, $tmpstripeacc, $tmpservicestatus, 1);
590 if ($tmpservicestatus == $servicestatus) {
591 $stripecu = $tmpcu->id;
596 if ($action ==
'synccardtostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
599 $companypaymentmode->fetch($id);
601 if ($companypaymentmode->type !=
'card') {
606 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
613 '@phan-var-force \Stripe\Customer $cu';
617 $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
625 if ($action ==
'syncsepatostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
628 $companypaymentmode->fetch($id);
630 if ($companypaymentmode->type !=
'ban') {
632 $langs->load(
"errors");
636 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
640 $langs->load(
"errors");
641 setEventMessages($langs->trans(
"ErrorStripeCustomerNotFoundCreateFirst"),
null,
'errors');
644 '@phan-var-force \Stripe\Customer $cu';
646 $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
651 setEventMessages(
"", array(
"Bank Account on Stripe",
"BAN is now linked to the Stripe customer account !"));
658 if (($action ==
'setkey_account' || $action ==
'setkey_accounttest') && $permissiontoaddupdatepaymentinformation) {
661 $tmpservice =
'StripeTest';
662 $tmpservicestatus = 0;
663 if ($action ==
'setkey_account') {
664 $tmpservice =
'StripeLive';
665 $tmpservicestatus = 1;
669 global $stripearrayofkeysbyenv;
670 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
672 if ($action ==
'setkey_account') {
673 $newcu =
GETPOST(
'key_account',
'alpha');
675 $newcu =
GETPOST(
'key_accounttest',
'alpha');
681 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_account";
682 $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 = ".$conf->entity;
684 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_account";
685 $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 = ".$conf->entity;
688 $resql = $db->query($sql);
689 $num = $db->num_rows($resql);
691 if (!empty($newcu)) {
694 $societeaccount->fk_soc =
$object->id;
695 $societeaccount->login =
'';
696 $societeaccount->pass_encoding =
'';
697 $societeaccount->site =
'stripe';
698 $societeaccount->status = $servicestatus;
699 $societeaccount->key_account = $newcu;
700 $societeaccount->site_account = $tmpsite_account;
701 $result = $societeaccount->create($user);
706 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"societe_account";
707 $sql .=
" SET key_account = '".$db->escape($newcu).
"', site_account = '".$db->escape($tmpsite_account).
"'";
708 $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 = ".$conf->entity;
709 $resql = $db->query($sql);
717 if ($tmpservicestatus == $servicestatus) {
727 if (($action ==
'setkey_account_supplier' || $action ==
'setkey_account_suppliertest') && $permissiontoaddupdatepaymentinformation) {
730 $tmpservice =
'StripeTest';
731 $tmpservicestatus = 0;
732 if ($action ==
'setkey_account_supplier') {
733 $tmpservice =
'StripeLive';
734 $tmpservicestatus = 1;
738 global $stripearrayofkeysbyenv;
739 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
741 if ($action ==
'setkey_account_supplier') {
742 $newsup =
GETPOST(
'key_account_supplier',
'alpha');
744 $newsup =
GETPOST(
'key_account_suppliertest',
'alpha');
749 if (empty($newsup)) {
750 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"oauth_token WHERE fk_soc = ".((int)
$object->id).
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".((int) $conf->entity);
755 $stripesup = \Stripe\Account::retrieve($newsup);
756 $tokenstring = array();
757 $tokenstring[
'stripe_user_id'] = $stripesup->id;
758 $tokenstring[
'type'] = $stripesup->type;
759 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"oauth_token";
760 $sql .=
" SET tokenstring = '".$db->escape(json_encode($tokenstring)).
"'";
761 $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 = ".$conf->entity;
763 $sql .=
" WHERE fk_soc = ".$object->id.
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".$conf->entity;
770 $resql = $db->query($sql);
771 $num = $db->num_rows($resql);
772 if (empty($num) && !empty($newsup)) {
774 $stripesup = \Stripe\Account::retrieve($newsup);
775 $tokenstring[
'stripe_user_id'] = $stripesup->id;
776 $tokenstring[
'type'] = $stripesup->type;
777 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"oauth_token (service, fk_soc, entity, tokenstring)";
778 $sql .=
" VALUES ('".$db->escape($tmpservice).
"', ".((int)
$object->id).
", ".((int) $conf->entity).
", '".$db->escape(json_encode($tokenstring)).
"')";
784 $resql = $db->query($sql);
788 if ($tmpservicestatus == $servicestatus) {
789 $stripesupplieracc = $newsup;
797 if ($action ==
'setlocalassourcedefault' && $permissiontoaddupdatepaymentinformation) {
799 $companypaymentmode->setAsDefault($id);
801 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
802 header(
'Location: '.$url);
808 } elseif ($action ==
'setassourcedefault' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
810 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
811 if (preg_match(
'/pm_|src_/', $source)) {
812 $cu->invoice_settings->default_payment_method = (string) $source;
814 $cu->default_source = (string) $source;
817 $result = $cu->save();
819 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
820 header(
'Location: '.$url);
826 } elseif ($action ==
'deletecard' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
829 if (preg_match(
'/pm_/', $source)) {
830 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
831 if ($payment_method) {
832 $payment_method->detach();
835 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
836 $card = $cu->sources->retrieve(
"$source");
839 if (method_exists($card,
'detach')) {
841 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
842 $sql .=
" SET stripe_card_ref = null";
843 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
845 $resql = $db->query($sql);
852 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
853 header(
'Location: '.$url);
859 } elseif ($action ==
'deletebank' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
862 if (preg_match(
'/pm_/', $source)) {
863 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
864 if ($payment_method) {
865 $payment_method->detach();
868 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
869 $card = $cu->sources->retrieve((
string) $source);
872 if (method_exists($card,
'detach')) {
874 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
875 $sql .=
" SET stripe_card_ref = null";
876 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
878 $resql = $db->query($sql);
885 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
887 $url .=
'&page_y='.GETPOSTINT(
'page_y');
890 header(
'Location: '.$url);
906$form =
new Form($db);
910$title = $langs->trans(
"ThirdParty");
912 $title =
$object->name.
" - ".$langs->trans(
'PaymentInformation');
925 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'), [],
'warning');
931 $companybankaccount->fetch(0,
'',
$object->id);
933 $companypaymentmode->fetch(0,
'',
$object->id,
'card');
935 $companybankaccount->fetch($id);
936 $companypaymentmode->fetch($id);
938if (empty($companybankaccount->socid)) {
939 $companybankaccount->socid =
$object->id;
942if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
943 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post">';
944 print
'<input type="hidden" name="token" value="'.newToken().
'">';
945 $actionforadd =
'update';
946 if ($action ==
'editcard') {
947 $actionforadd =
'updatecard';
949 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
950 print
'<input type="hidden" name="id" value="'.GETPOSTINT(
"id").
'">';
952if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
953 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post">';
954 print
'<input type="hidden" name="token" value="'.newToken().
'">';
955 $actionforadd =
'add';
956 if ($action ==
'createcard') {
957 $actionforadd =
'addcard';
959 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
964if ($socid && $action !=
'edit' && $action !=
'create' && $action !=
'editcard' && $action !=
'createcard') {
968 if ($action ==
'deletebank') {
969 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);
972 if ($action ==
'deletecard') {
973 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);
976 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
978 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
980 print
'<div class="fichecenter">';
982 print
'<div class="underbanner clearboth"></div>';
983 print
'<table class="border tableforfield centpercent">';
986 print
'<tr><td class="titlefield">';
987 print $langs->trans(
'NatureOfThirdParty');
993 print
'<tr><td class="titlefield">';
994 print $langs->trans(
'CustomerCode');
997 $tmpcheck =
$object->check_codeclient();
998 if ($tmpcheck != 0 && $tmpcheck != -5) {
999 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
1002 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
1003 $resql = $db->query($sql);
1008 $obj = $db->fetch_object($resql);
1009 $nbFactsClient = $obj->nb;
1010 $thirdTypeArray = array();
1011 $elementTypeArray = array();
1012 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
1013 if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
1014 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
1016 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
1017 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1019 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1020 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1022 if (
isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1023 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1028 global $stripearrayofkeysbyenv;
1031 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1032 $tmpstripeacc = $stripe->getStripeAccount((
string) $tmpservice);
1033 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1036 print
'<tr><td class="titlefield">';
1037 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1038 print
'</td><td'.(empty($tmpstripecu) ?
' class="right"' :
'').
'>';
1039 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu,
$object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1040 if ($tmpstripecu && $action !=
'editkey_accounttest') {
1042 if (!empty($stripeacc)) {
1043 $connect = $stripeacc.
'/';
1045 $url =
'https://dashboard.stripe.com/'.$connect.
'test/customers/'.$tmpstripecu;
1046 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1048 if (empty($tmpstripecu)) {
1049 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" class="nowraponall">';
1050 print
'<input type="hidden" name="action" value="synccustomertostripetest">';
1051 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1052 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1053 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1054 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomertest" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1060 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1061 $tmpstripeacc = $stripe->getStripeAccount((
string) $tmpservice);
1062 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1065 print
'<tr><td class="titlefield">';
1066 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1067 print
'</td><td'.(empty($tmpstripecu) ?
' class="right"' :
'').
'>';
1068 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu,
$object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1069 if ($tmpstripecu && $action !=
'editkey_account') {
1071 if (!empty($stripeacc)) {
1072 $connect = $stripeacc.
'/';
1074 $url =
'https://dashboard.stripe.com/'.$connect.
'customers/'.$tmpstripecu;
1075 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1077 if (empty($tmpstripecu)) {
1078 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" class="nowraponall">';
1079 print
'<input type="hidden" name="action" value="synccustomertostripe">';
1080 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1081 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1082 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1083 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomer" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1091 print
'<tr><td class="titlefield">';
1092 print $langs->trans(
'SupplierCode');
1095 $tmpcheck =
$object->check_codefournisseur();
1096 if ($tmpcheck != 0 && $tmpcheck != -5) {
1097 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
1100 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
1101 $resql = $db->query($sql);
1105 $obj = $db->fetch_object($resql);
1106 $nbFactsClient = $obj->nb;
1107 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
1108 if (
isModEnabled(
'propal') && $user->hasRight(
'propal',
'lire')) {
1109 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
1111 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
1112 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1114 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1115 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1117 if (
isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1118 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1123 if (
isModEnabled(
'stripe') && !empty($conf->stripeconnect->enabled) &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 2 && $service !==
null) {
1124 $stripesupplieracc = $stripe->getStripeAccount($service,
$object->id);
1127 print
'<tr><td class="titlefield">';
1128 print $form->editfieldkey(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1129 print
'</td><td'.(empty($stripesupplieracc) ?
' class="right"' :
'').
'>';
1130 print $form->editfieldval(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1131 if ($stripesupplieracc && $action !=
'editkey_account_supplier') {
1134 $url =
'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc;
1135 if ($servicestatus) {
1136 $url =
'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc;
1138 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key '.$site_account,
'globe').
'</a>';
1140 if (empty($stripesupplieracc)) {
1141 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" class="nowraponall">';
1142 print
'<input type="hidden" name="action" value="syncsuppliertostripe">';
1143 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1144 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1145 print
'<input type="hidden" name="companybankid" value="'.$ribid.
'">';
1159 $showcardpaymentmode = 0;
1161 $showcardpaymentmode++;
1165 $listofsources = array();
1167 $customerstripe =
null;
1168 if (isset($stripe) && is_object($stripe) && $stripeacc !==
null) {
1170 $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus);
1171 if (!empty($customerstripe->id)) {
1174 $listofsources = $customerstripe->sources->data;
1176 $service =
'StripeTest';
1179 $service =
'StripeLive';
1184 global $stripearrayofkeysbyenv;
1185 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
1188 if (empty($stripeacc)) {
1189 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"));
1190 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"));
1192 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"), array(
"stripe_account" => $stripeacc));
1193 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"), array(
"stripe_account" => $stripeacc));
1196 if ($paymentmethodobjsA->data !=
null && $paymentmethodobjsB->data !=
null) {
1197 $listofsources = array_merge((array) $paymentmethodobjsA->data, (array) $paymentmethodobjsB->data);
1198 } elseif ($paymentmethodobjsB->data !=
null) {
1199 $listofsources = $paymentmethodobjsB->data;
1201 $listofsources = $paymentmethodobjsA->data;
1210 dol_syslog(
"Error when searching/loading Stripe customer for thirdparty id =".
$object->id);
1216 if ($showcardpaymentmode &&
$object->client) {
1217 $morehtmlright =
'';
1219 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=createcard');
1221 print
load_fiche_titre($langs->trans(
'CreditCard'), $morehtmlright,
'fa-credit-card');
1224 print
'<!-- List of card payments -->'.
"\n";
1225 print
'<div class="div-table-responsive-no-min">';
1226 print
'<table class="liste centpercent noborder">'.
"\n";
1227 print
'<tr class="liste_titre">';
1228 print
'<td>'.$langs->trans(
'Label').
'</td>';
1229 print
'<td>'.$form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")).
'</td>';
1230 print
'<td>'.$langs->trans(
'Type').
'</td>';
1231 print
'<td>'.$langs->trans(
'Informations').
'</td>';
1233 print
'<td class="center">'.$langs->trans(
'Default').
'</td>';
1234 print
'<td>'.$langs->trans(
'Note').
'</td>';
1235 print
'<td>'.$langs->trans(
'DateModification').
'</td>';
1237 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'stripetitle');
1238 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
1239 print $hookmanager->resPrint;
1246 $arrayofremotecard = array();
1253 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_rib";
1254 $sql .=
" WHERE type in ('card')";
1255 $sql .=
" AND fk_soc = ".((int)
$object->id);
1256 $sql .=
" AND status = ".((int) $servicestatus);
1258 $resql = $db->query($sql);
1260 $num_rows = $db->num_rows($resql);
1263 while ($i < $num_rows) {
1266 $obj = $db->fetch_object($resql);
1268 $companypaymentmodetemp->fetch($obj->rowid);
1270 $arrayofremotecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref;
1272 print
'<tr class="oddeven" data-rowid="'.((int) $companypaymentmodetemp->id).
'">';
1274 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->label).
'">';
1278 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->stripe_card_ref.(empty($companypaymentmodetemp->stripe_account) ?
'' :
' - '.$companypaymentmodetemp->stripe_account)).
'">';
1279 if (!empty($companypaymentmodetemp->stripe_card_ref) && !empty($companypaymentmodetemp->ext_payment_site)) {
1280 if (
isModEnabled(
'stripe') && in_array($companypaymentmodetemp->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1282 if (!empty($stripeacc)) {
1283 $connect = $stripeacc.
'/';
1285 if ($companypaymentmodetemp->ext_payment_site ==
'StripeLive') {
1286 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$companypaymentmodetemp->stripe_card_ref;
1288 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
1290 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe').
' - '.$companypaymentmodetemp->stripe_account,
'globe').
"</a> ";
1301 print
'<td class="minwidth100">';
1302 if ($companypaymentmodetemp->owner_name) {
1303 print
'<span class="opacitymedium">'.$companypaymentmodetemp->owner_name.
'</span><br>';
1305 if ($companypaymentmodetemp->last_four) {
1306 print
'....'.$companypaymentmodetemp->last_four;
1308 if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) {
1309 print
' - '.sprintf(
"%02d", $companypaymentmodetemp->exp_date_month).
'/'.$companypaymentmodetemp->exp_date_year;
1313 print
'<td class="tdoverflowmax100">';
1314 if ($companypaymentmodetemp->country_code) {
1316 print $img ? $img.
' ' :
'';
1317 print
getCountry($companypaymentmodetemp->country_code,
'1');
1319 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1323 print
'<td class="center">';
1324 if (empty($companypaymentmodetemp->default_rib)) {
1325 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=setlocalassourcedefault&token='.
newToken().
'">';
1326 print
img_picto($langs->trans(
"Default"),
'off');
1329 print
img_picto($langs->trans(
"Default"),
'on');
1332 if (empty($companypaymentmodetemp->stripe_card_ref)) {
1333 $s = $langs->trans(
"Local");
1335 $s = $langs->trans(
"LocalAndRemote");
1337 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1341 print
dol_print_date($companypaymentmodetemp->date_modification,
'dayhour',
'tzuserrel');
1344 $parameters = array(
'arrayfields' => array(),
'obj' => $obj,
'linetype' =>
'stripecard');
1345 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1346 print $hookmanager->resPrint;
1348 print
'<td class="right minwidth50 nowraponall">';
1349 if ($permissiontoaddupdatepaymentinformation) {
1350 if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) {
1351 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=synccardtostripe&socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'" class="paddingrightonly marginrightonly">'.$langs->trans(
"CreateCardOnStripe").
'</a>';
1354 print
'<a class="editfielda marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=editcard&token='.
newToken().
'">';
1355 print
img_picto($langs->trans(
"Modify"),
'edit');
1357 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=deletecard&token='.
newToken().
'">';
1358 print
img_picto($langs->trans(
"Delete"),
'delete');
1373 if (is_array($listofsources) && count($listofsources)) {
1374 foreach ($listofsources as $src) {
1375 if (!empty($arrayofremotecard[$src->id])) {
1382 if ($src->object ==
'card') {
1384 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1386 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1388 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1390 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1394 print
'<tr class="oddeven">';
1398 print
'<td class="tdoverflowmax150">';
1400 if (!empty($stripeacc)) {
1401 $connect = $stripeacc.
'/';
1404 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1405 if ($servicestatus) {
1407 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1409 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1417 print
'<td valign="middle">';
1418 if ($src->object ==
'card') {
1419 print
'....'.$src->last4.
' - '.$src->exp_month.
'/'.$src->exp_year;
1421 if ($src->country) {
1423 print $img ? $img.
' ' :
'';
1426 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1428 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1429 print
'<span class="opacitymedium">'.$src->owner->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1432 if ($src->card->country) {
1434 print $img ? $img.
' ' :
'';
1437 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1439 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1440 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1442 if ($src->sepa_debit->country) {
1444 print $img ? $img.
' ' :
'';
1445 print
getCountry($src->sepa_debit->country,
'1');
1447 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1449 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1450 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1453 if ($src->card->country) {
1455 print $img ? $img.
' ' :
'';
1458 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1460 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1461 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1463 if ($src->sepa_debit->country) {
1465 print $img ? $img.
' ' :
'';
1466 print
getCountry($src->sepa_debit->country,
'1');
1468 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1475 print
'<td class="center" width="50">';
1476 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1477 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1478 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1479 print
img_picto($langs->trans(
"Default"),
'off');
1482 print
img_picto($langs->trans(
"Default"),
'on');
1486 print $langs->trans(
"Remote");
1495 $parameters = array(
'arrayfields' => array(),
'stripesource' => $src,
'linetype' =>
'stripecardremoteonly');
1496 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1497 print $hookmanager->resPrint;
1500 print
'<td class="right nowraponall">';
1501 if ($permissiontoaddupdatepaymentinformation) {
1502 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletecard&token='.
newToken().
'">';
1503 print
img_picto($langs->trans(
"Delete"),
'delete');
1512 if ($nbremote == 0 && $nblocal == 0) {
1514 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1522 if (
isModEnabled(
'stripe') && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc)) {
1523 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');
1524 $balance = \Stripe\Balance::retrieve(array(
"stripe_account" => $stripesupplieracc));
1525 print
'<!-- List of Stripe connected accounts -->'.
"\n";
1526 print
'<table class="liste centpercent noborder">'.
"\n";
1527 print
'<tr class="liste_titre">';
1528 print
'<td>'.$langs->trans(
'Currency').
'</td>';
1529 print
'<td>'.$langs->trans(
'Available').
'</td>';
1530 print
'<td>'.$langs->trans(
'Pending').
'</td>';
1531 print
'<td>'.$langs->trans(
'Total').
'</td>';
1534 $currencybalance = array();
1535 if (is_array($balance->available) && count($balance->available)) {
1536 foreach ($balance->available as $cpt) {
1537 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1538 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1539 $currencybalance[$cpt->currency][
'available'] = $cpt->amount / 100;
1541 $currencybalance[$cpt->currency][
'available'] = $cpt->amount;
1543 $currencybalance[$cpt->currency][
'currency'] = $cpt->currency;
1547 if (is_array($balance->pending) && count($balance->pending)) {
1548 foreach ($balance->pending as $cpt) {
1549 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1550 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1551 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount / 100;
1553 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount;
1558 if (is_array($currencybalance)) {
1559 foreach ($currencybalance as $cpt_arr) {
1560 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>';
1570 if ($permissiontoaddupdatepaymentinformation) {
1571 $morehtmlright =
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"] .
'?socid=' .
$object->id .
'&action=create');
1574 print
load_fiche_titre($langs->trans(
"BankAccounts"), $morehtmlright,
'bank');
1578 $arrayofremoteban = array();
1580 $rib_list =
$object->get_all_rib();
1582 if (is_array($rib_list)) {
1583 print
'<!-- List of bank accounts -->'.
"\n";
1584 print
'<div class="div-table-responsive-no-min">';
1585 print
'<table class="liste centpercent noborder">';
1587 print
'<tr class="liste_titre">';
1589 print_liste_field_titre($form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")));
1604 $parameters = array(
'arrayfields' => array(),
'linetype' =>
'stripebantitle');
1605 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1606 print $hookmanager->resPrint;
1611 foreach ($rib_list as $rib) {
1612 $arrayofremoteban[$rib->stripe_card_ref] = $rib->stripe_card_ref;
1616 print
'<tr class="oddeven">';
1618 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($rib->label).
'">'.
dolPrintHTML($rib->label);
1619 print
'<br><span class="opacitymedium">'.dolPrintHTML($rib->bank).
'</span>';
1623 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->stripe_card_ref.(empty($rib->stripe_account) ?
'' :
' - '.$rib->stripe_account)).
'">';
1624 if (!empty($rib->stripe_card_ref) && !empty($rib->ext_payment_site)) {
1625 if (
isModEnabled(
'stripe') && in_array($rib->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1627 if (!empty($stripeacc)) {
1628 $connect = $stripeacc.
'/';
1630 if ($rib->ext_payment_site ==
'StripeLive') {
1631 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$rib->stripe_card_ref;
1633 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$rib->stripe_card_ref;
1635 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1647 foreach ($rib->getFieldsToShow() as $val) {
1648 if ($val ==
'BankCode') {
1649 $string .= $rib->code_banque.
' ';
1650 } elseif ($val ==
'BankAccountNumber') {
1651 $string .= $rib->number.
' ';
1652 } elseif ($val ==
'DeskCode') {
1653 $string .= $rib->code_guichet.
' ';
1654 } elseif ($val ==
'BankAccountNumberKey') {
1655 $string .= $rib->cle_rib.
' ';
1663 if (!empty($rib->label) && $rib->number) {
1665 $string .=
img_picto($langs->trans(
"ValueIsNotValid"),
'warning',
'class="pictofixedwidth"').$string;
1667 $string .=
img_picto($langs->trans(
"ValueIsValid"),
'info',
'class="pictofixedwidth"').$string;
1671 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($string).
'">';
1676 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->iban).
'">';
1677 if (!empty($rib->iban)) {
1679 print
img_picto($langs->trans(
"IbanNotValid"),
'warning').
' ';
1686 if (!empty($rib->bic)) {
1688 print
img_picto($langs->trans(
"SwiftNotValid"),
'warning').
' ';
1696 print
'<td class="tdoverflowmax100 small" title="'.dolPrintHTMLForAttribute($rib->rum).
'">'.
dolPrintHTML($rib->rum);
1697 print
'<br><span class="opacitymedium">'.dolPrintHTML($rib->frstrecur).
'</span>';
1701 print
'<td>'.dol_print_date($rib->date_rum,
'day').
'</td>';
1705 print
'<td class="center" width="70">';
1706 if (!$rib->default_rib) {
1707 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?socid='.((int)
$object->id).
'&ribid='.((int) $rib->id).
'&action=setasbankdefault&token='.
newToken().
'">';
1708 print
img_picto($langs->trans(
"Disabled"),
'off');
1711 print
img_picto($langs->trans(
"Enabled"),
'on');
1716 print
'<td class="center">';
1718 $buttonlabel = $langs->trans(
"BuildDoc");
1719 $forname =
'builddocrib'.$rib->id;
1721 include_once DOL_DOCUMENT_ROOT.
'/core/modules/bank/modules_bank.php';
1725 if (is_array($modellist) && count($modellist)) {
1726 $out .=
'<form action="'.$_SERVER[
"PHP_SELF"].(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#builddoc').
'" name="'.$forname.
'" id="'.$forname.
'_form" method="post">';
1727 $out .=
'<input type="hidden" name="action" value="builddocrib">';
1728 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1729 $out .=
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1730 $out .=
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1732 $modelselected =
'';
1733 if (count($modellist) == 1) {
1734 $arraykeys = array_keys($modellist);
1735 $modelselected = $arraykeys[0];
1741 $morecss =
'maxwidth125';
1742 if ($conf->browser->layout ==
'phone') {
1743 $morecss =
'maxwidth100';
1746 $out .= $form->selectarray(
'modelrib'.$rib->id, $modellist, $modelselected, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 '.$morecss);
1751 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
1753 $defaultlang = $langs->getDefaultLang();
1754 $out .= $formadmin->select_language($defaultlang,
'lang_idrib'.$rib->id, 0, array(), 0, 0, 0, $morecss);
1757 $out .=
'<input class="button buttongen reposition nomargintop nomarginbottom small '.$morecss.
'" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
1758 $out .=
' type="submit" value="'.$buttonlabel.
'"';
1766 $parameters = array(
'arrayfields' => array(),
'stripe_card_ref' => $rib->stripe_card_ref,
'stripe_account' => $rib->stripe_account,
'linetype' =>
'stripeban');
1767 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1768 print $hookmanager->resPrint;
1772 print
'<td class="minwidth200 width200">';
1773 $useonlinesignature = 1;
1774 if ($useonlinesignature) {
1775 $rib->entity =
$object->entity;
1776 require_once DOL_DOCUMENT_ROOT .
'/core/lib/signature.lib.php';
1777 print showOnlineSignatureUrl($companybankaccount->element, (
string) $rib->id, $rib,
'short');
1783 print
'<td class="right nowraponall">';
1784 if ($permissiontoaddupdatepaymentinformation) {
1786 if (empty($rib->stripe_card_ref)) {
1789 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=syncsepatostripe&token='.
newToken().
'">';
1790 print
img_picto($langs->trans(
"CreateBANOnStripe"),
'stripe');
1793 print
'<span class="opacitymedium marginrightonly marginleftonly">';
1794 print
img_picto($langs->trans(
"ThirdPartyMustBeACustomerToCreateBANOnStripe"),
'stripe');
1800 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=edit">';
1801 print
img_picto($langs->trans(
"Modify"),
'edit');
1804 print
'<a class="marginrightonly marginleftonly reposition" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=deletebank&token='.
newToken().
'">';
1805 print
img_picto($langs->trans(
"Delete"),
'delete');
1815 foreach ($listofsources as $src) {
1816 if (!empty($arrayofremoteban[$src->id])) {
1821 if ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1822 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1823 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1824 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1831 print
'<tr class="oddeven">';
1836 print
'<td class="tdoverflowmax150">';
1838 if (!empty($stripeacc)) {
1839 $connect = $stripeacc.
'/';
1842 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1843 if ($servicestatus) {
1845 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1847 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1878 print
'<td class="center" width="50">';
1879 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1880 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1881 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1882 print
img_picto($langs->trans(
"Default"),
'off');
1885 print
img_picto($langs->trans(
"Default"),
'on');
1901 $parameters = array(
'arrayfields' => array(),
'stripe_card_ref' => $rib->stripe_card_ref,
'stripe_account' => $rib->stripe_account,
'linetype' =>
'stripebanremoteonly');
1902 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1903 print $hookmanager->resPrint;
1906 print
'<td class="right nowraponall">';
1907 if ($permissiontoaddupdatepaymentinformation) {
1908 print
'<a class="marginleftonly marginrightonly reposition" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletebank&token='.
newToken().
'">';
1909 print
img_picto($langs->trans(
"Delete"),
'delete');
1917 if ($nbremote == 0 && $nblocal == 0) {
1925 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoBANRecord").
'</span></td></tr>';
1935 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'');
1936 $reshook = $hookmanager->executeHooks(
'printNewTable', $parameters, $object);
1937 print $hookmanager->resPrint;
1942 print
'<div class="fichecenter"><div class="fichehalfleft">';
1943 print
'<a name="builddoc"></a>';
1948 $filedir = $conf->societe->multidir_output[
$object->entity ?? $conf->entity].
'/'.
$object->id;
1949 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".
$object->id;
1951 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);
1958 $result = $companypaymentmodetemp->fetch(0,
'',
$object->id,
'ban');
1960 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1963 $result = $ecmfile->fetch(0,
'',
'',
'',
'', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
1965 $companybankaccounttemp->last_main_doc = $ecmfile->filepath.
'/'.$ecmfile->filename;
1966 print
'<br><!-- Link to download main doc -->'.
"\n";
1971 print
'</div><div class="fichehalfright">';
1974 print
'</div></div>';
2000if ($socid && $action ==
'edit' && $permissiontoaddupdatepaymentinformation) {
2003 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2005 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2007 print
'<div class="underbanner clearboth"></div>';
2011 print
'<div class="div-table-responsive-no-min">';
2012 print
'<table class="border tableforfield centpercent">';
2014 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Label").
'</td>';
2015 print
'<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.
'"></td></tr>';
2017 $required = (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0) ?
"fieldrequired" :
"";
2018 print
'<tr><td class="'.$required.
'">'.$langs->trans(
"BankName").
'</td>';
2019 print
'<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.
'"></td></tr>';
2022 $bankaccount = $companybankaccount;
2024 foreach ($bankaccount->getFieldsToShow(1) as $val) {
2029 $content =
'NoContent';
2030 if ($val ==
'BankCode') {
2031 $name =
'code_banque';
2033 $content = $bankaccount->code_banque;
2034 } elseif ($val ==
'DeskCode') {
2035 $name =
'code_guichet';
2037 $content = $bankaccount->code_guichet;
2038 } elseif ($val ==
'BankAccountNumber') {
2041 $content = $bankaccount->number;
2042 } elseif ($val ==
'BankAccountNumberKey') {
2045 $content = $bankaccount->cle_rib;
2046 } elseif ($val ==
'IBAN') {
2049 $content = $bankaccount->iban;
2050 if ($bankaccount->needIBAN()) {
2053 $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';
2054 } elseif ($val ==
'BIC') {
2057 $content = $bankaccount->bic;
2058 if ($bankaccount->needBIC() && (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0)) {
2061 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2065 print
'<td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2068 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2070 print $langs->trans($val);
2073 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.$content.
'"></td>';
2077 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2078 print
'<textarea name="address" rows="'.ROWS_4.
'" cols="40" maxlength="255" spellcheck="false">';
2079 print $companybankaccount->address;
2080 print
"</textarea></td></tr>";
2082 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2083 print
'<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->owner_name.
'"></td></tr>';
2084 print
"</td></tr>\n";
2086 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2087 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" cols="40" maxlength="255" spellcheck="false">';
2088 print $companybankaccount->owner_address;
2089 print
"</textarea></td></tr>";
2097 print
'<div class="div-table-responsive-no-min">';
2098 print
'<table class="border tableforfield centpercent">';
2100 if (empty($companybankaccount->rum)) {
2101 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
2105 print
'<tr><td class="titlefieldcreate" colspan="5">'.$langs->trans(
"WithdrawalsSetup").
'</td></tr>';
2108 print
'<tr><td class="titlefield">'.$langs->trans(
"RUM").
'</td>';
2109 print
'<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).
'"></td></tr>';
2113 print
'<tr><td class="titlefield">'.$langs->trans(
"DateRUM").
'</td>';
2114 print
'<td>'.$form->selectDate($date_rum ? $date_rum : $companybankaccount->date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2116 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2117 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2118 print $form->selectarray(
"frstrecur", $tblArraychoice,
dol_escape_htmltag(
GETPOST(
'frstrecur',
'alpha') ?
GETPOST(
'frstrecur',
'alpha') : $companybankaccount->frstrecur), 0);
2121 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_...' or 'src_...')</td>";
2122 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
2131 print $form->buttonsSaveCancel(
"Modify");
2135if ($socid && $action ==
'editcard' && $permissiontoaddupdatepaymentinformation) {
2138 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2140 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2142 print
'<div class="nofichecenter">';
2144 print
'<div class="underbanner clearboth"></div>';
2148 print
'<div class="div-table-responsive-no-min">';
2149 print
'<table class="border centpercent">';
2151 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2152 print
'<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.
'"></td></tr>';
2154 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2155 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->owner_name.
'"></td></tr>';
2157 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2158 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.
'"></td></tr>';
2160 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2162 print $formother->select_month((
string) $companypaymentmode->exp_date_month,
'exp_date_month', 1);
2163 print $formother->selectyear((
string) $companypaymentmode->exp_date_year,
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2166 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2167 print
'<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.
'"></td></tr>';
2169 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_... ".$langs->trans(
"or").
" card_....')</td>";
2170 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
2178 print $form->buttonsSaveCancel(
"Modify");
2183if ($socid && $action ==
'create' && $permissiontoaddupdatepaymentinformation) {
2186 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2188 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2190 print
'<div class="nofichecenter">';
2192 print
'<div class="underbanner clearboth"></div>';
2196 print
'<div class="div-table-responsive-no-min">';
2197 print
'<table class="border tableforfield centpercent">';
2199 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2200 print
'<td><input class="minwidth250" type="text" id="label" name="label" value="'.(GETPOSTISSET(
'label') ?
GETPOST(
'label') : $langs->trans(
"Bank").
' '.
$object->
name).
'"></td></tr>';
2202 print
'<tr><td>'.$langs->trans(
"Bank").
'</td>';
2203 print
'<td><input class="minwidth250" type="text" id="bank" name="bank" value="'.GETPOST(
'bank').
'"></td></tr>';
2206 foreach ($companybankaccount->getFieldsToShow(1) as $val) {
2211 $content =
'NoContent';
2212 if ($val ==
'BankCode') {
2213 $name =
'code_banque';
2215 $content = $companybankaccount->code_banque;
2216 } elseif ($val ==
'DeskCode') {
2217 $name =
'code_guichet';
2219 $content = $companybankaccount->code_guichet;
2220 } elseif ($val ==
'BankAccountNumber') {
2223 $content = $companybankaccount->number;
2224 } elseif ($val ==
'BankAccountNumberKey') {
2227 $content = $companybankaccount->cle_rib;
2228 } elseif ($val ==
'IBAN') {
2231 $content = $companybankaccount->iban;
2232 if ($companybankaccount->needIBAN()) {
2235 $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';
2236 } elseif ($val ==
'BIC') {
2239 $content = $companybankaccount->bic;
2240 if ($companybankaccount->needBIC() && (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0)) {
2243 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2246 print
'<tr><td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2249 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2251 print $langs->trans($val);
2254 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.
GETPOST($name).
'"></td>';
2258 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2259 print
'<textarea name="address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2261 print
"</textarea></td></tr>";
2263 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2264 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio').
'"></td></tr>';
2265 print
"</td></tr>\n";
2267 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2268 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2269 print
GETPOST(
'owner_address');
2270 print
"</textarea></td></tr>";
2278 print
'<div class="div-table-responsive-no-min">';
2279 print
'<table class="border tableforfield centpercent">';
2282 print
'<tr><td class="titlefieldcreate" colspan="5">'.$langs->trans(
"WithdrawalsSetup").
'</td></tr>';
2285 print
'<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans(
"RUM"), $langs->trans(
"RUMLong").
'<br>'.$langs->trans(
"RUMWillBeGenerated")).
'</td>';
2286 print
'<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST(
'rum',
'alpha').
'"></td></tr>';
2290 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DateRUM").
'</td>';
2291 print
'<td colspan="4">'.$form->selectDate($date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2293 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2294 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2295 print $form->selectarray(
"frstrecur", $tblArraychoice, (GETPOSTISSET(
'frstrecur') ?
GETPOST(
'frstrecur') :
'FRST'), 0);
2298 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('src_....')</td>";
2299 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2311 print $form->buttonsSaveCancel(
"Add");
2315if ($socid && $action ==
'createcard' && $permissiontoaddupdatepaymentinformation) {
2318 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2320 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2322 print
'<div class="nofichecenter">';
2324 print
'<div class="underbanner clearboth"></div>';
2328 print
'<div class="div-table-responsive-no-min">';
2329 print
'<table class="border centpercent">';
2331 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2332 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST(
'label',
'alpha').
'"></td></tr>';
2334 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2335 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio',
'alpha').
'"></td></tr>';
2337 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2338 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST(
'cardnumber',
'alpha').
'"></td></tr>';
2340 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2342 print $formother->select_month((
string)
GETPOSTINT(
'exp_date_month'),
'exp_date_month', 1);
2343 print $formother->selectyear((
string)
GETPOSTINT(
'exp_date_year'),
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2346 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2347 print
'<td><input class="width50" type="text" name="cvn" value="'.GETPOST(
'cvn',
'alpha').
'"></td></tr>';
2349 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('card_....')</td>";
2350 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2361 print $form->buttonsSaveCancel(
"Add");
2364if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
2367if ($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='')
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.
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.
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)
Return array of tabs to used on pages for third parties cards.
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_credit_card($brand, $morecss='fa-2x inline-block valignmiddle')
Return image of a credit card according to its brand name.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
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).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
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.
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.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
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)
Return value of a param into GET or POST supervariable.
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).
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).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
$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, $mode=0)
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.