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'];
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);
143if (empty($reshook)) {
146 if (!empty($backtopage)) {
147 header(
"Location: ".$backtopage);
152 if ($action ==
'update' && $permissiontoaddupdatepaymentinformation) {
155 if (!
GETPOST(
'label',
'alpha')) {
156 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
159 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankName")),
null,
'errors');
164 $companybankaccount->fetch($id);
165 if ($companybankaccount->needIBAN() == 1) {
167 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
172 if ($companybankaccount->needBIC() == 1) {
174 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
181 $companybankaccount->oldcopy =
dol_clone($companybankaccount, 2);
183 $companybankaccount->socid =
$object->id;
185 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
186 $companybankaccount->label =
GETPOST(
'label',
'alpha');
187 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
188 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
189 $companybankaccount->number =
GETPOST(
'number',
'alpha');
190 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
191 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
192 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
194 $companybankaccount->currency_code =
GETPOST(
'account_currency_code',
'alpha');
195 $companybankaccount->fk_country =
GETPOSTINT(
'account_country_id');
196 $companybankaccount->state_id =
GETPOSTINT(
'account_state_id');
197 $companybankaccount->address =
GETPOST(
'address',
'alpha');
199 $companybankaccount->owner_name =
GETPOST(
'proprio',
'alpha');
200 $companybankaccount->proprio = $companybankaccount->owner_name;
201 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
202 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
203 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
204 $companybankaccount->date_rum =
GETPOSTDATE(
'date_rum',
'00:00:00');
205 if (empty($companybankaccount->rum)) {
206 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
209 $companybankaccount->status =
GETPOSTINT(
'clos');
211 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
213 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
215 $companybankaccount->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
217 $result = $companybankaccount->update($user);
220 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
224 if ($companybankaccount->default_rib) {
225 $companybankaccount->setAsDefault($id);
228 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
229 if ($companybankaccount->oldcopy->iban != $companybankaccount->iban) {
234 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
235 header(
'Location: '.$url);
241 if ($action ==
'updatecard' && $permissiontoaddupdatepaymentinformation) {
243 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
244 if (!
GETPOST(
'label',
'alpha')) {
245 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
247 if (!
GETPOST(
'proprio',
'alpha')) {
248 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
251 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
252 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
255 $action =
'createcard';
259 $companypaymentmode->fetch($id);
261 $companypaymentmode->oldcopy =
dol_clone($companypaymentmode, 2);
263 $companypaymentmode->fk_soc =
$object->id;
265 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
266 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
267 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
268 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
269 $companypaymentmode->owner_name =
GETPOST(
'proprio',
'alpha');
270 $companypaymentmode->proprio = $companypaymentmode->owner_name;
271 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
272 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
273 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
274 $companypaymentmode->country_code =
$object->country_code;
276 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
278 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
280 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
282 $result = $companypaymentmode->update($user);
284 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
287 if ($companypaymentmode->default_rib) {
288 $companypaymentmode->setAsDefault($id);
291 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
292 if ($companybankaccount->oldcopy->number != $companybankaccount->number) {
297 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
298 header(
'Location: '.$url);
305 if ($action ==
'add' && $permissiontoaddupdatepaymentinformation) {
308 if (!
GETPOST(
'label',
'alpha')) {
309 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
318 $companybankaccount->socid =
$object->id;
320 $companybankaccount->fetch_thirdparty();
322 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
323 $companybankaccount->label =
GETPOST(
'label',
'alpha');
324 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
325 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
326 $companybankaccount->number =
GETPOST(
'number',
'alpha');
327 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
328 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
329 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
331 $companybankaccount->currency_code =
GETPOST(
'account_currency_code',
'alpha');
332 $companybankaccount->fk_country =
GETPOSTINT(
'account_country_id');
333 $companybankaccount->state_id =
GETPOSTINT(
'account_state_id');
334 $companybankaccount->address =
GETPOST(
'address',
'alpha');
336 $companybankaccount->owner_name =
GETPOST(
'proprio',
'alpha');
337 $companybankaccount->proprio = $companybankaccount->owner_name;
338 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
339 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
340 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
341 $companybankaccount->date_rum =
GETPOSTDATE(
'date_rum',
'00:00:00');
342 $companybankaccount->datec =
dol_now();
344 $companybankaccount->status =
GETPOSTINT(
'clos');
346 $companybankaccount->bank = trim($companybankaccount->bank);
347 if (empty($companybankaccount->bank) && !empty($companybankaccount->thirdparty)) {
348 $companybankaccount->bank = $langs->trans(
"Bank").
' '.$companybankaccount->thirdparty->name;
350 $companybankaccount->bic = str_replace(
' ',
'', $companybankaccount->bic);
355 if ($companybankaccount->needIBAN() == 1) {
357 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
362 if ($companybankaccount->needBIC() == 1) {
364 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
371 $result = $companybankaccount->create($user);
374 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
378 if (empty($companybankaccount->rum)) {
379 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
384 $result = $companybankaccount->update($user);
387 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
395 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
396 header(
'Location: '.$url);
405 if ($action ==
'addcard' && $permissiontoaddupdatepaymentinformation) {
408 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
409 if (!
GETPOST(
'label',
'alpha')) {
410 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
412 if (!
GETPOST(
'proprio',
'alpha')) {
413 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
416 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
417 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
420 $action =
'createcard';
428 $companypaymentmode->fk_soc =
$object->id;
429 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
430 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
431 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
432 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
433 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
434 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
435 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
436 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
437 $companypaymentmode->datec =
dol_now();
438 $companypaymentmode->default_rib = 0;
439 $companypaymentmode->type =
'card';
440 $companypaymentmode->country_code =
$object->country_code;
441 $companypaymentmode->status = $servicestatus;
443 if (
GETPOST(
'stripe_card_ref',
'alpha')) {
445 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
447 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
452 $result = $companypaymentmode->create($user);
455 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
456 $action =
'createcard';
463 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
464 header(
'Location: '.$url);
472 if ($action ==
'setasbankdefault' &&
GETPOSTINT(
'ribid') > 0 && $permissiontoaddupdatepaymentinformation) {
474 $res = $companybankaccount->setAsDefault(
GETPOSTINT(
'ribid'));
476 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
477 header(
'Location: '.$url);
484 if ($action ==
'confirm_deletecard' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoaddupdatepaymentinformation) {
487 if ($companypaymentmode->fetch($ribid ? $ribid :
$id)) {
498 $result = $companypaymentmode->delete($user);
500 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
502 header(
'Location: '.$url);
505 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
508 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
511 if ($action ==
'confirm_deletebank' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoaddupdatepaymentinformation) {
514 if ($companybankaccount->fetch($ribid ? $ribid :
$id) > 0) {
525 $result = $companybankaccount->delete($user);
528 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
530 header(
'Location: '.$url);
533 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
536 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
543 if ($action ==
'builddocrib' && $permissiontoread) {
544 $action =
'builddoc';
546 'use_companybankid' =>
GETPOST(
'companybankid'),
549 $_POST[
'lang_id'] =
GETPOST(
'lang_idrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
550 $_POST[
'model'] =
GETPOST(
'modelrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
555 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
561 if (($action ==
'synccustomertostripe' || $action ==
'synccustomertostripetest') && $permissiontoaddupdatepaymentinformation) {
566 if ($action ==
'synccustomertostripe') {
567 $tmpservicestatus = 1;
568 $tmpservice =
'StripeLive';
570 $tmpservicestatus = 0;
571 $tmpservice =
'StripeTest';
575 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
578 $tmpcu = $stripe->customerStripe($object, $tmpstripeacc, $tmpservicestatus, 1);
584 if ($tmpservicestatus == $servicestatus) {
585 $stripecu = $tmpcu->id;
590 if ($action ==
'synccardtostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
593 $companypaymentmode->fetch($id);
595 if ($companypaymentmode->type !=
'card') {
600 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
607 '@phan-var-force \Stripe\Customer $cu';
611 $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
619 if ($action ==
'syncsepatostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
622 $companypaymentmode->fetch($id);
624 if ($companypaymentmode->type !=
'ban') {
626 $langs->load(
"errors");
630 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
634 $langs->load(
"errors");
635 setEventMessages($langs->trans(
"ErrorStripeCustomerNotFoundCreateFirst"),
null,
'errors');
638 '@phan-var-force \Stripe\Customer $cu';
640 $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
645 setEventMessages(
"", array(
"Bank Account on Stripe",
"BAN is now linked to the Stripe customer account !"));
652 if (($action ==
'setkey_account' || $action ==
'setkey_accounttest') && $permissiontoaddupdatepaymentinformation) {
655 $tmpservice =
'StripeTest';
656 $tmpservicestatus = 0;
657 if ($action ==
'setkey_account') {
658 $tmpservice =
'StripeLive';
659 $tmpservicestatus = 1;
663 global $stripearrayofkeysbyenv;
664 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
666 if ($action ==
'setkey_account') {
667 $newcu =
GETPOST(
'key_account',
'alpha');
669 $newcu =
GETPOST(
'key_accounttest',
'alpha');
675 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_account";
676 $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;
678 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_account";
679 $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;
682 $resql =
$db->query($sql);
683 $num =
$db->num_rows($resql);
685 if (!empty($newcu)) {
688 $societeaccount->fk_soc =
$object->id;
689 $societeaccount->login =
'';
690 $societeaccount->pass_encoding =
'';
691 $societeaccount->site =
'stripe';
692 $societeaccount->status = $servicestatus;
693 $societeaccount->key_account = $newcu;
694 $societeaccount->site_account = $tmpsite_account;
695 $result = $societeaccount->create($user);
700 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"societe_account";
701 $sql .=
" SET key_account = '".$db->escape($newcu).
"', site_account = '".
$db->escape($tmpsite_account).
"'";
702 $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;
703 $resql =
$db->query($sql);
711 if ($tmpservicestatus == $servicestatus) {
721 if (($action ==
'setkey_account_supplier' || $action ==
'setkey_account_suppliertest') && $permissiontoaddupdatepaymentinformation) {
724 $tmpservice =
'StripeTest';
725 $tmpservicestatus = 0;
726 if ($action ==
'setkey_account_supplier') {
727 $tmpservice =
'StripeLive';
728 $tmpservicestatus = 1;
732 global $stripearrayofkeysbyenv;
733 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
735 if ($action ==
'setkey_account_supplier') {
736 $newsup =
GETPOST(
'key_account_supplier',
'alpha');
738 $newsup =
GETPOST(
'key_account_suppliertest',
'alpha');
744 if (empty($newsup)) {
745 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"oauth_token WHERE fk_soc = ".((int)
$object->id).
" AND service = '".
$db->escape($tmpservice).
"' AND entity = ".((int)
$conf->entity);
750 $stripesup = \Stripe\Account::retrieve($newsup);
751 $tokenstring = array();
752 $tokenstring[
'stripe_user_id'] = $stripesup->id;
753 $tokenstring[
'type'] = $stripesup->type;
754 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"oauth_token";
755 $sql .=
" SET tokenstring = '".$db->escape(json_encode($tokenstring)).
"'";
756 $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;
758 $sql .=
" WHERE fk_soc = ".((int)
$object->id).
" AND service = '".
$db->escape($tmpservice).
"' AND entity = ".
$conf->entity;
765 $resql =
$db->query($sql);
766 $num =
$db->num_rows($resql);
767 if (empty($num) && !empty($newsup)) {
769 $stripesup = \Stripe\Account::retrieve($newsup);
770 $tokenstring[
'stripe_user_id'] = $stripesup->id;
771 $tokenstring[
'type'] = $stripesup->type;
772 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"oauth_token (service, fk_soc, entity, tokenstring)";
773 $sql .=
" VALUES ('".$db->escape($tmpservice).
"', ".((int)
$object->id).
", ".((int)
$conf->entity).
", '".
$db->escape(json_encode($tokenstring)).
"')";
779 $resql =
$db->query($sql);
783 if ($tmpservicestatus == $servicestatus) {
784 $stripesupplieracc = $newsup;
792 if ($action ==
'setlocalassourcedefault' && $permissiontoaddupdatepaymentinformation) {
794 $companypaymentmode->setAsDefault($id);
796 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
797 header(
'Location: '.$url);
803 } elseif ($action ==
'setassourcedefault' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
805 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
806 if (preg_match(
'/pm_|src_/', $source)) {
807 $cu->invoice_settings->default_payment_method = (
string) $source;
809 $cu->default_source = (
string) $source;
812 $result = $cu->save();
814 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
815 header(
'Location: '.$url);
821 } elseif ($action ==
'deletecard' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
824 if (preg_match(
'/pm_/', $source)) {
825 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
826 if ($payment_method) {
827 $payment_method->detach();
830 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
831 $card = $cu->sources->retrieve(
"$source");
834 if (method_exists($card,
'detach')) {
836 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
837 $sql .=
" SET stripe_card_ref = null";
838 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
840 $resql =
$db->query($sql);
842 $card->delete($user);
847 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
848 header(
'Location: '.$url);
854 } elseif ($action ==
'deletebank' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
857 if (preg_match(
'/pm_/', $source)) {
858 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
859 if ($payment_method) {
860 $payment_method->detach();
863 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
864 $card = $cu->sources->retrieve((
string) $source);
867 if (method_exists($card,
'detach')) {
869 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
870 $sql .=
" SET stripe_card_ref = null";
871 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
873 $resql =
$db->query($sql);
875 $card->delete($user);
880 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
882 $url .=
'&page_y='.GETPOSTINT(
'page_y');
885 header(
'Location: '.$url);
906$countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
908$title = $langs->trans(
"ThirdParty");
910 $title =
$object->name.
" - ".$langs->trans(
'PaymentInformation');
923 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'), [],
'warning');
929 $companybankaccount->fetch(0,
'',
$object->id);
931 $companypaymentmode->fetch(0,
'',
$object->id,
'card');
933 $companybankaccount->fetch($id);
934 $companypaymentmode->fetch($id);
936if (empty($companybankaccount->socid)) {
937 $companybankaccount->socid =
$object->id;
940if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
941 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post">';
942 print
'<input type="hidden" name="token" value="'.newToken().
'">';
943 $actionforadd =
'update';
944 if ($action ==
'editcard') {
945 $actionforadd =
'updatecard';
947 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
948 print
'<input type="hidden" name="id" value="'.GETPOSTINT(
"id").
'">';
950if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
951 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post">';
952 print
'<input type="hidden" name="token" value="'.newToken().
'">';
953 $actionforadd =
'add';
954 if ($action ==
'createcard') {
955 $actionforadd =
'addcard';
957 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
961if ($socid && $action !=
'edit' && $action !=
'create' && $action !=
'editcard' && $action !=
'createcard') {
965 if ($action ==
'deletebank') {
966 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);
969 if ($action ==
'deletecard') {
970 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);
973 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
975 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
977 print
'<div class="fichecenter">';
979 print
'<div class="underbanner clearboth"></div>';
980 print
'<table class="border tableforfield centpercent">';
983 print
'<tr><td class="titlefield">';
984 print $langs->trans(
'NatureOfThirdParty');
990 print
'<tr><td class="titlefield">';
991 print $langs->trans(
'CustomerCode');
994 $tmpcheck =
$object->check_codeclient();
995 if ($tmpcheck != 0 && $tmpcheck != -5) {
996 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
999 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
1000 $resql =
$db->query($sql);
1005 $obj =
$db->fetch_object($resql);
1006 $nbFactsClient = $obj->nb;
1007 $thirdTypeArray = array();
1008 $elementTypeArray = array();
1009 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
1010 if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
1011 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
1013 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
1014 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1016 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1017 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1019 if (
isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1020 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1025 global $stripearrayofkeysbyenv;
1028 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1029 $tmpstripeacc = $stripe->getStripeAccount((
string) $tmpservice);
1030 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1033 print
'<tr><td class="titlefield">';
1034 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1035 print
'</td><td'.(empty($tmpstripecu) ?
' class="right"' :
'').
'>';
1036 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu,
$object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1037 if ($tmpstripecu && $action !=
'editkey_accounttest') {
1039 if (!empty($stripeacc)) {
1040 $connect = $stripeacc.
'/';
1042 $url =
'https://dashboard.stripe.com/'.$connect.
'test/customers/'.$tmpstripecu;
1043 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1045 if (empty($tmpstripecu)) {
1046 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" class="nowraponall">';
1047 print
'<input type="hidden" name="action" value="synccustomertostripetest">';
1048 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1049 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1050 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1051 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomertest" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1057 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1058 $tmpstripeacc = $stripe->getStripeAccount((
string) $tmpservice);
1059 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1062 print
'<tr><td class="titlefield">';
1063 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1064 print
'</td><td'.(empty($tmpstripecu) ?
' class="right"' :
'').
'>';
1065 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu,
$object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1066 if ($tmpstripecu && $action !=
'editkey_account') {
1068 if (!empty($stripeacc)) {
1069 $connect = $stripeacc.
'/';
1071 $url =
'https://dashboard.stripe.com/'.$connect.
'customers/'.$tmpstripecu;
1072 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1074 if (empty($tmpstripecu)) {
1075 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" class="nowraponall">';
1076 print
'<input type="hidden" name="action" value="synccustomertostripe">';
1077 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1078 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1079 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1080 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomer" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1088 print
'<tr><td class="titlefield">';
1089 print $langs->trans(
'SupplierCode');
1092 $tmpcheck =
$object->check_codefournisseur();
1093 if ($tmpcheck != 0 && $tmpcheck != -5) {
1094 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
1097 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
1098 $resql =
$db->query($sql);
1102 $obj =
$db->fetch_object($resql);
1103 $nbFactsClient = $obj->nb;
1104 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
1105 if (
isModEnabled(
'propal') && $user->hasRight(
'propal',
'lire')) {
1106 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
1108 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
1109 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1111 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1112 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1114 if (
isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1115 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1121 $stripesupplieracc = $stripe->getStripeAccount($service,
$object->id);
1124 print
'<tr><td class="titlefield">';
1125 print $form->editfieldkey(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1126 print
'</td><td'.(empty($stripesupplieracc) ?
' class="right"' :
'').
'>';
1127 print $form->editfieldval(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1128 if ($stripesupplieracc && $action !=
'editkey_account_supplier') {
1131 $url =
'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc;
1132 if ($servicestatus) {
1133 $url =
'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc;
1135 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key '.$site_account,
'globe').
'</a>';
1137 if (empty($stripesupplieracc)) {
1138 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" class="nowraponall">';
1139 print
'<input type="hidden" name="action" value="syncsuppliertostripe">';
1140 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1141 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1142 print
'<input type="hidden" name="companybankid" value="'.$ribid.
'">';
1156 $showcardpaymentmode = 0;
1158 $showcardpaymentmode++;
1162 $listofsources = array();
1164 $customerstripe =
null;
1165 if (isset($stripe) && is_object($stripe) && $stripeacc !==
null) {
1167 $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus);
1168 if (!empty($customerstripe->id)) {
1171 $listofsources = $customerstripe->sources->data;
1173 $service =
'StripeTest';
1176 $service =
'StripeLive';
1181 global $stripearrayofkeysbyenv;
1182 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
1185 if (empty($stripeacc)) {
1186 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"));
1187 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"));
1189 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"), array(
"stripe_account" => $stripeacc));
1190 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"), array(
"stripe_account" => $stripeacc));
1193 if ($paymentmethodobjsA->data !=
null && $paymentmethodobjsB->data !=
null) {
1194 $listofsources = array_merge((array) $paymentmethodobjsA->data, (array) $paymentmethodobjsB->data);
1195 } elseif ($paymentmethodobjsB->data !=
null) {
1196 $listofsources = $paymentmethodobjsB->data;
1198 $listofsources = $paymentmethodobjsA->data;
1207 dol_syslog(
"Error when searching/loading Stripe customer for thirdparty id =".
$object->id);
1213 if ($showcardpaymentmode &&
$object->client) {
1214 $morehtmlright =
'';
1216 $morehtmlright .= dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=createcard');
1218 print
load_fiche_titre($langs->trans(
'CreditCard'), $morehtmlright,
'fa-credit-card');
1221 print
'<!-- List of card payments -->'.
"\n";
1222 print
'<div class="div-table-responsive-no-min">';
1223 print
'<table class="liste centpercent noborder">'.
"\n";
1224 print
'<tr class="liste_titre">';
1225 print
'<td>'.$langs->trans(
'Label').
'</td>';
1226 print
'<td>'.$form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")).
'</td>';
1227 print
'<td>'.$langs->trans(
'Type').
'</td>';
1228 print
'<td>'.$langs->trans(
'Informations').
'</td>';
1230 print
'<td class="center">'.$langs->trans(
'Default').
'</td>';
1231 print
'<td>'.$langs->trans(
'Note').
'</td>';
1232 print
'<td>'.$langs->trans(
'DateModification').
'</td>';
1234 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'stripetitle');
1235 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
1236 print $hookmanager->resPrint;
1243 $arrayofremotecard = array();
1250 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_rib";
1251 $sql .=
" WHERE type in ('card')";
1252 $sql .=
" AND fk_soc = ".((int)
$object->id);
1253 $sql .=
" AND status = ".((int) $servicestatus);
1255 $resql =
$db->query($sql);
1257 $num_rows =
$db->num_rows($resql);
1260 while ($i < $num_rows) {
1263 $obj =
$db->fetch_object($resql);
1265 $companypaymentmodetemp->fetch($obj->rowid);
1267 $arrayofremotecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref;
1269 print
'<tr class="oddeven" data-rowid="'.((int) $companypaymentmodetemp->id).
'">';
1271 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->label).
'">';
1275 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->stripe_card_ref.(empty($companypaymentmodetemp->stripe_account) ?
'' :
' - '.$companypaymentmodetemp->stripe_account)).
'">';
1276 if (!empty($companypaymentmodetemp->stripe_card_ref) && !empty($companypaymentmodetemp->ext_payment_site)) {
1277 if (
isModEnabled(
'stripe') && in_array($companypaymentmodetemp->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1279 if (!empty($stripeacc)) {
1280 $connect = $stripeacc.
'/';
1282 if ($companypaymentmodetemp->ext_payment_site ==
'StripeLive') {
1283 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$companypaymentmodetemp->stripe_card_ref;
1285 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
1287 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe').
' - '.$companypaymentmodetemp->stripe_account,
'globe').
"</a> ";
1298 print
'<td class="minwidth100">';
1299 if ($companypaymentmodetemp->owner_name) {
1300 print
'<span class="opacitymedium">'.$companypaymentmodetemp->owner_name.
'</span><br>';
1302 if ($companypaymentmodetemp->last_four) {
1303 print
'....'.$companypaymentmodetemp->last_four;
1305 if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) {
1306 print
' - '.sprintf(
"%02d", $companypaymentmodetemp->exp_date_month).
'/'.$companypaymentmodetemp->exp_date_year;
1310 print
'<td class="tdoverflowmax100">';
1311 if ($companypaymentmodetemp->country_code) {
1313 print $img ? $img.
' ' :
'';
1314 print
getCountry($companypaymentmodetemp->country_code,
'1');
1316 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1320 print
'<td class="center">';
1321 if (empty($companypaymentmodetemp->default_rib)) {
1322 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=setlocalassourcedefault&token='.newToken().
'">';
1323 print
img_picto($langs->trans(
"Default"),
'off');
1326 print
img_picto($langs->trans(
"Default"),
'on');
1329 if (empty($companypaymentmodetemp->stripe_card_ref)) {
1330 $s = $langs->trans(
"Local");
1332 $s = $langs->trans(
"LocalAndRemote");
1334 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1338 print
dol_print_date($companypaymentmodetemp->date_modification,
'dayhour',
'tzuserrel');
1341 $parameters = array(
'arrayfields' => array(),
'obj' => $obj,
'linetype' =>
'stripecard');
1342 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1343 print $hookmanager->resPrint;
1345 print
'<td class="right minwidth50 nowraponall">';
1346 if ($permissiontoaddupdatepaymentinformation) {
1347 if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) {
1348 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=synccardtostripe&socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'" class="paddingrightonly marginrightonly">'.$langs->trans(
"CreateCardOnStripe").
'</a>';
1351 print
'<a class="editfielda marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=editcard&token='.newToken().
'">';
1352 print
img_picto($langs->trans(
"Modify"),
'edit');
1354 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=deletecard&token='.newToken().
'">';
1355 print
img_picto($langs->trans(
"Delete"),
'delete');
1370 if (is_array($listofsources) && count($listofsources)) {
1371 foreach ($listofsources as $src) {
1372 if (!empty($arrayofremotecard[$src->id])) {
1379 if ($src->object ==
'card') {
1381 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1383 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1385 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1387 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1391 print
'<tr class="oddeven">';
1395 print
'<td class="tdoverflowmax150">';
1397 if (!empty($stripeacc)) {
1398 $connect = $stripeacc.
'/';
1401 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1402 if ($servicestatus) {
1404 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1406 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1414 print
'<td valign="middle">';
1415 if ($src->object ==
'card') {
1416 print
'....'.$src->last4.
' - '.$src->exp_month.
'/'.$src->exp_year;
1418 if ($src->country) {
1420 print $img ? $img.
' ' :
'';
1423 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1425 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1426 print
'<span class="opacitymedium">'.$src->owner->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1429 if ($src->card->country) {
1431 print $img ? $img.
' ' :
'';
1434 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1436 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1437 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1439 if ($src->sepa_debit->country) {
1441 print $img ? $img.
' ' :
'';
1442 print
getCountry($src->sepa_debit->country,
'1');
1444 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1446 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1447 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1450 if ($src->card->country) {
1452 print $img ? $img.
' ' :
'';
1455 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1457 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1458 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1460 if ($src->sepa_debit->country) {
1462 print $img ? $img.
' ' :
'';
1463 print
getCountry($src->sepa_debit->country,
'1');
1465 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1472 print
'<td class="center" width="50">';
1473 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1474 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1475 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.newToken().
'">';
1476 print
img_picto($langs->trans(
"Default"),
'off');
1479 print
img_picto($langs->trans(
"Default"),
'on');
1483 print $langs->trans(
"Remote");
1492 $parameters = array(
'arrayfields' => array(),
'stripesource' => $src,
'linetype' =>
'stripecardremoteonly');
1493 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1494 print $hookmanager->resPrint;
1497 print
'<td class="right nowraponall">';
1498 if ($permissiontoaddupdatepaymentinformation) {
1499 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletecard&token='.newToken().
'">';
1500 print
img_picto($langs->trans(
"Delete"),
'delete');
1509 if ($nbremote == 0 && $nblocal == 0) {
1511 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1519 if (
isModEnabled(
'stripe') && !empty(
$conf->stripeconnect->enabled) && !empty($stripesupplieracc)) {
1520 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');
1521 $balance = \Stripe\Balance::retrieve(array(
"stripe_account" => $stripesupplieracc));
1522 print
'<!-- List of Stripe connected accounts -->'.
"\n";
1523 print
'<table class="liste centpercent noborder">'.
"\n";
1524 print
'<tr class="liste_titre">';
1525 print
'<td>'.$langs->trans(
'Currency').
'</td>';
1526 print
'<td>'.$langs->trans(
'Available').
'</td>';
1527 print
'<td>'.$langs->trans(
'Pending').
'</td>';
1528 print
'<td>'.$langs->trans(
'Total').
'</td>';
1531 $currencybalance = array();
1532 if (is_array($balance->available) && count($balance->available)) {
1533 foreach ($balance->available as $cpt) {
1534 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1535 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1536 $currencybalance[$cpt->currency][
'available'] = $cpt->amount / 100;
1538 $currencybalance[$cpt->currency][
'available'] = $cpt->amount;
1540 $currencybalance[$cpt->currency][
'currency'] = $cpt->currency;
1544 if (is_array($balance->pending) && count($balance->pending)) {
1545 foreach ($balance->pending as $cpt) {
1546 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1547 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1548 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount / 100;
1550 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount;
1555 if (is_array($currencybalance)) {
1556 foreach ($currencybalance as $cpt_arr) {
1557 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>';
1567 if ($permissiontoaddupdatepaymentinformation) {
1568 $morehtmlright = dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"] .
'?socid=' .
$object->id .
'&action=create');
1571 print
load_fiche_titre($langs->trans(
"BankAccounts"), $morehtmlright,
'bank');
1575 $arrayofremoteban = array();
1577 $rib_list =
$object->get_all_rib();
1579 if (is_array($rib_list)) {
1580 print
'<!-- List of bank accounts -->'.
"\n";
1581 print
'<div class="div-table-responsive-no-min">';
1582 print
'<table class="liste centpercent noborder">';
1584 print
'<tr class="liste_titre">';
1586 print_liste_field_titre($form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")));
1601 $parameters = array(
'arrayfields' => array(),
'linetype' =>
'stripebantitle');
1602 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1603 print $hookmanager->resPrint;
1608 foreach ($rib_list as $rib) {
1609 $arrayofremoteban[$rib->stripe_card_ref] = $rib->stripe_card_ref;
1613 print
'<tr class="oddeven">';
1615 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($rib->label).
'">'.
dolPrintHTML($rib->label);
1616 print
'<br><span class="opacitymedium">'.dolPrintHTML($rib->bank).
'</span>';
1620 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->stripe_card_ref.(empty($rib->stripe_account) ?
'' :
' - '.$rib->stripe_account)).
'">';
1621 if (!empty($rib->stripe_card_ref) && !empty($rib->ext_payment_site)) {
1622 if (
isModEnabled(
'stripe') && in_array($rib->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1624 if (!empty($stripeacc)) {
1625 $connect = $stripeacc.
'/';
1627 if ($rib->ext_payment_site ==
'StripeLive') {
1628 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$rib->stripe_card_ref;
1630 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$rib->stripe_card_ref;
1632 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1644 foreach ($rib->getFieldsToShow() as $val) {
1645 if ($val ==
'BankCode') {
1646 $string .= $rib->code_banque.
' ';
1647 } elseif ($val ==
'BankAccountNumber') {
1648 $string .= $rib->number.
' ';
1649 } elseif ($val ==
'DeskCode') {
1650 $string .= $rib->code_guichet.
' ';
1651 } elseif ($val ==
'BankAccountNumberKey') {
1652 $string .= $rib->cle_rib.
' ';
1660 if (!empty($rib->label) && $rib->number) {
1662 $string .=
img_picto($langs->trans(
"ValueIsNotValid"),
'warning',
'class="pictofixedwidth"').$string;
1664 $string .=
img_picto($langs->trans(
"ValueIsValid"),
'info',
'class="pictofixedwidth"').$string;
1668 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($string).
'">';
1673 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->iban).
'">';
1674 if (!empty($rib->iban)) {
1676 print
img_picto($langs->trans(
"IbanNotValid"),
'warning').
' ';
1683 if (!empty($rib->bic)) {
1685 print
img_picto($langs->trans(
"SwiftNotValid"),
'warning').
' ';
1693 print
'<td class="tdoverflowmax100 small" title="'.dolPrintHTMLForAttribute($rib->rum).
'">'.
dolPrintHTML($rib->rum);
1694 print
'<br><span class="opacitymedium">'.dolPrintHTML($rib->frstrecur).
'</span>';
1698 print
'<td>'.dol_print_date($rib->date_rum,
'day').
'</td>';
1702 print
'<td class="center" width="70">';
1703 if (!$rib->default_rib) {
1704 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?socid='.((int)
$object->id).
'&ribid='.((int) $rib->id).
'&action=setasbankdefault&token='.newToken().
'">';
1705 print
img_picto($langs->trans(
"Disabled"),
'off');
1708 print
img_picto($langs->trans(
"Enabled"),
'on');
1713 print
'<td class="center">';
1715 $buttonlabel = $langs->trans(
"BuildDoc");
1716 $forname =
'builddocrib'.$rib->id;
1718 include_once DOL_DOCUMENT_ROOT.
'/core/modules/bank/modules_bank.php';
1722 if (is_array($modellist) && count($modellist)) {
1723 $out .=
'<form action="'.$_SERVER[
"PHP_SELF"].(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#builddoc').
'" name="'.$forname.
'" id="'.$forname.
'_form" method="post">';
1724 $out .=
'<input type="hidden" name="action" value="builddocrib">';
1725 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1726 $out .=
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1727 $out .=
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1729 $modelselected =
'';
1730 if (count($modellist) == 1) {
1731 $arraykeys = array_keys($modellist);
1732 $modelselected = $arraykeys[0];
1738 $morecss =
'maxwidth125';
1739 if (
$conf->browser->layout ==
'phone') {
1740 $morecss =
'maxwidth100';
1743 $out .= $form->selectarray(
'modelrib'.$rib->id, $modellist, $modelselected, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 '.$morecss);
1748 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
1750 $defaultlang = $langs->getDefaultLang();
1751 $out .= $formadmin->select_language($defaultlang,
'lang_idrib'.$rib->id, 0, array(), 0, 0, 0, $morecss);
1754 $out .=
'<input class="button buttongen reposition nomargintop nomarginbottom small '.$morecss.
'" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
1755 $out .=
' type="submit" value="'.$buttonlabel.
'"';
1763 $parameters = array(
'arrayfields' => array(),
'stripe_card_ref' => $rib->stripe_card_ref,
'stripe_account' => $rib->stripe_account,
'linetype' =>
'stripeban');
1764 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1765 print $hookmanager->resPrint;
1769 print
'<td class="minwidth200 width200">';
1770 $useonlinesignature = 1;
1771 if ($useonlinesignature) {
1772 $rib->entity =
$object->entity;
1773 require_once DOL_DOCUMENT_ROOT .
'/core/lib/signature.lib.php';
1774 print showOnlineSignatureUrl($companybankaccount->element, (
string) $rib->id, $rib,
'short');
1780 print
'<td class="right nowraponall">';
1781 if ($permissiontoaddupdatepaymentinformation) {
1783 if (empty($rib->stripe_card_ref)) {
1786 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=syncsepatostripe&token='.newToken().
'">';
1787 print
img_picto($langs->trans(
"CreateBANOnStripe"),
'stripe');
1790 print
'<span class="opacitymedium marginrightonly marginleftonly">';
1791 print
img_picto($langs->trans(
"ThirdPartyMustBeACustomerToCreateBANOnStripe"),
'stripe');
1797 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=edit">';
1798 print
img_picto($langs->trans(
"Modify"),
'edit');
1801 print
'<a class="marginrightonly marginleftonly reposition" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=deletebank&token='.newToken().
'">';
1802 print
img_picto($langs->trans(
"Delete"),
'delete');
1812 foreach ($listofsources as $src) {
1813 if (!empty($arrayofremoteban[$src->id])) {
1818 if ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1819 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1820 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1821 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1828 print
'<tr class="oddeven">';
1833 print
'<td class="tdoverflowmax150">';
1835 if (!empty($stripeacc)) {
1836 $connect = $stripeacc.
'/';
1839 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1840 if ($servicestatus) {
1842 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1844 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1875 print
'<td class="center" width="50">';
1876 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1877 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1878 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.newToken().
'">';
1879 print
img_picto($langs->trans(
"Default"),
'off');
1882 print
img_picto($langs->trans(
"Default"),
'on');
1897 $parameters = array(
'arrayfields' => array(),
'src' => $src,
'linetype' =>
'stripebanremoteonly');
1898 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1899 print $hookmanager->resPrint;
1902 print
'<td class="right nowraponall">';
1903 if ($permissiontoaddupdatepaymentinformation) {
1904 print
'<a class="marginleftonly marginrightonly reposition" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletebank&token='.newToken().
'">';
1905 print
img_picto($langs->trans(
"Delete"),
'delete');
1913 if ($nbremote == 0 && $nblocal == 0) {
1921 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoBANRecord").
'</span></td></tr>';
1931 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'');
1932 $reshook = $hookmanager->executeHooks(
'printNewTable', $parameters, $object);
1933 print $hookmanager->resPrint;
1938 print
'<div class="fichecenter"><div class="fichehalfleft">';
1939 print
'<a name="builddoc"></a>';
1945 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".
$object->id;
1947 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);
1954 $result = $companypaymentmodetemp->fetch(0,
'',
$object->id,
'ban');
1956 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1959 $result = $ecmfile->fetch(0,
'',
'',
'',
'', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
1961 $companybankaccounttemp->last_main_doc = $ecmfile->filepath.
'/'.$ecmfile->filename;
1962 print
'<br><!-- Link to download main doc -->'.
"\n";
1963 print showDirectDownloadLink($companybankaccounttemp).
'<br>';
1967 print
'</div><div class="fichehalfright">';
1970 print
'</div></div>';
1996if ($socid && $action ==
'edit' && $permissiontoaddupdatepaymentinformation) {
1999 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2001 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2003 print
'<div class="underbanner clearboth"></div>';
2007 print
'<div class="div-table-responsive-no-min">';
2008 print
'<table class="border tableforfield centpercent">';
2010 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Label").
'</td>';
2011 print
'<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.
'" spellcheck="false"></td></tr>';
2013 $required = (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0) ?
"fieldrequired" :
"";
2014 print
'<tr><td class="'.$required.
'">'.$langs->trans(
"BankName").
'</td>';
2015 print
'<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.
'" spellcheck="false"></td></tr>';
2018 $companybankaccount->fetch($id);
2019 $bankaccount = $companybankaccount;
2021 foreach ($bankaccount->getFieldsToShow(1) as $val) {
2026 $content =
'NoContent';
2027 if ($val ==
'BankCode') {
2028 $name =
'code_banque';
2030 $content = $bankaccount->code_banque;
2031 } elseif ($val ==
'DeskCode') {
2032 $name =
'code_guichet';
2034 $content = $bankaccount->code_guichet;
2035 } elseif ($val ==
'BankAccountNumber') {
2038 $content = $bankaccount->number;
2039 } elseif ($val ==
'BankAccountNumberKey') {
2042 $content = $bankaccount->cle_rib;
2043 } elseif ($val ==
'IBAN') {
2046 $content = $bankaccount->iban;
2047 if ($bankaccount->needIBAN()) {
2050 $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';
2051 } elseif ($val ==
'BIC') {
2054 $content = $bankaccount->bic;
2055 if ($bankaccount->needBIC() && (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0)) {
2058 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2062 print
'<td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2065 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2067 print $langs->trans($val);
2070 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.$content.
'"></td>';
2075 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Currency").
'</td>';
2077 $selectedcode = $bankaccount->currency_code;
2078 if (!$selectedcode) {
2079 $selectedcode =
$conf->currency;
2081 print $form->selectCurrency((GETPOSTISSET(
"account_currency_code") ?
GETPOST(
"account_currency_code") : $selectedcode),
'account_currency_code');
2087 $account_status = $bankaccount->status;
2088 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
'</td>';
2090 print $form->selectarray(
"clos", $bankaccount->labelStatus, $account_status, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth150onsmartphone');
2094 $country_codeid =
GETPOST(
"account_country_id") ?
GETPOST(
"account_country_id") : $bankaccount->fk_country;
2095 if (empty($country_codeid)) {
2096 $country_codeid =
$mysoc->country_code;
2098 $bankaccount->country_code =
getCountry($country_codeid,
'2');
2100 print
'<tr><td class="fieldrequired">'.$langs->trans(
"BankAccountCountry").
'</td>';
2102 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
2103 print $form->select_country($country_codeid,
'account_country_id');
2105 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2110 $selected_state_id = $bankaccount->state_id;
2111 print
'<tr><td>'.$langs->trans(
'State').
'</td><td>';
2112 if ($country_codeid) {
2113 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2114 print $formcompany->select_state($selected_state_id, $country_codeid,
'account_state_id');
2116 print $countrynotdefined;
2120 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2121 print
'<textarea name="address" rows="'.ROWS_4.
'" cols="40" maxlength="255" spellcheck="false">';
2123 print
"</textarea></td></tr>";
2125 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2126 print
'<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->owner_name.
'" spellcheck="false"></td></tr>';
2127 print
"</td></tr>\n";
2129 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2130 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" cols="40" maxlength="255" spellcheck="false">';
2132 print
"</textarea></td></tr>";
2140 print
'<div class="div-table-responsive-no-min">';
2141 print
'<table class="border tableforfield centpercent">';
2143 if (empty($companybankaccount->rum)) {
2144 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
2148 print
'<tr><td class="titlefieldcreate" colspan="5">'.$langs->trans(
"WithdrawalsSetup").
'</td></tr>';
2151 print
'<tr><td class="titlefield">'.$langs->trans(
"RUM").
'</td>';
2152 print
'<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).
'" spellcheck="false"></td></tr>';
2156 print
'<tr><td class="titlefield">'.$langs->trans(
"DateRUM").
'</td>';
2157 print
'<td>'.$form->selectDate($date_rum ? $date_rum : $companybankaccount->date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2159 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2160 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2161 print $form->selectarray(
"frstrecur", $tblArraychoice,
dol_escape_htmltag(
GETPOST(
'frstrecur',
'alpha') ?
GETPOST(
'frstrecur',
'alpha') : $companybankaccount->frstrecur), 0);
2164 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_...' or 'src_...')</td>";
2165 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'" spellcheck="false"></td></tr>';
2174 print $form->buttonsSaveCancel(
"Modify");
2178if ($socid && $action ==
'editcard' && $permissiontoaddupdatepaymentinformation) {
2181 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2183 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2185 print
'<div class="nofichecenter">';
2187 print
'<div class="underbanner clearboth"></div>';
2191 print
'<div class="div-table-responsive-no-min">';
2192 print
'<table class="border centpercent">';
2194 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2195 print
'<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.
'" spellcheck="false"></td></tr>';
2197 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2198 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->owner_name.
'" spellcheck="false"></td></tr>';
2200 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2201 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.
'" spellcheck="false"></td></tr>';
2203 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2205 print $formother->select_month((
string) $companypaymentmode->exp_date_month,
'exp_date_month', 1);
2206 print $formother->selectyear((
string) $companypaymentmode->exp_date_year,
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2209 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2210 print
'<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.
'"></td></tr>';
2212 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_... ".$langs->trans(
"or").
" card_....')</td>";
2213 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'" spellcheck="false"></td></tr>';
2221 print $form->buttonsSaveCancel(
"Modify");
2226if ($socid && $action ==
'create' && $permissiontoaddupdatepaymentinformation) {
2229 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2231 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2233 print
'<div class="nofichecenter">';
2235 print
'<div class="underbanner clearboth"></div>';
2239 print
'<div class="div-table-responsive-no-min">';
2240 print
'<table class="border tableforfield centpercent">';
2242 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2243 print
'<td><input class="minwidth250" type="text" id="label" name="label" value="'.(GETPOSTISSET(
'label') ?
GETPOST(
'label') : $langs->trans(
"Bank").
' '.
$object->
name).
'" spellcheck="false"></td></tr>';
2245 print
'<tr><td>'.$langs->trans(
"Bank").
'</td>';
2246 print
'<td><input class="minwidth250" type="text" id="bank" name="bank" value="'.GETPOST(
'bank').
'" spellcheck="false"></td></tr>';
2249 foreach ($companybankaccount->getFieldsToShow(1) as $val) {
2254 $content =
'NoContent';
2256 if ($val ==
'BankCode') {
2257 $name =
'code_banque';
2259 $content = $companybankaccount->code_banque;
2260 } elseif ($val ==
'DeskCode') {
2261 $name =
'code_guichet';
2263 $content = $companybankaccount->code_guichet;
2264 } elseif ($val ==
'BankAccountNumber') {
2267 $content = $companybankaccount->number;
2268 } elseif ($val ==
'BankAccountNumberKey') {
2271 $content = $companybankaccount->cle_rib;
2272 } elseif ($val ==
'IBAN') {
2275 $content = $companybankaccount->iban;
2276 if ($companybankaccount->needIBAN()) {
2279 $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';
2280 } elseif ($val ==
'BIC') {
2283 $content = $companybankaccount->bic;
2284 if ($companybankaccount->needBIC() && (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0)) {
2287 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2290 print
'<tr><td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2293 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2295 print $langs->trans($val);
2298 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" id="'.$name.
'" value="'.
GETPOST($name).
'" spellcheck="false"></td>';
2303 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Currency").
'</td>';
2305 $selectedcode =
$object->currency_code;
2306 if (!$selectedcode) {
2307 $selectedcode =
$conf->currency;
2309 print $form->selectCurrency((GETPOSTISSET(
"account_currency_code") ?
GETPOST(
"account_currency_code") : $selectedcode),
'account_currency_code');
2315 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
'</td>';
2317 print $form->selectarray(
"clos", $companybankaccount->labelStatus, (GETPOSTISSET(
'clos') ?
GETPOSTINT(
'clos') : $companybankaccount::STATUS_OPEN), 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth150onsmartphone');
2322 if (GETPOSTISSET(
"account_country_id")) {
2323 $selectedcode =
GETPOST(
"account_country_id") ?
GETPOST(
"account_country_id") :
$object->country_code;
2324 } elseif (empty($selectedcode)) {
2325 $selectedcode =
$mysoc->country_code;
2329 print
'<tr><td class="fieldrequired">'.$langs->trans(
"BankAccountCountry").
'</td>';
2331 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
2332 print $form->select_country($selectedcode,
'account_country_id');
2334 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2339 print
'<tr><td>'.$langs->trans(
'State').
'</td><td>';
2340 if ($selectedcode) {
2341 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2342 print $formcompany->select_state(GETPOSTISSET(
"account_state_id") ?
GETPOSTINT(
"account_state_id") : 0, $selectedcode,
'account_state_id');
2344 print $countrynotdefined;
2348 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2349 print
'<textarea name="address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2351 print
"</textarea></td></tr>";
2353 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2354 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio').
'" spellcheck="false"></td></tr>';
2355 print
"</td></tr>\n";
2357 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2358 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2360 print
"</textarea></td></tr>";
2368 print
'<div class="div-table-responsive-no-min">';
2369 print
'<table class="border tableforfield centpercent">';
2372 print
'<tr><td class="titlefieldcreate" colspan="5">'.$langs->trans(
"WithdrawalsSetup").
'</td></tr>';
2375 print
'<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans(
"RUM"), $langs->trans(
"RUMLong").
'<br>'.$langs->trans(
"RUMWillBeGenerated")).
'</td>';
2376 print
'<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST(
'rum',
'alpha').
'" spellcheck="false"></td></tr>';
2380 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DateRUM").
'</td>';
2381 print
'<td colspan="4">'.$form->selectDate($date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2383 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2384 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2385 print $form->selectarray(
"frstrecur", $tblArraychoice, (GETPOSTISSET(
'frstrecur') ?
GETPOST(
'frstrecur') :
'FRST'), 0);
2388 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('src_....')</td>";
2389 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'" spellcheck="false"></td></tr>';
2401 print $form->buttonsSaveCancel(
"Add");
2405if ($socid && $action ==
'createcard' && $permissiontoaddupdatepaymentinformation) {
2408 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2410 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2412 print
'<div class="nofichecenter">';
2414 print
'<div class="underbanner clearboth"></div>';
2418 print
'<div class="div-table-responsive-no-min">';
2419 print
'<table class="border centpercent">';
2421 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2422 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST(
'label',
'alpha').
'" spellcheck="false"></td></tr>';
2424 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2425 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio',
'alpha').
'" spellcheck="false"></td></tr>';
2427 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2428 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST(
'cardnumber',
'alpha').
'" spellcheck="false"></td></tr>';
2430 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2432 print $formother->select_month((
string)
GETPOSTINT(
'exp_date_month'),
'exp_date_month', 1);
2433 print $formother->selectyear((
string)
GETPOSTINT(
'exp_date_year'),
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2436 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2437 print
'<td><input class="width50" type="text" name="cvn" value="'.GETPOST(
'cvn',
'alpha').
'" spellcheck="false"></td></tr>';
2439 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('card_....')</td>";
2440 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'" spellcheck="false"></td></tr>';
2451 print $form->buttonsSaveCancel(
"Add");
2454if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
2457if ($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, $subtabs='')
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.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
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.
dolPrintHTMLForTextArea($s, $allowiframe=0)
Return a string ready to be output on input textarea.
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)
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).
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...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
$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.