36require
'../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/societe/class/companypaymentmode.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
56$langs->loadLangs(array(
"companies",
"commercial",
"banks",
"bills",
'paypal',
'stripe',
'withdrawals'));
60$action =
GETPOST(
"action",
'alpha', 3);
61$cancel =
GETPOST(
'cancel',
'alpha');
62$backtopage =
GETPOST(
'backtopage');
65$source =
GETPOST(
"source",
"alpha");
71 $socid = $user->socid;
85$extrafields->fetch_name_optionals_label(
$object->table_element);
88$hookmanager->initHooks(array(
'thirdpartybancard',
'globalcard'));
91$permissiontoread = $user->hasRight(
'societe',
'lire');
92$permissiontoadd = $user->hasRight(
'societe',
'creer');
94$permissiontoaddupdatepaymentinformation = $user->hasRight(
'societe',
'thirdparty_paymentinformation',
'write');
104$site_account =
'UnknownSiteAccount';
107if (isModEnabled(
'stripe')) {
108 $service =
'StripeTest';
110 $service =
'StripeLive';
115 global $stripearrayofkeysbyenv;
116 $site_account = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
118 $stripe =
new Stripe($db);
119 $stripeacc = $stripe->getStripeAccount($service);
120 $stripecu = $stripe->getStripeCustomerAccount(
$object->id, $servicestatus, $site_account);
135$parameters = array(
'id' => $socid);
136$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
141if (empty($reshook)) {
144 if (!empty($backtopage)) {
145 header(
"Location: ".$backtopage);
150 if ($action ==
'update' && $permissiontoaddupdatepaymentinformation) {
153 if (!
GETPOST(
'label',
'alpha')) {
154 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
157 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankName")),
null,
'errors');
162 $companybankaccount->fetch($id);
163 if ($companybankaccount->needIBAN() == 1) {
165 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
170 if ($companybankaccount->needBIC() == 1) {
172 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
179 $companybankaccount->oldcopy =
dol_clone($companybankaccount, 2);
181 $companybankaccount->socid =
$object->id;
183 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
184 $companybankaccount->label =
GETPOST(
'label',
'alpha');
185 $companybankaccount->status =
GETPOSTINT(
'clos');
186 $companybankaccount->clos = $companybankaccount->status;
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->address =
GETPOST(
'address',
'alpha');
196 $companybankaccount->owner_name =
GETPOST(
'proprio',
'alpha');
197 $companybankaccount->proprio = $companybankaccount->owner_name;
198 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
199 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
200 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
201 $companybankaccount->date_rum =
GETPOSTDATE(
'date_rum',
'00:00:00');
202 if (empty($companybankaccount->rum)) {
203 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
206 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
208 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
210 $companybankaccount->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
212 $result = $companybankaccount->update($user);
215 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
219 if ($companybankaccount->default_rib) {
220 $companybankaccount->setAsDefault($id);
223 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
224 if ($companybankaccount->oldcopy->iban != $companybankaccount->iban) {
229 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
230 header(
'Location: '.$url);
236 if ($action ==
'updatecard' && $permissiontoaddupdatepaymentinformation) {
238 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
239 if (!
GETPOST(
'label',
'alpha')) {
240 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
242 if (!
GETPOST(
'proprio',
'alpha')) {
243 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
246 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
247 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
250 $action =
'createcard';
254 $companypaymentmode->fetch($id);
256 $companypaymentmode->oldcopy =
dol_clone($companypaymentmode, 2);
258 $companypaymentmode->fk_soc =
$object->id;
260 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
261 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
262 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
263 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
264 $companypaymentmode->owner_name =
GETPOST(
'proprio',
'alpha');
265 $companypaymentmode->proprio = $companypaymentmode->owner_name;
266 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
267 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
268 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
269 $companypaymentmode->country_code =
$object->country_code;
271 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
273 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
275 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
277 $result = $companypaymentmode->update($user);
279 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
282 if ($companypaymentmode->default_rib) {
283 $companypaymentmode->setAsDefault($id);
286 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
287 if ($companybankaccount->oldcopy->number != $companybankaccount->number) {
292 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
293 header(
'Location: '.$url);
300 if ($action ==
'add' && $permissiontoaddupdatepaymentinformation) {
303 if (!
GETPOST(
'label',
'alpha')) {
304 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
313 $companybankaccount->socid =
$object->id;
315 $companybankaccount->fetch_thirdparty();
317 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
318 $companybankaccount->label =
GETPOST(
'label',
'alpha');
319 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
320 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
321 $companybankaccount->number =
GETPOST(
'number',
'alpha');
322 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
323 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
324 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
326 $companybankaccount->address =
GETPOST(
'address',
'alpha');
328 $companybankaccount->owner_name =
GETPOST(
'proprio',
'alpha');
329 $companybankaccount->proprio = $companybankaccount->owner_name;
330 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
331 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
332 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
333 $companybankaccount->date_rum =
GETPOSTDATE(
'date_rum',
'00:00:00');
334 $companybankaccount->datec =
dol_now();
337 $companybankaccount->status =
GETPOSTINT(
'clos');
339 $companybankaccount->bank = trim($companybankaccount->bank);
340 if (empty($companybankaccount->bank) && !empty($companybankaccount->thirdparty)) {
341 $companybankaccount->bank = $langs->trans(
"Bank").
' '.$companybankaccount->thirdparty->name;
343 $companybankaccount->bic = str_replace(
' ',
'', $companybankaccount->bic);
348 if ($companybankaccount->needIBAN() == 1) {
350 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
355 if ($companybankaccount->needBIC() == 1) {
357 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
364 $result = $companybankaccount->create($user);
367 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
371 if (empty($companybankaccount->rum)) {
372 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
377 $result = $companybankaccount->update($user);
380 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
388 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
389 header(
'Location: '.$url);
398 if ($action ==
'addcard' && $permissiontoaddupdatepaymentinformation) {
401 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
402 if (!
GETPOST(
'label',
'alpha')) {
403 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
405 if (!
GETPOST(
'proprio',
'alpha')) {
406 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
409 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
410 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
413 $action =
'createcard';
421 $companypaymentmode->fk_soc =
$object->id;
422 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
423 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
424 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
425 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
426 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
427 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
428 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
429 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
430 $companypaymentmode->datec =
dol_now();
431 $companypaymentmode->default_rib = 0;
432 $companypaymentmode->type =
'card';
433 $companypaymentmode->country_code =
$object->country_code;
434 $companypaymentmode->status = $servicestatus;
436 if (
GETPOST(
'stripe_card_ref',
'alpha')) {
438 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
440 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
445 $result = $companypaymentmode->create($user);
448 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
449 $action =
'createcard';
456 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
457 header(
'Location: '.$url);
465 if ($action ==
'setasbankdefault' &&
GETPOSTINT(
'ribid') > 0 && $permissiontoaddupdatepaymentinformation) {
467 $res = $companybankaccount->setAsDefault(
GETPOSTINT(
'ribid'));
469 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
470 header(
'Location: '.$url);
477 if ($action ==
'confirm_deletecard' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoaddupdatepaymentinformation) {
480 if ($companypaymentmode->fetch($ribid ? $ribid :
$id)) {
491 $result = $companypaymentmode->delete($user);
493 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
495 header(
'Location: '.$url);
498 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
501 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
504 if ($action ==
'confirm_deletebank' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoaddupdatepaymentinformation) {
507 if ($companybankaccount->fetch($ribid ? $ribid :
$id) > 0) {
518 $result = $companybankaccount->delete($user);
521 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
523 header(
'Location: '.$url);
526 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
529 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
536 if ($action ==
'builddocrib' && $permissiontoread) {
537 $action =
'builddoc';
539 'use_companybankid' =>
GETPOST(
'companybankid'),
542 $_POST[
'lang_id'] =
GETPOST(
'lang_idrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
543 $_POST[
'model'] =
GETPOST(
'modelrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
547 $upload_dir =
$conf->societe->multidir_output[
$object->entity];
548 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
553 if (isModEnabled(
'stripe') && class_exists(
'Stripe')) {
554 if (($action ==
'synccustomertostripe' || $action ==
'synccustomertostripetest') && $permissiontoaddupdatepaymentinformation) {
559 if ($action ==
'synccustomertostripe') {
560 $tmpservicestatus = 1;
561 $tmpservice =
'StripeLive';
563 $tmpservicestatus = 0;
564 $tmpservice =
'StripeTest';
567 $stripe =
new Stripe($db);
568 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
571 $tmpcu = $stripe->customerStripe($object, $tmpstripeacc, $tmpservicestatus, 1);
577 if ($tmpservicestatus == $servicestatus) {
578 $stripecu = $tmpcu->id;
583 if ($action ==
'synccardtostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
586 $companypaymentmode->fetch($id);
588 if ($companypaymentmode->type !=
'card') {
593 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
600 '@phan-var-force \Stripe\Customer $cu';
604 $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
612 if ($action ==
'syncsepatostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
615 $companypaymentmode->fetch($id);
617 if ($companypaymentmode->type !=
'ban') {
619 $langs->load(
"errors");
623 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
627 $langs->load(
"errors");
628 setEventMessages($langs->trans(
"ErrorStripeCustomerNotFoundCreateFirst"),
null,
'errors');
631 '@phan-var-force \Stripe\Customer $cu';
633 $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
638 setEventMessages(
"", array(
"Bank Account on Stripe",
"BAN is now linked to the Stripe customer account !"));
645 if (($action ==
'setkey_account' || $action ==
'setkey_accounttest') && $permissiontoaddupdatepaymentinformation) {
648 $tmpservice =
'StripeTest';
649 $tmpservicestatus = 0;
650 if ($action ==
'setkey_account') {
651 $tmpservice =
'StripeLive';
652 $tmpservicestatus = 1;
656 global $stripearrayofkeysbyenv;
657 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
659 if ($action ==
'setkey_account') {
660 $newcu =
GETPOST(
'key_account',
'alpha');
662 $newcu =
GETPOST(
'key_accounttest',
'alpha');
668 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_account";
669 $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;
671 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_account";
672 $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;
675 $resql = $db->query($sql);
676 $num = $db->num_rows($resql);
678 if (!empty($newcu)) {
681 $societeaccount->fk_soc =
$object->id;
682 $societeaccount->login =
'';
683 $societeaccount->pass_encoding =
'';
684 $societeaccount->site =
'stripe';
685 $societeaccount->status = $servicestatus;
686 $societeaccount->key_account = $newcu;
687 $societeaccount->site_account = $tmpsite_account;
688 $result = $societeaccount->create($user);
693 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"societe_account";
694 $sql .=
" SET key_account = '".$db->escape($newcu).
"', site_account = '".$db->escape($tmpsite_account).
"'";
695 $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;
696 $resql = $db->query($sql);
704 if ($tmpservicestatus == $servicestatus) {
714 if (($action ==
'setkey_account_supplier' || $action ==
'setkey_account_suppliertest') && $permissiontoaddupdatepaymentinformation) {
717 $tmpservice =
'StripeTest';
718 $tmpservicestatus = 0;
719 if ($action ==
'setkey_account_supplier') {
720 $tmpservice =
'StripeLive';
721 $tmpservicestatus = 1;
725 global $stripearrayofkeysbyenv;
726 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
728 if ($action ==
'setkey_account_supplier') {
729 $newsup =
GETPOST(
'key_account_supplier',
'alpha');
731 $newsup =
GETPOST(
'key_account_suppliertest',
'alpha');
736 if (empty($newsup)) {
737 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"oauth_token WHERE fk_soc = ".((int)
$object->id).
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".((int)
$conf->entity);
742 $stripesup = \Stripe\Account::retrieve($newsup);
743 $tokenstring = array();
744 $tokenstring[
'stripe_user_id'] = $stripesup->id;
745 $tokenstring[
'type'] = $stripesup->type;
746 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"oauth_token";
747 $sql .=
" SET tokenstring = '".$db->escape(json_encode($tokenstring)).
"'";
748 $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;
750 $sql .=
" WHERE fk_soc = ".$object->id.
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".
$conf->entity;
757 $resql = $db->query($sql);
758 $num = $db->num_rows($resql);
759 if (empty($num) && !empty($newsup)) {
761 $stripesup = \Stripe\Account::retrieve($newsup);
762 $tokenstring[
'stripe_user_id'] = $stripesup->id;
763 $tokenstring[
'type'] = $stripesup->type;
764 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"oauth_token (service, fk_soc, entity, tokenstring)";
765 $sql .=
" VALUES ('".$db->escape($tmpservice).
"', ".((int)
$object->id).
", ".((int)
$conf->entity).
", '".$db->escape(json_encode($tokenstring)).
"')";
771 $resql = $db->query($sql);
775 if ($tmpservicestatus == $servicestatus) {
776 $stripesupplieracc = $newsup;
784 if ($action ==
'setlocalassourcedefault' && $permissiontoaddupdatepaymentinformation) {
786 $companypaymentmode->setAsDefault($id);
788 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
789 header(
'Location: '.$url);
795 } elseif ($action ==
'setassourcedefault' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
797 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
798 if (preg_match(
'/pm_|src_/', $source)) {
799 $cu->invoice_settings->default_payment_method = (string) $source;
801 $cu->default_source = (string) $source;
804 $result = $cu->save();
806 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
807 header(
'Location: '.$url);
813 } elseif ($action ==
'deletecard' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
816 if (preg_match(
'/pm_/', $source)) {
817 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
818 if ($payment_method) {
819 $payment_method->detach();
822 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
823 $card = $cu->sources->retrieve(
"$source");
826 if (method_exists($card,
'detach')) {
828 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
829 $sql .=
" SET stripe_card_ref = null";
830 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
832 $resql = $db->query($sql);
834 $card->delete($user);
839 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
840 header(
'Location: '.$url);
846 } elseif ($action ==
'deletebank' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
849 if (preg_match(
'/pm_/', $source)) {
850 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
851 if ($payment_method) {
852 $payment_method->detach();
855 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
856 $card = $cu->sources->retrieve((
string) $source);
859 if (method_exists($card,
'detach')) {
861 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
862 $sql .=
" SET stripe_card_ref = null";
863 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
865 $resql = $db->query($sql);
867 $card->delete($user);
872 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
874 $url .=
'&page_y='.GETPOSTINT(
'page_y');
877 header(
'Location: '.$url);
893$form =
new Form($db);
897$title = $langs->trans(
"ThirdParty");
899 $title =
$object->name.
" - ".$langs->trans(
'PaymentInformation');
912 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'), [],
'warning');
918 $companybankaccount->fetch(0,
'',
$object->id);
920 $companypaymentmode->fetch(0,
'',
$object->id,
'card');
922 $companybankaccount->fetch($id);
923 $companypaymentmode->fetch($id);
925if (empty($companybankaccount->socid)) {
926 $companybankaccount->socid =
$object->id;
929if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
930 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post">';
931 print
'<input type="hidden" name="token" value="'.newToken().
'">';
932 $actionforadd =
'update';
933 if ($action ==
'editcard') {
934 $actionforadd =
'updatecard';
936 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
937 print
'<input type="hidden" name="id" value="'.GETPOSTINT(
"id").
'">';
939if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
940 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post">';
941 print
'<input type="hidden" name="token" value="'.newToken().
'">';
942 $actionforadd =
'add';
943 if ($action ==
'createcard') {
944 $actionforadd =
'addcard';
946 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
951if ($socid && $action !=
'edit' && $action !=
'create' && $action !=
'editcard' && $action !=
'createcard') {
955 if ($action ==
'deletebank') {
956 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);
959 if ($action ==
'deletecard') {
960 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);
963 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
965 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
967 print
'<div class="fichecenter">';
969 print
'<div class="underbanner clearboth"></div>';
970 print
'<table class="border tableforfield centpercent">';
973 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td colspan="2">';
978 print
'<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="2">'.
$object->prefix_comm.
'</td></tr>';
982 print
'<tr><td class="titlefield">';
983 print $langs->trans(
'CustomerCode').
'</td><td colspan="2">';
985 $tmpcheck =
$object->check_codeclient();
986 if ($tmpcheck != 0 && $tmpcheck != -5) {
987 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
990 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
991 $resql = $db->query($sql);
996 $obj = $db->fetch_object($resql);
997 $nbFactsClient = $obj->nb;
998 $thirdTypeArray = array();
999 $elementTypeArray = array();
1000 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
1001 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
1002 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
1004 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
1005 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1007 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1008 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1010 if (isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1011 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1014 if (isModEnabled(
'stripe')) {
1016 global $stripearrayofkeysbyenv;
1019 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1020 $tmpstripeacc = $stripe->getStripeAccount((
string) $tmpservice);
1021 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1024 print
'<tr><td class="titlefield">';
1025 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1027 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1028 if ($tmpstripecu && $action !=
'editkey_accounttest') {
1030 if (!empty($stripeacc)) {
1031 $connect = $stripeacc.
'/';
1033 $url =
'https://dashboard.stripe.com/'.$connect.
'test/customers/'.$tmpstripecu;
1034 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1036 print
'</td><td class="right">';
1037 if (empty($tmpstripecu)) {
1038 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1039 print
'<input type="hidden" name="action" value="synccustomertostripetest">';
1040 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1041 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1042 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1043 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomertest" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1049 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1050 $tmpstripeacc = $stripe->getStripeAccount((
string) $tmpservice);
1051 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1054 print
'<tr><td class="titlefield">';
1055 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1057 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1058 if ($tmpstripecu && $action !=
'editkey_account') {
1060 if (!empty($stripeacc)) {
1061 $connect = $stripeacc.
'/';
1063 $url =
'https://dashboard.stripe.com/'.$connect.
'customers/'.$tmpstripecu;
1064 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1066 print
'</td><td class="right">';
1067 if (empty($tmpstripecu)) {
1068 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1069 print
'<input type="hidden" name="action" value="synccustomertostripe">';
1070 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1071 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1072 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1073 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomer" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1081 print
'<tr><td class="titlefield">';
1082 print $langs->trans(
'SupplierCode').
'</td><td colspan="2">';
1084 $tmpcheck =
$object->check_codefournisseur();
1085 if ($tmpcheck != 0 && $tmpcheck != -5) {
1086 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
1089 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
1090 $resql = $db->query($sql);
1094 $obj = $db->fetch_object($resql);
1095 $nbFactsClient = $obj->nb;
1096 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
1097 if (isModEnabled(
'propal') && $user->hasRight(
'propal',
'lire')) {
1098 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
1100 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
1101 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1103 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1104 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1106 if (isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1107 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1112 if (isModEnabled(
'stripe') && !empty(
$conf->stripeconnect->enabled) &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 2 && $service !==
null) {
1113 $stripesupplieracc = $stripe->getStripeAccount($service,
$object->id);
1116 print
'<tr><td class="titlefield">';
1117 print $form->editfieldkey(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1119 print $form->editfieldval(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1120 if (isModEnabled(
'stripe') && $stripesupplieracc && $action !=
'editkey_account_supplier') {
1123 $url =
'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc;
1124 if ($servicestatus) {
1125 $url =
'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc;
1127 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key '.$site_account,
'globe').
'</a>';
1129 print
'</td><td class="right">';
1130 if (empty($stripesupplieracc)) {
1131 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1132 print
'<input type="hidden" name="action" value="syncsuppliertostripe">';
1133 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1134 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1135 print
'<input type="hidden" name="companybankid" value="'.$ribid.
'">';
1149 $showcardpaymentmode = 0;
1150 if (isModEnabled(
'stripe')) {
1151 $showcardpaymentmode++;
1155 $listofsources = array();
1157 $customerstripe =
null;
1158 if (isset($stripe) && is_object($stripe) && $stripeacc !==
null) {
1160 $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus);
1161 if (!empty($customerstripe->id)) {
1164 $listofsources = $customerstripe->sources->data;
1166 $service =
'StripeTest';
1169 $service =
'StripeLive';
1174 global $stripearrayofkeysbyenv;
1175 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
1178 if (empty($stripeacc)) {
1179 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"));
1180 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"));
1182 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"), array(
"stripe_account" => $stripeacc));
1183 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"), array(
"stripe_account" => $stripeacc));
1186 if ($paymentmethodobjsA->data !=
null && $paymentmethodobjsB->data !=
null) {
1187 $listofsources = array_merge((array) $paymentmethodobjsA->data, (array) $paymentmethodobjsB->data);
1188 } elseif ($paymentmethodobjsB->data !=
null) {
1189 $listofsources = $paymentmethodobjsB->data;
1191 $listofsources = $paymentmethodobjsA->data;
1200 dol_syslog(
"Error when searching/loading Stripe customer for thirdparty id =".
$object->id);
1206 if ($showcardpaymentmode &&
$object->client) {
1207 $morehtmlright =
'';
1209 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=createcard');
1211 print
load_fiche_titre($langs->trans(
'CreditCard'), $morehtmlright,
'fa-credit-card');
1214 print
'<!-- List of card payments -->'.
"\n";
1215 print
'<div class="div-table-responsive-no-min">';
1216 print
'<table class="liste centpercent noborder">'.
"\n";
1217 print
'<tr class="liste_titre">';
1218 print
'<td>'.$langs->trans(
'Label').
'</td>';
1219 print
'<td>'.$form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")).
'</td>';
1220 print
'<td>'.$langs->trans(
'Type').
'</td>';
1221 print
'<td>'.$langs->trans(
'Informations').
'</td>';
1223 print
'<td class="center">'.$langs->trans(
'Default').
'</td>';
1224 print
'<td>'.$langs->trans(
'Note').
'</td>';
1225 print
'<td>'.$langs->trans(
'DateModification').
'</td>';
1227 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'stripetitle');
1228 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
1229 print $hookmanager->resPrint;
1236 $arrayofremotecard = array();
1243 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_rib";
1244 $sql .=
" WHERE type in ('card')";
1245 $sql .=
" AND fk_soc = ".((int)
$object->id);
1246 $sql .=
" AND status = ".((int) $servicestatus);
1248 $resql = $db->query($sql);
1250 $num_rows = $db->num_rows($resql);
1253 while ($i < $num_rows) {
1256 $obj = $db->fetch_object($resql);
1258 $companypaymentmodetemp->fetch($obj->rowid);
1260 $arrayofremotecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref;
1262 print
'<tr class="oddeven" data-rowid="'.((int) $companypaymentmodetemp->id).
'">';
1264 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->label).
'">';
1268 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->stripe_card_ref.(empty($companypaymentmodetemp->stripe_account) ?
'' :
' - '.$companypaymentmodetemp->stripe_account)).
'">';
1269 if (!empty($companypaymentmodetemp->stripe_card_ref) && !empty($companypaymentmodetemp->ext_payment_site)) {
1270 if (isModEnabled(
'stripe') && in_array($companypaymentmodetemp->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1272 if (!empty($stripeacc)) {
1273 $connect = $stripeacc.
'/';
1275 if ($companypaymentmodetemp->ext_payment_site ==
'StripeLive') {
1276 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$companypaymentmodetemp->stripe_card_ref;
1278 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
1280 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe').
' - '.$companypaymentmodetemp->stripe_account,
'globe').
"</a> ";
1291 print
'<td class="minwidth100">';
1292 if ($companypaymentmodetemp->owner_name) {
1293 print
'<span class="opacitymedium">'.$companypaymentmodetemp->owner_name.
'</span><br>';
1295 if ($companypaymentmodetemp->last_four) {
1296 print
'....'.$companypaymentmodetemp->last_four;
1298 if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) {
1299 print
' - '.sprintf(
"%02d", $companypaymentmodetemp->exp_date_month).
'/'.$companypaymentmodetemp->exp_date_year;
1303 print
'<td class="tdoverflowmax100">';
1304 if ($companypaymentmodetemp->country_code) {
1306 print $img ? $img.
' ' :
'';
1307 print
getCountry($companypaymentmodetemp->country_code,
'1');
1309 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1313 print
'<td class="center">';
1314 if (empty($companypaymentmodetemp->default_rib)) {
1315 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=setlocalassourcedefault&token='.
newToken().
'">';
1316 print
img_picto($langs->trans(
"Default"),
'off');
1319 print
img_picto($langs->trans(
"Default"),
'on');
1322 if (empty($companypaymentmodetemp->stripe_card_ref)) {
1323 $s = $langs->trans(
"Local");
1325 $s = $langs->trans(
"LocalAndRemote");
1327 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1331 print
dol_print_date($companypaymentmodetemp->date_modification,
'dayhour',
'tzuserrel');
1334 $parameters = array(
'arrayfields' => array(),
'obj' => $obj,
'linetype' =>
'stripecard');
1335 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1336 print $hookmanager->resPrint;
1338 print
'<td class="right minwidth50 nowraponall">';
1339 if ($permissiontoaddupdatepaymentinformation) {
1340 if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) {
1341 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=synccardtostripe&socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'" class="paddingrightonly marginrightonly">'.$langs->trans(
"CreateCardOnStripe").
'</a>';
1344 print
'<a class="editfielda marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=editcard&token='.
newToken().
'">';
1345 print
img_picto($langs->trans(
"Modify"),
'edit');
1347 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=deletecard&token='.
newToken().
'">';
1348 print
img_picto($langs->trans(
"Delete"),
'delete');
1363 if (is_array($listofsources) && count($listofsources)) {
1364 foreach ($listofsources as $src) {
1365 if (!empty($arrayofremotecard[$src->id])) {
1372 if ($src->object ==
'card') {
1374 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1376 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1378 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1380 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1384 print
'<tr class="oddeven">';
1388 print
'<td class="tdoverflowmax150">';
1390 if (!empty($stripeacc)) {
1391 $connect = $stripeacc.
'/';
1394 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1395 if ($servicestatus) {
1397 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1399 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1407 print
'<td valign="middle">';
1408 if ($src->object ==
'card') {
1409 print
'....'.$src->last4.
' - '.$src->exp_month.
'/'.$src->exp_year;
1411 if ($src->country) {
1413 print $img ? $img.
' ' :
'';
1416 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1418 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1419 print
'<span class="opacitymedium">'.$src->owner->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1422 if ($src->card->country) {
1424 print $img ? $img.
' ' :
'';
1427 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1429 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1430 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1432 if ($src->sepa_debit->country) {
1434 print $img ? $img.
' ' :
'';
1435 print
getCountry($src->sepa_debit->country,
'1');
1437 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1439 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1440 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1443 if ($src->card->country) {
1445 print $img ? $img.
' ' :
'';
1448 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1450 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1451 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1453 if ($src->sepa_debit->country) {
1455 print $img ? $img.
' ' :
'';
1456 print
getCountry($src->sepa_debit->country,
'1');
1458 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1465 print
'<td class="center" width="50">';
1466 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1467 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1468 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1469 print
img_picto($langs->trans(
"Default"),
'off');
1472 print
img_picto($langs->trans(
"Default"),
'on');
1476 print $langs->trans(
"Remote");
1485 $parameters = array(
'arrayfields' => array(),
'stripesource' => $src,
'linetype' =>
'stripecardremoteonly');
1486 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1487 print $hookmanager->resPrint;
1490 print
'<td class="right nowraponall">';
1491 if ($permissiontoaddupdatepaymentinformation) {
1492 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletecard&token='.
newToken().
'">';
1493 print
img_picto($langs->trans(
"Delete"),
'delete');
1502 if ($nbremote == 0 && $nblocal == 0) {
1504 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1512 if (isModEnabled(
'stripe') && !empty(
$conf->stripeconnect->enabled) && !empty($stripesupplieracc)) {
1513 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');
1514 $balance = \Stripe\Balance::retrieve(array(
"stripe_account" => $stripesupplieracc));
1515 print
'<!-- List of Stripe connected accounts -->'.
"\n";
1516 print
'<table class="liste centpercent noborder">'.
"\n";
1517 print
'<tr class="liste_titre">';
1518 print
'<td>'.$langs->trans(
'Currency').
'</td>';
1519 print
'<td>'.$langs->trans(
'Available').
'</td>';
1520 print
'<td>'.$langs->trans(
'Pending').
'</td>';
1521 print
'<td>'.$langs->trans(
'Total').
'</td>';
1524 $currencybalance = array();
1525 if (is_array($balance->available) && count($balance->available)) {
1526 foreach ($balance->available as $cpt) {
1527 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1528 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1529 $currencybalance[$cpt->currency][
'available'] = $cpt->amount / 100;
1531 $currencybalance[$cpt->currency][
'available'] = $cpt->amount;
1533 $currencybalance[$cpt->currency][
'currency'] = $cpt->currency;
1537 if (is_array($balance->pending) && count($balance->pending)) {
1538 foreach ($balance->pending as $cpt) {
1539 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1540 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1541 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount / 100;
1543 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount;
1548 if (is_array($currencybalance)) {
1549 foreach ($currencybalance as $cpt_arr) {
1550 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>';
1560 if ($permissiontoaddupdatepaymentinformation) {
1561 $morehtmlright =
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"] .
'?socid=' .
$object->id .
'&action=create');
1564 print
load_fiche_titre($langs->trans(
"BankAccounts"), $morehtmlright,
'bank');
1568 $arrayofremoteban = array();
1570 $rib_list =
$object->get_all_rib();
1572 if (is_array($rib_list)) {
1573 print
'<!-- List of bank accounts -->'.
"\n";
1574 print
'<div class="div-table-responsive-no-min">';
1575 print
'<table class="liste centpercent noborder">';
1577 print
'<tr class="liste_titre">';
1579 print_liste_field_titre($form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")));
1584 if (isModEnabled(
'prelevement')) {
1594 $parameters = array(
'arrayfields' => array(),
'linetype' =>
'stripebantitle');
1595 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1596 print $hookmanager->resPrint;
1601 foreach ($rib_list as $rib) {
1602 $arrayofremoteban[$rib->stripe_card_ref] = $rib->stripe_card_ref;
1606 print
'<tr class="oddeven">';
1608 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($rib->label).
'">'.
dolPrintHTML($rib->label);
1609 print
'<br><span class="opacitymedium">'.dolPrintHTML($rib->bank).
'</span>';
1613 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->stripe_card_ref.(empty($rib->stripe_account) ?
'' :
' - '.$rib->stripe_account)).
'">';
1614 if (!empty($rib->stripe_card_ref) && !empty($rib->ext_payment_site)) {
1615 if (isModEnabled(
'stripe') && in_array($rib->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1617 if (!empty($stripeacc)) {
1618 $connect = $stripeacc.
'/';
1620 if ($rib->ext_payment_site ==
'StripeLive') {
1621 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$rib->stripe_card_ref;
1623 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$rib->stripe_card_ref;
1625 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1637 foreach ($rib->getFieldsToShow() as $val) {
1638 if ($val ==
'BankCode') {
1639 $string .= $rib->code_banque.
' ';
1640 } elseif ($val ==
'BankAccountNumber') {
1641 $string .= $rib->number.
' ';
1642 } elseif ($val ==
'DeskCode') {
1643 $string .= $rib->code_guichet.
' ';
1644 } elseif ($val ==
'BankAccountNumberKey') {
1645 $string .= $rib->cle_rib.
' ';
1653 if (!empty($rib->label) && $rib->number) {
1655 $string .=
img_picto($langs->trans(
"ValueIsNotValid"),
'warning',
'class="pictofixedwidth"').$string;
1657 $string .=
img_picto($langs->trans(
"ValueIsValid"),
'info',
'class="pictofixedwidth"').$string;
1661 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($string).
'">';
1666 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->iban).
'">';
1667 if (!empty($rib->iban)) {
1669 print
img_picto($langs->trans(
"IbanNotValid"),
'warning').
' ';
1676 if (!empty($rib->bic)) {
1678 print
img_picto($langs->trans(
"SwiftNotValid"),
'warning').
' ';
1684 if (isModEnabled(
'prelevement')) {
1686 print
'<td class="tdoverflowmax100 small" title="'.dolPrintHTMLForAttribute($rib->rum).
'">'.
dolPrintHTML($rib->rum);
1687 print
'<br><span class="opacitymedium">'.dolPrintHTML($rib->frstrecur).
'</span>';
1691 print
'<td>'.dol_print_date($rib->date_rum,
'day').
'</td>';
1695 print
'<td class="center" width="70">';
1696 if (!$rib->default_rib) {
1697 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?socid='.((int)
$object->id).
'&ribid='.((int) $rib->id).
'&action=setasbankdefault&token='.
newToken().
'">';
1698 print
img_picto($langs->trans(
"Disabled"),
'off');
1701 print
img_picto($langs->trans(
"Enabled"),
'on');
1706 print
'<td class="center">';
1708 $buttonlabel = $langs->trans(
"BuildDoc");
1709 $forname =
'builddocrib'.$rib->id;
1711 include_once DOL_DOCUMENT_ROOT.
'/core/modules/bank/modules_bank.php';
1715 if (is_array($modellist) && count($modellist)) {
1716 $out .=
'<form action="'.$_SERVER[
"PHP_SELF"].(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#builddoc').
'" name="'.$forname.
'" id="'.$forname.
'_form" method="post">';
1717 $out .=
'<input type="hidden" name="action" value="builddocrib">';
1718 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1719 $out .=
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1720 $out .=
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1722 $modelselected =
'';
1723 if (count($modellist) == 1) {
1724 $arraykeys = array_keys($modellist);
1725 $modelselected = $arraykeys[0];
1731 $morecss =
'maxwidth125';
1732 if (
$conf->browser->layout ==
'phone') {
1733 $morecss =
'maxwidth100';
1736 $out .= $form->selectarray(
'modelrib'.$rib->id, $modellist, $modelselected, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 '.$morecss);
1741 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
1743 $defaultlang = $langs->getDefaultLang();
1744 $out .= $formadmin->select_language($defaultlang,
'lang_idrib'.$rib->id, 0, array(), 0, 0, 0, $morecss);
1747 $out .=
'<input class="button buttongen reposition nomargintop nomarginbottom small '.$morecss.
'" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
1748 $out .=
' type="submit" value="'.$buttonlabel.
'"';
1756 $parameters = array(
'arrayfields' => array(),
'stripe_card_ref' => $rib->stripe_card_ref,
'stripe_account' => $rib->stripe_account,
'linetype' =>
'stripeban');
1757 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1758 print $hookmanager->resPrint;
1762 print
'<td class="minwidth200 width200">';
1763 $useonlinesignature = 1;
1764 if ($useonlinesignature) {
1765 $rib->entity =
$object->entity;
1766 require_once DOL_DOCUMENT_ROOT .
'/core/lib/signature.lib.php';
1767 print showOnlineSignatureUrl($companybankaccount->element, (
string) $rib->id, $rib,
'short');
1773 print
'<td class="right nowraponall">';
1774 if ($permissiontoaddupdatepaymentinformation) {
1775 if (isModEnabled(
'stripe')) {
1776 if (empty($rib->stripe_card_ref)) {
1779 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=syncsepatostripe&token='.
newToken().
'">';
1780 print
img_picto($langs->trans(
"CreateBANOnStripe"),
'stripe');
1783 print
'<span class="opacitymedium marginrightonly marginleftonly">';
1784 print
img_picto($langs->trans(
"ThirdPartyMustBeACustomerToCreateBANOnStripe"),
'stripe');
1790 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=edit">';
1791 print
img_picto($langs->trans(
"Modify"),
'edit');
1794 print
'<a class="marginrightonly marginleftonly reposition" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=deletebank&token='.
newToken().
'">';
1795 print
img_picto($langs->trans(
"Delete"),
'delete');
1805 foreach ($listofsources as $src) {
1806 if (!empty($arrayofremoteban[$src->id])) {
1811 if ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1812 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1813 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1814 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1821 print
'<tr class="oddeven">';
1826 print
'<td class="tdoverflowmax150">';
1828 if (!empty($stripeacc)) {
1829 $connect = $stripeacc.
'/';
1832 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1833 if ($servicestatus) {
1835 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1837 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1857 if (isModEnabled(
'prelevement')) {
1868 print
'<td class="center" width="50">';
1869 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1870 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1871 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1872 print
img_picto($langs->trans(
"Default"),
'off');
1875 print
img_picto($langs->trans(
"Default"),
'on');
1891 $parameters = array(
'arrayfields' => array(),
'stripe_card_ref' => $rib->stripe_card_ref,
'stripe_account' => $rib->stripe_account,
'linetype' =>
'stripebanremoteonly');
1892 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1893 print $hookmanager->resPrint;
1896 print
'<td class="right nowraponall">';
1897 if ($permissiontoaddupdatepaymentinformation) {
1898 print
'<a class="marginleftonly marginrightonly reposition" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletebank&token='.
newToken().
'">';
1899 print
img_picto($langs->trans(
"Delete"),
'delete');
1907 if ($nbremote == 0 && $nblocal == 0) {
1909 if (isModEnabled(
'prelevement')) {
1915 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoBANRecord").
'</span></td></tr>';
1925 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'');
1926 $reshook = $hookmanager->executeHooks(
'printNewTable', $parameters, $object);
1927 print $hookmanager->resPrint;
1932 print
'<div class="fichecenter"><div class="fichehalfleft">';
1933 print
'<a name="builddoc"></a>';
1939 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".
$object->id;
1941 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);
1948 $result = $companypaymentmodetemp->fetch(0,
'',
$object->id,
'ban');
1950 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1953 $result = $ecmfile->fetch(0,
'',
'',
'',
'', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
1955 $companybankaccounttemp->last_main_doc = $ecmfile->filepath.
'/'.$ecmfile->filename;
1956 print
'<br><!-- Link to download main doc -->'.
"\n";
1961 print
'</div><div class="fichehalfright">';
1964 print
'</div></div>';
1990if ($socid && $action ==
'edit' && $permissiontoaddupdatepaymentinformation) {
1993 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1995 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
1997 print
'<div class="underbanner clearboth"></div>';
2001 print
'<div class="div-table-responsive-no-min">';
2002 print
'<table class="border centpercent">';
2004 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Label").
'</td>';
2005 print
'<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.
'"></td></tr>';
2007 $required = (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0) ?
"fieldrequired" :
"";
2008 print
'<tr><td class="'.$required.
'">'.$langs->trans(
"BankName").
'</td>';
2009 print
'<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.
'"></td></tr>';
2012 $bankaccount = $companybankaccount;
2014 foreach ($bankaccount->getFieldsToShow(1) as $val) {
2019 $content =
'NoContent';
2020 if ($val ==
'BankCode') {
2021 $name =
'code_banque';
2023 $content = $bankaccount->code_banque;
2024 } elseif ($val ==
'DeskCode') {
2025 $name =
'code_guichet';
2027 $content = $bankaccount->code_guichet;
2028 } elseif ($val ==
'BankAccountNumber') {
2031 $content = $bankaccount->number;
2032 } elseif ($val ==
'BankAccountNumberKey') {
2035 $content = $bankaccount->cle_rib;
2036 } elseif ($val ==
'IBAN') {
2039 $content = $bankaccount->iban;
2040 if ($bankaccount->needIBAN()) {
2043 $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';
2044 } elseif ($val ==
'BIC') {
2047 $content = $bankaccount->bic;
2048 if ($bankaccount->needBIC() && (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0)) {
2051 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2055 print
'<td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2058 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2060 print $langs->trans($val);
2063 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.$content.
'"></td>';
2067 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2068 print
'<textarea name="address" rows="4" cols="40" maxlength="255">';
2069 print $companybankaccount->address;
2070 print
"</textarea></td></tr>";
2072 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2073 print
'<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->owner_name.
'"></td></tr>';
2074 print
"</td></tr>\n";
2076 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2077 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" cols="40" maxlength="255">';
2078 print $companybankaccount->owner_address;
2079 print
"</textarea></td></tr>";
2084 if (isModEnabled(
'prelevement')) {
2087 print
'<div class="div-table-responsive-no-min">';
2088 print
'<table class="border centpercent">';
2090 if (empty($companybankaccount->rum)) {
2091 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
2095 print
'<tr><td class="titlefield">'.$langs->trans(
"RUM").
'</td>';
2096 print
'<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).
'"></td></tr>';
2100 print
'<tr><td class="titlefield">'.$langs->trans(
"DateRUM").
'</td>';
2101 print
'<td>'.$form->selectDate($date_rum ? $date_rum : $companybankaccount->date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2103 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2104 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2105 print $form->selectarray(
"frstrecur", $tblArraychoice,
dol_escape_htmltag(
GETPOST(
'frstrecur',
'alpha') ?
GETPOST(
'frstrecur',
'alpha') : $companybankaccount->frstrecur), 0);
2108 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_...' or 'src_...')</td>";
2109 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
2118 print $form->buttonsSaveCancel(
"Modify");
2122if ($socid && $action ==
'editcard' && $permissiontoaddupdatepaymentinformation) {
2125 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2127 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2129 print
'<div class="nofichecenter">';
2131 print
'<div class="underbanner clearboth"></div>';
2135 print
'<div class="div-table-responsive-no-min">';
2136 print
'<table class="border centpercent">';
2138 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2139 print
'<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.
'"></td></tr>';
2141 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2142 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->owner_name.
'"></td></tr>';
2144 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2145 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.
'"></td></tr>';
2147 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2149 print $formother->select_month((
string) $companypaymentmode->exp_date_month,
'exp_date_month', 1);
2150 print $formother->selectyear((
string) $companypaymentmode->exp_date_year,
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2153 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2154 print
'<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.
'"></td></tr>';
2156 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_... ".$langs->trans(
"or").
" card_....')</td>";
2157 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
2165 print $form->buttonsSaveCancel(
"Modify");
2170if ($socid && $action ==
'create' && $permissiontoaddupdatepaymentinformation) {
2173 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2175 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2177 print
'<div class="nofichecenter">';
2179 print
'<div class="underbanner clearboth"></div>';
2183 print
'<div class="div-table-responsive-no-min">';
2184 print
'<table class="border centpercent">';
2186 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2187 print
'<td><input class="minwidth250" type="text" id="label" name="label" value="'.(GETPOSTISSET(
'label') ?
GETPOST(
'label') : $langs->trans(
"Bank").
' '.
$object->
name).
'"></td></tr>';
2189 print
'<tr><td>'.$langs->trans(
"Bank").
'</td>';
2190 print
'<td><input class="minwidth250" type="text" id="bank" name="bank" value="'.GETPOST(
'bank').
'"></td></tr>';
2193 foreach ($companybankaccount->getFieldsToShow(1) as $val) {
2198 $content =
'NoContent';
2199 if ($val ==
'BankCode') {
2200 $name =
'code_banque';
2202 $content = $companybankaccount->code_banque;
2203 } elseif ($val ==
'DeskCode') {
2204 $name =
'code_guichet';
2206 $content = $companybankaccount->code_guichet;
2207 } elseif ($val ==
'BankAccountNumber') {
2210 $content = $companybankaccount->number;
2211 } elseif ($val ==
'BankAccountNumberKey') {
2214 $content = $companybankaccount->cle_rib;
2215 } elseif ($val ==
'IBAN') {
2218 $content = $companybankaccount->iban;
2219 if ($companybankaccount->needIBAN()) {
2222 $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';
2223 } elseif ($val ==
'BIC') {
2226 $content = $companybankaccount->bic;
2227 if ($companybankaccount->needBIC() && (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0)) {
2230 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2233 print
'<tr><td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2236 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2238 print $langs->trans($val);
2241 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.
GETPOST($name).
'"></td>';
2245 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2246 print
'<textarea name="address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2248 print
"</textarea></td></tr>";
2250 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2251 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio').
'"></td></tr>';
2252 print
"</td></tr>\n";
2254 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2255 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2256 print
GETPOST(
'owner_address');
2257 print
"</textarea></td></tr>";
2262 if (isModEnabled(
'prelevement')) {
2265 print
'<div class="div-table-responsive-no-min">';
2266 print
'<table class="border centpercent">';
2269 print
'<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans(
"RUM"), $langs->trans(
"RUMLong").
'<br>'.$langs->trans(
"RUMWillBeGenerated")).
'</td>';
2270 print
'<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST(
'rum',
'alpha').
'"></td></tr>';
2274 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DateRUM").
'</td>';
2275 print
'<td colspan="4">'.$form->selectDate($date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2277 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2278 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2279 print $form->selectarray(
"frstrecur", $tblArraychoice, (GETPOSTISSET(
'frstrecur') ?
GETPOST(
'frstrecur') :
'FRST'), 0);
2282 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('src_....')</td>";
2283 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2295 print $form->buttonsSaveCancel(
"Add");
2299if ($socid && $action ==
'createcard' && $permissiontoaddupdatepaymentinformation) {
2302 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2304 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2306 print
'<div class="nofichecenter">';
2308 print
'<div class="underbanner clearboth"></div>';
2312 print
'<div class="div-table-responsive-no-min">';
2313 print
'<table class="border centpercent">';
2315 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2316 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST(
'label',
'alpha').
'"></td></tr>';
2318 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2319 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio',
'alpha').
'"></td></tr>';
2321 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2322 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST(
'cardnumber',
'alpha').
'"></td></tr>';
2324 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2326 print $formother->select_month((
string)
GETPOSTINT(
'exp_date_month'),
'exp_date_month', 1);
2327 print $formother->selectyear((
string)
GETPOSTINT(
'exp_date_year'),
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2330 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2331 print
'<td><input class="width50" type="text" name="cvn" value="'.GETPOST(
'cvn',
'alpha').
'"></td></tr>';
2333 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('card_....')</td>";
2334 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2345 print $form->buttonsSaveCancel(
"Add");
2348if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
2351if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
checkIbanForAccount($account=null, $ibantocheck=null)
Check IBAN number information for a bank account.
checkBanForAccount($account)
Check account number information for a bank account.
checkSwiftForAccount($account=null, $swift=null)
Check SWIFT information for a bank account.
Class to manage withdrawal receipts.
Class to manage bank accounts description of third parties.
Class for CompanyPaymentMode.
Class to manage ECM files.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class for SocieteAccount.
Class to manage third parties objects (customers, suppliers, prospects...)
Stripe class @TODO No reason to extend CommonObject.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
showDirectDownloadLink($object)
Return string with full Url.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_credit_card($brand, $morecss=null)
Return image of a credit card according to its brand name.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
$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.