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';
49$langs->loadLangs(array(
"companies",
"commercial",
"banks",
"bills",
'paypal',
'stripe',
'withdrawals'));
53$action =
GETPOST(
"action",
'alpha', 3);
54$cancel =
GETPOST(
'cancel',
'alpha');
55$backtopage =
GETPOST(
'backtopage');
58$source =
GETPOST(
"source",
"alpha");
64 $socid = $user->socid;
78$extrafields->fetch_name_optionals_label(
$object->table_element);
81$hookmanager->initHooks(array(
'thirdpartybancard',
'globalcard'));
84$permissiontoread = $user->hasRight(
'societe',
'lire');
85$permissiontoadd = $user->hasRight(
'societe',
'creer');
87$permissiontoaddupdatepaymentinformation = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $permissiontoadd) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'societe',
'thirdparty_paymentinformation_advance',
'write')));
98if (isModEnabled(
'stripe')) {
99 $service =
'StripeTest';
102 $service =
'StripeLive';
107 global $stripearrayofkeysbyenv;
108 $site_account = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
110 $stripe =
new Stripe($db);
111 $stripeacc = $stripe->getStripeAccount($service);
112 $stripecu = $stripe->getStripeCustomerAccount(
$object->id, $servicestatus, $site_account);
127$parameters = array(
'id' => $socid);
128$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
133if (empty($reshook)) {
136 if (!empty($backtopage)) {
137 header(
"Location: ".$backtopage);
142 if ($action ==
'update' && $permissiontoaddupdatepaymentinformation) {
145 if (!
GETPOST(
'label',
'alpha')) {
146 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
149 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankName")),
null,
'errors');
154 $companybankaccount->fetch($id);
155 if ($companybankaccount->needIBAN() == 1) {
157 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
162 if ($companybankaccount->needBIC() == 1) {
164 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
171 $companybankaccount->oldcopy =
dol_clone($companybankaccount, 2);
173 $companybankaccount->socid =
$object->id;
175 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
176 $companybankaccount->label =
GETPOST(
'label',
'alpha');
177 $companybankaccount->status =
GETPOSTINT(
'clos');
178 $companybankaccount->clos = $companybankaccount->status;
179 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
180 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
181 $companybankaccount->number =
GETPOST(
'number',
'alpha');
182 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
183 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
184 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
186 $companybankaccount->address =
GETPOST(
'address',
'alpha');
187 $companybankaccount->domiciliation = $companybankaccount->address;
189 $companybankaccount->owner_name =
GETPOST(
'proprio',
'alpha');
190 $companybankaccount->proprio = $companybankaccount->owner_name;
191 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
192 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
193 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
195 if (empty($companybankaccount->rum)) {
196 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, $companybankaccount->id);
199 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
201 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
203 $companybankaccount->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
205 $result = $companybankaccount->update($user);
208 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
212 if ($companybankaccount->default_rib) {
213 $companybankaccount->setAsDefault($id);
216 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
217 if ($companybankaccount->oldcopy->iban != $companybankaccount->iban) {
222 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
223 header(
'Location: '.$url);
229 if ($action ==
'updatecard' && $permissiontoaddupdatepaymentinformation) {
231 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
232 if (!
GETPOST(
'label',
'alpha')) {
233 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
235 if (!
GETPOST(
'proprio',
'alpha')) {
236 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
239 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
240 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
243 $action =
'createcard';
247 $companypaymentmode->fetch($id);
249 $companybankaccount->oldcopy =
dol_clone($companybankaccount, 2);
251 $companypaymentmode->fk_soc =
$object->id;
253 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
254 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
255 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
256 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
257 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
258 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
259 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
260 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
261 $companypaymentmode->country_code =
$object->country_code;
263 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
265 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
267 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
269 $result = $companypaymentmode->update($user);
271 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
274 if ($companypaymentmode->default_rib) {
275 $companypaymentmode->setAsDefault($id);
278 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
279 if ($companybankaccount->oldcopy->number != $companybankaccount->number) {
284 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
285 header(
'Location: '.$url);
292 if ($action ==
'add' && $permissiontoaddupdatepaymentinformation) {
295 if (!
GETPOST(
'label',
'alpha')) {
296 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
305 $companybankaccount->socid =
$object->id;
307 $companybankaccount->fetch_thirdparty();
309 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
310 $companybankaccount->label =
GETPOST(
'label',
'alpha');
311 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
312 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
313 $companybankaccount->number =
GETPOST(
'number',
'alpha');
314 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
315 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
316 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
318 $companybankaccount->domiciliation =
GETPOST(
'address',
'alpha');
319 $companybankaccount->address =
GETPOST(
'address',
'alpha');
321 $companybankaccount->proprio =
GETPOST(
'proprio',
'alpha');
322 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
323 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
324 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
326 $companybankaccount->datec =
dol_now();
329 $companybankaccount->status =
GETPOSTINT(
'clos');
331 $companybankaccount->bank = trim($companybankaccount->bank);
332 if (empty($companybankaccount->bank) && !empty($companybankaccount->thirdparty)) {
333 $companybankaccount->bank = $langs->trans(
"Bank").
' '.$companybankaccount->thirdparty->name;
335 $companybankaccount->bic = str_replace(
' ',
'', $companybankaccount->bic);
340 if ($companybankaccount->needIBAN() == 1) {
342 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
347 if ($companybankaccount->needBIC() == 1) {
349 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
356 $result = $companybankaccount->create($user);
359 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
363 if (empty($companybankaccount->rum)) {
364 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, $companybankaccount->id);
369 $result = $companybankaccount->update($user);
372 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
380 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
381 header(
'Location: '.$url);
390 if ($action ==
'addcard' && $permissiontoaddupdatepaymentinformation) {
393 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
394 if (!
GETPOST(
'label',
'alpha')) {
395 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
397 if (!
GETPOST(
'proprio',
'alpha')) {
398 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
401 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
402 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
405 $action =
'createcard';
413 $companypaymentmode->fk_soc =
$object->id;
414 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
415 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
416 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
417 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
418 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
419 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
420 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
421 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
422 $companypaymentmode->datec =
dol_now();
423 $companypaymentmode->default_rib = 0;
424 $companypaymentmode->type =
'card';
425 $companypaymentmode->country_code =
$object->country_code;
426 $companypaymentmode->status = $servicestatus;
428 if (
GETPOST(
'stripe_card_ref',
'alpha')) {
430 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
432 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
437 $result = $companypaymentmode->create($user);
440 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
441 $action =
'createcard';
448 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
449 header(
'Location: '.$url);
457 if ($action ==
'setasbankdefault' &&
GETPOSTINT(
'ribid') > 0 && $permissiontoaddupdatepaymentinformation) {
459 $res = $companybankaccount->setAsDefault(
GETPOSTINT(
'ribid'));
461 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
462 header(
'Location: '.$url);
469 if ($action ==
'confirm_deletecard' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoaddupdatepaymentinformation) {
472 if ($companypaymentmode->fetch($ribid ? $ribid :
$id)) {
483 $result = $companypaymentmode->delete($user);
485 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
487 header(
'Location: '.$url);
490 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
493 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
496 if ($action ==
'confirm_deletebank' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoaddupdatepaymentinformation) {
499 if ($companybankaccount->fetch($ribid ? $ribid :
$id) > 0) {
510 $result = $companybankaccount->delete($user);
513 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
515 header(
'Location: '.$url);
518 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
521 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
528 if ($action ==
'builddocrib' && $permissiontoread) {
529 $action =
'builddoc';
531 'use_companybankid' =>
GETPOST(
'companybankid'),
534 $_POST[
'lang_id'] =
GETPOST(
'lang_idrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
535 $_POST[
'model'] =
GETPOST(
'modelrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
539 $upload_dir = $conf->societe->multidir_output[
$object->entity];
540 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
545 if (isModEnabled(
'stripe') && class_exists(
'Stripe')) {
546 if (($action ==
'synccustomertostripe' || $action ==
'synccustomertostripetest') && $permissiontoaddupdatepaymentinformation) {
551 if ($action ==
'synccustomertostripe') {
552 $tmpservicestatus = 1;
553 $tmpservice =
'StripeLive';
555 $tmpservicestatus = 0;
556 $tmpservice =
'StripeTest';
559 $stripe =
new Stripe($db);
560 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
563 $tmpcu = $stripe->customerStripe($object, $tmpstripeacc, $tmpservicestatus, 1);
569 if ($tmpservicestatus == $servicestatus) {
570 $stripecu = $tmpcu->id;
575 if ($action ==
'synccardtostripe' && $permissiontoaddupdatepaymentinformation) {
578 $companypaymentmode->fetch($id);
580 if ($companypaymentmode->type !=
'card') {
585 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
595 $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
603 if ($action ==
'syncsepatostripe' && $permissiontoaddupdatepaymentinformation) {
606 $companypaymentmode->fetch($id);
608 if ($companypaymentmode->type !=
'ban') {
610 $langs->load(
"errors");
614 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
618 $langs->load(
"errors");
619 setEventMessages($langs->trans(
"ErrorStripeCustomerNotFoundCreateFirst"),
null,
'errors');
623 $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
628 setEventMessages(
"", array(
"Bank Account on Stripe",
"BAN is now linked to the Stripe customer account !"));
635 if (($action ==
'setkey_account' || $action ==
'setkey_accounttest') && $permissiontoaddupdatepaymentinformation) {
638 $tmpservice =
'StripeTest';
639 $tmpservicestatus = 0;
640 if ($action ==
'setkey_account') {
641 $tmpservice =
'StripeLive';
642 $tmpservicestatus = 1;
646 global $stripearrayofkeysbyenv;
647 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
649 if ($action ==
'setkey_account') {
650 $newcu =
GETPOST(
'key_account',
'alpha');
652 $newcu =
GETPOST(
'key_accounttest',
'alpha');
658 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_account WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($tmpsite_account).
"') AND fk_soc = ".
$object->id.
" AND status = ".((int) $tmpservicestatus).
" AND entity = ".$conf->entity;
660 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_account";
661 $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;
664 $resql = $db->query($sql);
665 $num = $db->num_rows($resql);
666 if (!empty($newcu)) {
669 $societeaccount->fk_soc =
$object->id;
670 $societeaccount->login =
'';
671 $societeaccount->pass_encoding =
'';
672 $societeaccount->site =
'stripe';
673 $societeaccount->status = $servicestatus;
674 $societeaccount->key_account = $newcu;
675 $societeaccount->site_account = $tmpsite_account;
676 $result = $societeaccount->create($user);
681 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"societe_account";
682 $sql .=
" SET key_account = '".$db->escape($newcu).
"', site_account = '".$db->escape($tmpsite_account).
"'";
683 $sql .=
" WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($tmpsite_account).
"') AND fk_soc = ".((int)
$object->id).
" AND status = ".((int) $tmpservicestatus).
" AND entity = ".$conf->entity;
684 $resql = $db->query($sql);
692 if ($tmpservicestatus == $servicestatus) {
702 if (($action ==
'setkey_account_supplier' || $action ==
'setkey_account_suppliertest') && $permissiontoaddupdatepaymentinformation) {
705 $tmpservice =
'StripeTest';
706 $tmpservicestatus = 0;
707 if ($action ==
'setkey_account_supplier') {
708 $tmpservice =
'StripeLive';
709 $tmpservicestatus = 1;
713 global $stripearrayofkeysbyenv;
714 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
716 if ($action ==
'setkey_account_supplier') {
717 $newsup =
GETPOST(
'key_account_supplier',
'alpha');
719 $newsup =
GETPOST(
'key_account_suppliertest',
'alpha');
724 if (empty($newsup)) {
725 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"oauth_token WHERE fk_soc = ".
$object->id.
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".$conf->entity;
730 $stripesup = \Stripe\Account::retrieve($newsup);
731 $tokenstring = array();
732 $tokenstring[
'stripe_user_id'] = $stripesup->id;
733 $tokenstring[
'type'] = $stripesup->type;
734 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"oauth_token";
735 $sql .=
" SET tokenstring = '".$db->escape(json_encode($tokenstring)).
"'";
736 $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;
738 $sql .=
" WHERE fk_soc = ".$object->id.
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".$conf->entity;
745 $resql = $db->query($sql);
746 $num = $db->num_rows($resql);
747 if (empty($num) && !empty($newsup)) {
749 $stripesup = \Stripe\Account::retrieve($newsup);
750 $tokenstring[
'stripe_user_id'] = $stripesup->id;
751 $tokenstring[
'type'] = $stripesup->type;
752 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"oauth_token (service, fk_soc, entity, tokenstring)";
753 $sql .=
" VALUES ('".$db->escape($tmpservice).
"', ".((int)
$object->id).
", ".((int) $conf->entity).
", '".$db->escape(json_encode($tokenstring)).
"')";
759 $resql = $db->query($sql);
763 if ($tmpservicestatus == $servicestatus) {
764 $stripesupplieracc = $newsup;
772 if ($action ==
'setlocalassourcedefault' && $permissiontoaddupdatepaymentinformation) {
774 $companypaymentmode->setAsDefault($id);
776 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
777 header(
'Location: '.$url);
783 } elseif ($action ==
'setassourcedefault' && $permissiontoaddupdatepaymentinformation) {
785 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
786 if (preg_match(
'/pm_|src_/', $source)) {
787 $cu->invoice_settings->default_payment_method = (string) $source;
789 $cu->default_source = (string) $source;
792 $result = $cu->save();
794 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
795 header(
'Location: '.$url);
801 } elseif ($action ==
'deletecard' && $source && $permissiontoaddupdatepaymentinformation) {
804 if (preg_match(
'/pm_/', $source)) {
805 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
806 if ($payment_method) {
807 $payment_method->detach();
810 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
811 $card = $cu->sources->retrieve(
"$source");
814 if (method_exists($card,
'detach')) {
816 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
817 $sql .=
" SET stripe_card_ref = null";
818 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
819 $resql = $db->query($sql);
821 $card->delete($user);
826 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
827 header(
'Location: '.$url);
833 } elseif ($action ==
'deletebank' && $source && $permissiontoaddupdatepaymentinformation) {
836 if (preg_match(
'/pm_/', $source)) {
837 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
838 if ($payment_method) {
839 $payment_method->detach();
842 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
843 $card = $cu->sources->retrieve(
"$source");
846 if (method_exists($card,
'detach')) {
848 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
849 $sql .=
" SET stripe_card_ref = null";
850 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
852 $resql = $db->query($sql);
854 $card->delete($user);
859 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
861 $url .=
'&page_y='.GETPOSTINT(
'page_y');
864 header(
'Location: '.$url);
880$form =
new Form($db);
884$title = $langs->trans(
"ThirdParty");
886 $title =
$object->name.
" - ".$langs->trans(
'PaymentInformation');
900 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'), [],
'warning');
906 $companybankaccount->fetch(0,
'',
$object->id);
908 $companypaymentmode->fetch(0,
null,
$object->id,
'card');
910 $companybankaccount->fetch($id);
911 $companypaymentmode->fetch($id);
913if (empty($companybankaccount->socid)) {
914 $companybankaccount->socid =
$object->id;
917if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
918 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post">';
919 print
'<input type="hidden" name="token" value="'.newToken().
'">';
920 $actionforadd =
'update';
921 if ($action ==
'editcard') {
922 $actionforadd =
'updatecard';
924 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
925 print
'<input type="hidden" name="id" value="'.GETPOSTINT(
"id").
'">';
927if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
928 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post">';
929 print
'<input type="hidden" name="token" value="'.newToken().
'">';
930 $actionforadd =
'add';
931 if ($action ==
'createcard') {
932 $actionforadd =
'addcard';
934 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
939if ($socid && $action !=
'edit' && $action !=
'create' && $action !=
'editcard' && $action !=
'createcard') {
943 if ($action ==
'deletebank') {
944 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);
947 if ($action ==
'deletecard') {
948 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);
951 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
953 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
955 print
'<div class="fichecenter">';
957 print
'<div class="underbanner clearboth"></div>';
958 print
'<table class="border tableforfield centpercent">';
961 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td colspan="2">';
966 print
'<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="2">'.
$object->prefix_comm.
'</td></tr>';
970 print
'<tr><td class="titlefield">';
971 print $langs->trans(
'CustomerCode').
'</td><td colspan="2">';
973 $tmpcheck =
$object->check_codeclient();
974 if ($tmpcheck != 0 && $tmpcheck != -5) {
975 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
978 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
979 $resql = $db->query($sql);
984 $obj = $db->fetch_object($resql);
985 $nbFactsClient = $obj->nb;
986 $thirdTypeArray = array();
987 $elementTypeArray = array();
988 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
989 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
990 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
992 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
993 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
995 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
996 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
998 if (isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
999 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1002 if (isModEnabled(
'stripe')) {
1004 global $stripearrayofkeysbyenv;
1007 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1008 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
1009 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1012 print
'<tr><td class="titlefield">';
1013 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1015 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1016 if ($tmpstripecu && $action !=
'editkey_accounttest') {
1018 if (!empty($stripeacc)) {
1019 $connect = $stripeacc.
'/';
1021 $url =
'https://dashboard.stripe.com/'.$connect.
'test/customers/'.$tmpstripecu;
1022 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1024 print
'</td><td class="right">';
1025 if (empty($tmpstripecu)) {
1026 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1027 print
'<input type="hidden" name="action" value="synccustomertostripetest">';
1028 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1029 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1030 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1031 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomertest" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1037 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1038 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
1039 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1042 print
'<tr><td class="titlefield">';
1043 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1045 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1046 if ($tmpstripecu && $action !=
'editkey_account') {
1048 if (!empty($stripeacc)) {
1049 $connect = $stripeacc.
'/';
1051 $url =
'https://dashboard.stripe.com/'.$connect.
'customers/'.$tmpstripecu;
1052 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1054 print
'</td><td class="right">';
1055 if (empty($tmpstripecu)) {
1056 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1057 print
'<input type="hidden" name="action" value="synccustomertostripe">';
1058 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1059 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1060 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1061 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomer" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1069 print
'<tr><td class="titlefield">';
1070 print $langs->trans(
'SupplierCode').
'</td><td colspan="2">';
1072 $tmpcheck =
$object->check_codefournisseur();
1073 if ($tmpcheck != 0 && $tmpcheck != -5) {
1074 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
1077 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
1078 $resql = $db->query($sql);
1082 $obj = $db->fetch_object($resql);
1083 $nbFactsClient = $obj->nb;
1084 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
1085 if (isModEnabled(
'propal') && $user->hasRight(
'propal',
'lire')) {
1086 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
1088 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
1089 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1091 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1092 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1094 if (isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1095 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1100 if (isModEnabled(
'stripe') && !empty($conf->stripeconnect->enabled) &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 2) {
1101 $stripesupplieracc = $stripe->getStripeAccount($service,
$object->id);
1104 print
'<tr><td class="titlefield">';
1105 print $form->editfieldkey(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1107 print $form->editfieldval(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1108 if (isModEnabled(
'stripe') && $stripesupplieracc && $action !=
'editkey_account_supplier') {
1111 $url =
'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc;
1112 if ($servicestatus) {
1113 $url =
'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc;
1115 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key '.$site_account,
'globe').
'</a>';
1117 print
'</td><td class="right">';
1118 if (empty($stripesupplieracc)) {
1119 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1120 print
'<input type="hidden" name="action" value="syncsuppliertostripe">';
1121 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1122 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1123 print
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1137 $showcardpaymentmode = 0;
1138 if (isModEnabled(
'stripe')) {
1139 $showcardpaymentmode++;
1143 $listofsources = array();
1145 if (isset($stripe) && is_object($stripe)) {
1147 $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus);
1148 if (!empty($customerstripe->id)) {
1151 $listofsources = $customerstripe->sources->data;
1153 $service =
'StripeTest';
1156 $service =
'StripeLive';
1161 global $stripearrayofkeysbyenv;
1162 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
1165 if (empty($stripeacc)) {
1166 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"));
1167 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"));
1169 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"), array(
"stripe_account" => $stripeacc));
1170 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"), array(
"stripe_account" => $stripeacc));
1173 if ($paymentmethodobjsA->data !=
null && $paymentmethodobjsB->data !=
null) {
1174 $listofsources = array_merge((array) $paymentmethodobjsA->data, (array) $paymentmethodobjsB->data);
1175 } elseif ($paymentmethodobjsB->data !=
null) {
1176 $listofsources = $paymentmethodobjsB->data;
1178 $listofsources = $paymentmethodobjsA->data;
1187 dol_syslog(
"Error when searching/loading Stripe customer for thirdparty id =".
$object->id);
1193 if ($showcardpaymentmode &&
$object->client) {
1194 $morehtmlright =
'';
1196 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=createcard');
1198 print
load_fiche_titre($langs->trans(
'CreditCard'), $morehtmlright,
'fa-credit-card');
1201 print
'<!-- List of card payments -->'.
"\n";
1202 print
'<div class="div-table-responsive-no-min">';
1203 print
'<table class="liste centpercent noborder">'.
"\n";
1204 print
'<tr class="liste_titre">';
1205 print
'<td>'.$langs->trans(
'Label').
'</td>';
1206 print
'<td>'.$form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")).
'</td>';
1207 print
'<td>'.$langs->trans(
'Type').
'</td>';
1208 print
'<td>'.$langs->trans(
'Informations').
'</td>';
1210 print
'<td class="center">'.$langs->trans(
'Default').
'</td>';
1211 print
'<td>'.$langs->trans(
'Note').
'</td>';
1212 print
'<td>'.$langs->trans(
'DateModification').
'</td>';
1214 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'stripetitle');
1215 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
1216 print $hookmanager->resPrint;
1223 $arrayofremotecard = array();
1230 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_rib";
1231 $sql .=
" WHERE type in ('card')";
1232 $sql .=
" AND fk_soc = ".((int)
$object->id);
1233 $sql .=
" AND status = ".((int) $servicestatus);
1235 $resql = $db->query($sql);
1237 $num_rows = $db->num_rows($resql);
1240 while ($i < $num_rows) {
1243 $obj = $db->fetch_object($resql);
1245 $companypaymentmodetemp->fetch($obj->rowid);
1247 $arrayofremotecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref;
1249 print
'<tr class="oddeven" data-rowid="'.((int) $companypaymentmodetemp->id).
'">';
1251 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->label).
'">';
1255 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->stripe_card_ref.(empty($companypaymentmodetemp->stripe_account) ?
'' :
' - '.$companypaymentmodetemp->stripe_account)).
'">';
1256 if (!empty($companypaymentmodetemp->stripe_card_ref) && !empty($companypaymentmodetemp->ext_payment_site)) {
1257 if (isModEnabled(
'stripe') && in_array($companypaymentmodetemp->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1259 if (!empty($stripeacc)) {
1260 $connect = $stripeacc.
'/';
1262 if ($companypaymentmodetemp->ext_payment_site ==
'StripeLive') {
1263 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$companypaymentmodetemp->stripe_card_ref;
1265 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
1267 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe').
' - '.$companypaymentmodetemp->stripe_account,
'globe').
"</a> ";
1278 print
'<td class="minwidth100">';
1279 if ($companypaymentmodetemp->proprio) {
1280 print
'<span class="opacitymedium">'.$companypaymentmodetemp->proprio.
'</span><br>';
1282 if ($companypaymentmodetemp->last_four) {
1283 print
'....'.$companypaymentmodetemp->last_four;
1285 if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) {
1286 print
' - '.sprintf(
"%02d", $companypaymentmodetemp->exp_date_month).
'/'.$companypaymentmodetemp->exp_date_year;
1290 print
'<td class="tdoverflowmax100">';
1291 if ($companypaymentmodetemp->country_code) {
1293 print $img ? $img.
' ' :
'';
1294 print
getCountry($companypaymentmodetemp->country_code,
'1');
1296 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1300 print
'<td class="center">';
1301 if (empty($companypaymentmodetemp->default_rib)) {
1302 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=setlocalassourcedefault&token='.
newToken().
'">';
1303 print
img_picto($langs->trans(
"Default"),
'off');
1306 print
img_picto($langs->trans(
"Default"),
'on');
1309 if (empty($companypaymentmodetemp->stripe_card_ref)) {
1310 $s = $langs->trans(
"Local");
1312 $s = $langs->trans(
"LocalAndRemote");
1314 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1318 print
dol_print_date($companypaymentmodetemp->date_modification,
'dayhour',
'tzuserrel');
1321 $parameters = array(
'arrayfields' => array(),
'obj' => $obj,
'linetype' =>
'stripecard');
1322 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1323 print $hookmanager->resPrint;
1325 print
'<td class="right minwidth50 nowraponall">';
1326 if ($permissiontoaddupdatepaymentinformation) {
1327 if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) {
1328 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=synccardtostripe&socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'" class="paddingrightonly marginrightonly">'.$langs->trans(
"CreateCardOnStripe").
'</a>';
1331 print
'<a class="editfielda marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=editcard&token='.
newToken().
'">';
1332 print
img_picto($langs->trans(
"Modify"),
'edit');
1334 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=deletecard&token='.
newToken().
'">';
1335 print
img_picto($langs->trans(
"Delete"),
'delete');
1350 if (is_array($listofsources) && count($listofsources)) {
1351 foreach ($listofsources as $src) {
1352 if (!empty($arrayofremotecard[$src->id])) {
1359 if ($src->object ==
'card') {
1361 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1363 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1365 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1367 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1371 print
'<tr class="oddeven">';
1375 print
'<td class="tdoverflowmax150">';
1377 if (!empty($stripeacc)) {
1378 $connect = $stripeacc.
'/';
1381 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1382 if ($servicestatus) {
1384 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1386 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1394 print
'<td valign="middle">';
1395 if ($src->object ==
'card') {
1396 print
'....'.$src->last4.
' - '.$src->exp_month.
'/'.$src->exp_year;
1398 if ($src->country) {
1400 print $img ? $img.
' ' :
'';
1403 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1405 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1406 print
'<span class="opacitymedium">'.$src->owner->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1409 if ($src->card->country) {
1411 print $img ? $img.
' ' :
'';
1414 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1416 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1417 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1419 if ($src->sepa_debit->country) {
1421 print $img ? $img.
' ' :
'';
1422 print
getCountry($src->sepa_debit->country,
'1');
1424 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1426 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1427 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1430 if ($src->card->country) {
1432 print $img ? $img.
' ' :
'';
1435 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1437 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1438 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1440 if ($src->sepa_debit->country) {
1442 print $img ? $img.
' ' :
'';
1443 print
getCountry($src->sepa_debit->country,
'1');
1445 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1452 print
'<td class="center" width="50">';
1453 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1454 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1455 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1456 print
img_picto($langs->trans(
"Default"),
'off');
1459 print
img_picto($langs->trans(
"Default"),
'on');
1463 print $langs->trans(
"Remote");
1472 $parameters = array(
'arrayfields' => array(),
'stripesource' => $src,
'linetype' =>
'stripecardremoteonly');
1473 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1474 print $hookmanager->resPrint;
1477 print
'<td class="right nowraponall">';
1478 if ($permissiontoaddupdatepaymentinformation) {
1479 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletecard&token='.
newToken().
'">';
1480 print
img_picto($langs->trans(
"Delete"),
'delete');
1489 if ($nbremote == 0 && $nblocal == 0) {
1491 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1499 if (isModEnabled(
'stripe') && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc)) {
1500 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');
1501 $balance = \Stripe\Balance::retrieve(array(
"stripe_account" => $stripesupplieracc));
1502 print
'<table class="liste centpercent noborder">'.
"\n";
1503 print
'<tr class="liste_titre">';
1504 print
'<td>'.$langs->trans(
'Currency').
'</td>';
1505 print
'<td>'.$langs->trans(
'Available').
'</td>';
1506 print
'<td>'.$langs->trans(
'Pending').
'</td>';
1507 print
'<td>'.$langs->trans(
'Total').
'</td>';
1510 $currencybalance = array();
1511 if (is_array($balance->available) && count($balance->available)) {
1512 foreach ($balance->available as $cpt) {
1513 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1514 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1515 $currencybalance[$cpt->currency][
'available'] = $cpt->amount / 100;
1517 $currencybalance[$cpt->currency][
'available'] = $cpt->amount;
1519 $currencybalance[$cpt->currency][
'currency'] = $cpt->currency;
1523 if (is_array($balance->pending) && count($balance->pending)) {
1524 foreach ($balance->pending as $cpt) {
1525 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1526 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1527 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount / 100;
1529 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount;
1534 if (is_array($currencybalance)) {
1535 foreach ($currencybalance as $cpt) {
1536 print
'<tr><td>'.$langs->trans(
"Currency".strtoupper($cpt[
'currency'])).
'</td><td>'.
price($cpt[
'available'], 0,
'', 1, - 1, - 1, strtoupper($cpt[
'currency'])).
'</td><td>'.
price(isset($cpt->pending) ? $cpt->pending : 0, 0,
'', 1, - 1, - 1, strtoupper($cpt[
'currency'])).
'</td><td>'.
price($cpt[
'available'] + (isset($cpt->pending) ? $cpt->pending : 0), 0,
'', 1, - 1, - 1, strtoupper($cpt[
'currency'])).
'</td></tr>';
1546 if ($permissiontoaddupdatepaymentinformation) {
1547 $morehtmlright =
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"] .
'?socid=' .
$object->id .
'&action=create');
1550 print
load_fiche_titre($langs->trans(
"BankAccounts"), $morehtmlright,
'bank');
1554 $arrayofremoteban = array();
1556 $rib_list =
$object->get_all_rib();
1558 if (is_array($rib_list)) {
1559 print
'<div class="div-table-responsive-no-min">';
1560 print
'<table class="liste centpercent noborder">';
1562 print
'<tr class="liste_titre">';
1564 print_liste_field_titre($form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")));
1569 if (isModEnabled(
'prelevement')) {
1580 $parameters = array(
'arrayfields' => array(),
'linetype' =>
'stripebantitle');
1581 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1582 print $hookmanager->resPrint;
1587 foreach ($rib_list as $rib) {
1588 $arrayofremoteban[$rib->stripe_card_ref] = $rib->stripe_card_ref;
1592 print
'<tr class="oddeven">';
1594 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->label).
'">'.
dol_escape_htmltag($rib->label).
'</td>';
1596 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->stripe_card_ref.(empty($rib->stripe_account) ?
'' :
' - '.$rib->stripe_account)).
'">';
1597 if (!empty($rib->stripe_card_ref) && !empty($rib->ext_payment_site)) {
1598 if (isModEnabled(
'stripe') && in_array($rib->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1600 if (!empty($stripeacc)) {
1601 $connect = $stripeacc.
'/';
1603 if ($rib->ext_payment_site ==
'StripeLive') {
1604 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$rib->stripe_card_ref;
1606 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$rib->stripe_card_ref;
1608 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1615 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->bank).
'">'.
dol_escape_htmltag($rib->bank).
'</td>';
1618 foreach ($rib->getFieldsToShow() as $val) {
1619 if ($val ==
'BankCode') {
1620 $string .= $rib->code_banque.
' ';
1621 } elseif ($val ==
'BankAccountNumber') {
1622 $string .= $rib->number.
' ';
1623 } elseif ($val ==
'DeskCode') {
1624 $string .= $rib->code_guichet.
' ';
1625 } elseif ($val ==
'BankAccountNumberKey') {
1626 $string .= $rib->cle_rib.
' ';
1635 if (!empty($rib->label) && $rib->number) {
1637 $string .=
' '.img_picto($langs->trans(
"ValueIsNotValid"),
'warning');
1639 $string .=
' '.img_picto($langs->trans(
"ValueIsValid"),
'info');
1642 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($string).
'">';
1646 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->iban).
'">';
1647 if (!empty($rib->iban)) {
1649 print
img_picto($langs->trans(
"IbanNotValid"),
'warning').
' ';
1656 if (!empty($rib->bic)) {
1658 print
img_picto($langs->trans(
"SwiftNotValid"),
'warning').
' ';
1664 if (isModEnabled(
'prelevement')) {
1667 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->rum).
'">'.
dol_escape_htmltag($rib->rum).
'</td>';
1669 print
'<td>'.dol_print_date($rib->date_rum,
'day').
'</td>';
1672 print
'<td>'.dol_escape_htmltag($rib->frstrecur).
'</td>';
1676 print
'<td class="center" width="70">';
1677 if (!$rib->default_rib) {
1678 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?socid='.((int)
$object->id).
'&ribid='.((int) $rib->id).
'&action=setasbankdefault&token='.
newToken().
'">';
1679 print
img_picto($langs->trans(
"Disabled"),
'off');
1682 print
img_picto($langs->trans(
"Enabled"),
'on');
1687 print
'<td class="center">';
1689 $buttonlabel = $langs->trans(
"BuildDoc");
1690 $forname =
'builddocrib'.$rib->id;
1692 include_once DOL_DOCUMENT_ROOT.
'/core/modules/bank/modules_bank.php';
1696 if (is_array($modellist) && count($modellist)) {
1697 $out .=
'<form action="'.$_SERVER[
"PHP_SELF"].(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#builddoc').
'" name="'.$forname.
'" id="'.$forname.
'_form" method="post">';
1698 $out .=
'<input type="hidden" name="action" value="builddocrib">';
1699 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1700 $out .=
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1701 $out .=
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1703 $modelselected =
'';
1704 if (count($modellist) == 1) {
1705 $arraykeys = array_keys($modellist);
1706 $modelselected = $arraykeys[0];
1712 $out .= $form->selectarray(
'modelrib'.$rib->id, $modellist, $modelselected, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth125');
1717 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
1719 $defaultlang = $langs->getDefaultLang();
1720 $morecss =
'maxwidth150';
1721 if ($conf->browser->layout ==
'phone') {
1722 $morecss =
'maxwidth100';
1724 $out .= $formadmin->select_language($defaultlang,
'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss);
1727 $out .=
'<input class="button buttongen reposition nomargintop nomarginbottom" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
1728 $out .=
' type="submit" value="'.$buttonlabel.
'"';
1736 $parameters = array(
'arrayfields' => array(),
'stripe_card_ref' => $rib->stripe_card_ref,
'stripe_account' => $rib->stripe_account,
'linetype' =>
'stripeban');
1737 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1738 print $hookmanager->resPrint;
1742 print
'<td class="width200">';
1743 $useonlinesignature = 1;
1744 if ($useonlinesignature) {
1745 require_once DOL_DOCUMENT_ROOT .
'/core/lib/signature.lib.php';
1746 print showOnlineSignatureUrl($companybankaccount->element, (
string) $rib->id, $rib,
'short');
1752 print
'<td class="right nowraponall">';
1753 if ($permissiontoaddupdatepaymentinformation) {
1754 if (isModEnabled(
'stripe')) {
1755 if (empty($rib->stripe_card_ref)) {
1758 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=syncsepatostripe&token='.
newToken().
'">';
1759 print
img_picto($langs->trans(
"CreateBANOnStripe"),
'stripe');
1762 print
'<span class="opacitymedium marginrightonly marginleftonly">';
1763 print
img_picto($langs->trans(
"ThirdPartyMustBeACustomerToCreateBANOnStripe"),
'stripe');
1769 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=edit">';
1770 print
img_picto($langs->trans(
"Modify"),
'edit');
1773 print
'<a class="marginrightonly marginleftonly reposition" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=deletebank&token='.
newToken().
'">';
1774 print
img_picto($langs->trans(
"Delete"),
'delete');
1784 foreach ($listofsources as $src) {
1785 if (!empty($arrayofremoteban[$src->id])) {
1790 if ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1791 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1792 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1793 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1800 print
'<tr class="oddeven">';
1804 print
'<td class="tdoverflowmax150">';
1806 if (!empty($stripeacc)) {
1807 $connect = $stripeacc.
'/';
1810 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1811 if ($servicestatus) {
1813 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1815 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1822 print
'<td valign="middle">';
1825 print
'<td valign="middle">';
1829 print
'<td valign="middle">';
1833 if (isModEnabled(
'prelevement')) {
1835 print
'<td valign="middle">';
1839 print
'<td valign="middle">';
1843 print
'<td valign="middle">';
1849 print
'<td class="center" width="50">';
1850 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1851 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1852 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1853 print
img_picto($langs->trans(
"Default"),
'off');
1856 print
img_picto($langs->trans(
"Default"),
'on');
1871 $parameters = array(
'arrayfields' => array(),
'stripe_card_ref' => $rib->stripe_card_ref,
'stripe_account' => $rib->stripe_account,
'linetype' =>
'stripebanremoteonly');
1872 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1873 print $hookmanager->resPrint;
1876 print
'<td class="right nowraponall">';
1877 if ($permissiontoaddupdatepaymentinformation) {
1878 print
'<a class="marginleftonly marginrightonly reposition" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletebank&token='.
newToken().
'">';
1879 print
img_picto($langs->trans(
"Delete"),
'delete');
1887 if ($nbremote == 0 && $nblocal == 0) {
1889 if (isModEnabled(
'prelevement')) {
1892 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoBANRecord").
'</span></td></tr>';
1902 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'');
1903 $reshook = $hookmanager->executeHooks(
'printNewTable', $parameters, $object);
1904 print $hookmanager->resPrint;
1909 print
'<div class="fichecenter"><div class="fichehalfleft">';
1910 print
'<a name="builddoc"></a>';
1915 $filedir = $conf->societe->multidir_output[
$object->entity].
'/'.
$object->id;
1916 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".
$object->id;
1918 print $formfile->showdocuments(
'company',
$object->id, $filedir, $urlsource, $permissiontoread, $permissiontoaddupdatepaymentinformation,
$object->model_pdf, 0, 0, 0, 28, 0,
'entity='.$object->entity, 0,
'',
$object->default_lang);
1925 $result = $companypaymentmodetemp->fetch(0,
null,
$object->id,
'ban');
1927 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1930 $result = $ecmfile->fetch(0,
'',
'',
'',
'', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
1932 $companybankaccounttemp->last_main_doc = $ecmfile->filepath.
'/'.$ecmfile->filename;
1933 print
'<br><!-- Link to download main doc -->'.
"\n";
1938 print
'</div><div class="fichehalfright">';
1941 print
'</div></div>';
1967if ($socid && $action ==
'edit' && $permissiontoaddupdatepaymentinformation) {
1970 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1972 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
1974 print
'<div class="underbanner clearboth"></div>';
1978 print
'<div class="div-table-responsive-no-min">';
1979 print
'<table class="border centpercent">';
1981 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Label").
'</td>';
1982 print
'<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.
'"></td></tr>';
1984 $required = (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0) ?
"fieldrequired" :
"";
1985 print
'<tr><td class="'.$required.
'">'.$langs->trans(
"BankName").
'</td>';
1986 print
'<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.
'"></td></tr>';
1989 $bankaccount = $companybankaccount;
1991 foreach ($bankaccount->getFieldsToShow(1) as $val) {
1994 if ($val ==
'BankCode') {
1995 $name =
'code_banque';
1997 $content = $bankaccount->code_banque;
1998 } elseif ($val ==
'DeskCode') {
1999 $name =
'code_guichet';
2001 $content = $bankaccount->code_guichet;
2002 } elseif ($val ==
'BankAccountNumber') {
2005 $content = $bankaccount->number;
2006 } elseif ($val ==
'BankAccountNumberKey') {
2009 $content = $bankaccount->cle_rib;
2010 } elseif ($val ==
'IBAN') {
2013 $content = $bankaccount->iban;
2014 if ($bankaccount->needIBAN()) {
2017 $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';
2018 } elseif ($val ==
'BIC') {
2021 $content = $bankaccount->bic;
2022 if ($bankaccount->needBIC() && (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0)) {
2025 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2029 print
'<td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2031 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2033 print $langs->trans($val);
2036 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.$content.
'"></td>';
2040 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2041 print
'<textarea name="address" rows="4" cols="40" maxlength="255">';
2042 print $companybankaccount->address;
2043 print
"</textarea></td></tr>";
2045 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2046 print
'<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->owner_name.
'"></td></tr>';
2047 print
"</td></tr>\n";
2049 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2050 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" cols="40" maxlength="255">';
2051 print $companybankaccount->owner_address;
2052 print
"</textarea></td></tr>";
2057 if (isModEnabled(
'prelevement')) {
2060 print
'<div class="div-table-responsive-no-min">';
2061 print
'<table class="border centpercent">';
2063 if (empty($companybankaccount->rum)) {
2064 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, $companybankaccount->id);
2068 print
'<tr><td class="titlefield">'.$langs->trans(
"RUM").
'</td>';
2069 print
'<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).
'"></td></tr>';
2073 print
'<tr><td class="titlefield">'.$langs->trans(
"DateRUM").
'</td>';
2074 print
'<td>'.$form->selectDate($date_rum ? $date_rum : $companybankaccount->date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2076 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2077 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2078 print $form->selectarray(
"frstrecur", $tblArraychoice,
dol_escape_htmltag(
GETPOST(
'frstrecur',
'alpha') ?
GETPOST(
'frstrecur',
'alpha') : $companybankaccount->frstrecur), 0);
2081 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_...' or 'src_...')</td>";
2082 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
2091 print $form->buttonsSaveCancel(
"Modify");
2095if ($socid && $action ==
'editcard' && $permissiontoaddupdatepaymentinformation) {
2098 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2100 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2102 print
'<div class="nofichecenter">';
2104 print
'<div class="underbanner clearboth"></div>';
2108 print
'<table class="border centpercent">';
2110 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2111 print
'<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.
'"></td></tr>';
2113 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2114 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->proprio.
'"></td></tr>';
2116 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2117 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.
'"></td></tr>';
2119 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2121 print $formother->select_month($companypaymentmode->exp_date_month,
'exp_date_month', 1);
2122 print $formother->selectyear($companypaymentmode->exp_date_year,
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2125 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2126 print
'<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.
'"></td></tr>';
2128 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_... ".$langs->trans(
"or").
" card_....')</td>";
2129 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
2136 print $form->buttonsSaveCancel(
"Modify");
2141if ($socid && $action ==
'create' && $permissiontoaddupdatepaymentinformation) {
2144 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2146 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2148 print
'<div class="nofichecenter">';
2150 print
'<div class="underbanner clearboth"></div>';
2154 print
'<table class="border centpercent">';
2156 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2157 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.(GETPOSTISSET(
'label') ?
GETPOST(
'label') :
$object->
name).
'"></td></tr>';
2159 print
'<tr><td>'.$langs->trans(
"Bank").
'</td>';
2160 print
'<td><input class="minwidth200" type="text" id="bank" name="bank" value="'.GETPOST(
'bank').
'"></td></tr>';
2163 foreach ($companybankaccount->getFieldsToShow(1) as $val) {
2166 if ($val ==
'BankCode') {
2167 $name =
'code_banque';
2169 $content = $companybankaccount->code_banque;
2170 } elseif ($val ==
'DeskCode') {
2171 $name =
'code_guichet';
2173 $content = $companybankaccount->code_guichet;
2174 } elseif ($val ==
'BankAccountNumber') {
2177 $content = $companybankaccount->number;
2178 } elseif ($val ==
'BankAccountNumberKey') {
2181 $content = $companybankaccount->cle_rib;
2182 } elseif ($val ==
'IBAN') {
2185 $content = $companybankaccount->iban;
2186 if ($companybankaccount->needIBAN()) {
2189 $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';
2190 } elseif ($val ==
'BIC') {
2193 $content = $companybankaccount->bic;
2194 if ($companybankaccount->needBIC() && (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0)) {
2197 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2200 print
'<tr><td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2202 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2204 print $langs->trans($val);
2207 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.
GETPOST($name).
'"></td>';
2211 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2212 print
'<textarea name="address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2214 print
"</textarea></td></tr>";
2216 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2217 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio').
'"></td></tr>';
2218 print
"</td></tr>\n";
2220 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2221 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2222 print
GETPOST(
'owner_address');
2223 print
"</textarea></td></tr>";
2227 if (isModEnabled(
'prelevement')) {
2230 print
'<table class="border centpercent">';
2233 print
'<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans(
"RUM"), $langs->trans(
"RUMLong").
'<br>'.$langs->trans(
"RUMWillBeGenerated")).
'</td>';
2234 print
'<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST(
'rum',
'alpha').
'"></td></tr>';
2238 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DateRUM").
'</td>';
2239 print
'<td colspan="4">'.$form->selectDate($date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2241 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2242 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2243 print $form->selectarray(
"frstrecur", $tblArraychoice, (GETPOSTISSET(
'frstrecur') ?
GETPOST(
'frstrecur') :
'FRST'), 0);
2246 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('src_....')</td>";
2247 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2258 print $form->buttonsSaveCancel(
"Add");
2262if ($socid && $action ==
'createcard' && $permissiontoaddupdatepaymentinformation) {
2265 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2267 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2269 print
'<div class="nofichecenter">';
2271 print
'<div class="underbanner clearboth"></div>';
2275 print
'<table class="border centpercent">';
2277 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2278 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST(
'label',
'alpha').
'"></td></tr>';
2280 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2281 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio',
'alpha').
'"></td></tr>';
2283 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2284 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST(
'cardnumber',
'alpha').
'"></td></tr>';
2286 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2288 print $formother->select_month(
GETPOSTINT(
'exp_date_month'),
'exp_date_month', 1);
2289 print $formother->selectyear(
GETPOSTINT(
'exp_date_year'),
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2292 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2293 print
'<td><input class="width50" type="text" name="cvn" value="'.GETPOST(
'cvn',
'alpha').
'"></td></tr>';
2295 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('card_....')</td>";
2296 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2306 print $form->buttonsSaveCancel(
"Add");
2309if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
2312if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
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.
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 extends CommonObject.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
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.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
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.
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'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
$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.