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')));
98$site_account =
'UnknownSiteAccount';
101if (isModEnabled(
'stripe')) {
102 $service =
'StripeTest';
104 $service =
'StripeLive';
109 global $stripearrayofkeysbyenv;
110 $site_account = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
112 $stripe =
new Stripe($db);
113 $stripeacc = $stripe->getStripeAccount($service);
114 $stripecu = $stripe->getStripeCustomerAccount(
$object->id, $servicestatus, $site_account);
129$parameters = array(
'id' => $socid);
130$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
135if (empty($reshook)) {
138 if (!empty($backtopage)) {
139 header(
"Location: ".$backtopage);
144 if ($action ==
'update' && $permissiontoaddupdatepaymentinformation) {
147 if (!
GETPOST(
'label',
'alpha')) {
148 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
151 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankName")),
null,
'errors');
156 $companybankaccount->fetch($id);
157 if ($companybankaccount->needIBAN() == 1) {
159 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
164 if ($companybankaccount->needBIC() == 1) {
166 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
173 $cbClassName = get_class($companybankaccount);
174 $cbClassName::$oldcopy =
dol_clone($companybankaccount, 2);
176 $companybankaccount->socid =
$object->id;
178 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
179 $companybankaccount->label =
GETPOST(
'label',
'alpha');
180 $companybankaccount->status =
GETPOSTINT(
'clos');
181 $companybankaccount->clos = $companybankaccount->status;
182 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
183 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
184 $companybankaccount->number =
GETPOST(
'number',
'alpha');
185 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
186 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
187 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
189 $companybankaccount->address =
GETPOST(
'address',
'alpha');
191 $companybankaccount->owner_name =
GETPOST(
'proprio',
'alpha');
192 $companybankaccount->proprio = $companybankaccount->owner_name;
193 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
194 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
195 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
197 if (empty($companybankaccount->rum)) {
198 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, $companybankaccount->id);
201 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
203 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
205 $companybankaccount->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
207 $result = $companybankaccount->update($user);
210 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
214 if ($companybankaccount->default_rib) {
215 $companybankaccount->setAsDefault($id);
218 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
219 if ($companybankaccount->oldcopy->iban != $companybankaccount->iban) {
224 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
225 header(
'Location: '.$url);
231 if ($action ==
'updatecard' && $permissiontoaddupdatepaymentinformation) {
233 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
234 if (!
GETPOST(
'label',
'alpha')) {
235 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
237 if (!
GETPOST(
'proprio',
'alpha')) {
238 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
241 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
242 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
245 $action =
'createcard';
249 $companypaymentmode->fetch($id);
251 $cbClassName = get_class($companybankaccount);
252 $cbClassName::$oldcopy =
dol_clone($companybankaccount, 2);
254 $companypaymentmode->fk_soc =
$object->id;
256 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
257 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
258 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
259 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
260 $companypaymentmode->owner_name =
GETPOST(
'proprio',
'alpha');
261 $companypaymentmode->proprio = $companypaymentmode->owner_name;
262 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
263 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
264 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
265 $companypaymentmode->country_code =
$object->country_code;
267 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
269 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
271 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
273 $result = $companypaymentmode->update($user);
275 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
278 if ($companypaymentmode->default_rib) {
279 $companypaymentmode->setAsDefault($id);
282 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
283 if ($companybankaccount->oldcopy->number != $companybankaccount->number) {
288 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
289 header(
'Location: '.$url);
296 if ($action ==
'add' && $permissiontoaddupdatepaymentinformation) {
299 if (!
GETPOST(
'label',
'alpha')) {
300 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
309 $companybankaccount->socid =
$object->id;
311 $companybankaccount->fetch_thirdparty();
313 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
314 $companybankaccount->label =
GETPOST(
'label',
'alpha');
315 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
316 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
317 $companybankaccount->number =
GETPOST(
'number',
'alpha');
318 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
319 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
320 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
322 $companybankaccount->address =
GETPOST(
'address',
'alpha');
324 $companybankaccount->owner_name =
GETPOST(
'proprio',
'alpha');
325 $companybankaccount->proprio = $companybankaccount->owner_name;
326 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
327 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
328 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
330 $companybankaccount->datec =
dol_now();
333 $companybankaccount->status =
GETPOSTINT(
'clos');
335 $companybankaccount->bank = trim($companybankaccount->bank);
336 if (empty($companybankaccount->bank) && !empty($companybankaccount->thirdparty)) {
337 $companybankaccount->bank = $langs->trans(
"Bank").
' '.$companybankaccount->thirdparty->name;
339 $companybankaccount->bic = str_replace(
' ',
'', $companybankaccount->bic);
344 if ($companybankaccount->needIBAN() == 1) {
346 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
351 if ($companybankaccount->needBIC() == 1) {
353 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
360 $result = $companybankaccount->create($user);
363 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
367 if (empty($companybankaccount->rum)) {
368 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, $companybankaccount->id);
373 $result = $companybankaccount->update($user);
376 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
384 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
385 header(
'Location: '.$url);
394 if ($action ==
'addcard' && $permissiontoaddupdatepaymentinformation) {
397 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
398 if (!
GETPOST(
'label',
'alpha')) {
399 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
401 if (!
GETPOST(
'proprio',
'alpha')) {
402 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
405 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
406 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
409 $action =
'createcard';
417 $companypaymentmode->fk_soc =
$object->id;
418 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
419 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
420 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
421 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
422 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
423 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
424 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
425 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
426 $companypaymentmode->datec =
dol_now();
427 $companypaymentmode->default_rib = 0;
428 $companypaymentmode->type =
'card';
429 $companypaymentmode->country_code =
$object->country_code;
430 $companypaymentmode->status = $servicestatus;
432 if (
GETPOST(
'stripe_card_ref',
'alpha')) {
434 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
436 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
441 $result = $companypaymentmode->create($user);
444 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
445 $action =
'createcard';
452 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
453 header(
'Location: '.$url);
461 if ($action ==
'setasbankdefault' &&
GETPOSTINT(
'ribid') > 0 && $permissiontoaddupdatepaymentinformation) {
463 $res = $companybankaccount->setAsDefault(
GETPOSTINT(
'ribid'));
465 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
466 header(
'Location: '.$url);
473 if ($action ==
'confirm_deletecard' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoaddupdatepaymentinformation) {
476 if ($companypaymentmode->fetch($ribid ? $ribid :
$id)) {
487 $result = $companypaymentmode->delete($user);
489 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
491 header(
'Location: '.$url);
494 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
497 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
500 if ($action ==
'confirm_deletebank' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoaddupdatepaymentinformation) {
503 if ($companybankaccount->fetch($ribid ? $ribid :
$id) > 0) {
514 $result = $companybankaccount->delete($user);
517 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
519 header(
'Location: '.$url);
522 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
525 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
532 if ($action ==
'builddocrib' && $permissiontoread) {
533 $action =
'builddoc';
535 'use_companybankid' =>
GETPOST(
'companybankid'),
538 $_POST[
'lang_id'] =
GETPOST(
'lang_idrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
539 $_POST[
'model'] =
GETPOST(
'modelrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
543 $upload_dir = $conf->societe->multidir_output[
$object->entity];
544 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
549 if (isModEnabled(
'stripe') && class_exists(
'Stripe')) {
550 if (($action ==
'synccustomertostripe' || $action ==
'synccustomertostripetest') && $permissiontoaddupdatepaymentinformation) {
555 if ($action ==
'synccustomertostripe') {
556 $tmpservicestatus = 1;
557 $tmpservice =
'StripeLive';
559 $tmpservicestatus = 0;
560 $tmpservice =
'StripeTest';
563 $stripe =
new Stripe($db);
564 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
567 $tmpcu = $stripe->customerStripe($object, $tmpstripeacc, $tmpservicestatus, 1);
573 if ($tmpservicestatus == $servicestatus) {
574 $stripecu = $tmpcu->id;
579 if ($action ==
'synccardtostripe' && $permissiontoaddupdatepaymentinformation) {
582 $companypaymentmode->fetch($id);
584 if ($companypaymentmode->type !=
'card') {
589 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
599 $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
607 if ($action ==
'syncsepatostripe' && $permissiontoaddupdatepaymentinformation) {
610 $companypaymentmode->fetch($id);
612 if ($companypaymentmode->type !=
'ban') {
614 $langs->load(
"errors");
618 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
622 $langs->load(
"errors");
623 setEventMessages($langs->trans(
"ErrorStripeCustomerNotFoundCreateFirst"),
null,
'errors');
627 $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
632 setEventMessages(
"", array(
"Bank Account on Stripe",
"BAN is now linked to the Stripe customer account !"));
639 if (($action ==
'setkey_account' || $action ==
'setkey_accounttest') && $permissiontoaddupdatepaymentinformation) {
642 $tmpservice =
'StripeTest';
643 $tmpservicestatus = 0;
644 if ($action ==
'setkey_account') {
645 $tmpservice =
'StripeLive';
646 $tmpservicestatus = 1;
650 global $stripearrayofkeysbyenv;
651 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
653 if ($action ==
'setkey_account') {
654 $newcu =
GETPOST(
'key_account',
'alpha');
656 $newcu =
GETPOST(
'key_accounttest',
'alpha');
662 $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;
664 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_account";
665 $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;
668 $resql = $db->query($sql);
669 $num = $db->num_rows($resql);
670 if (!empty($newcu)) {
673 $societeaccount->fk_soc =
$object->id;
674 $societeaccount->login =
'';
675 $societeaccount->pass_encoding =
'';
676 $societeaccount->site =
'stripe';
677 $societeaccount->status = $servicestatus;
678 $societeaccount->key_account = $newcu;
679 $societeaccount->site_account = $tmpsite_account;
680 $result = $societeaccount->create($user);
685 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"societe_account";
686 $sql .=
" SET key_account = '".$db->escape($newcu).
"', site_account = '".$db->escape($tmpsite_account).
"'";
687 $sql .=
" WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($tmpsite_account).
"') AND fk_soc = ".((int)
$object->id).
" AND status = ".((int) $tmpservicestatus).
" AND entity = ".$conf->entity;
688 $resql = $db->query($sql);
696 if ($tmpservicestatus == $servicestatus) {
706 if (($action ==
'setkey_account_supplier' || $action ==
'setkey_account_suppliertest') && $permissiontoaddupdatepaymentinformation) {
709 $tmpservice =
'StripeTest';
710 $tmpservicestatus = 0;
711 if ($action ==
'setkey_account_supplier') {
712 $tmpservice =
'StripeLive';
713 $tmpservicestatus = 1;
717 global $stripearrayofkeysbyenv;
718 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
720 if ($action ==
'setkey_account_supplier') {
721 $newsup =
GETPOST(
'key_account_supplier',
'alpha');
723 $newsup =
GETPOST(
'key_account_suppliertest',
'alpha');
728 if (empty($newsup)) {
729 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"oauth_token WHERE fk_soc = ".
$object->id.
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".$conf->entity;
734 $stripesup = \Stripe\Account::retrieve($newsup);
735 $tokenstring = array();
736 $tokenstring[
'stripe_user_id'] = $stripesup->id;
737 $tokenstring[
'type'] = $stripesup->type;
738 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"oauth_token";
739 $sql .=
" SET tokenstring = '".$db->escape(json_encode($tokenstring)).
"'";
740 $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;
742 $sql .=
" WHERE fk_soc = ".$object->id.
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".$conf->entity;
749 $resql = $db->query($sql);
750 $num = $db->num_rows($resql);
751 if (empty($num) && !empty($newsup)) {
753 $stripesup = \Stripe\Account::retrieve($newsup);
754 $tokenstring[
'stripe_user_id'] = $stripesup->id;
755 $tokenstring[
'type'] = $stripesup->type;
756 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"oauth_token (service, fk_soc, entity, tokenstring)";
757 $sql .=
" VALUES ('".$db->escape($tmpservice).
"', ".((int)
$object->id).
", ".((int) $conf->entity).
", '".$db->escape(json_encode($tokenstring)).
"')";
763 $resql = $db->query($sql);
767 if ($tmpservicestatus == $servicestatus) {
768 $stripesupplieracc = $newsup;
776 if ($action ==
'setlocalassourcedefault' && $permissiontoaddupdatepaymentinformation) {
778 $companypaymentmode->setAsDefault($id);
780 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
781 header(
'Location: '.$url);
787 } elseif ($action ==
'setassourcedefault' && $permissiontoaddupdatepaymentinformation) {
789 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
790 if (preg_match(
'/pm_|src_/', $source)) {
791 $cu->invoice_settings->default_payment_method = (string) $source;
793 $cu->default_source = (string) $source;
796 $result = $cu->save();
798 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
799 header(
'Location: '.$url);
805 } elseif ($action ==
'deletecard' && $source && $permissiontoaddupdatepaymentinformation) {
808 if (preg_match(
'/pm_/', $source)) {
809 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
810 if ($payment_method) {
811 $payment_method->detach();
814 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
815 $card = $cu->sources->retrieve(
"$source");
818 if (method_exists($card,
'detach')) {
820 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
821 $sql .=
" SET stripe_card_ref = null";
822 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
824 $resql = $db->query($sql);
826 $card->delete($user);
831 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
832 header(
'Location: '.$url);
838 } elseif ($action ==
'deletebank' && $source && $permissiontoaddupdatepaymentinformation) {
841 if (preg_match(
'/pm_/', $source)) {
842 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
843 if ($payment_method) {
844 $payment_method->detach();
847 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
848 $card = $cu->sources->retrieve(
"$source");
851 if (method_exists($card,
'detach')) {
853 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
854 $sql .=
" SET stripe_card_ref = null";
855 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
857 $resql = $db->query($sql);
859 $card->delete($user);
864 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
866 $url .=
'&page_y='.GETPOSTINT(
'page_y');
869 header(
'Location: '.$url);
885$form =
new Form($db);
889$title = $langs->trans(
"ThirdParty");
891 $title =
$object->name.
" - ".$langs->trans(
'PaymentInformation');
905 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'), [],
'warning');
911 $companybankaccount->fetch(0,
'',
$object->id);
913 $companypaymentmode->fetch(0,
'',
$object->id,
'card');
915 $companybankaccount->fetch($id);
916 $companypaymentmode->fetch($id);
918if (empty($companybankaccount->socid)) {
919 $companybankaccount->socid =
$object->id;
922if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
923 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post">';
924 print
'<input type="hidden" name="token" value="'.newToken().
'">';
925 $actionforadd =
'update';
926 if ($action ==
'editcard') {
927 $actionforadd =
'updatecard';
929 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
930 print
'<input type="hidden" name="id" value="'.GETPOSTINT(
"id").
'">';
932if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
933 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post">';
934 print
'<input type="hidden" name="token" value="'.newToken().
'">';
935 $actionforadd =
'add';
936 if ($action ==
'createcard') {
937 $actionforadd =
'addcard';
939 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
944if ($socid && $action !=
'edit' && $action !=
'create' && $action !=
'editcard' && $action !=
'createcard') {
948 if ($action ==
'deletebank') {
949 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);
952 if ($action ==
'deletecard') {
953 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);
956 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
958 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
960 print
'<div class="fichecenter">';
962 print
'<div class="underbanner clearboth"></div>';
963 print
'<table class="border tableforfield centpercent">';
966 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td colspan="2">';
971 print
'<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="2">'.
$object->prefix_comm.
'</td></tr>';
975 print
'<tr><td class="titlefield">';
976 print $langs->trans(
'CustomerCode').
'</td><td colspan="2">';
978 $tmpcheck =
$object->check_codeclient();
979 if ($tmpcheck != 0 && $tmpcheck != -5) {
980 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
983 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
984 $resql = $db->query($sql);
989 $obj = $db->fetch_object($resql);
990 $nbFactsClient = $obj->nb;
991 $thirdTypeArray = array();
992 $elementTypeArray = array();
993 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
994 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
995 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
997 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
998 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1000 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1001 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1003 if (isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1004 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1007 if (isModEnabled(
'stripe')) {
1009 global $stripearrayofkeysbyenv;
1012 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1013 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
1014 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1017 print
'<tr><td class="titlefield">';
1018 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1020 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1021 if ($tmpstripecu && $action !=
'editkey_accounttest') {
1023 if (!empty($stripeacc)) {
1024 $connect = $stripeacc.
'/';
1026 $url =
'https://dashboard.stripe.com/'.$connect.
'test/customers/'.$tmpstripecu;
1027 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1029 print
'</td><td class="right">';
1030 if (empty($tmpstripecu)) {
1031 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1032 print
'<input type="hidden" name="action" value="synccustomertostripetest">';
1033 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1034 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1035 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1036 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomertest" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1042 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1043 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
1044 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1047 print
'<tr><td class="titlefield">';
1048 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1050 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1051 if ($tmpstripecu && $action !=
'editkey_account') {
1053 if (!empty($stripeacc)) {
1054 $connect = $stripeacc.
'/';
1056 $url =
'https://dashboard.stripe.com/'.$connect.
'customers/'.$tmpstripecu;
1057 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1059 print
'</td><td class="right">';
1060 if (empty($tmpstripecu)) {
1061 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1062 print
'<input type="hidden" name="action" value="synccustomertostripe">';
1063 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1064 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1065 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1066 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomer" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1074 print
'<tr><td class="titlefield">';
1075 print $langs->trans(
'SupplierCode').
'</td><td colspan="2">';
1077 $tmpcheck =
$object->check_codefournisseur();
1078 if ($tmpcheck != 0 && $tmpcheck != -5) {
1079 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
1082 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
1083 $resql = $db->query($sql);
1087 $obj = $db->fetch_object($resql);
1088 $nbFactsClient = $obj->nb;
1089 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
1090 if (isModEnabled(
'propal') && $user->hasRight(
'propal',
'lire')) {
1091 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
1093 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
1094 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1096 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1097 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1099 if (isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1100 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1105 if (isModEnabled(
'stripe') && !empty($conf->stripeconnect->enabled) &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 2) {
1106 $stripesupplieracc = $stripe->getStripeAccount($service,
$object->id);
1109 print
'<tr><td class="titlefield">';
1110 print $form->editfieldkey(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1112 print $form->editfieldval(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1113 if (isModEnabled(
'stripe') && $stripesupplieracc && $action !=
'editkey_account_supplier') {
1116 $url =
'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc;
1117 if ($servicestatus) {
1118 $url =
'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc;
1120 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key '.$site_account,
'globe').
'</a>';
1122 print
'</td><td class="right">';
1123 if (empty($stripesupplieracc)) {
1124 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1125 print
'<input type="hidden" name="action" value="syncsuppliertostripe">';
1126 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1127 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1128 print
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1142 $showcardpaymentmode = 0;
1143 if (isModEnabled(
'stripe')) {
1144 $showcardpaymentmode++;
1148 $listofsources = array();
1150 $customerstripe =
null;
1151 if (isset($stripe) && is_object($stripe)) {
1153 $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus);
1154 if (!empty($customerstripe->id)) {
1157 $listofsources = $customerstripe->sources->data;
1159 $service =
'StripeTest';
1162 $service =
'StripeLive';
1167 global $stripearrayofkeysbyenv;
1168 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
1171 if (empty($stripeacc)) {
1172 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"));
1173 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"));
1175 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"), array(
"stripe_account" => $stripeacc));
1176 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"), array(
"stripe_account" => $stripeacc));
1179 if ($paymentmethodobjsA->data !=
null && $paymentmethodobjsB->data !=
null) {
1180 $listofsources = array_merge((array) $paymentmethodobjsA->data, (array) $paymentmethodobjsB->data);
1181 } elseif ($paymentmethodobjsB->data !=
null) {
1182 $listofsources = $paymentmethodobjsB->data;
1184 $listofsources = $paymentmethodobjsA->data;
1193 dol_syslog(
"Error when searching/loading Stripe customer for thirdparty id =".
$object->id);
1199 if ($showcardpaymentmode &&
$object->client) {
1200 $morehtmlright =
'';
1202 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=createcard');
1204 print
load_fiche_titre($langs->trans(
'CreditCard'), $morehtmlright,
'fa-credit-card');
1207 print
'<!-- List of card payments -->'.
"\n";
1208 print
'<div class="div-table-responsive-no-min">';
1209 print
'<table class="liste centpercent noborder">'.
"\n";
1210 print
'<tr class="liste_titre">';
1211 print
'<td>'.$langs->trans(
'Label').
'</td>';
1212 print
'<td>'.$form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")).
'</td>';
1213 print
'<td>'.$langs->trans(
'Type').
'</td>';
1214 print
'<td>'.$langs->trans(
'Informations').
'</td>';
1216 print
'<td class="center">'.$langs->trans(
'Default').
'</td>';
1217 print
'<td>'.$langs->trans(
'Note').
'</td>';
1218 print
'<td>'.$langs->trans(
'DateModification').
'</td>';
1220 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'stripetitle');
1221 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
1222 print $hookmanager->resPrint;
1229 $arrayofremotecard = array();
1236 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_rib";
1237 $sql .=
" WHERE type in ('card')";
1238 $sql .=
" AND fk_soc = ".((int)
$object->id);
1239 $sql .=
" AND status = ".((int) $servicestatus);
1241 $resql = $db->query($sql);
1243 $num_rows = $db->num_rows($resql);
1246 while ($i < $num_rows) {
1249 $obj = $db->fetch_object($resql);
1251 $companypaymentmodetemp->fetch($obj->rowid);
1253 $arrayofremotecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref;
1255 print
'<tr class="oddeven" data-rowid="'.((int) $companypaymentmodetemp->id).
'">';
1257 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->label).
'">';
1261 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->stripe_card_ref.(empty($companypaymentmodetemp->stripe_account) ?
'' :
' - '.$companypaymentmodetemp->stripe_account)).
'">';
1262 if (!empty($companypaymentmodetemp->stripe_card_ref) && !empty($companypaymentmodetemp->ext_payment_site)) {
1263 if (isModEnabled(
'stripe') && in_array($companypaymentmodetemp->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1265 if (!empty($stripeacc)) {
1266 $connect = $stripeacc.
'/';
1268 if ($companypaymentmodetemp->ext_payment_site ==
'StripeLive') {
1269 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$companypaymentmodetemp->stripe_card_ref;
1271 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
1273 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe').
' - '.$companypaymentmodetemp->stripe_account,
'globe').
"</a> ";
1284 print
'<td class="minwidth100">';
1285 if ($companypaymentmodetemp->owner_name) {
1286 print
'<span class="opacitymedium">'.$companypaymentmodetemp->owner_name.
'</span><br>';
1288 if ($companypaymentmodetemp->last_four) {
1289 print
'....'.$companypaymentmodetemp->last_four;
1291 if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) {
1292 print
' - '.sprintf(
"%02d", $companypaymentmodetemp->exp_date_month).
'/'.$companypaymentmodetemp->exp_date_year;
1296 print
'<td class="tdoverflowmax100">';
1297 if ($companypaymentmodetemp->country_code) {
1299 print $img ? $img.
' ' :
'';
1300 print
getCountry($companypaymentmodetemp->country_code,
'1');
1302 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1306 print
'<td class="center">';
1307 if (empty($companypaymentmodetemp->default_rib)) {
1308 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=setlocalassourcedefault&token='.
newToken().
'">';
1309 print
img_picto($langs->trans(
"Default"),
'off');
1312 print
img_picto($langs->trans(
"Default"),
'on');
1315 if (empty($companypaymentmodetemp->stripe_card_ref)) {
1316 $s = $langs->trans(
"Local");
1318 $s = $langs->trans(
"LocalAndRemote");
1320 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1324 print
dol_print_date($companypaymentmodetemp->date_modification,
'dayhour',
'tzuserrel');
1327 $parameters = array(
'arrayfields' => array(),
'obj' => $obj,
'linetype' =>
'stripecard');
1328 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1329 print $hookmanager->resPrint;
1331 print
'<td class="right minwidth50 nowraponall">';
1332 if ($permissiontoaddupdatepaymentinformation) {
1333 if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) {
1334 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=synccardtostripe&socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'" class="paddingrightonly marginrightonly">'.$langs->trans(
"CreateCardOnStripe").
'</a>';
1337 print
'<a class="editfielda marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=editcard&token='.
newToken().
'">';
1338 print
img_picto($langs->trans(
"Modify"),
'edit');
1340 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=deletecard&token='.
newToken().
'">';
1341 print
img_picto($langs->trans(
"Delete"),
'delete');
1356 if (is_array($listofsources) && count($listofsources)) {
1357 foreach ($listofsources as $src) {
1358 if (!empty($arrayofremotecard[$src->id])) {
1365 if ($src->object ==
'card') {
1367 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1369 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1371 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1373 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1377 print
'<tr class="oddeven">';
1381 print
'<td class="tdoverflowmax150">';
1383 if (!empty($stripeacc)) {
1384 $connect = $stripeacc.
'/';
1387 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1388 if ($servicestatus) {
1390 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1392 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1400 print
'<td valign="middle">';
1401 if ($src->object ==
'card') {
1402 print
'....'.$src->last4.
' - '.$src->exp_month.
'/'.$src->exp_year;
1404 if ($src->country) {
1406 print $img ? $img.
' ' :
'';
1409 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1411 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1412 print
'<span class="opacitymedium">'.$src->owner->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1415 if ($src->card->country) {
1417 print $img ? $img.
' ' :
'';
1420 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1422 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1423 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1425 if ($src->sepa_debit->country) {
1427 print $img ? $img.
' ' :
'';
1428 print
getCountry($src->sepa_debit->country,
'1');
1430 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1432 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1433 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1436 if ($src->card->country) {
1438 print $img ? $img.
' ' :
'';
1441 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1443 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1444 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1446 if ($src->sepa_debit->country) {
1448 print $img ? $img.
' ' :
'';
1449 print
getCountry($src->sepa_debit->country,
'1');
1451 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1458 print
'<td class="center" width="50">';
1459 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1460 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1461 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1462 print
img_picto($langs->trans(
"Default"),
'off');
1465 print
img_picto($langs->trans(
"Default"),
'on');
1469 print $langs->trans(
"Remote");
1478 $parameters = array(
'arrayfields' => array(),
'stripesource' => $src,
'linetype' =>
'stripecardremoteonly');
1479 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1480 print $hookmanager->resPrint;
1483 print
'<td class="right nowraponall">';
1484 if ($permissiontoaddupdatepaymentinformation) {
1485 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletecard&token='.
newToken().
'">';
1486 print
img_picto($langs->trans(
"Delete"),
'delete');
1495 if ($nbremote == 0 && $nblocal == 0) {
1497 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1505 if (isModEnabled(
'stripe') && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc)) {
1506 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');
1507 $balance = \Stripe\Balance::retrieve(array(
"stripe_account" => $stripesupplieracc));
1508 print
'<table class="liste centpercent noborder">'.
"\n";
1509 print
'<tr class="liste_titre">';
1510 print
'<td>'.$langs->trans(
'Currency').
'</td>';
1511 print
'<td>'.$langs->trans(
'Available').
'</td>';
1512 print
'<td>'.$langs->trans(
'Pending').
'</td>';
1513 print
'<td>'.$langs->trans(
'Total').
'</td>';
1516 $currencybalance = array();
1517 if (is_array($balance->available) && count($balance->available)) {
1518 foreach ($balance->available as $cpt) {
1519 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1520 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1521 $currencybalance[$cpt->currency][
'available'] = $cpt->amount / 100;
1523 $currencybalance[$cpt->currency][
'available'] = $cpt->amount;
1525 $currencybalance[$cpt->currency][
'currency'] = $cpt->currency;
1529 if (is_array($balance->pending) && count($balance->pending)) {
1530 foreach ($balance->pending as $cpt) {
1531 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1532 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1533 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount / 100;
1535 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount;
1540 if (is_array($currencybalance)) {
1541 foreach ($currencybalance as $cpt) {
1542 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>';
1552 if ($permissiontoaddupdatepaymentinformation) {
1553 $morehtmlright =
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"] .
'?socid=' .
$object->id .
'&action=create');
1556 print
load_fiche_titre($langs->trans(
"BankAccounts"), $morehtmlright,
'bank');
1560 $arrayofremoteban = array();
1562 $rib_list =
$object->get_all_rib();
1564 if (is_array($rib_list)) {
1565 print
'<div class="div-table-responsive-no-min">';
1566 print
'<table class="liste centpercent noborder">';
1568 print
'<tr class="liste_titre">';
1570 print_liste_field_titre($form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")));
1575 if (isModEnabled(
'prelevement')) {
1586 $parameters = array(
'arrayfields' => array(),
'linetype' =>
'stripebantitle');
1587 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1588 print $hookmanager->resPrint;
1593 foreach ($rib_list as $rib) {
1594 $arrayofremoteban[$rib->stripe_card_ref] = $rib->stripe_card_ref;
1598 print
'<tr class="oddeven">';
1600 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->label).
'">'.
dol_escape_htmltag($rib->label).
'</td>';
1602 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->stripe_card_ref.(empty($rib->stripe_account) ?
'' :
' - '.$rib->stripe_account)).
'">';
1603 if (!empty($rib->stripe_card_ref) && !empty($rib->ext_payment_site)) {
1604 if (isModEnabled(
'stripe') && in_array($rib->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1606 if (!empty($stripeacc)) {
1607 $connect = $stripeacc.
'/';
1609 if ($rib->ext_payment_site ==
'StripeLive') {
1610 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$rib->stripe_card_ref;
1612 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$rib->stripe_card_ref;
1614 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1621 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->bank).
'">'.
dol_escape_htmltag($rib->bank).
'</td>';
1624 foreach ($rib->getFieldsToShow() as $val) {
1625 if ($val ==
'BankCode') {
1626 $string .= $rib->code_banque.
' ';
1627 } elseif ($val ==
'BankAccountNumber') {
1628 $string .= $rib->number.
' ';
1629 } elseif ($val ==
'DeskCode') {
1630 $string .= $rib->code_guichet.
' ';
1631 } elseif ($val ==
'BankAccountNumberKey') {
1632 $string .= $rib->cle_rib.
' ';
1640 if (!empty($rib->label) && $rib->number) {
1642 $string .=
' '.img_picto($langs->trans(
"ValueIsNotValid"),
'warning');
1644 $string .=
' '.img_picto($langs->trans(
"ValueIsValid"),
'info');
1648 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($string).
'">';
1652 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->iban).
'">';
1653 if (!empty($rib->iban)) {
1655 print
img_picto($langs->trans(
"IbanNotValid"),
'warning').
' ';
1662 if (!empty($rib->bic)) {
1664 print
img_picto($langs->trans(
"SwiftNotValid"),
'warning').
' ';
1670 if (isModEnabled(
'prelevement')) {
1673 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->rum).
'">'.
dol_escape_htmltag($rib->rum).
'</td>';
1675 print
'<td>'.dol_print_date($rib->date_rum,
'day').
'</td>';
1678 print
'<td>'.dol_escape_htmltag($rib->frstrecur).
'</td>';
1682 print
'<td class="center" width="70">';
1683 if (!$rib->default_rib) {
1684 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?socid='.((int)
$object->id).
'&ribid='.((int) $rib->id).
'&action=setasbankdefault&token='.
newToken().
'">';
1685 print
img_picto($langs->trans(
"Disabled"),
'off');
1688 print
img_picto($langs->trans(
"Enabled"),
'on');
1693 print
'<td class="center">';
1695 $buttonlabel = $langs->trans(
"BuildDoc");
1696 $forname =
'builddocrib'.$rib->id;
1698 include_once DOL_DOCUMENT_ROOT.
'/core/modules/bank/modules_bank.php';
1702 if (is_array($modellist) && count($modellist)) {
1703 $out .=
'<form action="'.$_SERVER[
"PHP_SELF"].(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#builddoc').
'" name="'.$forname.
'" id="'.$forname.
'_form" method="post">';
1704 $out .=
'<input type="hidden" name="action" value="builddocrib">';
1705 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1706 $out .=
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1707 $out .=
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1709 $modelselected =
'';
1710 if (count($modellist) == 1) {
1711 $arraykeys = array_keys($modellist);
1712 $modelselected = $arraykeys[0];
1718 $out .= $form->selectarray(
'modelrib'.$rib->id, $modellist, $modelselected, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth125');
1723 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
1725 $defaultlang = $langs->getDefaultLang();
1726 $morecss =
'maxwidth150';
1727 if ($conf->browser->layout ==
'phone') {
1728 $morecss =
'maxwidth100';
1730 $out .= $formadmin->select_language($defaultlang,
'lang_idrib'.$rib->id, 0, array(), 0, 0, 0, $morecss);
1733 $out .=
'<input class="button buttongen reposition nomargintop nomarginbottom" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
1734 $out .=
' type="submit" value="'.$buttonlabel.
'"';
1742 $parameters = array(
'arrayfields' => array(),
'stripe_card_ref' => $rib->stripe_card_ref,
'stripe_account' => $rib->stripe_account,
'linetype' =>
'stripeban');
1743 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1744 print $hookmanager->resPrint;
1748 print
'<td class="minwidth200 width200">';
1749 $useonlinesignature = 1;
1750 if ($useonlinesignature) {
1751 require_once DOL_DOCUMENT_ROOT .
'/core/lib/signature.lib.php';
1752 print showOnlineSignatureUrl($companybankaccount->element, (
string) $rib->id, $rib,
'short');
1758 print
'<td class="right nowraponall">';
1759 if ($permissiontoaddupdatepaymentinformation) {
1760 if (isModEnabled(
'stripe')) {
1761 if (empty($rib->stripe_card_ref)) {
1764 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=syncsepatostripe&token='.
newToken().
'">';
1765 print
img_picto($langs->trans(
"CreateBANOnStripe"),
'stripe');
1768 print
'<span class="opacitymedium marginrightonly marginleftonly">';
1769 print
img_picto($langs->trans(
"ThirdPartyMustBeACustomerToCreateBANOnStripe"),
'stripe');
1775 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=edit">';
1776 print
img_picto($langs->trans(
"Modify"),
'edit');
1779 print
'<a class="marginrightonly marginleftonly reposition" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=deletebank&token='.
newToken().
'">';
1780 print
img_picto($langs->trans(
"Delete"),
'delete');
1790 foreach ($listofsources as $src) {
1791 if (!empty($arrayofremoteban[$src->id])) {
1796 if ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1797 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1798 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1799 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1806 print
'<tr class="oddeven">';
1810 print
'<td class="tdoverflowmax150">';
1812 if (!empty($stripeacc)) {
1813 $connect = $stripeacc.
'/';
1816 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1817 if ($servicestatus) {
1819 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1821 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1839 if (isModEnabled(
'prelevement')) {
1855 print
'<td class="center" width="50">';
1856 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1857 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1858 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1859 print
img_picto($langs->trans(
"Default"),
'off');
1862 print
img_picto($langs->trans(
"Default"),
'on');
1877 $parameters = array(
'arrayfields' => array(),
'stripe_card_ref' => $rib->stripe_card_ref,
'stripe_account' => $rib->stripe_account,
'linetype' =>
'stripebanremoteonly');
1878 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1879 print $hookmanager->resPrint;
1882 print
'<td class="right nowraponall">';
1883 if ($permissiontoaddupdatepaymentinformation) {
1884 print
'<a class="marginleftonly marginrightonly reposition" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletebank&token='.
newToken().
'">';
1885 print
img_picto($langs->trans(
"Delete"),
'delete');
1893 if ($nbremote == 0 && $nblocal == 0) {
1895 if (isModEnabled(
'prelevement')) {
1901 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoBANRecord").
'</span></td></tr>';
1911 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'');
1912 $reshook = $hookmanager->executeHooks(
'printNewTable', $parameters, $object);
1913 print $hookmanager->resPrint;
1918 print
'<div class="fichecenter"><div class="fichehalfleft">';
1919 print
'<a name="builddoc"></a>';
1924 $filedir = $conf->societe->multidir_output[
$object->entity].
'/'.
$object->id;
1925 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".
$object->id;
1927 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);
1934 $result = $companypaymentmodetemp->fetch(0,
'',
$object->id,
'ban');
1936 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1939 $result = $ecmfile->fetch(0,
'',
'',
'',
'', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
1941 $companybankaccounttemp->last_main_doc = $ecmfile->filepath.
'/'.$ecmfile->filename;
1942 print
'<br><!-- Link to download main doc -->'.
"\n";
1947 print
'</div><div class="fichehalfright">';
1950 print
'</div></div>';
1976if ($socid && $action ==
'edit' && $permissiontoaddupdatepaymentinformation) {
1979 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1981 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
1983 print
'<div class="underbanner clearboth"></div>';
1987 print
'<div class="div-table-responsive-no-min">';
1988 print
'<table class="border centpercent">';
1990 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Label").
'</td>';
1991 print
'<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.
'"></td></tr>';
1993 $required = (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0) ?
"fieldrequired" :
"";
1994 print
'<tr><td class="'.$required.
'">'.$langs->trans(
"BankName").
'</td>';
1995 print
'<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.
'"></td></tr>';
1998 $bankaccount = $companybankaccount;
2000 foreach ($bankaccount->getFieldsToShow(1) as $val) {
2005 $content =
'NoContent';
2006 if ($val ==
'BankCode') {
2007 $name =
'code_banque';
2009 $content = $bankaccount->code_banque;
2010 } elseif ($val ==
'DeskCode') {
2011 $name =
'code_guichet';
2013 $content = $bankaccount->code_guichet;
2014 } elseif ($val ==
'BankAccountNumber') {
2017 $content = $bankaccount->number;
2018 } elseif ($val ==
'BankAccountNumberKey') {
2021 $content = $bankaccount->cle_rib;
2022 } elseif ($val ==
'IBAN') {
2025 $content = $bankaccount->iban;
2026 if ($bankaccount->needIBAN()) {
2029 $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';
2030 } elseif ($val ==
'BIC') {
2033 $content = $bankaccount->bic;
2034 if ($bankaccount->needBIC() && (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0)) {
2037 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2041 print
'<td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2044 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2046 print $langs->trans($val);
2049 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.$content.
'"></td>';
2053 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2054 print
'<textarea name="address" rows="4" cols="40" maxlength="255">';
2055 print $companybankaccount->address;
2056 print
"</textarea></td></tr>";
2058 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2059 print
'<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->owner_name.
'"></td></tr>';
2060 print
"</td></tr>\n";
2062 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2063 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" cols="40" maxlength="255">';
2064 print $companybankaccount->owner_address;
2065 print
"</textarea></td></tr>";
2070 if (isModEnabled(
'prelevement')) {
2073 print
'<div class="div-table-responsive-no-min">';
2074 print
'<table class="border centpercent">';
2076 if (empty($companybankaccount->rum)) {
2077 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, $companybankaccount->id);
2081 print
'<tr><td class="titlefield">'.$langs->trans(
"RUM").
'</td>';
2082 print
'<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).
'"></td></tr>';
2086 print
'<tr><td class="titlefield">'.$langs->trans(
"DateRUM").
'</td>';
2087 print
'<td>'.$form->selectDate($date_rum ? $date_rum : $companybankaccount->date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2089 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2090 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2091 print $form->selectarray(
"frstrecur", $tblArraychoice,
dol_escape_htmltag(
GETPOST(
'frstrecur',
'alpha') ?
GETPOST(
'frstrecur',
'alpha') : $companybankaccount->frstrecur), 0);
2094 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_...' or 'src_...')</td>";
2095 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
2104 print $form->buttonsSaveCancel(
"Modify");
2108if ($socid && $action ==
'editcard' && $permissiontoaddupdatepaymentinformation) {
2111 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2113 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2115 print
'<div class="nofichecenter">';
2117 print
'<div class="underbanner clearboth"></div>';
2121 print
'<table class="border centpercent">';
2123 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2124 print
'<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.
'"></td></tr>';
2126 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2127 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->owner_name.
'"></td></tr>';
2129 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2130 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.
'"></td></tr>';
2132 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2134 print $formother->select_month($companypaymentmode->exp_date_month,
'exp_date_month', 1);
2135 print $formother->selectyear($companypaymentmode->exp_date_year,
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2138 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2139 print
'<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.
'"></td></tr>';
2141 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_... ".$langs->trans(
"or").
" card_....')</td>";
2142 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
2149 print $form->buttonsSaveCancel(
"Modify");
2154if ($socid && $action ==
'create' && $permissiontoaddupdatepaymentinformation) {
2157 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2159 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2161 print
'<div class="nofichecenter">';
2163 print
'<div class="underbanner clearboth"></div>';
2167 print
'<table class="border centpercent">';
2169 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2170 print
'<td><input class="minwidth250" type="text" id="label" name="label" value="'.(GETPOSTISSET(
'label') ?
GETPOST(
'label') : $langs->trans(
"Bank").
' '.
$object->
name).
'"></td></tr>';
2172 print
'<tr><td>'.$langs->trans(
"Bank").
'</td>';
2173 print
'<td><input class="minwidth250" type="text" id="bank" name="bank" value="'.GETPOST(
'bank').
'"></td></tr>';
2176 foreach ($companybankaccount->getFieldsToShow(1) as $val) {
2181 $content =
'NoContent';
2182 if ($val ==
'BankCode') {
2183 $name =
'code_banque';
2185 $content = $companybankaccount->code_banque;
2186 } elseif ($val ==
'DeskCode') {
2187 $name =
'code_guichet';
2189 $content = $companybankaccount->code_guichet;
2190 } elseif ($val ==
'BankAccountNumber') {
2193 $content = $companybankaccount->number;
2194 } elseif ($val ==
'BankAccountNumberKey') {
2197 $content = $companybankaccount->cle_rib;
2198 } elseif ($val ==
'IBAN') {
2201 $content = $companybankaccount->iban;
2202 if ($companybankaccount->needIBAN()) {
2205 $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';
2206 } elseif ($val ==
'BIC') {
2209 $content = $companybankaccount->bic;
2210 if ($companybankaccount->needBIC() && (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0)) {
2213 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2216 print
'<tr><td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2219 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2221 print $langs->trans($val);
2224 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.
GETPOST($name).
'"></td>';
2228 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2229 print
'<textarea name="address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2231 print
"</textarea></td></tr>";
2233 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2234 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio').
'"></td></tr>';
2235 print
"</td></tr>\n";
2237 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2238 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2239 print
GETPOST(
'owner_address');
2240 print
"</textarea></td></tr>";
2244 if (isModEnabled(
'prelevement')) {
2247 print
'<table class="border centpercent">';
2250 print
'<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans(
"RUM"), $langs->trans(
"RUMLong").
'<br>'.$langs->trans(
"RUMWillBeGenerated")).
'</td>';
2251 print
'<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST(
'rum',
'alpha').
'"></td></tr>';
2255 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DateRUM").
'</td>';
2256 print
'<td colspan="4">'.$form->selectDate($date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2258 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2259 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2260 print $form->selectarray(
"frstrecur", $tblArraychoice, (GETPOSTISSET(
'frstrecur') ?
GETPOST(
'frstrecur') :
'FRST'), 0);
2263 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('src_....')</td>";
2264 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2275 print $form->buttonsSaveCancel(
"Add");
2279if ($socid && $action ==
'createcard' && $permissiontoaddupdatepaymentinformation) {
2282 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2284 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2286 print
'<div class="nofichecenter">';
2288 print
'<div class="underbanner clearboth"></div>';
2292 print
'<table class="border centpercent">';
2294 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2295 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST(
'label',
'alpha').
'"></td></tr>';
2297 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2298 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio',
'alpha').
'"></td></tr>';
2300 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2301 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST(
'cardnumber',
'alpha').
'"></td></tr>';
2303 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2305 print $formother->select_month(
GETPOSTINT(
'exp_date_month'),
'exp_date_month', 1);
2306 print $formother->selectyear(
GETPOSTINT(
'exp_date_year'),
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2309 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2310 print
'<td><input class="width50" type="text" name="cvn" value="'.GETPOST(
'cvn',
'alpha').
'"></td></tr>';
2312 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('card_....')</td>";
2313 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2323 print $form->buttonsSaveCancel(
"Add");
2326if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
2329if ($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.