36require
'../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/societe/class/companypaymentmode.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
56$langs->loadLangs(array(
"companies",
"commercial",
"banks",
"bills",
'paypal',
'stripe',
'withdrawals'));
60$action =
GETPOST(
"action",
'alpha', 3);
61$cancel =
GETPOST(
'cancel',
'alpha');
62$backtopage =
GETPOST(
'backtopage');
65$source =
GETPOST(
"source",
"alpha");
71 $socid = $user->socid;
85$extrafields->fetch_name_optionals_label(
$object->table_element);
88$hookmanager->initHooks(array(
'thirdpartybancard',
'globalcard'));
91$permissiontoread = $user->hasRight(
'societe',
'lire');
92$permissiontoadd = $user->hasRight(
'societe',
'creer');
94$permissiontoaddupdatepaymentinformation = $user->hasRight(
'societe',
'thirdparty_paymentinformation',
'write');
104$site_account =
'UnknownSiteAccount';
107if (isModEnabled(
'stripe')) {
108 $service =
'StripeTest';
110 $service =
'StripeLive';
115 global $stripearrayofkeysbyenv;
116 $site_account = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
118 $stripe =
new Stripe($db);
119 $stripeacc = $stripe->getStripeAccount($service);
120 $stripecu = $stripe->getStripeCustomerAccount(
$object->id, $servicestatus, $site_account);
135$parameters = array(
'id' => $socid);
136$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
141if (empty($reshook)) {
144 if (!empty($backtopage)) {
145 header(
"Location: ".$backtopage);
153 if (in_array($action, [
'update',
'updatecard',
'edit',
'editcard',
'setasbankdefault',
'confirm_deletecard',
'confirm_deletebank',
'synccardtostripe',
'syncsepatostripe'])) {
154 $idtocheckowner = ($ribid > 0 ? $ribid :
$id);
155 if ($idtocheckowner > 0) {
157 if ($tmppaymentinfo->fetch($idtocheckowner) <= 0 || $tmppaymentinfo->socid !=
$object->id) {
163 if ($action ==
'update' && $permissiontoaddupdatepaymentinformation) {
166 if (!
GETPOST(
'label',
'alpha')) {
167 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
170 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankName")),
null,
'errors');
175 $companybankaccount->fetch($id);
176 if ($companybankaccount->needIBAN() == 1) {
178 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
183 if ($companybankaccount->needBIC() == 1) {
185 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
192 $companybankaccount->oldcopy =
dol_clone($companybankaccount, 2);
194 $companybankaccount->socid =
$object->id;
196 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
197 $companybankaccount->label =
GETPOST(
'label',
'alpha');
198 $companybankaccount->status =
GETPOSTINT(
'clos');
199 $companybankaccount->clos = $companybankaccount->status;
200 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
201 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
202 $companybankaccount->number =
GETPOST(
'number',
'alpha');
203 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
204 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
205 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
207 $companybankaccount->address =
GETPOST(
'address',
'alpha');
209 $companybankaccount->owner_name =
GETPOST(
'proprio',
'alpha');
210 $companybankaccount->proprio = $companybankaccount->owner_name;
211 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
212 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
213 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
214 $companybankaccount->date_rum =
GETPOSTDATE(
'date_rum',
'00:00:00');
215 if (empty($companybankaccount->rum)) {
216 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
219 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
221 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
223 $companybankaccount->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
225 $result = $companybankaccount->update($user);
228 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
232 if ($companybankaccount->default_rib) {
233 $companybankaccount->setAsDefault($id);
236 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
237 if ($companybankaccount->oldcopy->iban != $companybankaccount->iban) {
242 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
243 header(
'Location: '.$url);
249 if ($action ==
'updatecard' && $permissiontoaddupdatepaymentinformation) {
251 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
252 if (!
GETPOST(
'label',
'alpha')) {
253 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
255 if (!
GETPOST(
'proprio',
'alpha')) {
256 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
259 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
260 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
263 $action =
'createcard';
267 $companypaymentmode->fetch($id);
269 $companypaymentmode->oldcopy =
dol_clone($companypaymentmode, 2);
271 $companypaymentmode->fk_soc =
$object->id;
273 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
274 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
275 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
276 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
277 $companypaymentmode->owner_name =
GETPOST(
'proprio',
'alpha');
278 $companypaymentmode->proprio = $companypaymentmode->owner_name;
279 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
280 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
281 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
282 $companypaymentmode->country_code =
$object->country_code;
284 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
286 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
288 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
290 $result = $companypaymentmode->update($user);
292 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
295 if ($companypaymentmode->default_rib) {
296 $companypaymentmode->setAsDefault($id);
299 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
300 if ($companybankaccount->oldcopy->number != $companybankaccount->number) {
305 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
306 header(
'Location: '.$url);
313 if ($action ==
'add' && $permissiontoaddupdatepaymentinformation) {
316 if (!
GETPOST(
'label',
'alpha')) {
317 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
326 $companybankaccount->socid =
$object->id;
328 $companybankaccount->fetch_thirdparty();
330 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
331 $companybankaccount->label =
GETPOST(
'label',
'alpha');
332 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
333 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
334 $companybankaccount->number =
GETPOST(
'number',
'alpha');
335 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
336 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
337 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
339 $companybankaccount->address =
GETPOST(
'address',
'alpha');
341 $companybankaccount->owner_name =
GETPOST(
'proprio',
'alpha');
342 $companybankaccount->proprio = $companybankaccount->owner_name;
343 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
344 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
345 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
346 $companybankaccount->date_rum =
GETPOSTDATE(
'date_rum',
'00:00:00');
347 $companybankaccount->datec =
dol_now();
350 $companybankaccount->status =
GETPOSTINT(
'clos');
352 $companybankaccount->bank = trim($companybankaccount->bank);
353 if (empty($companybankaccount->bank) && !empty($companybankaccount->thirdparty)) {
354 $companybankaccount->bank = $langs->trans(
"Bank").
' '.$companybankaccount->thirdparty->name;
356 $companybankaccount->bic = str_replace(
' ',
'', $companybankaccount->bic);
361 if ($companybankaccount->needIBAN() == 1) {
363 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
368 if ($companybankaccount->needBIC() == 1) {
370 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
377 $result = $companybankaccount->create($user);
380 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
384 if (empty($companybankaccount->rum)) {
385 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
390 $result = $companybankaccount->update($user);
393 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
401 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
402 header(
'Location: '.$url);
411 if ($action ==
'addcard' && $permissiontoaddupdatepaymentinformation) {
414 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
415 if (!
GETPOST(
'label',
'alpha')) {
416 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
418 if (!
GETPOST(
'proprio',
'alpha')) {
419 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
422 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
423 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
426 $action =
'createcard';
434 $companypaymentmode->fk_soc =
$object->id;
435 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
436 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
437 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
438 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
439 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
440 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
441 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
442 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
443 $companypaymentmode->datec =
dol_now();
444 $companypaymentmode->default_rib = 0;
445 $companypaymentmode->type =
'card';
446 $companypaymentmode->country_code =
$object->country_code;
447 $companypaymentmode->status = $servicestatus;
449 if (
GETPOST(
'stripe_card_ref',
'alpha')) {
451 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
453 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
458 $result = $companypaymentmode->create($user);
461 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
462 $action =
'createcard';
469 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
470 header(
'Location: '.$url);
478 if ($action ==
'setasbankdefault' &&
GETPOSTINT(
'ribid') > 0 && $permissiontoaddupdatepaymentinformation) {
480 $res = $companybankaccount->setAsDefault(
GETPOSTINT(
'ribid'));
482 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
483 header(
'Location: '.$url);
490 if ($action ==
'confirm_deletecard' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoaddupdatepaymentinformation) {
493 if ($companypaymentmode->fetch($ribid ? $ribid :
$id)) {
504 $result = $companypaymentmode->delete($user);
506 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
508 header(
'Location: '.$url);
511 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
514 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
517 if ($action ==
'confirm_deletebank' &&
GETPOST(
'confirm',
'alpha') ==
'yes' && $permissiontoaddupdatepaymentinformation) {
520 if ($companybankaccount->fetch($ribid ? $ribid :
$id) > 0) {
531 $result = $companybankaccount->delete($user);
534 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
536 header(
'Location: '.$url);
539 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
542 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
549 if ($action ==
'builddocrib' && $permissiontoread) {
550 $action =
'builddoc';
552 'use_companybankid' =>
GETPOST(
'companybankid'),
555 $_POST[
'lang_id'] =
GETPOST(
'lang_idrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
556 $_POST[
'model'] =
GETPOST(
'modelrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
560 $upload_dir =
$conf->societe->multidir_output[
$object->entity];
561 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
566 if (isModEnabled(
'stripe') && class_exists(
'Stripe')) {
567 if (($action ==
'synccustomertostripe' || $action ==
'synccustomertostripetest') && $permissiontoaddupdatepaymentinformation) {
572 if ($action ==
'synccustomertostripe') {
573 $tmpservicestatus = 1;
574 $tmpservice =
'StripeLive';
576 $tmpservicestatus = 0;
577 $tmpservice =
'StripeTest';
580 $stripe =
new Stripe($db);
581 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
584 $tmpcu = $stripe->customerStripe($object, $tmpstripeacc, $tmpservicestatus, 1);
590 if ($tmpservicestatus == $servicestatus) {
591 $stripecu = $tmpcu->id;
596 if ($action ==
'synccardtostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
599 $companypaymentmode->fetch($id);
601 if ($companypaymentmode->type !=
'card') {
606 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
613 '@phan-var-force \Stripe\Customer $cu';
617 $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
625 if ($action ==
'syncsepatostripe' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
628 $companypaymentmode->fetch($id);
630 if ($companypaymentmode->type !=
'ban') {
632 $langs->load(
"errors");
636 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
640 $langs->load(
"errors");
641 setEventMessages($langs->trans(
"ErrorStripeCustomerNotFoundCreateFirst"),
null,
'errors');
644 '@phan-var-force \Stripe\Customer $cu';
646 $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
651 setEventMessages(
"", array(
"Bank Account on Stripe",
"BAN is now linked to the Stripe customer account !"));
658 if (($action ==
'setkey_account' || $action ==
'setkey_accounttest') && $permissiontoaddupdatepaymentinformation) {
661 $tmpservice =
'StripeTest';
662 $tmpservicestatus = 0;
663 if ($action ==
'setkey_account') {
664 $tmpservice =
'StripeLive';
665 $tmpservicestatus = 1;
669 global $stripearrayofkeysbyenv;
670 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
672 if ($action ==
'setkey_account') {
673 $newcu =
GETPOST(
'key_account',
'alpha');
675 $newcu =
GETPOST(
'key_accounttest',
'alpha');
681 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_account";
682 $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 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_account";
685 $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);
689 $num = $db->num_rows($resql);
691 if (!empty($newcu)) {
694 $societeaccount->fk_soc =
$object->id;
695 $societeaccount->login =
'';
696 $societeaccount->pass_encoding =
'';
697 $societeaccount->site =
'stripe';
698 $societeaccount->status = $servicestatus;
699 $societeaccount->key_account = $newcu;
700 $societeaccount->site_account = $tmpsite_account;
701 $result = $societeaccount->create($user);
706 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"societe_account";
707 $sql .=
" SET key_account = '".$db->escape($newcu).
"', site_account = '".$db->escape($tmpsite_account).
"'";
708 $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;
709 $resql = $db->query($sql);
717 if ($tmpservicestatus == $servicestatus) {
727 if (($action ==
'setkey_account_supplier' || $action ==
'setkey_account_suppliertest') && $permissiontoaddupdatepaymentinformation) {
730 $tmpservice =
'StripeTest';
731 $tmpservicestatus = 0;
732 if ($action ==
'setkey_account_supplier') {
733 $tmpservice =
'StripeLive';
734 $tmpservicestatus = 1;
738 global $stripearrayofkeysbyenv;
739 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
741 if ($action ==
'setkey_account_supplier') {
742 $newsup =
GETPOST(
'key_account_supplier',
'alpha');
744 $newsup =
GETPOST(
'key_account_suppliertest',
'alpha');
749 if (empty($newsup)) {
750 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"oauth_token WHERE fk_soc = ".((int)
$object->id).
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".((int)
$conf->entity);
755 $stripesup = \Stripe\Account::retrieve($newsup);
756 $tokenstring = array();
757 $tokenstring[
'stripe_user_id'] = $stripesup->id;
758 $tokenstring[
'type'] = $stripesup->type;
759 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"oauth_token";
760 $sql .=
" SET tokenstring = '".$db->escape(json_encode($tokenstring)).
"'";
761 $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;
763 $sql .=
" WHERE fk_soc = ".$object->id.
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".
$conf->entity;
770 $resql = $db->query($sql);
771 $num = $db->num_rows($resql);
772 if (empty($num) && !empty($newsup)) {
774 $stripesup = \Stripe\Account::retrieve($newsup);
775 $tokenstring[
'stripe_user_id'] = $stripesup->id;
776 $tokenstring[
'type'] = $stripesup->type;
777 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"oauth_token (service, fk_soc, entity, tokenstring)";
778 $sql .=
" VALUES ('".$db->escape($tmpservice).
"', ".((int)
$object->id).
", ".((int)
$conf->entity).
", '".$db->escape(json_encode($tokenstring)).
"')";
784 $resql = $db->query($sql);
788 if ($tmpservicestatus == $servicestatus) {
789 $stripesupplieracc = $newsup;
797 if ($action ==
'setlocalassourcedefault' && $permissiontoaddupdatepaymentinformation) {
799 $companypaymentmode->setAsDefault($id);
801 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
802 header(
'Location: '.$url);
808 } elseif ($action ==
'setassourcedefault' && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
810 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
811 if (preg_match(
'/pm_|src_/', $source)) {
812 $cu->invoice_settings->default_payment_method = (string) $source;
814 $cu->default_source = (string) $source;
817 $result = $cu->save();
819 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
820 header(
'Location: '.$url);
826 } elseif ($action ==
'deletecard' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
829 if (preg_match(
'/pm_/', $source)) {
830 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
831 if ($payment_method) {
832 $payment_method->detach();
835 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
836 $card = $cu->sources->retrieve(
"$source");
839 if (method_exists($card,
'detach')) {
841 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
842 $sql .=
" SET stripe_card_ref = null";
843 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
845 $resql = $db->query($sql);
852 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
853 header(
'Location: '.$url);
859 } elseif ($action ==
'deletebank' && $source && $permissiontoaddupdatepaymentinformation && $stripeacc !==
null) {
862 if (preg_match(
'/pm_/', $source)) {
863 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
864 if ($payment_method) {
865 $payment_method->detach();
868 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
869 $card = $cu->sources->retrieve((
string) $source);
872 if (method_exists($card,
'detach')) {
874 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
875 $sql .=
" SET stripe_card_ref = null";
876 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
878 $resql = $db->query($sql);
885 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
887 $url .=
'&page_y='.GETPOSTINT(
'page_y');
890 header(
'Location: '.$url);
906$form =
new Form($db);
910$title = $langs->trans(
"ThirdParty");
912 $title =
$object->name.
" - ".$langs->trans(
'PaymentInformation');
925 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'), [],
'warning');
931 $companybankaccount->fetch(0,
'',
$object->id);
933 $companypaymentmode->fetch(0,
'',
$object->id,
'card');
935 $companybankaccount->fetch($id);
936 $companypaymentmode->fetch($id);
938if (empty($companybankaccount->socid)) {
939 $companybankaccount->socid =
$object->id;
942if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
943 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post">';
944 print
'<input type="hidden" name="token" value="'.newToken().
'">';
945 $actionforadd =
'update';
946 if ($action ==
'editcard') {
947 $actionforadd =
'updatecard';
949 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
950 print
'<input type="hidden" name="id" value="'.GETPOSTINT(
"id").
'">';
952if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
953 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post">';
954 print
'<input type="hidden" name="token" value="'.newToken().
'">';
955 $actionforadd =
'add';
956 if ($action ==
'createcard') {
957 $actionforadd =
'addcard';
959 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
964if ($socid && $action !=
'edit' && $action !=
'create' && $action !=
'editcard' && $action !=
'createcard') {
968 if ($action ==
'deletebank') {
969 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);
972 if ($action ==
'deletecard') {
973 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);
976 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
978 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
980 print
'<div class="fichecenter">';
982 print
'<div class="underbanner clearboth"></div>';
983 print
'<table class="border tableforfield centpercent">';
986 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td colspan="2">';
991 print
'<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="2">'.
$object->prefix_comm.
'</td></tr>';
995 print
'<tr><td class="titlefield">';
996 print $langs->trans(
'CustomerCode').
'</td><td colspan="2">';
998 $tmpcheck =
$object->check_codeclient();
999 if ($tmpcheck != 0 && $tmpcheck != -5) {
1000 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
1003 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
1004 $resql = $db->query($sql);
1009 $obj = $db->fetch_object($resql);
1010 $nbFactsClient = $obj->nb;
1011 $thirdTypeArray = array();
1012 $elementTypeArray = array();
1013 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
1014 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
1015 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
1017 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
1018 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1020 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1021 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1023 if (isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1024 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1027 if (isModEnabled(
'stripe')) {
1029 global $stripearrayofkeysbyenv;
1032 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1033 $tmpstripeacc = $stripe->getStripeAccount((
string) $tmpservice);
1034 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1037 print
'<tr><td class="titlefield">';
1038 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1040 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1041 if ($tmpstripecu && $action !=
'editkey_accounttest') {
1043 if (!empty($stripeacc)) {
1044 $connect = $stripeacc.
'/';
1046 $url =
'https://dashboard.stripe.com/'.$connect.
'test/customers/'.$tmpstripecu;
1047 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1049 print
'</td><td class="right">';
1050 if (empty($tmpstripecu)) {
1051 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1052 print
'<input type="hidden" name="action" value="synccustomertostripetest">';
1053 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1054 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1055 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1056 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomertest" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1062 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1063 $tmpstripeacc = $stripe->getStripeAccount((
string) $tmpservice);
1064 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1067 print
'<tr><td class="titlefield">';
1068 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1070 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1071 if ($tmpstripecu && $action !=
'editkey_account') {
1073 if (!empty($stripeacc)) {
1074 $connect = $stripeacc.
'/';
1076 $url =
'https://dashboard.stripe.com/'.$connect.
'customers/'.$tmpstripecu;
1077 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1079 print
'</td><td class="right">';
1080 if (empty($tmpstripecu)) {
1081 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1082 print
'<input type="hidden" name="action" value="synccustomertostripe">';
1083 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1084 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1085 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1086 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomer" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1094 print
'<tr><td class="titlefield">';
1095 print $langs->trans(
'SupplierCode').
'</td><td colspan="2">';
1097 $tmpcheck =
$object->check_codefournisseur();
1098 if ($tmpcheck != 0 && $tmpcheck != -5) {
1099 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
1102 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
1103 $resql = $db->query($sql);
1107 $obj = $db->fetch_object($resql);
1108 $nbFactsClient = $obj->nb;
1109 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
1110 if (isModEnabled(
'propal') && $user->hasRight(
'propal',
'lire')) {
1111 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
1113 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
1114 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1116 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1117 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1119 if (isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1120 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1125 if (isModEnabled(
'stripe') && !empty(
$conf->stripeconnect->enabled) &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 2 && $service !==
null) {
1126 $stripesupplieracc = $stripe->getStripeAccount($service,
$object->id);
1129 print
'<tr><td class="titlefield">';
1130 print $form->editfieldkey(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, (
int) $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1132 print $form->editfieldval(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1133 if (isModEnabled(
'stripe') && $stripesupplieracc && $action !=
'editkey_account_supplier') {
1136 $url =
'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc;
1137 if ($servicestatus) {
1138 $url =
'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc;
1140 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key '.$site_account,
'globe').
'</a>';
1142 print
'</td><td class="right">';
1143 if (empty($stripesupplieracc)) {
1144 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1145 print
'<input type="hidden" name="action" value="syncsuppliertostripe">';
1146 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1147 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1148 print
'<input type="hidden" name="companybankid" value="'.$ribid.
'">';
1162 $showcardpaymentmode = 0;
1163 if (isModEnabled(
'stripe')) {
1164 $showcardpaymentmode++;
1168 $listofsources = array();
1170 $customerstripe =
null;
1171 if (isset($stripe) && is_object($stripe) && $stripeacc !==
null) {
1173 $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus);
1174 if (!empty($customerstripe->id)) {
1177 $listofsources = $customerstripe->sources->data;
1179 $service =
'StripeTest';
1182 $service =
'StripeLive';
1187 global $stripearrayofkeysbyenv;
1188 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
1191 if (empty($stripeacc)) {
1192 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"));
1193 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"));
1195 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"), array(
"stripe_account" => $stripeacc));
1196 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"), array(
"stripe_account" => $stripeacc));
1199 if ($paymentmethodobjsA->data !=
null && $paymentmethodobjsB->data !=
null) {
1200 $listofsources = array_merge((array) $paymentmethodobjsA->data, (array) $paymentmethodobjsB->data);
1201 } elseif ($paymentmethodobjsB->data !=
null) {
1202 $listofsources = $paymentmethodobjsB->data;
1204 $listofsources = $paymentmethodobjsA->data;
1213 dol_syslog(
"Error when searching/loading Stripe customer for thirdparty id =".
$object->id);
1219 if ($showcardpaymentmode &&
$object->client) {
1220 $morehtmlright =
'';
1222 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=createcard');
1224 print
load_fiche_titre($langs->trans(
'CreditCard'), $morehtmlright,
'fa-credit-card');
1227 print
'<!-- List of card payments -->'.
"\n";
1228 print
'<div class="div-table-responsive-no-min">';
1229 print
'<table class="liste centpercent noborder">'.
"\n";
1230 print
'<tr class="liste_titre">';
1231 print
'<td>'.$langs->trans(
'Label').
'</td>';
1232 print
'<td>'.$form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")).
'</td>';
1233 print
'<td>'.$langs->trans(
'Type').
'</td>';
1234 print
'<td>'.$langs->trans(
'Informations').
'</td>';
1236 print
'<td class="center">'.$langs->trans(
'Default').
'</td>';
1237 print
'<td>'.$langs->trans(
'Note').
'</td>';
1238 print
'<td>'.$langs->trans(
'DateModification').
'</td>';
1240 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'stripetitle');
1241 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
1242 print $hookmanager->resPrint;
1249 $arrayofremotecard = array();
1256 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_rib";
1257 $sql .=
" WHERE type in ('card')";
1258 $sql .=
" AND fk_soc = ".((int)
$object->id);
1259 $sql .=
" AND status = ".((int) $servicestatus);
1261 $resql = $db->query($sql);
1263 $num_rows = $db->num_rows($resql);
1266 while ($i < $num_rows) {
1269 $obj = $db->fetch_object($resql);
1271 $companypaymentmodetemp->fetch($obj->rowid);
1273 $arrayofremotecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref;
1275 print
'<tr class="oddeven" data-rowid="'.((int) $companypaymentmodetemp->id).
'">';
1277 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->label).
'">';
1281 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->stripe_card_ref.(empty($companypaymentmodetemp->stripe_account) ?
'' :
' - '.$companypaymentmodetemp->stripe_account)).
'">';
1282 if (!empty($companypaymentmodetemp->stripe_card_ref) && !empty($companypaymentmodetemp->ext_payment_site)) {
1283 if (isModEnabled(
'stripe') && in_array($companypaymentmodetemp->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1285 if (!empty($stripeacc)) {
1286 $connect = $stripeacc.
'/';
1288 if ($companypaymentmodetemp->ext_payment_site ==
'StripeLive') {
1289 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$companypaymentmodetemp->stripe_card_ref;
1291 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
1293 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe').
' - '.$companypaymentmodetemp->stripe_account,
'globe').
"</a> ";
1304 print
'<td class="minwidth100">';
1305 if ($companypaymentmodetemp->owner_name) {
1306 print
'<span class="opacitymedium">'.$companypaymentmodetemp->owner_name.
'</span><br>';
1308 if ($companypaymentmodetemp->last_four) {
1309 print
'....'.$companypaymentmodetemp->last_four;
1311 if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) {
1312 print
' - '.sprintf(
"%02d", $companypaymentmodetemp->exp_date_month).
'/'.$companypaymentmodetemp->exp_date_year;
1316 print
'<td class="tdoverflowmax100">';
1317 if ($companypaymentmodetemp->country_code) {
1319 print $img ? $img.
' ' :
'';
1320 print
getCountry($companypaymentmodetemp->country_code,
'1');
1322 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1326 print
'<td class="center">';
1327 if (empty($companypaymentmodetemp->default_rib)) {
1328 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=setlocalassourcedefault&token='.
newToken().
'">';
1329 print
img_picto($langs->trans(
"Default"),
'off');
1332 print
img_picto($langs->trans(
"Default"),
'on');
1335 if (empty($companypaymentmodetemp->stripe_card_ref)) {
1336 $s = $langs->trans(
"Local");
1338 $s = $langs->trans(
"LocalAndRemote");
1340 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1344 print
dol_print_date($companypaymentmodetemp->date_modification,
'dayhour',
'tzuserrel');
1347 $parameters = array(
'arrayfields' => array(),
'obj' => $obj,
'linetype' =>
'stripecard');
1348 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1349 print $hookmanager->resPrint;
1351 print
'<td class="right minwidth50 nowraponall">';
1352 if ($permissiontoaddupdatepaymentinformation) {
1353 if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) {
1354 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=synccardtostripe&socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'" class="paddingrightonly marginrightonly">'.$langs->trans(
"CreateCardOnStripe").
'</a>';
1357 print
'<a class="editfielda marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=editcard&token='.
newToken().
'">';
1358 print
img_picto($langs->trans(
"Modify"),
'edit');
1360 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=deletecard&token='.
newToken().
'">';
1361 print
img_picto($langs->trans(
"Delete"),
'delete');
1376 if (is_array($listofsources) && count($listofsources)) {
1377 foreach ($listofsources as $src) {
1378 if (!empty($arrayofremotecard[$src->id])) {
1385 if ($src->object ==
'card') {
1387 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1389 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1391 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1393 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1397 print
'<tr class="oddeven">';
1401 print
'<td class="tdoverflowmax150">';
1403 if (!empty($stripeacc)) {
1404 $connect = $stripeacc.
'/';
1407 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1408 if ($servicestatus) {
1410 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1412 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1420 print
'<td valign="middle">';
1421 if ($src->object ==
'card') {
1422 print
'....'.$src->last4.
' - '.$src->exp_month.
'/'.$src->exp_year;
1424 if ($src->country) {
1426 print $img ? $img.
' ' :
'';
1429 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1431 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1432 print
'<span class="opacitymedium">'.$src->owner->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1435 if ($src->card->country) {
1437 print $img ? $img.
' ' :
'';
1440 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1442 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1443 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1445 if ($src->sepa_debit->country) {
1447 print $img ? $img.
' ' :
'';
1448 print
getCountry($src->sepa_debit->country,
'1');
1450 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1452 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1453 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1456 if ($src->card->country) {
1458 print $img ? $img.
' ' :
'';
1461 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1463 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1464 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1466 if ($src->sepa_debit->country) {
1468 print $img ? $img.
' ' :
'';
1469 print
getCountry($src->sepa_debit->country,
'1');
1471 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1478 print
'<td class="center" width="50">';
1479 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1480 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1481 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1482 print
img_picto($langs->trans(
"Default"),
'off');
1485 print
img_picto($langs->trans(
"Default"),
'on');
1489 print $langs->trans(
"Remote");
1498 $parameters = array(
'arrayfields' => array(),
'stripesource' => $src,
'linetype' =>
'stripecardremoteonly');
1499 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1500 print $hookmanager->resPrint;
1503 print
'<td class="right nowraponall">';
1504 if ($permissiontoaddupdatepaymentinformation) {
1505 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletecard&token='.
newToken().
'">';
1506 print
img_picto($langs->trans(
"Delete"),
'delete');
1515 if ($nbremote == 0 && $nblocal == 0) {
1517 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1525 if (isModEnabled(
'stripe') && !empty(
$conf->stripeconnect->enabled) && !empty($stripesupplieracc)) {
1526 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');
1527 $balance = \Stripe\Balance::retrieve(array(
"stripe_account" => $stripesupplieracc));
1528 print
'<!-- List of Stripe connected accounts -->'.
"\n";
1529 print
'<table class="liste centpercent noborder">'.
"\n";
1530 print
'<tr class="liste_titre">';
1531 print
'<td>'.$langs->trans(
'Currency').
'</td>';
1532 print
'<td>'.$langs->trans(
'Available').
'</td>';
1533 print
'<td>'.$langs->trans(
'Pending').
'</td>';
1534 print
'<td>'.$langs->trans(
'Total').
'</td>';
1537 $currencybalance = array();
1538 if (is_array($balance->available) && count($balance->available)) {
1539 foreach ($balance->available as $cpt) {
1540 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1541 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1542 $currencybalance[$cpt->currency][
'available'] = $cpt->amount / 100;
1544 $currencybalance[$cpt->currency][
'available'] = $cpt->amount;
1546 $currencybalance[$cpt->currency][
'currency'] = $cpt->currency;
1550 if (is_array($balance->pending) && count($balance->pending)) {
1551 foreach ($balance->pending as $cpt) {
1552 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1553 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1554 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount / 100;
1556 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount;
1561 if (is_array($currencybalance)) {
1562 foreach ($currencybalance as $cpt_arr) {
1563 print
'<tr><td>'.$langs->trans(
"Currency".strtoupper($cpt_arr[
'currency'])).
'</td><td>'.
price($cpt_arr[
'available'], 0,
'', 1, - 1, - 1, strtoupper($cpt_arr[
'currency'])).
'</td><td>'.
price(isset($cpt_arr[
'pending']) ? $cpt_arr[
'pending'] : 0, 0,
'', 1, - 1, - 1, strtoupper($cpt_arr[
'currency'])).
'</td><td>'.
price($cpt_arr[
'available'] + (isset($cpt_arr[
'pending']) ? $cpt_arr[
'pending'] : 0), 0,
'', 1, - 1, - 1, strtoupper($cpt_arr[
'currency'])).
'</td></tr>';
1573 if ($permissiontoaddupdatepaymentinformation) {
1574 $morehtmlright =
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"] .
'?socid=' .
$object->id .
'&action=create');
1577 print
load_fiche_titre($langs->trans(
"BankAccounts"), $morehtmlright,
'bank');
1581 $arrayofremoteban = array();
1583 $rib_list =
$object->get_all_rib();
1585 if (is_array($rib_list)) {
1586 print
'<!-- List of bank accounts -->'.
"\n";
1587 print
'<div class="div-table-responsive-no-min">';
1588 print
'<table class="liste centpercent noborder">';
1590 print
'<tr class="liste_titre">';
1592 print_liste_field_titre($form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")));
1597 if (isModEnabled(
'prelevement')) {
1607 $parameters = array(
'arrayfields' => array(),
'linetype' =>
'stripebantitle');
1608 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1609 print $hookmanager->resPrint;
1614 foreach ($rib_list as $rib) {
1615 $arrayofremoteban[$rib->stripe_card_ref] = $rib->stripe_card_ref;
1619 print
'<tr class="oddeven">';
1621 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($rib->label).
'">'.
dolPrintHTML($rib->label);
1622 print
'<br><span class="opacitymedium">'.dolPrintHTML($rib->bank).
'</span>';
1626 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->stripe_card_ref.(empty($rib->stripe_account) ?
'' :
' - '.$rib->stripe_account)).
'">';
1627 if (!empty($rib->stripe_card_ref) && !empty($rib->ext_payment_site)) {
1628 if (isModEnabled(
'stripe') && in_array($rib->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1630 if (!empty($stripeacc)) {
1631 $connect = $stripeacc.
'/';
1633 if ($rib->ext_payment_site ==
'StripeLive') {
1634 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$rib->stripe_card_ref;
1636 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$rib->stripe_card_ref;
1638 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1650 foreach ($rib->getFieldsToShow() as $val) {
1651 if ($val ==
'BankCode') {
1652 $string .= $rib->code_banque.
' ';
1653 } elseif ($val ==
'BankAccountNumber') {
1654 $string .= $rib->number.
' ';
1655 } elseif ($val ==
'DeskCode') {
1656 $string .= $rib->code_guichet.
' ';
1657 } elseif ($val ==
'BankAccountNumberKey') {
1658 $string .= $rib->cle_rib.
' ';
1666 if (!empty($rib->label) && $rib->number) {
1668 $string .=
img_picto($langs->trans(
"ValueIsNotValid"),
'warning',
'class="pictofixedwidth"').$string;
1670 $string .=
img_picto($langs->trans(
"ValueIsValid"),
'info',
'class="pictofixedwidth"').$string;
1674 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($string).
'">';
1679 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->iban).
'">';
1680 if (!empty($rib->iban)) {
1682 print
img_picto($langs->trans(
"IbanNotValid"),
'warning').
' ';
1689 if (!empty($rib->bic)) {
1691 print
img_picto($langs->trans(
"SwiftNotValid"),
'warning').
' ';
1697 if (isModEnabled(
'prelevement')) {
1699 print
'<td class="tdoverflowmax100 small" title="'.dolPrintHTMLForAttribute($rib->rum).
'">'.
dolPrintHTML($rib->rum);
1700 print
'<br><span class="opacitymedium">'.dolPrintHTML($rib->frstrecur).
'</span>';
1704 print
'<td>'.dol_print_date($rib->date_rum,
'day').
'</td>';
1708 print
'<td class="center" width="70">';
1709 if (!$rib->default_rib) {
1710 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?socid='.((int)
$object->id).
'&ribid='.((int) $rib->id).
'&action=setasbankdefault&token='.
newToken().
'">';
1711 print
img_picto($langs->trans(
"Disabled"),
'off');
1714 print
img_picto($langs->trans(
"Enabled"),
'on');
1719 print
'<td class="center">';
1721 $buttonlabel = $langs->trans(
"BuildDoc");
1722 $forname =
'builddocrib'.$rib->id;
1724 include_once DOL_DOCUMENT_ROOT.
'/core/modules/bank/modules_bank.php';
1728 if (is_array($modellist) && count($modellist)) {
1729 $out .=
'<form action="'.$_SERVER[
"PHP_SELF"].(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#builddoc').
'" name="'.$forname.
'" id="'.$forname.
'_form" method="post">';
1730 $out .=
'<input type="hidden" name="action" value="builddocrib">';
1731 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1732 $out .=
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1733 $out .=
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1735 $modelselected =
'';
1736 if (count($modellist) == 1) {
1737 $arraykeys = array_keys($modellist);
1738 $modelselected = $arraykeys[0];
1744 $morecss =
'maxwidth125';
1745 if (
$conf->browser->layout ==
'phone') {
1746 $morecss =
'maxwidth100';
1749 $out .= $form->selectarray(
'modelrib'.$rib->id, $modellist, $modelselected, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 '.$morecss);
1754 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
1756 $defaultlang = $langs->getDefaultLang();
1757 $out .= $formadmin->select_language($defaultlang,
'lang_idrib'.$rib->id, 0, array(), 0, 0, 0, $morecss);
1760 $out .=
'<input class="button buttongen reposition nomargintop nomarginbottom small '.$morecss.
'" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
1761 $out .=
' type="submit" value="'.$buttonlabel.
'"';
1769 $parameters = array(
'arrayfields' => array(),
'stripe_card_ref' => $rib->stripe_card_ref,
'stripe_account' => $rib->stripe_account,
'linetype' =>
'stripeban');
1770 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1771 print $hookmanager->resPrint;
1775 print
'<td class="minwidth200 width200">';
1776 $useonlinesignature = 1;
1777 if ($useonlinesignature) {
1778 $rib->entity =
$object->entity;
1779 require_once DOL_DOCUMENT_ROOT .
'/core/lib/signature.lib.php';
1780 print showOnlineSignatureUrl($companybankaccount->element, (
string) $rib->id, $rib,
'short');
1786 print
'<td class="right nowraponall">';
1787 if ($permissiontoaddupdatepaymentinformation) {
1788 if (isModEnabled(
'stripe')) {
1789 if (empty($rib->stripe_card_ref)) {
1792 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=syncsepatostripe&token='.
newToken().
'">';
1793 print
img_picto($langs->trans(
"CreateBANOnStripe"),
'stripe');
1796 print
'<span class="opacitymedium marginrightonly marginleftonly">';
1797 print
img_picto($langs->trans(
"ThirdPartyMustBeACustomerToCreateBANOnStripe"),
'stripe');
1803 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=edit">';
1804 print
img_picto($langs->trans(
"Modify"),
'edit');
1807 print
'<a class="marginrightonly marginleftonly reposition" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=deletebank&token='.
newToken().
'">';
1808 print
img_picto($langs->trans(
"Delete"),
'delete');
1818 foreach ($listofsources as $src) {
1819 if (!empty($arrayofremoteban[$src->id])) {
1824 if ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1825 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1826 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1827 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1834 print
'<tr class="oddeven">';
1839 print
'<td class="tdoverflowmax150">';
1841 if (!empty($stripeacc)) {
1842 $connect = $stripeacc.
'/';
1845 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1846 if ($servicestatus) {
1848 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1850 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1870 if (isModEnabled(
'prelevement')) {
1881 print
'<td class="center" width="50">';
1882 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1883 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1884 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1885 print
img_picto($langs->trans(
"Default"),
'off');
1888 print
img_picto($langs->trans(
"Default"),
'on');
1904 $parameters = array(
'arrayfields' => array(),
'stripe_card_ref' => $rib->stripe_card_ref,
'stripe_account' => $rib->stripe_account,
'linetype' =>
'stripebanremoteonly');
1905 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1906 print $hookmanager->resPrint;
1909 print
'<td class="right nowraponall">';
1910 if ($permissiontoaddupdatepaymentinformation) {
1911 print
'<a class="marginleftonly marginrightonly reposition" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletebank&token='.
newToken().
'">';
1912 print
img_picto($langs->trans(
"Delete"),
'delete');
1920 if ($nbremote == 0 && $nblocal == 0) {
1922 if (isModEnabled(
'prelevement')) {
1928 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoBANRecord").
'</span></td></tr>';
1938 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'');
1939 $reshook = $hookmanager->executeHooks(
'printNewTable', $parameters, $object);
1940 print $hookmanager->resPrint;
1945 print
'<div class="fichecenter"><div class="fichehalfleft">';
1946 print
'<a name="builddoc"></a>';
1952 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".
$object->id;
1954 print $formfile->showdocuments(
'company', (
string)
$object->id, $filedir, $urlsource, $permissiontoread, (
int) $permissiontoaddupdatepaymentinformation,
$object->model_pdf, 0, 0, 0, 28, 0,
'entity='.$object->entity,
'',
'',
$object->default_lang);
1961 $result = $companypaymentmodetemp->fetch(0,
'',
$object->id,
'ban');
1963 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1966 $result = $ecmfile->fetch(0,
'',
'',
'',
'', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
1968 $companybankaccounttemp->last_main_doc = $ecmfile->filepath.
'/'.$ecmfile->filename;
1969 print
'<br><!-- Link to download main doc -->'.
"\n";
1974 print
'</div><div class="fichehalfright">';
1977 print
'</div></div>';
2003if ($socid && $action ==
'edit' && $permissiontoaddupdatepaymentinformation) {
2006 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2008 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2010 print
'<div class="underbanner clearboth"></div>';
2014 print
'<div class="div-table-responsive-no-min">';
2015 print
'<table class="border centpercent">';
2017 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Label").
'</td>';
2018 print
'<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.
'"></td></tr>';
2020 $required = (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0) ?
"fieldrequired" :
"";
2021 print
'<tr><td class="'.$required.
'">'.$langs->trans(
"BankName").
'</td>';
2022 print
'<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.
'"></td></tr>';
2025 $bankaccount = $companybankaccount;
2027 foreach ($bankaccount->getFieldsToShow(1) as $val) {
2032 $content =
'NoContent';
2033 if ($val ==
'BankCode') {
2034 $name =
'code_banque';
2036 $content = $bankaccount->code_banque;
2037 } elseif ($val ==
'DeskCode') {
2038 $name =
'code_guichet';
2040 $content = $bankaccount->code_guichet;
2041 } elseif ($val ==
'BankAccountNumber') {
2044 $content = $bankaccount->number;
2045 } elseif ($val ==
'BankAccountNumberKey') {
2048 $content = $bankaccount->cle_rib;
2049 } elseif ($val ==
'IBAN') {
2052 $content = $bankaccount->iban;
2053 if ($bankaccount->needIBAN()) {
2056 $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';
2057 } elseif ($val ==
'BIC') {
2060 $content = $bankaccount->bic;
2061 if ($bankaccount->needBIC() && (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0)) {
2064 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2068 print
'<td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2071 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2073 print $langs->trans($val);
2076 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.$content.
'"></td>';
2080 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2081 print
'<textarea name="address" rows="4" cols="40" maxlength="255">';
2082 print $companybankaccount->address;
2083 print
"</textarea></td></tr>";
2085 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2086 print
'<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->owner_name.
'"></td></tr>';
2087 print
"</td></tr>\n";
2089 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2090 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" cols="40" maxlength="255">';
2091 print $companybankaccount->owner_address;
2092 print
"</textarea></td></tr>";
2097 if (isModEnabled(
'prelevement')) {
2100 print
'<div class="div-table-responsive-no-min">';
2101 print
'<table class="border centpercent">';
2103 if (empty($companybankaccount->rum)) {
2104 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, (
string) $companybankaccount->id);
2108 print
'<tr><td class="titlefield">'.$langs->trans(
"RUM").
'</td>';
2109 print
'<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).
'"></td></tr>';
2113 print
'<tr><td class="titlefield">'.$langs->trans(
"DateRUM").
'</td>';
2114 print
'<td>'.$form->selectDate($date_rum ? $date_rum : $companybankaccount->date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2116 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2117 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2118 print $form->selectarray(
"frstrecur", $tblArraychoice,
dol_escape_htmltag(
GETPOST(
'frstrecur',
'alpha') ?
GETPOST(
'frstrecur',
'alpha') : $companybankaccount->frstrecur), 0);
2121 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_...' or 'src_...')</td>";
2122 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
2131 print $form->buttonsSaveCancel(
"Modify");
2135if ($socid && $action ==
'editcard' && $permissiontoaddupdatepaymentinformation) {
2138 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2140 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2142 print
'<div class="nofichecenter">';
2144 print
'<div class="underbanner clearboth"></div>';
2148 print
'<div class="div-table-responsive-no-min">';
2149 print
'<table class="border centpercent">';
2151 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2152 print
'<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.
'"></td></tr>';
2154 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2155 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->owner_name.
'"></td></tr>';
2157 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2158 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.
'"></td></tr>';
2160 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2162 print $formother->select_month((
string) $companypaymentmode->exp_date_month,
'exp_date_month', 1);
2163 print $formother->selectyear((
string) $companypaymentmode->exp_date_year,
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2166 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2167 print
'<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.
'"></td></tr>';
2169 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_... ".$langs->trans(
"or").
" card_....')</td>";
2170 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
2178 print $form->buttonsSaveCancel(
"Modify");
2183if ($socid && $action ==
'create' && $permissiontoaddupdatepaymentinformation) {
2186 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2188 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2190 print
'<div class="nofichecenter">';
2192 print
'<div class="underbanner clearboth"></div>';
2196 print
'<div class="div-table-responsive-no-min">';
2197 print
'<table class="border centpercent">';
2199 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2200 print
'<td><input class="minwidth250" type="text" id="label" name="label" value="'.(GETPOSTISSET(
'label') ?
GETPOST(
'label') : $langs->trans(
"Bank").
' '.
$object->
name).
'"></td></tr>';
2202 print
'<tr><td>'.$langs->trans(
"Bank").
'</td>';
2203 print
'<td><input class="minwidth250" type="text" id="bank" name="bank" value="'.GETPOST(
'bank').
'"></td></tr>';
2206 foreach ($companybankaccount->getFieldsToShow(1) as $val) {
2211 $content =
'NoContent';
2212 if ($val ==
'BankCode') {
2213 $name =
'code_banque';
2215 $content = $companybankaccount->code_banque;
2216 } elseif ($val ==
'DeskCode') {
2217 $name =
'code_guichet';
2219 $content = $companybankaccount->code_guichet;
2220 } elseif ($val ==
'BankAccountNumber') {
2223 $content = $companybankaccount->number;
2224 } elseif ($val ==
'BankAccountNumberKey') {
2227 $content = $companybankaccount->cle_rib;
2228 } elseif ($val ==
'IBAN') {
2231 $content = $companybankaccount->iban;
2232 if ($companybankaccount->needIBAN()) {
2235 $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';
2236 } elseif ($val ==
'BIC') {
2239 $content = $companybankaccount->bic;
2240 if ($companybankaccount->needBIC() && (
getDolGlobalInt(
'WITHDRAWAL_WITHOUT_BIC') == 0)) {
2243 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2246 print
'<tr><td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2249 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2251 print $langs->trans($val);
2254 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.
GETPOST($name).
'"></td>';
2258 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2259 print
'<textarea name="address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2261 print
"</textarea></td></tr>";
2263 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2264 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio').
'"></td></tr>';
2265 print
"</td></tr>\n";
2267 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2268 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2269 print
GETPOST(
'owner_address');
2270 print
"</textarea></td></tr>";
2275 if (isModEnabled(
'prelevement')) {
2278 print
'<div class="div-table-responsive-no-min">';
2279 print
'<table class="border centpercent">';
2282 print
'<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans(
"RUM"), $langs->trans(
"RUMLong").
'<br>'.$langs->trans(
"RUMWillBeGenerated")).
'</td>';
2283 print
'<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST(
'rum',
'alpha').
'"></td></tr>';
2287 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DateRUM").
'</td>';
2288 print
'<td colspan="4">'.$form->selectDate($date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2290 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2291 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2292 print $form->selectarray(
"frstrecur", $tblArraychoice, (GETPOSTISSET(
'frstrecur') ?
GETPOST(
'frstrecur') :
'FRST'), 0);
2295 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('src_....')</td>";
2296 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2308 print $form->buttonsSaveCancel(
"Add");
2312if ($socid && $action ==
'createcard' && $permissiontoaddupdatepaymentinformation) {
2315 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2317 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2319 print
'<div class="nofichecenter">';
2321 print
'<div class="underbanner clearboth"></div>';
2325 print
'<div class="div-table-responsive-no-min">';
2326 print
'<table class="border centpercent">';
2328 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2329 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST(
'label',
'alpha').
'"></td></tr>';
2331 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2332 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio',
'alpha').
'"></td></tr>';
2334 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2335 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST(
'cardnumber',
'alpha').
'"></td></tr>';
2337 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2339 print $formother->select_month((
string)
GETPOSTINT(
'exp_date_month'),
'exp_date_month', 1);
2340 print $formother->selectyear((
string)
GETPOSTINT(
'exp_date_year'),
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2343 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2344 print
'<td><input class="width50" type="text" name="cvn" value="'.GETPOST(
'cvn',
'alpha').
'"></td></tr>';
2346 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('card_....')</td>";
2347 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2358 print $form->buttonsSaveCancel(
"Add");
2361if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
2364if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
checkIbanForAccount($account=null, $ibantocheck=null)
Check IBAN number information for a bank account.
checkBanForAccount($account)
Check account number information for a bank account.
checkSwiftForAccount($account=null, $swift=null)
Check SWIFT information for a bank account.
Class to manage withdrawal receipts.
Class to manage bank accounts description of third parties.
Class for CompanyPaymentMode.
Class to manage ECM files.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class for SocieteAccount.
Class to manage third parties objects (customers, suppliers, prospects...)
Stripe class @TODO No reason to extend CommonObject.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
showDirectDownloadLink($object)
Return string with full Url.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_credit_card($brand, $morecss=null)
Return image of a credit card according to its brand name.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
$conf db name
Only used if Module[ID]Name translation string is not found.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.