36require
'../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/societe/class/companypaymentmode.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
57$langs->loadLangs(array(
"companies",
"commercial",
"banks",
"bills",
'paypal',
'stripe',
'withdrawals'));
61$action =
GETPOST(
"action",
'alpha', 3);
62$cancel =
GETPOST(
'cancel',
'alpha');
63$backtopage =
GETPOST(
'backtopage');
66$source =
GETPOST(
"source",
"alpha");
72 $socid = $user->socid;
86$extrafields->fetch_name_optionals_label(
$object->table_element);
89$hookmanager->initHooks(array(
'thirdpartybancard',
'globalcard'));
92$permissiontoread = $user->hasRight(
'societe',
'lire');
93$permissiontoadd = $user->hasRight(
'societe',
'creer');
95$permissiontoaddupdatepaymentinformation = $user->hasRight(
'societe',
'thirdparty_paymentinformation',
'write');
106$site_account =
'UnknownSiteAccount';
110 $service =
'StripeTest';
112 $service =
'StripeLive';
117 global $stripearrayofkeysbyenv;
118 $site_account = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
120 $stripe =
new Stripe($db);
121 $stripeacc = $stripe->getStripeAccount($service);
122 $stripecu = $stripe->getStripeCustomerAccount(
$object->id, $servicestatus, $site_account);
137$parameters = array(
'id' => $socid);
138$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
140 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
143if (empty($reshook)) {
146 if (!empty($backtopage)) {
147 header(
"Location: ".$backtopage);
155 if (in_array($action, [
'update',
'updatecard',
'edit',
'editcard',
'setasbankdefault',
'confirm_deletecard',
'confirm_deletebank',
'synccardtostripe',
'syncsepatostripe'])) {
156 $idtocheckowner = ($ribid > 0 ? $ribid :
$id);
157 if ($idtocheckowner > 0) {
159 if ($tmppaymentinfo->fetch($idtocheckowner) <= 0 || $tmppaymentinfo->socid !=
$object->id) {
165 if ($action ==
'update' && $permissiontoaddupdatepaymentinformation) {
168 if (!
GETPOST(
'label',
'alpha')) {
169 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
172 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankName")),
null,
'errors');
177 $companybankaccount->fetch($id);
178 if ($companybankaccount->needIBAN() == 1) {
180 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
185 if ($companybankaccount->needBIC() == 1) {
187 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
194 $companybankaccount->oldcopy =
dol_clone($companybankaccount, 2);
196 $companybankaccount->socid =
$object->id;
198 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
199 $companybankaccount->label =
GETPOST(
'label',
'alpha');
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->currency_code =
GETPOST(
'account_currency_code',
'alpha');
208 $companybankaccount->fk_country =
GETPOSTINT(
'account_country_id');
209 $companybankaccount->state_id =
GETPOSTINT(
'account_state_id');
210 $companybankaccount->address =
GETPOST(
'address',
'alpha');
212 $companybankaccount->owner_name =
GETPOST(
'proprio',
'alpha');
213 $companybankaccount->proprio = $companybankaccount->owner_name;
214 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
215 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
216 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
217 $companybankaccount->date_rum =
GETPOSTDATE(
'date_rum',
'00:00:00');
218 if (empty($companybankaccount->rum)) {
219 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
222 $companybankaccount->status =
GETPOSTINT(
'clos');
224 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
226 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
228 $companybankaccount->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
230 $result = $companybankaccount->update($user);
233 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
237 if ($companybankaccount->default_rib) {
238 $companybankaccount->setAsDefault($id);
241 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
242 if ($companybankaccount->oldcopy->iban != $companybankaccount->iban) {
247 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
248 header(
'Location: '.$url);
254 if ($action ==
'updatecard' && $permissiontoaddupdatepaymentinformation) {
256 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
257 if (!
GETPOST(
'label',
'alpha')) {
258 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
260 if (!
GETPOST(
'proprio',
'alpha')) {
261 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
264 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
265 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
268 $action =
'createcard';
272 $companypaymentmode->fetch($id);
274 $companypaymentmode->oldcopy =
dol_clone($companypaymentmode, 2);
276 $companypaymentmode->fk_soc =
$object->id;
278 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
279 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
280 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
281 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
282 $companypaymentmode->owner_name =
GETPOST(
'proprio',
'alpha');
283 $companypaymentmode->proprio = $companypaymentmode->owner_name;
284 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
285 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
286 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
287 $companypaymentmode->country_code =
$object->country_code;
289 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
291 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
293 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
295 $result = $companypaymentmode->update($user);
297 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
300 if ($companypaymentmode->default_rib) {
301 $companypaymentmode->setAsDefault($id);
304 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
305 if ($companybankaccount->oldcopy->number != $companybankaccount->number) {
310 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
311 header(
'Location: '.$url);
318 if ($action ==
'add' && $permissiontoaddupdatepaymentinformation) {
321 if (!
GETPOST(
'label',
'alpha')) {
322 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
331 $companybankaccount->socid =
$object->id;
333 $companybankaccount->fetch_thirdparty();
335 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
336 $companybankaccount->label =
GETPOST(
'label',
'alpha');
337 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
338 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
339 $companybankaccount->number =
GETPOST(
'number',
'alpha');
340 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
341 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
342 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
344 $companybankaccount->currency_code =
GETPOST(
'account_currency_code',
'alpha');
345 $companybankaccount->fk_country =
GETPOSTINT(
'account_country_id');
346 $companybankaccount->state_id =
GETPOSTINT(
'account_state_id');
347 $companybankaccount->address =
GETPOST(
'address',
'alpha');
349 $companybankaccount->owner_name =
GETPOST(
'proprio',
'alpha');
350 $companybankaccount->proprio = $companybankaccount->owner_name;
351 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
352 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
353 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
354 $companybankaccount->date_rum =
GETPOSTDATE(
'date_rum',
'00:00:00');
355 $companybankaccount->datec =
dol_now();
357 $companybankaccount->status =
GETPOSTINT(
'clos');
359 $companybankaccount->bank = trim($companybankaccount->bank);
360 if (empty($companybankaccount->bank) && !empty($companybankaccount->thirdparty)) {
361 $companybankaccount->bank = $langs->trans(
"Bank").
' '.$companybankaccount->thirdparty->name;
363 $companybankaccount->bic = str_replace(
' ',
'', $companybankaccount->bic);
368 if ($companybankaccount->needIBAN() == 1) {
370 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
375 if ($companybankaccount->needBIC() == 1) {
377 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
384 $result = $companybankaccount->create($user);
387 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
391 if (empty($companybankaccount->rum)) {
392 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
397 $result = $companybankaccount->update($user);
400 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
408 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
409 header(
'Location: '.$url);
418 if ($action ==
'addcard' && $permissiontoaddupdatepaymentinformation) {
421 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
422 if (!
GETPOST(
'label',
'alpha')) {
423 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
425 if (!
GETPOST(
'proprio',
'alpha')) {
426 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
429 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
430 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
433 $action =
'createcard';
441 $companypaymentmode->fk_soc =
$object->id;
442 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
443 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
444 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
445 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
446 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
447 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
448 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
449 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
450 $companypaymentmode->datec =
dol_now();
451 $companypaymentmode->default_rib = 0;
452 $companypaymentmode->type =
'card';
453 $companypaymentmode->country_code =
$object->country_code;
454 $companypaymentmode->status = $servicestatus;
456 if (
GETPOST(
'stripe_card_ref',
'alpha')) {
458 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
460 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
465 $result = $companypaymentmode->create($user);
468 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
469 $action =
'createcard';
476 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
477 header(
'Location: '.$url);
485 if ($action ==
'setasbankdefault' &&
GETPOSTINT(
'ribid') > 0 && $permissiontoaddupdatepaymentinformation) {
487 $res = $companybankaccount->setAsDefault(
GETPOSTINT(
'ribid'));
489 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
490 header(
'Location: '.$url);
493 setEventMessages($db->lasterror,
null,
'errors');
497 if ($action ==
'confirm_deletecard' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoaddupdatepaymentinformation) {
500 if ($companypaymentmode->fetch($ribid ? $ribid :
$id)) {
511 $result = $companypaymentmode->delete($user);
513 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
515 header(
'Location: '.$url);
518 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
521 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
524 if ($action ==
'confirm_deletebank' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoaddupdatepaymentinformation) {
527 if ($companybankaccount->fetch($ribid ? $ribid :
$id) > 0) {
538 $result = $companybankaccount->delete($user);
541 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
543 header(
'Location: '.$url);
546 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
549 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
556 if ($action ==
'builddocrib' && $permissiontoread) {
557 $action =
'builddoc';
559 'use_companybankid' =>
GETPOST(
'companybankid'),
562 $_POST[
'lang_id'] =
GETPOST(
'lang_idrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
563 $_POST[
'model'] =
GETPOST(
'modelrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
568 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
574 if (($action ==
'synccustomertostripe' || $action ==
'synccustomertostripetest') && $permissiontoaddupdatepaymentinformation) {
577 setEventMessages(
'ThisThirdpartyIsNotACustomer',
null,
'errors');
579 if ($action ==
'synccustomertostripe') {
580 $tmpservicestatus = 1;
581 $tmpservice =
'StripeLive';
583 $tmpservicestatus = 0;
584 $tmpservice =
'StripeTest';
587 $stripe =
new Stripe($db);
588 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
591 $tmpcu = $stripe->customerStripe($object, $tmpstripeacc, $tmpservicestatus, 1);
595 setEventMessages($stripe->error, $stripe->errors,
'errors');
597 if ($tmpservicestatus == $servicestatus) {
598 $stripecu = $tmpcu->id;
603 if ($action ==
'synccardtostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
606 $companypaymentmode->fetch($id);
608 if ($companypaymentmode->type !=
'card') {
610 setEventMessages(
'ThisPaymentModeIsNotACard',
null,
'errors');
613 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
616 setEventMessages($stripe->error, $stripe->errors,
'errors');
620 '@phan-var-force \Stripe\Customer $cu';
624 $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
627 setEventMessages($stripe->error, $stripe->errors,
'errors');
632 if ($action ==
'syncsepatostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
635 $companypaymentmode->fetch($id);
637 if ($companypaymentmode->type !=
'ban') {
639 $langs->load(
"errors");
640 setEventMessages(
'ThisPaymentModeIsNotABan',
null,
'errors');
643 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
647 $langs->load(
"errors");
648 setEventMessages($langs->trans(
"ErrorStripeCustomerNotFoundCreateFirst"),
null,
'errors');
651 '@phan-var-force \Stripe\Customer $cu';
653 $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
656 setEventMessages($stripe->error, $stripe->errors,
'errors');
658 setEventMessages(
"", array(
"Bank Account on Stripe",
"BAN is now linked to the Stripe customer account !"));
665 if (($action ==
'setkey_account' || $action ==
'setkey_accounttest') && $permissiontoaddupdatepaymentinformation) {
668 $tmpservice =
'StripeTest';
669 $tmpservicestatus = 0;
670 if ($action ==
'setkey_account') {
671 $tmpservice =
'StripeLive';
672 $tmpservicestatus = 1;
676 global $stripearrayofkeysbyenv;
677 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
679 if ($action ==
'setkey_account') {
680 $newcu =
GETPOST(
'key_account',
'alpha');
682 $newcu =
GETPOST(
'key_accounttest',
'alpha');
688 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_account";
689 $sql .=
" WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($tmpsite_account).
"') AND fk_soc = ".((int)
$object->id).
" AND status = ".((int) $tmpservicestatus).
" AND entity = ".((int)
$conf->entity);
691 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_account";
692 $sql .=
" WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($tmpsite_account).
"') AND fk_soc = ".((int)
$object->id).
" AND status = ".((int) $tmpservicestatus).
" AND entity = ".((int)
$conf->entity);
695 $resql = $db->query($sql);
696 $num = $db->num_rows($resql);
698 if (!empty($newcu)) {
701 $societeaccount->fk_soc =
$object->id;
702 $societeaccount->login =
'';
703 $societeaccount->pass_encoding =
'';
704 $societeaccount->site =
'stripe';
705 $societeaccount->status = $servicestatus;
706 $societeaccount->key_account = $newcu;
707 $societeaccount->site_account = $tmpsite_account;
708 $result = $societeaccount->create($user);
713 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"societe_account";
714 $sql .=
" SET key_account = '".$db->escape($newcu).
"', site_account = '".$db->escape($tmpsite_account).
"'";
715 $sql .=
" WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($tmpsite_account).
"') AND fk_soc = ".((int)
$object->id).
" AND status = ".((int) $tmpservicestatus).
" AND entity = ".((int)
$conf->entity);
716 $resql = $db->query($sql);
724 if ($tmpservicestatus == $servicestatus) {
734 if (($action ==
'setkey_account_supplier' || $action ==
'setkey_account_suppliertest') && $permissiontoaddupdatepaymentinformation) {
737 $tmpservice =
'StripeTest';
738 $tmpservicestatus = 0;
739 if ($action ==
'setkey_account_supplier') {
740 $tmpservice =
'StripeLive';
741 $tmpservicestatus = 1;
745 global $stripearrayofkeysbyenv;
746 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
748 if ($action ==
'setkey_account_supplier') {
749 $newsup =
GETPOST(
'key_account_supplier',
'alpha');
751 $newsup =
GETPOST(
'key_account_suppliertest',
'alpha');
757 if (empty($newsup)) {
758 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"oauth_token WHERE fk_soc = ".((int)
$object->id).
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".((int)
$conf->entity);
763 $stripesup = \Stripe\Account::retrieve($newsup);
764 $tokenstring = array();
765 $tokenstring[
'stripe_user_id'] = $stripesup->id;
766 $tokenstring[
'type'] = $stripesup->type;
767 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"oauth_token";
768 $sql .=
" SET tokenstring = '".$db->escape(json_encode($tokenstring)).
"'";
769 $sql .=
" WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($tmpsite_account).
"') AND fk_soc = ".((int)
$object->id).
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".((int)
$conf->entity);
771 $sql .=
" WHERE fk_soc = ".((int)
$object->id).
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".((int)
$conf->entity);
774 setEventMessages($e->getMessage(),
null,
'errors');
778 $resql = $db->query($sql);
779 $num = $db->num_rows($resql);
780 if (empty($num) && !empty($newsup)) {
782 $stripesup = \Stripe\Account::retrieve($newsup);
783 $tokenstring[
'stripe_user_id'] = $stripesup->id;
784 $tokenstring[
'type'] = $stripesup->type;
785 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"oauth_token (service, fk_soc, entity, tokenstring)";
786 $sql .=
" VALUES ('".$db->escape($tmpservice).
"', ".((int)
$object->id).
", ".((int)
$conf->entity).
", '".$db->escape(json_encode($tokenstring)).
"')";
790 setEventMessages($e->getMessage(),
null,
'errors');
792 $resql = $db->query($sql);
796 if ($tmpservicestatus == $servicestatus) {
797 $stripesupplieracc = $newsup;
805 if ($action ==
'setlocalassourcedefault' && $permissiontoaddupdatepaymentinformation) {
807 $companypaymentmode->setAsDefault($id);
809 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
810 header(
'Location: '.$url);
814 setEventMessages($e->getMessage(),
null,
'errors');
816 } elseif ($action ==
'setassourcedefault' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
818 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
819 if (preg_match(
'/pm_|src_/', $source)) {
820 $cu->invoice_settings->default_payment_method = (string) $source;
822 $cu->default_source = (string) $source;
825 $result = $cu->save();
827 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
828 header(
'Location: '.$url);
832 setEventMessages($e->getMessage(),
null,
'errors');
834 } elseif ($action ==
'deletecard' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
837 if (preg_match(
'/pm_/', $source)) {
838 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
839 if ($payment_method) {
840 $payment_method->detach();
843 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
844 $card = $cu->sources->retrieve(
"$source");
847 if (method_exists($card,
'detach')) {
849 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
850 $sql .=
" SET stripe_card_ref = null";
851 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
853 $resql = $db->query($sql);
860 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
861 header(
'Location: '.$url);
865 setEventMessages($e->getMessage(),
null,
'errors');
867 } elseif ($action ==
'deletebank' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
870 if (preg_match(
'/pm_/', $source)) {
871 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
872 if ($payment_method) {
873 $payment_method->detach();
876 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
877 $card = $cu->sources->retrieve((
string) $source);
880 if (method_exists($card,
'detach')) {
882 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
883 $sql .=
" SET stripe_card_ref = null";
884 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
886 $resql = $db->query($sql);
893 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
895 $url .=
'&page_y='.GETPOSTINT(
'page_y');
898 header(
'Location: '.$url);
902 setEventMessages($e->getMessage(),
null,
'errors');
914$form =
new Form($db);
919$countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
921$title = $langs->trans(
"ThirdParty");
923 $title =
$object->name.
" - ".$langs->trans(
'PaymentInformation');
936 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'), [],
'warning');
942 $companybankaccount->fetch(0,
'',
$object->id);
944 $companypaymentmode->fetch(0,
'',
$object->id,
'card');
946 $companybankaccount->fetch($id);
947 $companypaymentmode->fetch($id);
949if (empty($companybankaccount->socid)) {
950 $companybankaccount->socid =
$object->id;
953if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
954 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post" spellcheck="false">';
955 print
'<input type="hidden" name="token" value="'.newToken().
'">';
956 $actionforadd =
'update';
957 if ($action ==
'editcard') {
958 $actionforadd =
'updatecard';
960 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
961 print
'<input type="hidden" name="id" value="'.GETPOSTINT(
"id").
'">';
963if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
964 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post" spellcheck="false">';
965 print
'<input type="hidden" name="token" value="'.newToken().
'">';
966 $actionforadd =
'add';
967 if ($action ==
'createcard') {
968 $actionforadd =
'addcard';
970 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
974if ($socid && $action !=
'edit' && $action !=
'create' && $action !=
'editcard' && $action !=
'createcard') {
978 if ($action ==
'deletebank') {
979 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);
982 if ($action ==
'deletecard') {
983 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);
986 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
988 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
990 print
'<div class="fichecenter">';
992 print
'<div class="underbanner clearboth"></div>';
993 print
'<table class="border tableforfield centpercent">';
996 print
'<tr><td class="titlefield">';
997 print $langs->trans(
'NatureOfThirdParty');
1003 print
'<tr><td class="titlefield">';
1004 print $langs->trans(
'CustomerCode');
1007 $tmpcheck =
$object->check_codeclient();
1008 if ($tmpcheck != 0 && $tmpcheck != -5) {
1009 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
1012 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
1013 $resql = $db->query($sql);
1015 dol_print_error($db);
1018 $obj = $db->fetch_object($resql);
1019 $nbFactsClient = $obj->nb;
1020 $thirdTypeArray = array();
1021 $elementTypeArray = array();
1022 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
1023 if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
1024 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
1026 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
1027 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1029 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1030 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1032 if (
isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1033 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1038 global $stripearrayofkeysbyenv;
1041 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1042 $tmpstripeacc = $stripe->getStripeAccount((
string) $tmpservice);
1043 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1046 print
'<tr><td class="titlefield">';
1047 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1048 print
'</td><td'.(empty($tmpstripecu) ?
' class="right"' :
'').
'>';
1049 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu,
$object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1050 if ($tmpstripecu && $action !=
'editkey_accounttest') {
1052 if (!empty($stripeacc)) {
1053 $connect = $stripeacc.
'/';
1055 $url =
'https://dashboard.stripe.com/'.$connect.
'test/customers/'.$tmpstripecu;
1056 print
' <a href="'.$url.
'" target="_stripe">'.img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1058 if (empty($tmpstripecu)) {
1059 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" class="nowraponall" spellcheck="false">';
1060 print
'<input type="hidden" name="action" value="synccustomertostripetest">';
1061 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1062 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1063 print img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1064 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomertest" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1070 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1071 $tmpstripeacc = $stripe->getStripeAccount((
string) $tmpservice);
1072 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1075 print
'<tr><td class="titlefield">';
1076 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1077 print
'</td><td'.(empty($tmpstripecu) ?
' class="right"' :
'').
'>';
1078 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu,
$object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1079 if ($tmpstripecu && $action !=
'editkey_account') {
1081 if (!empty($stripeacc)) {
1082 $connect = $stripeacc.
'/';
1084 $url =
'https://dashboard.stripe.com/'.$connect.
'customers/'.$tmpstripecu;
1085 print
' <a href="'.$url.
'" target="_stripe">'.img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1087 if (empty($tmpstripecu)) {
1088 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" class="nowraponall" spellcheck="false">';
1089 print
'<input type="hidden" name="action" value="synccustomertostripe">';
1090 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1091 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1092 print img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1093 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomer" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1101 print
'<tr><td class="titlefield">';
1102 print $langs->trans(
'SupplierCode');
1105 $tmpcheck =
$object->check_codefournisseur();
1106 if ($tmpcheck != 0 && $tmpcheck != -5) {
1107 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
1110 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
1111 $resql = $db->query($sql);
1113 dol_print_error($db);
1115 $obj = $db->fetch_object($resql);
1116 $nbFactsClient = $obj->nb;
1117 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
1118 if (
isModEnabled(
'propal') && $user->hasRight(
'propal',
'lire')) {
1119 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
1121 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
1122 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1124 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1125 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1127 if (
isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1128 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1134 $stripesupplieracc = $stripe->getStripeAccount($service,
$object->id);
1137 print
'<tr><td class="titlefield">';
1138 print $form->editfieldkey(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1139 print
'</td><td'.(empty($stripesupplieracc) ?
' class="right"' :
'').
'>';
1140 print $form->editfieldval(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1141 if ($stripesupplieracc && $action !=
'editkey_account_supplier') {
1144 $url =
'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc;
1145 if ($servicestatus) {
1146 $url =
'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc;
1148 print
' <a href="'.$url.
'" target="_stripe">'.img_picto($langs->trans(
'ShowInStripe').
' - Publishable key '.$site_account,
'globe').
'</a>';
1150 if (empty($stripesupplieracc)) {
1151 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" class="nowraponall" spellcheck="false">';
1152 print
'<input type="hidden" name="action" value="syncsuppliertostripe">';
1153 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1154 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1155 print
'<input type="hidden" name="companybankid" value="'.$ribid.
'">';
1169 $showcardpaymentmode = 0;
1171 $showcardpaymentmode++;
1175 $listofsources = array();
1177 $customerstripe =
null;
1178 if (isset($stripe) && is_object($stripe) && $stripeacc !==
null) {
1180 $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus);
1181 if (!empty($customerstripe->id)) {
1184 $listofsources = $customerstripe->sources->data;
1186 $service =
'StripeTest';
1189 $service =
'StripeLive';
1194 global $stripearrayofkeysbyenv;
1195 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
1198 if (empty($stripeacc)) {
1199 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"));
1200 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"));
1202 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"), array(
"stripe_account" => $stripeacc));
1203 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"), array(
"stripe_account" => $stripeacc));
1206 if ($paymentmethodobjsA->data !=
null && $paymentmethodobjsB->data !=
null) {
1207 $listofsources = array_merge((array) $paymentmethodobjsA->data, (array) $paymentmethodobjsB->data);
1208 } elseif ($paymentmethodobjsB->data !=
null) {
1209 $listofsources = $paymentmethodobjsB->data;
1211 $listofsources = $paymentmethodobjsA->data;
1215 setEventMessages($e->getMessage(),
null,
'errors');
1220 dol_syslog(
"Error when searching/loading Stripe customer for thirdparty id =".
$object->id);
1226 if ($showcardpaymentmode &&
$object->client) {
1227 $morehtmlright =
'';
1229 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=createcard');
1231 print
load_fiche_titre($langs->trans(
'CreditCard'), $morehtmlright,
'fa-credit-card');
1234 print
'<!-- List of card payments -->'.
"\n";
1235 print
'<div class="div-table-responsive-no-min">';
1236 print
'<table class="liste centpercent noborder">'.
"\n";
1237 print
'<tr class="liste_titre">';
1238 print
'<td>'.$langs->trans(
'Label').
'</td>';
1239 print
'<td>'.$form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")).
'</td>';
1240 print
'<td>'.$langs->trans(
'Type').
'</td>';
1241 print
'<td>'.$langs->trans(
'Informations').
'</td>';
1243 print
'<td class="center">'.$langs->trans(
'Default').
'</td>';
1244 print
'<td>'.$langs->trans(
'Note').
'</td>';
1245 print
'<td>'.$langs->trans(
'DateModification').
'</td>';
1247 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'stripetitle');
1248 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
1249 print $hookmanager->resPrint;
1256 $arrayofremotecard = array();
1263 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_rib";
1264 $sql .=
" WHERE type in ('card')";
1265 $sql .=
" AND fk_soc = ".((int)
$object->id);
1266 $sql .=
" AND status = ".((int) $servicestatus);
1268 $resql = $db->query($sql);
1270 $num_rows = $db->num_rows($resql);
1273 while ($i < $num_rows) {
1276 $obj = $db->fetch_object($resql);
1278 $companypaymentmodetemp->fetch($obj->rowid);
1280 $arrayofremotecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref;
1282 print
'<tr class="oddeven" data-rowid="'.((int) $companypaymentmodetemp->id).
'">';
1284 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->label).
'">';
1288 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->stripe_card_ref.(empty($companypaymentmodetemp->stripe_account) ?
'' :
' - '.$companypaymentmodetemp->stripe_account)).
'">';
1289 if (!empty($companypaymentmodetemp->stripe_card_ref) && !empty($companypaymentmodetemp->ext_payment_site)) {
1290 if (
isModEnabled(
'stripe') && in_array($companypaymentmodetemp->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1292 if (!empty($stripeacc)) {
1293 $connect = $stripeacc.
'/';
1295 if ($companypaymentmodetemp->ext_payment_site ==
'StripeLive') {
1296 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$companypaymentmodetemp->stripe_card_ref;
1298 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
1300 print
"<a href='".$url.
"' target='_stripe'>".img_picto($langs->trans(
'ShowInStripe').
' - '.$companypaymentmodetemp->stripe_account,
'globe').
"</a> ";
1311 print
'<td class="minwidth100">';
1312 if ($companypaymentmodetemp->owner_name) {
1313 print
'<span class="opacitymedium">'.$companypaymentmodetemp->owner_name.
'</span><br>';
1315 if ($companypaymentmodetemp->last_four) {
1316 print
'....'.$companypaymentmodetemp->last_four;
1318 if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) {
1319 print
' - '.sprintf(
"%02d", $companypaymentmodetemp->exp_date_month).
'/'.$companypaymentmodetemp->exp_date_year;
1323 print
'<td class="tdoverflowmax100">';
1324 if ($companypaymentmodetemp->country_code) {
1326 print $img ? $img.
' ' :
'';
1327 print
getCountry($companypaymentmodetemp->country_code,
'1');
1329 print img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1333 print
'<td class="center">';
1334 if (empty($companypaymentmodetemp->default_rib)) {
1335 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=setlocalassourcedefault&token='.
newToken().
'">';
1336 print img_picto($langs->trans(
"Default"),
'off');
1339 print img_picto($langs->trans(
"Default"),
'on');
1342 if (empty($companypaymentmodetemp->stripe_card_ref)) {
1343 $s = $langs->trans(
"Local");
1345 $s = $langs->trans(
"LocalAndRemote");
1347 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1351 print
dol_print_date($companypaymentmodetemp->date_modification,
'dayhour',
'tzuserrel');
1354 $parameters = array(
'arrayfields' => array(),
'obj' => $obj,
'linetype' =>
'stripecard');
1355 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1356 print $hookmanager->resPrint;
1358 print
'<td class="right minwidth50 nowraponall">';
1359 if ($permissiontoaddupdatepaymentinformation) {
1360 if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) {
1361 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=synccardtostripe&socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'" class="paddingrightonly marginrightonly">'.$langs->trans(
"CreateCardOnStripe").
'</a>';
1364 print
'<a class="editfielda marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=editcard&token='.
newToken().
'">';
1365 print img_picto($langs->trans(
"Modify"),
'edit');
1367 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=deletecard&token='.
newToken().
'">';
1368 print img_picto($langs->trans(
"Delete"),
'delete');
1378 dol_print_error($db);
1383 if (is_array($listofsources) && count($listofsources)) {
1384 foreach ($listofsources as $src) {
1385 if (!empty($arrayofremotecard[$src->id])) {
1392 if ($src->object ==
'card') {
1394 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1396 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1398 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1400 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1404 print
'<tr class="oddeven">';
1408 print
'<td class="tdoverflowmax150">';
1410 if (!empty($stripeacc)) {
1411 $connect = $stripeacc.
'/';
1414 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1415 if ($servicestatus) {
1417 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1419 print
"<a href='".$url.
"' target='_stripe'>".img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1427 print
'<td valign="middle">';
1428 if ($src->object ==
'card') {
1429 print
'....'.$src->last4.
' - '.$src->exp_month.
'/'.$src->exp_year;
1431 if ($src->country) {
1433 print $img ? $img.
' ' :
'';
1436 print img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1438 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1439 print
'<span class="opacitymedium">'.$src->owner->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1442 if ($src->card->country) {
1444 print $img ? $img.
' ' :
'';
1447 print img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1449 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1450 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1452 if ($src->sepa_debit->country) {
1454 print $img ? $img.
' ' :
'';
1455 print
getCountry($src->sepa_debit->country,
'1');
1457 print img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1459 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1460 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1463 if ($src->card->country) {
1465 print $img ? $img.
' ' :
'';
1468 print img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1470 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1471 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1473 if ($src->sepa_debit->country) {
1475 print $img ? $img.
' ' :
'';
1476 print
getCountry($src->sepa_debit->country,
'1');
1478 print img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1485 print
'<td class="center" width="50">';
1486 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1487 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1488 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1489 print img_picto($langs->trans(
"Default"),
'off');
1492 print img_picto($langs->trans(
"Default"),
'on');
1496 print $langs->trans(
"Remote");
1505 $parameters = array(
'arrayfields' => array(),
'stripesource' => $src,
'linetype' =>
'stripecardremoteonly');
1506 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1507 print $hookmanager->resPrint;
1510 print
'<td class="right nowraponall">';
1511 if ($permissiontoaddupdatepaymentinformation) {
1512 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletecard&token='.
newToken().
'">';
1513 print img_picto($langs->trans(
"Delete"),
'delete');
1522 if ($nbremote == 0 && $nblocal == 0) {
1524 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1532 if (
isModEnabled(
'stripe') && !empty(
$conf->stripeconnect->enabled) && !empty($stripesupplieracc)) {
1533 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');
1534 $balance = \Stripe\Balance::retrieve(array(
"stripe_account" => $stripesupplieracc));
1535 print
'<!-- List of Stripe connected accounts -->'.
"\n";
1536 print
'<table class="liste centpercent noborder">'.
"\n";
1537 print
'<tr class="liste_titre">';
1538 print
'<td>'.$langs->trans(
'Currency').
'</td>';
1539 print
'<td>'.$langs->trans(
'Available').
'</td>';
1540 print
'<td>'.$langs->trans(
'Pending').
'</td>';
1541 print
'<td>'.$langs->trans(
'Total').
'</td>';
1544 $currencybalance = array();
1545 if (is_array($balance->available) && count($balance->available)) {
1546 foreach ($balance->available as $cpt) {
1547 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1548 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1549 $currencybalance[$cpt->currency][
'available'] = $cpt->amount / 100;
1551 $currencybalance[$cpt->currency][
'available'] = $cpt->amount;
1553 $currencybalance[$cpt->currency][
'currency'] = $cpt->currency;
1557 if (is_array($balance->pending) && count($balance->pending)) {
1558 foreach ($balance->pending as $cpt) {
1559 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1560 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1561 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount / 100;
1563 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount;
1568 if (is_array($currencybalance)) {
1569 foreach ($currencybalance as $cpt_arr) {
1570 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>';
1580 if ($permissiontoaddupdatepaymentinformation) {
1581 $morehtmlright =
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"] .
'?socid=' .
$object->id .
'&action=create');
1584 print
load_fiche_titre($langs->trans(
"BankAccounts"), $morehtmlright,
'bank');
1588 $arrayofremoteban = array();
1590 $rib_list =
$object->get_all_rib();
1592 if (is_array($rib_list)) {
1593 print
'<!-- List of bank accounts -->'.
"\n";
1594 print
'<div class="div-table-responsive-no-min">';
1595 print
'<table class="liste centpercent noborder">';
1597 print
'<tr class="liste_titre">';
1599 print_liste_field_titre($form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")));
1614 $parameters = array(
'arrayfields' => array(),
'linetype' =>
'stripebantitle');
1615 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1616 print $hookmanager->resPrint;
1621 foreach ($rib_list as $rib) {
1622 $arrayofremoteban[$rib->stripe_card_ref] = $rib->stripe_card_ref;
1626 print
'<tr class="oddeven">';
1628 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($rib->label).
'">'.dolPrintHTML($rib->label);
1629 print
'<br><span class="opacitymedium">'.dolPrintHTML($rib->bank).
'</span>';
1633 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->stripe_card_ref.(empty($rib->stripe_account) ?
'' :
' - '.$rib->stripe_account)).
'">';
1634 if (!empty($rib->stripe_card_ref) && !empty($rib->ext_payment_site)) {
1635 if (
isModEnabled(
'stripe') && in_array($rib->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1637 if (!empty($stripeacc)) {
1638 $connect = $stripeacc.
'/';
1640 if ($rib->ext_payment_site ==
'StripeLive') {
1641 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$rib->stripe_card_ref;
1643 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$rib->stripe_card_ref;
1645 print
"<a href='".$url.
"' target='_stripe'>".img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1657 foreach ($rib->getFieldsToShow() as $val) {
1658 if ($val ==
'BankCode') {
1659 $string .= $rib->code_banque.
' ';
1660 } elseif ($val ==
'BankAccountNumber') {
1661 $string .= $rib->number.
' ';
1662 } elseif ($val ==
'DeskCode') {
1663 $string .= $rib->code_guichet.
' ';
1664 } elseif ($val ==
'BankAccountNumberKey') {
1665 $string .= $rib->cle_rib.
' ';
1673 if (!empty($rib->label) && $rib->number) {
1675 $string .= img_picto($langs->trans(
"ValueIsNotValid"),
'warning',
'class="pictofixedwidth"').$string;
1677 $string .= img_picto($langs->trans(
"ValueIsValid"),
'info',
'class="pictofixedwidth"').$string;
1681 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($string).
'">';
1686 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->iban).
'">';
1687 if (!empty($rib->iban)) {
1689 print img_picto($langs->trans(
"IbanNotValid"),
'warning').
' ';
1696 if (!empty($rib->bic)) {
1698 print img_picto($langs->trans(
"SwiftNotValid"),
'warning').
' ';
1706 print
'<td class="tdoverflowmax100 small" title="'.dolPrintHTMLForAttribute($rib->rum).
'">'.dolPrintHTML($rib->rum);
1707 print
'<br><span class="opacitymedium">'.dolPrintHTML($rib->frstrecur).
'</span>';
1711 print
'<td>'.dol_print_date($rib->date_rum,
'day').
'</td>';
1715 print
'<td class="center" width="70">';
1716 if (!$rib->default_rib) {
1717 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?socid='.((int)
$object->id).
'&ribid='.((int) $rib->id).
'&action=setasbankdefault&token='.
newToken().
'">';
1718 print img_picto($langs->trans(
"Disabled"),
'off');
1721 print img_picto($langs->trans(
"Enabled"),
'on');
1726 print
'<td class="center">';
1728 $buttonlabel = $langs->trans(
"BuildDoc");
1729 $forname =
'builddocrib'.$rib->id;
1731 include_once DOL_DOCUMENT_ROOT.
'/core/modules/bank/modules_bank.php';
1735 if (is_array($modellist) && count($modellist)) {
1736 $out .=
'<form action="'.$_SERVER[
"PHP_SELF"].(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#builddoc').
'" name="'.$forname.
'" id="'.$forname.
'_form" method="post" autocomplete="off" spellcheck="false">';
1737 $out .=
'<input type="hidden" name="action" value="builddocrib">';
1738 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1739 $out .=
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1740 $out .=
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1742 $modelselected =
'';
1743 if (count($modellist) == 1) {
1744 $arraykeys = array_keys($modellist);
1745 $modelselected = $arraykeys[0];
1751 $morecss =
'maxwidth125';
1752 if (
$conf->browser->layout ==
'phone') {
1753 $morecss =
'maxwidth100';
1756 $out .= $form->selectarray(
'modelrib'.$rib->id, $modellist, $modelselected, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 '.$morecss);
1761 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
1763 $defaultlang = $langs->getDefaultLang();
1764 $out .= $formadmin->select_language($defaultlang,
'lang_idrib'.$rib->id, 0, array(), 0, 0, 0, $morecss);
1767 $out .=
'<input class="button buttongen reposition nomargintop nomarginbottom small '.$morecss.
'" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
1768 $out .=
' type="submit" value="'.$buttonlabel.
'"';
1776 $parameters = array(
'arrayfields' => array(),
'stripe_card_ref' => $rib->stripe_card_ref,
'stripe_account' => $rib->stripe_account,
'linetype' =>
'stripeban');
1777 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1778 print $hookmanager->resPrint;
1782 print
'<td class="minwidth200 width200">';
1783 $useonlinesignature = 1;
1784 if ($useonlinesignature) {
1785 $rib->entity =
$object->entity;
1786 require_once DOL_DOCUMENT_ROOT .
'/core/lib/signature.lib.php';
1787 print showOnlineSignatureUrl($companybankaccount->element, (
string) $rib->id, $rib,
'short');
1793 print
'<td class="right nowraponall">';
1794 if ($permissiontoaddupdatepaymentinformation) {
1796 if (empty($rib->stripe_card_ref)) {
1799 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=syncsepatostripe&token='.
newToken().
'">';
1800 print img_picto($langs->trans(
"CreateBANOnStripe"),
'stripe');
1803 print
'<span class="opacitymedium marginrightonly marginleftonly">';
1804 print img_picto($langs->trans(
"ThirdPartyMustBeACustomerToCreateBANOnStripe"),
'stripe');
1810 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=edit">';
1811 print img_picto($langs->trans(
"Modify"),
'edit');
1814 print
'<a class="marginrightonly marginleftonly reposition" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=deletebank&token='.
newToken().
'">';
1815 print img_picto($langs->trans(
"Delete"),
'delete');
1825 foreach ($listofsources as $src) {
1826 if (!empty($arrayofremoteban[$src->id])) {
1831 if ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1832 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1833 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1834 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1841 print
'<tr class="oddeven">';
1846 print
'<td class="tdoverflowmax150">';
1848 if (!empty($stripeacc)) {
1849 $connect = $stripeacc.
'/';
1852 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1853 if ($servicestatus) {
1855 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1857 print
"<a href='".$url.
"' target='_stripe'>".img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1888 print
'<td class="center" width="50">';
1889 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1890 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1891 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1892 print img_picto($langs->trans(
"Default"),
'off');
1895 print img_picto($langs->trans(
"Default"),
'on');
1910 $parameters = array(
'arrayfields' => array(),
'src' => $src,
'linetype' =>
'stripebanremoteonly');
1911 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1912 print $hookmanager->resPrint;
1915 print
'<td class="right nowraponall">';
1916 if ($permissiontoaddupdatepaymentinformation) {
1917 print
'<a class="marginleftonly marginrightonly reposition" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletebank&token='.
newToken().
'">';
1918 print img_picto($langs->trans(
"Delete"),
'delete');
1926 if ($nbremote == 0 && $nblocal == 0) {
1934 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoBANRecord").
'</span></td></tr>';
1940 dol_print_error($db);
1944 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'');
1945 $reshook = $hookmanager->executeHooks(
'printNewTable', $parameters, $object);
1946 print $hookmanager->resPrint;
1951 print
'<div class="fichecenter"><div class="fichehalfleft">';
1952 print
'<a name="builddoc"></a>';
1958 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".
$object->id;
1960 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);
1967 $result = $companypaymentmodetemp->fetch(0,
'',
$object->id,
'ban');
1969 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1972 $result = $ecmfile->fetch(0,
'',
'',
'',
'', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
1974 $companybankaccounttemp->last_main_doc = $ecmfile->filepath.
'/'.$ecmfile->filename;
1975 print
'<br><!-- Link to download main doc -->'.
"\n";
1980 print
'</div><div class="fichehalfright">';
1983 print
'</div></div>';
2009if ($socid && $action ==
'edit' && $permissiontoaddupdatepaymentinformation) {
2012 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2014 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2016 print
'<div class="underbanner clearboth"></div>';
2020 print
'<div class="div-table-responsive-no-min">';
2021 print
'<table class="border tableforfield centpercent">';
2023 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Label").
'</td>';
2024 print
'<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.
'" spellcheck="false"></td></tr>';
2026 print
'<tr><td>'.$langs->trans(
"BankName").
'</td>';
2027 print
'<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.
'" spellcheck="false"></td></tr>';
2030 $companybankaccount->fetch($id);
2031 $bankaccount = $companybankaccount;
2033 foreach ($bankaccount->getFieldsToShow(1) as $val) {
2038 $content =
'NoContent';
2039 if ($val ==
'BankCode') {
2040 $name =
'code_banque';
2042 $content = $bankaccount->code_banque;
2043 } elseif ($val ==
'DeskCode') {
2044 $name =
'code_guichet';
2046 $content = $bankaccount->code_guichet;
2047 } elseif ($val ==
'BankAccountNumber') {
2050 $content = $bankaccount->number;
2051 } elseif ($val ==
'BankAccountNumberKey') {
2054 $content = $bankaccount->cle_rib;
2055 } elseif ($val ==
'IBAN') {
2058 $content = $bankaccount->iban;
2059 if ($bankaccount->needIBAN()) {
2062 $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';
2063 } elseif ($val ==
'BIC') {
2066 $content = $bankaccount->bic;
2067 if ($bankaccount->needBIC() && (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0)) {
2070 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2074 print
'<td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2077 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2079 print $langs->trans($val);
2082 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.$content.
'"></td>';
2087 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Currency").
'</td>';
2089 $selectedcode = $bankaccount->currency_code;
2090 if (!$selectedcode) {
2091 $selectedcode =
$conf->currency;
2093 print $form->selectCurrency((
GETPOSTISSET(
"account_currency_code") ?
GETPOST(
"account_currency_code") : $selectedcode),
'account_currency_code');
2099 $account_status = $bankaccount->status;
2100 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
'</td>';
2102 print $form->selectarray(
"clos", $bankaccount->labelStatus, $account_status, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth150onsmartphone');
2106 $country_codeid =
GETPOST(
"account_country_id") ?
GETPOST(
"account_country_id") : $bankaccount->fk_country;
2107 if (empty($country_codeid)) {
2108 $country_codeid =
$mysoc->country_code;
2110 $bankaccount->country_code =
getCountry($country_codeid,
'2');
2112 print
'<tr><td class="fieldrequired">'.$langs->trans(
"BankAccountCountry").
'</td>';
2114 print img_picto(
'',
'country',
'class="pictofixedwidth"');
2115 print $form->select_country($country_codeid,
'account_country_id');
2117 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2122 $selected_state_id = $bankaccount->state_id;
2123 print
'<tr><td>'.$langs->trans(
'State').
'</td><td>';
2124 if ($country_codeid) {
2125 print img_picto(
'',
'state',
'class="pictofixedwidth"');
2126 print $formcompany->select_state($selected_state_id, $country_codeid,
'account_state_id');
2128 print $countrynotdefined;
2132 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2133 print
'<textarea name="address" rows="'.ROWS_4.
'" cols="40" maxlength="255" spellcheck="false">';
2134 print dolPrintHTMLForTextArea($companybankaccount->address);
2135 print
"</textarea></td></tr>";
2137 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2138 print
'<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->owner_name.
'" spellcheck="false"></td></tr>';
2139 print
"</td></tr>\n";
2141 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2142 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" cols="40" maxlength="255" spellcheck="false">';
2143 print dolPrintHTMLForTextArea($companybankaccount->owner_address);
2144 print
"</textarea></td></tr>";
2152 print
'<div class="div-table-responsive-no-min">';
2153 print
'<table class="border tableforfield centpercent">';
2155 if (empty($companybankaccount->rum)) {
2156 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
2160 print
'<tr><td class="titlefieldcreate" colspan="5">'.$langs->trans(
"WithdrawalsSetup").
'</td></tr>';
2163 print
'<tr><td class="titlefield">'.$langs->trans(
"RUM").
'</td>';
2164 print
'<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).
'" spellcheck="false"></td></tr>';
2168 print
'<tr><td class="titlefield">'.$langs->trans(
"DateRUM").
'</td>';
2169 print
'<td>'.$form->selectDate($date_rum ? $date_rum : $companybankaccount->date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2171 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2172 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2173 print $form->selectarray(
"frstrecur", $tblArraychoice,
dol_escape_htmltag(
GETPOST(
'frstrecur',
'alpha') ?
GETPOST(
'frstrecur',
'alpha') : $companybankaccount->frstrecur), 0);
2176 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_...' or 'src_...')</td>";
2177 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'" spellcheck="false"></td></tr>';
2186 print $form->buttonsSaveCancel(
"Modify");
2190if ($socid && $action ==
'editcard' && $permissiontoaddupdatepaymentinformation) {
2193 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2195 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2197 print
'<div class="nofichecenter">';
2199 print
'<div class="underbanner clearboth"></div>';
2203 print
'<div class="div-table-responsive-no-min">';
2204 print
'<table class="border centpercent">';
2206 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2207 print
'<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.
'" spellcheck="false"></td></tr>';
2209 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2210 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->owner_name.
'" spellcheck="false"></td></tr>';
2212 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2213 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.
'" spellcheck="false"></td></tr>';
2215 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2217 print $formother->select_month((
string) $companypaymentmode->exp_date_month,
'exp_date_month', 1);
2218 print $formother->selectyear((
string) $companypaymentmode->exp_date_year,
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2221 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2222 print
'<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.
'"></td></tr>';
2224 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_... ".$langs->trans(
"or").
" card_....')</td>";
2225 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'" spellcheck="false"></td></tr>';
2233 print $form->buttonsSaveCancel(
"Modify");
2238if ($socid && $action ==
'create' && $permissiontoaddupdatepaymentinformation) {
2241 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2243 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2245 print
'<div class="nofichecenter">';
2247 print
'<div class="underbanner clearboth"></div>';
2251 print
'<div class="div-table-responsive-no-min">';
2252 print
'<table class="border tableforfield centpercent">';
2254 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2255 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>';
2257 print
'<tr><td>'.$langs->trans(
"Bank").
'</td>';
2258 print
'<td><input class="minwidth250" type="text" id="bank" name="bank" value="'.GETPOST(
'bank').
'" spellcheck="false"></td></tr>';
2261 foreach ($companybankaccount->getFieldsToShow(1) as $val) {
2266 $content =
'NoContent';
2268 if ($val ==
'BankCode') {
2269 $name =
'code_banque';
2271 $content = $companybankaccount->code_banque;
2272 } elseif ($val ==
'DeskCode') {
2273 $name =
'code_guichet';
2275 $content = $companybankaccount->code_guichet;
2276 } elseif ($val ==
'BankAccountNumber') {
2279 $content = $companybankaccount->number;
2280 } elseif ($val ==
'BankAccountNumberKey') {
2283 $content = $companybankaccount->cle_rib;
2284 } elseif ($val ==
'IBAN') {
2287 $content = $companybankaccount->iban;
2288 if ($companybankaccount->needIBAN()) {
2291 $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';
2292 } elseif ($val ==
'BIC') {
2295 $content = $companybankaccount->bic;
2296 if ($companybankaccount->needBIC() && (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0)) {
2299 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2302 print
'<tr><td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2305 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2307 print $langs->trans($val);
2310 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" id="'.$name.
'" value="'.
GETPOST($name).
'" spellcheck="false"></td>';
2315 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Currency").
'</td>';
2317 $selectedcode =
$object->currency_code;
2318 if (!$selectedcode) {
2319 $selectedcode =
$conf->currency;
2321 print $form->selectCurrency((
GETPOSTISSET(
"account_currency_code") ?
GETPOST(
"account_currency_code") : $selectedcode),
'account_currency_code');
2327 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
'</td>';
2329 print $form->selectarray(
"clos", $companybankaccount->labelStatus, (
GETPOSTISSET(
'clos') ?
GETPOSTINT(
'clos') : $companybankaccount::STATUS_OPEN), 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth150onsmartphone');
2335 $selectedcode =
GETPOST(
"account_country_id") ?
GETPOST(
"account_country_id") :
$object->country_code;
2336 } elseif (empty($selectedcode)) {
2337 $selectedcode =
$mysoc->country_code;
2341 print
'<tr><td class="fieldrequired">'.$langs->trans(
"BankAccountCountry").
'</td>';
2343 print img_picto(
'',
'country',
'class="pictofixedwidth"');
2344 print $form->select_country($selectedcode,
'account_country_id');
2346 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2351 print
'<tr><td>'.$langs->trans(
'State').
'</td><td>';
2352 if ($selectedcode) {
2353 print img_picto(
'',
'state',
'class="pictofixedwidth"');
2354 print $formcompany->select_state(
GETPOSTISSET(
"account_state_id") ?
GETPOSTINT(
"account_state_id") : 0, $selectedcode,
'account_state_id');
2356 print $countrynotdefined;
2360 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2361 print
'<textarea name="address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2362 print dolPrintHTMLForTextArea(
GETPOST(
'address'));
2363 print
"</textarea></td></tr>";
2365 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2366 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio').
'" spellcheck="false"></td></tr>';
2367 print
"</td></tr>\n";
2369 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2370 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2371 print dolPrintHTMLForTextArea(
GETPOST(
'owner_address'));
2372 print
"</textarea></td></tr>";
2380 print
'<div class="div-table-responsive-no-min">';
2381 print
'<table class="border tableforfield centpercent">';
2384 print
'<tr><td class="titlefieldcreate" colspan="5">'.$langs->trans(
"WithdrawalsSetup").
'</td></tr>';
2387 print
'<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans(
"RUM"), $langs->trans(
"RUMLong").
'<br>'.$langs->trans(
"RUMWillBeGenerated")).
'</td>';
2388 print
'<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST(
'rum',
'alpha').
'" spellcheck="false"></td></tr>';
2392 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DateRUM").
'</td>';
2393 print
'<td colspan="4">'.$form->selectDate($date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2395 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2396 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2397 print $form->selectarray(
"frstrecur", $tblArraychoice, (
GETPOSTISSET(
'frstrecur') ?
GETPOST(
'frstrecur') :
'FRST'), 0);
2400 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('src_....')</td>";
2401 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'" spellcheck="false"></td></tr>';
2413 print $form->buttonsSaveCancel(
"Add");
2417if ($socid && $action ==
'createcard' && $permissiontoaddupdatepaymentinformation) {
2420 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2422 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2424 print
'<div class="nofichecenter">';
2426 print
'<div class="underbanner clearboth"></div>';
2430 print
'<div class="div-table-responsive-no-min">';
2431 print
'<table class="border centpercent">';
2433 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2434 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST(
'label',
'alpha').
'" spellcheck="false"></td></tr>';
2436 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2437 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio',
'alpha').
'" spellcheck="false"></td></tr>';
2439 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2440 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST(
'cardnumber',
'alpha').
'" spellcheck="false"></td></tr>';
2442 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2444 print $formother->select_month((
string)
GETPOSTINT(
'exp_date_month'),
'exp_date_month', 1);
2445 print $formother->selectyear((
string)
GETPOSTINT(
'exp_date_year'),
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2448 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2449 print
'<td><input class="width50" type="text" name="cvn" value="'.GETPOST(
'cvn',
'alpha').
'" spellcheck="false"></td></tr>';
2451 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('card_....')</td>";
2452 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'" spellcheck="false"></td></tr>';
2463 print $form->buttonsSaveCancel(
"Add");
2466if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
2469if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='', $placeholder='')
Convert a html select field into an ajax combobox.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
checkIbanForAccount($account=null, $ibantocheck=null)
Check IBAN number information for a bank account.
checkBanForAccount($account)
Check account number information for a bank account.
checkSwiftForAccount($account=null, $swift=null)
Check SWIFT information for a bank account.
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.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
img_credit_card($brand, $morecss='fa-2x inline-block valignmiddle')
Return image of a credit card according to its brand name.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
showDirectDownloadLink($object)
Return string with full Url.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
$conf db name
Only used if Module[ID]Name translation string is not found.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.