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')));
95if (isModEnabled(
'stripe')) {
96 $service =
'StripeTest';
99 $service =
'StripeLive';
104 global $stripearrayofkeysbyenv;
105 $site_account = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
107 $stripe =
new Stripe($db);
108 $stripeacc = $stripe->getStripeAccount($service);
109 $stripecu = $stripe->getStripeCustomerAccount(
$object->id, $servicestatus, $site_account);
124$parameters = array(
'id' => $socid);
125$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
130if (empty($reshook)) {
133 if (!empty($backtopage)) {
134 header(
"Location: ".$backtopage);
139 if ($action ==
'update') {
142 if (!
GETPOST(
'label',
'alpha')) {
143 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
145 if (!
GETPOST(
'bank',
'alpha')) {
146 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankName")),
null,
'errors');
151 $companybankaccount->fetch($id);
152 if ($companybankaccount->needIBAN() == 1) {
154 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
159 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
166 $companybankaccount->oldcopy =
dol_clone($companybankaccount, 2);
168 $companybankaccount->socid =
$object->id;
170 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
171 $companybankaccount->label =
GETPOST(
'label',
'alpha');
172 $companybankaccount->status =
GETPOSTINT(
'clos');
173 $companybankaccount->clos = $companybankaccount->status;
174 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
175 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
176 $companybankaccount->number =
GETPOST(
'number',
'alpha');
177 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
178 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
179 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
181 $companybankaccount->address =
GETPOST(
'address',
'alpha');
182 $companybankaccount->domiciliation = $companybankaccount->address;
184 $companybankaccount->owner_name =
GETPOST(
'proprio',
'alpha');
185 $companybankaccount->proprio = $companybankaccount->owner_name;
186 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
187 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
188 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
190 if (empty($companybankaccount->rum)) {
191 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, $companybankaccount->id);
194 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
196 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
198 $companybankaccount->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
200 $result = $companybankaccount->update($user);
203 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
207 if ($companybankaccount->default_rib) {
208 $companybankaccount->setAsDefault($id);
211 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
212 if ($companybankaccount->oldcopy->iban != $companybankaccount->iban) {
217 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
218 header(
'Location: '.$url);
224 if ($action ==
'updatecard') {
226 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
227 if (!
GETPOST(
'label',
'alpha')) {
228 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
230 if (!
GETPOST(
'proprio',
'alpha')) {
231 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
234 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
235 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
238 $action =
'createcard';
242 $companypaymentmode->fetch($id);
244 $companybankaccount->oldcopy =
dol_clone($companybankaccount, 2);
246 $companypaymentmode->fk_soc =
$object->id;
248 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
249 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
250 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
251 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
252 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
253 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
254 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
255 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
256 $companypaymentmode->country_code =
$object->country_code;
258 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
260 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
262 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
264 $result = $companypaymentmode->update($user);
266 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
269 if ($companypaymentmode->default_rib) {
270 $companypaymentmode->setAsDefault($id);
273 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
274 if ($companybankaccount->oldcopy->number != $companybankaccount->number) {
279 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
280 header(
'Location: '.$url);
287 if ($action ==
'add') {
290 if (!
GETPOST(
'label',
'alpha')) {
291 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
300 $companybankaccount->socid =
$object->id;
302 $companybankaccount->fetch_thirdparty();
304 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
305 $companybankaccount->label =
GETPOST(
'label',
'alpha');
306 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
307 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
308 $companybankaccount->number =
GETPOST(
'number',
'alpha');
309 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
310 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
311 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
313 $companybankaccount->domiciliation =
GETPOST(
'address',
'alpha');
314 $companybankaccount->address =
GETPOST(
'address',
'alpha');
316 $companybankaccount->proprio =
GETPOST(
'proprio',
'alpha');
317 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
318 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
319 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
321 $companybankaccount->datec =
dol_now();
324 $companybankaccount->status =
GETPOSTINT(
'clos');
326 $companybankaccount->bank = trim($companybankaccount->bank);
327 if (empty($companybankaccount->bank) && !empty($companybankaccount->thirdparty)) {
328 $companybankaccount->bank = $langs->trans(
"Bank").
' '.$companybankaccount->thirdparty->name;
330 $companybankaccount->bic = str_replace(
' ',
'', $companybankaccount->bic);
335 if ($companybankaccount->needIBAN() == 1) {
337 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
342 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
349 $result = $companybankaccount->create($user);
352 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
356 if (empty($companybankaccount->rum)) {
357 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, $companybankaccount->id);
362 $result = $companybankaccount->update($user);
365 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
373 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
374 header(
'Location: '.$url);
383 if ($action ==
'addcard') {
386 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
387 if (!
GETPOST(
'label',
'alpha')) {
388 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
390 if (!
GETPOST(
'proprio',
'alpha')) {
391 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
394 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
395 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
398 $action =
'createcard';
406 $companypaymentmode->fk_soc =
$object->id;
407 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
408 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
409 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
410 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
411 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
412 $companypaymentmode->exp_date_month =
GETPOSTINT(
'exp_date_month');
413 $companypaymentmode->exp_date_year =
GETPOSTINT(
'exp_date_year');
414 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
415 $companypaymentmode->datec =
dol_now();
416 $companypaymentmode->default_rib = 0;
417 $companypaymentmode->type =
'card';
418 $companypaymentmode->country_code =
$object->country_code;
419 $companypaymentmode->status = $servicestatus;
421 if (
GETPOST(
'stripe_card_ref',
'alpha')) {
423 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
425 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
430 $result = $companypaymentmode->create($user);
433 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
434 $action =
'createcard';
441 $url = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id;
442 header(
'Location: '.$url);
450 if ($action ==
'setasbankdefault' &&
GETPOSTINT(
'ribid') > 0) {
452 $res = $companybankaccount->setAsDefault(
GETPOSTINT(
'ribid'));
454 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
455 header(
'Location: '.$url);
462 if ($action ==
'confirm_deletecard' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
465 if ($companypaymentmode->fetch($ribid ? $ribid : $id)) {
476 $result = $companypaymentmode->delete($user);
478 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
480 header(
'Location: '.$url);
483 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
486 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
489 if ($action ==
'confirm_deletebank' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
492 if ($companybankaccount->fetch($ribid ? $ribid : $id) > 0) {
503 $result = $companybankaccount->delete($user);
506 $url = $_SERVER[
'PHP_SELF'].
"?socid=".
$object->id;
508 header(
'Location: '.$url);
511 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
514 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
521 if ($action ==
'builddocrib') {
522 $action =
'builddoc';
524 'use_companybankid' =>
GETPOST(
'companybankid'),
527 $_POST[
'lang_id'] =
GETPOST(
'lang_idrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
528 $_POST[
'model'] =
GETPOST(
'modelrib'.
GETPOSTINT(
'companybankid'),
'alphanohtml');
532 $upload_dir = $conf->societe->multidir_output[
$object->entity];
533 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
538 if (isModEnabled(
'stripe') && class_exists(
'Stripe')) {
539 if ($action ==
'synccustomertostripe' || $action ==
'synccustomertostripetest') {
544 if ($action ==
'synccustomertostripe') {
545 $tmpservicestatus = 1;
546 $tmpservice =
'StripeLive';
548 $tmpservicestatus = 0;
549 $tmpservice =
'StripeTest';
552 $stripe =
new Stripe($db);
553 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
556 $tmpcu = $stripe->customerStripe($object, $tmpstripeacc, $tmpservicestatus, 1);
562 if ($tmpservicestatus == $servicestatus) {
563 $stripecu = $tmpcu->id;
568 if ($action ==
'synccardtostripe') {
571 $companypaymentmode->fetch($id);
573 if ($companypaymentmode->type !=
'card') {
578 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
588 $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
596 if ($action ==
'syncsepatostripe') {
599 $companypaymentmode->fetch($id);
601 if ($companypaymentmode->type !=
'ban') {
603 $langs->load(
"errors");
607 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
611 $langs->load(
"errors");
612 setEventMessages($langs->trans(
"ErrorStripeCustomerNotFoundCreateFirst"),
null,
'errors');
616 $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
621 setEventMessages(
"", array(
"Bank Account on Stripe",
"BAN is now linked to the Stripe customer account !"));
628 if ($action ==
'setkey_account' || $action ==
'setkey_accounttest') {
631 $tmpservice =
'StripeTest';
632 $tmpservicestatus = 0;
633 if ($action ==
'setkey_account') {
634 $tmpservice =
'StripeLive';
635 $tmpservicestatus = 1;
639 global $stripearrayofkeysbyenv;
640 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
642 if ($action ==
'setkey_account') {
643 $newcu =
GETPOST(
'key_account',
'alpha');
645 $newcu =
GETPOST(
'key_accounttest',
'alpha');
651 $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;
653 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_account";
654 $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;
657 $resql = $db->query($sql);
658 $num = $db->num_rows($resql);
659 if (!empty($newcu)) {
662 $societeaccount->fk_soc =
$object->id;
663 $societeaccount->login =
'';
664 $societeaccount->pass_encoding =
'';
665 $societeaccount->site =
'stripe';
666 $societeaccount->status = $servicestatus;
667 $societeaccount->key_account = $newcu;
668 $societeaccount->site_account = $tmpsite_account;
669 $result = $societeaccount->create($user);
674 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"societe_account";
675 $sql .=
" SET key_account = '".$db->escape($newcu).
"', site_account = '".$db->escape($tmpsite_account).
"'";
676 $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;
677 $resql = $db->query($sql);
685 if ($tmpservicestatus == $servicestatus) {
695 if ($action ==
'setkey_account_supplier' || $action ==
'setkey_account_suppliertest') {
698 $tmpservice =
'StripeTest';
699 $tmpservicestatus = 0;
700 if ($action ==
'setkey_account_supplier') {
701 $tmpservice =
'StripeLive';
702 $tmpservicestatus = 1;
706 global $stripearrayofkeysbyenv;
707 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
709 if ($action ==
'setkey_account_supplier') {
710 $newsup =
GETPOST(
'key_account_supplier',
'alpha');
712 $newsup =
GETPOST(
'key_account_suppliertest',
'alpha');
717 if (empty($newsup)) {
718 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"oauth_token WHERE fk_soc = ".
$object->id.
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".$conf->entity;
723 $stripesup = \Stripe\Account::retrieve($newsup);
724 $tokenstring = array();
725 $tokenstring[
'stripe_user_id'] = $stripesup->id;
726 $tokenstring[
'type'] = $stripesup->type;
727 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"oauth_token";
728 $sql .=
" SET tokenstring = '".$db->escape(json_encode($tokenstring)).
"'";
729 $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;
731 $sql .=
" WHERE fk_soc = ".$object->id.
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".$conf->entity;
738 $resql = $db->query($sql);
739 $num = $db->num_rows($resql);
740 if (empty($num) && !empty($newsup)) {
742 $stripesup = \Stripe\Account::retrieve($newsup);
743 $tokenstring[
'stripe_user_id'] = $stripesup->id;
744 $tokenstring[
'type'] = $stripesup->type;
745 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"oauth_token (service, fk_soc, entity, tokenstring)";
746 $sql .=
" VALUES ('".$db->escape($tmpservice).
"', ".((int)
$object->id).
", ".((int) $conf->entity).
", '".$db->escape(json_encode($tokenstring)).
"')";
752 $resql = $db->query($sql);
756 if ($tmpservicestatus == $servicestatus) {
757 $stripesupplieracc = $newsup;
765 if ($action ==
'setlocalassourcedefault') {
767 $companypaymentmode->setAsDefault($id);
769 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
770 header(
'Location: '.$url);
776 } elseif ($action ==
'setassourcedefault') {
778 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
779 if (preg_match(
'/pm_|src_/', $source)) {
780 $cu->invoice_settings->default_payment_method = (string) $source;
782 $cu->default_source = (string) $source;
785 $result = $cu->save();
787 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
788 header(
'Location: '.$url);
794 } elseif ($action ==
'deletecard' && $source) {
797 if (preg_match(
'/pm_/', $source)) {
798 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
799 if ($payment_method) {
800 $payment_method->detach();
803 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
804 $card = $cu->sources->retrieve(
"$source");
807 if (method_exists($card,
'detach')) {
809 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
810 $sql .=
" SET stripe_card_ref = null";
811 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
812 $resql = $db->query($sql);
814 $card->delete($user);
819 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
820 header(
'Location: '.$url);
826 } elseif ($action ==
'deletebank' && $source) {
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);
847 $card->delete($user);
852 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id;
854 $url .=
'&page_y='.GETPOSTINT(
'page_y');
857 header(
'Location: '.$url);
873$form =
new Form($db);
877$title = $langs->trans(
"ThirdParty");
879 $title =
$object->name.
" - ".$langs->trans(
'PaymentInformation');
893 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'),
'',
'warning');
899 $companybankaccount->fetch(0,
'',
$object->id);
901 $companypaymentmode->fetch(0,
null,
$object->id,
'card');
903 $companybankaccount->fetch($id);
904 $companypaymentmode->fetch($id);
906if (empty($companybankaccount->socid)) {
907 $companybankaccount->socid =
$object->id;
910if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
911 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post">';
912 print
'<input type="hidden" name="token" value="'.newToken().
'">';
913 $actionforadd =
'update';
914 if ($action ==
'editcard') {
915 $actionforadd =
'updatecard';
917 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
918 print
'<input type="hidden" name="id" value="'.GETPOSTINT(
"id").
'">';
920if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
921 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post">';
922 print
'<input type="hidden" name="token" value="'.newToken().
'">';
923 $actionforadd =
'add';
924 if ($action ==
'createcard') {
925 $actionforadd =
'addcard';
927 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
932if ($socid && $action !=
'edit' && $action !=
'create' && $action !=
'editcard' && $action !=
'createcard') {
936 if ($action ==
'deletebank') {
937 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);
940 if ($action ==
'deletecard') {
941 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);
944 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
946 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
948 print
'<div class="fichecenter">';
950 print
'<div class="underbanner clearboth"></div>';
951 print
'<table class="border tableforfield centpercent">';
954 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td colspan="2">';
959 print
'<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="2">'.
$object->prefix_comm.
'</td></tr>';
963 print
'<tr><td class="titlefield">';
964 print $langs->trans(
'CustomerCode').
'</td><td colspan="2">';
966 $tmpcheck =
$object->check_codeclient();
967 if ($tmpcheck != 0 && $tmpcheck != -5) {
968 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
971 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
972 $resql = $db->query($sql);
977 $obj = $db->fetch_object($resql);
978 $nbFactsClient = $obj->nb;
979 $thirdTypeArray = array();
980 $elementTypeArray = array();
981 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
982 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
983 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
985 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
986 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
988 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
989 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
991 if (isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
992 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
995 if (isModEnabled(
'stripe')) {
997 global $stripearrayofkeysbyenv;
1000 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1001 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
1002 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1005 print
'<tr><td class="titlefield">';
1006 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1008 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1009 if ($tmpstripecu && $action !=
'editkey_accounttest') {
1011 if (!empty($stripeacc)) {
1012 $connect = $stripeacc.
'/';
1014 $url =
'https://dashboard.stripe.com/'.$connect.
'test/customers/'.$tmpstripecu;
1015 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1017 print
'</td><td class="right">';
1018 if (empty($tmpstripecu)) {
1019 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1020 print
'<input type="hidden" name="action" value="synccustomertostripetest">';
1021 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1022 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1023 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1024 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomertest" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1030 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1031 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
1032 $tmpstripecu = $stripe->getStripeCustomerAccount(
$object->id, $tmpservice, $tmpsite_account);
1035 print
'<tr><td class="titlefield">';
1036 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1038 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1039 if ($tmpstripecu && $action !=
'editkey_account') {
1041 if (!empty($stripeacc)) {
1042 $connect = $stripeacc.
'/';
1044 $url =
'https://dashboard.stripe.com/'.$connect.
'customers/'.$tmpstripecu;
1045 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1047 print
'</td><td class="right">';
1048 if (empty($tmpstripecu)) {
1049 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1050 print
'<input type="hidden" name="action" value="synccustomertostripe">';
1051 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1052 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1053 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1054 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomer" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1062 print
'<tr><td class="titlefield">';
1063 print $langs->trans(
'SupplierCode').
'</td><td colspan="2">';
1065 $tmpcheck =
$object->check_codefournisseur();
1066 if ($tmpcheck != 0 && $tmpcheck != -5) {
1067 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
1070 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
1071 $resql = $db->query($sql);
1075 $obj = $db->fetch_object($resql);
1076 $nbFactsClient = $obj->nb;
1077 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
1078 if (isModEnabled(
'propal') && $user->hasRight(
'propal',
'lire')) {
1079 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
1081 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
1082 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1084 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
1085 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1087 if (isModEnabled(
'contract') && $user->hasRight(
'contrat',
'lire')) {
1088 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1093 if (isModEnabled(
'stripe') && !empty($conf->stripeconnect->enabled) &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 2) {
1094 $stripesupplieracc = $stripe->getStripeAccount($service,
$object->id);
1097 print
'<tr><td class="titlefield">';
1098 print $form->editfieldkey(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1100 print $form->editfieldval(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1101 if (isModEnabled(
'stripe') && $stripesupplieracc && $action !=
'editkey_account_supplier') {
1104 $url =
'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc;
1105 if ($servicestatus) {
1106 $url =
'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc;
1108 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key '.$site_account,
'globe').
'</a>';
1110 print
'</td><td class="right">';
1111 if (empty($stripesupplieracc)) {
1112 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1113 print
'<input type="hidden" name="action" value="syncsuppliertostripe">';
1114 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1115 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1116 print
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1130 $showcardpaymentmode = 0;
1131 if (isModEnabled(
'stripe')) {
1132 $showcardpaymentmode++;
1136 $listofsources = array();
1138 if (isset($stripe) && is_object($stripe)) {
1140 $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus);
1141 if (!empty($customerstripe->id)) {
1144 $listofsources = $customerstripe->sources->data;
1146 $service =
'StripeTest';
1149 $service =
'StripeLive';
1154 global $stripearrayofkeysbyenv;
1155 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
1158 if (empty($stripeacc)) {
1159 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"));
1160 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"));
1162 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"), array(
"stripe_account" => $stripeacc));
1163 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"), array(
"stripe_account" => $stripeacc));
1166 if ($paymentmethodobjsA->data !=
null && $paymentmethodobjsB->data !=
null) {
1167 $listofsources = array_merge((array) $paymentmethodobjsA->data, (array) $paymentmethodobjsB->data);
1168 } elseif ($paymentmethodobjsB->data !=
null) {
1169 $listofsources = $paymentmethodobjsB->data;
1171 $listofsources = $paymentmethodobjsA->data;
1180 dol_syslog(
"Error when searching/loading Stripe customer for thirdparty id =".
$object->id);
1186 if ($showcardpaymentmode &&
$object->client) {
1187 $morehtmlright =
'';
1189 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=createcard');
1191 print
load_fiche_titre($langs->trans(
'CreditCard'), $morehtmlright,
'fa-credit-card');
1194 print
'<!-- List of card payments -->'.
"\n";
1195 print
'<div class="div-table-responsive-no-min">';
1196 print
'<table class="liste centpercent">'.
"\n";
1197 print
'<tr class="liste_titre">';
1198 print
'<td>'.$langs->trans(
'Label').
'</td>';
1199 print
'<td>'.$form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")).
'</td>';
1200 print
'<td>'.$langs->trans(
'Type').
'</td>';
1201 print
'<td>'.$langs->trans(
'Informations').
'</td>';
1203 print
'<td class="center">'.$langs->trans(
'Default').
'</td>';
1204 print
'<td>'.$langs->trans(
'Note').
'</td>';
1205 print
'<td>'.$langs->trans(
'DateModification').
'</td>';
1207 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'stripetitle');
1208 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
1209 print $hookmanager->resPrint;
1216 $arrayofremotecard = array();
1223 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_rib";
1224 $sql .=
" WHERE type in ('card')";
1225 $sql .=
" AND fk_soc = ".((int)
$object->id);
1226 $sql .=
" AND status = ".((int) $servicestatus);
1228 $resql = $db->query($sql);
1230 $num_rows = $db->num_rows($resql);
1233 while ($i < $num_rows) {
1236 $obj = $db->fetch_object($resql);
1238 $companypaymentmodetemp->fetch($obj->rowid);
1240 $arrayofremotecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref;
1242 print
'<tr class="oddeven" data-rowid="'.((int) $companypaymentmodetemp->id).
'">';
1244 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->label).
'">';
1248 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->stripe_card_ref.(empty($companypaymentmodetemp->stripe_account) ?
'' :
' - '.$companypaymentmodetemp->stripe_account)).
'">';
1249 if (!empty($companypaymentmodetemp->stripe_card_ref) && !empty($companypaymentmodetemp->ext_payment_site)) {
1250 if (isModEnabled(
'stripe') && in_array($companypaymentmodetemp->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1252 if (!empty($stripeacc)) {
1253 $connect = $stripeacc.
'/';
1255 if ($companypaymentmodetemp->ext_payment_site ==
'StripeLive') {
1256 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$companypaymentmodetemp->stripe_card_ref;
1258 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
1260 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe').
' - '.$companypaymentmodetemp->stripe_account,
'globe').
"</a> ";
1271 print
'<td class="minwidth100">';
1272 if ($companypaymentmodetemp->proprio) {
1273 print
'<span class="opacitymedium">'.$companypaymentmodetemp->proprio.
'</span><br>';
1275 if ($companypaymentmodetemp->last_four) {
1276 print
'....'.$companypaymentmodetemp->last_four;
1278 if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) {
1279 print
' - '.sprintf(
"%02d", $companypaymentmodetemp->exp_date_month).
'/'.$companypaymentmodetemp->exp_date_year;
1283 print
'<td class="tdoverflowmax100">';
1284 if ($companypaymentmodetemp->country_code) {
1286 print $img ? $img.
' ' :
'';
1287 print
getCountry($companypaymentmodetemp->country_code, 1);
1289 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1293 print
'<td class="center">';
1294 if (empty($companypaymentmodetemp->default_rib)) {
1295 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=setlocalassourcedefault&token='.
newToken().
'">';
1296 print
img_picto($langs->trans(
"Default"),
'off');
1299 print
img_picto($langs->trans(
"Default"),
'on');
1302 if (empty($companypaymentmodetemp->stripe_card_ref)) {
1303 $s = $langs->trans(
"Local");
1305 $s = $langs->trans(
"LocalAndRemote");
1307 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1311 print
dol_print_date($companypaymentmodetemp->tms,
'dayhour',
'tzuserrel');
1314 $parameters = array(
'arrayfields' => array(),
'obj' => $obj,
'linetype' =>
'stripecard');
1315 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1316 print $hookmanager->resPrint;
1318 print
'<td class="right minwidth50 nowraponall">';
1319 if ($permissiontoaddupdatepaymentinformation) {
1320 if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) {
1321 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=synccardtostripe&socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'" class="paddingrightonly marginrightonly">'.$langs->trans(
"CreateCardOnStripe").
'</a>';
1324 print
'<a class="editfielda marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=editcard&token='.
newToken().
'">';
1325 print
img_picto($langs->trans(
"Modify"),
'edit');
1327 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=deletecard&token='.
newToken().
'">';
1328 print
img_picto($langs->trans(
"Delete"),
'delete');
1343 if (is_array($listofsources) && count($listofsources)) {
1344 foreach ($listofsources as $src) {
1345 if (!empty($arrayofremotecard[$src->id])) {
1352 if ($src->object ==
'card') {
1354 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1356 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1358 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1360 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1364 print
'<tr class="oddeven">';
1368 print
'<td class="tdoverflowmax150">';
1370 if (!empty($stripeacc)) {
1371 $connect = $stripeacc.
'/';
1374 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1375 if ($servicestatus) {
1377 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1379 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1387 print
'<td valign="middle">';
1388 if ($src->object ==
'card') {
1389 print
'....'.$src->last4.
' - '.$src->exp_month.
'/'.$src->exp_year;
1391 if ($src->country) {
1393 print $img ? $img.
' ' :
'';
1396 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1398 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1399 print
'<span class="opacitymedium">'.$src->owner->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1402 if ($src->card->country) {
1404 print $img ? $img.
' ' :
'';
1407 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1409 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1410 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1412 if ($src->sepa_debit->country) {
1414 print $img ? $img.
' ' :
'';
1415 print
getCountry($src->sepa_debit->country, 1);
1417 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1419 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1420 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1423 if ($src->card->country) {
1425 print $img ? $img.
' ' :
'';
1428 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1430 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1431 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1433 if ($src->sepa_debit->country) {
1435 print $img ? $img.
' ' :
'';
1436 print
getCountry($src->sepa_debit->country, 1);
1438 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1445 print
'<td class="center" width="50">';
1446 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1447 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1448 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1449 print
img_picto($langs->trans(
"Default"),
'off');
1452 print
img_picto($langs->trans(
"Default"),
'on');
1456 print $langs->trans(
"Remote");
1465 $parameters = array(
'arrayfields' => array(),
'stripesource' => $src,
'linetype' =>
'stripecardremoteonly');
1466 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1467 print $hookmanager->resPrint;
1470 print
'<td class="right nowraponall">';
1471 if ($permissiontoaddupdatepaymentinformation) {
1472 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletecard&token='.
newToken().
'">';
1473 print
img_picto($langs->trans(
"Delete"),
'delete');
1482 if ($nbremote == 0 && $nblocal == 0) {
1484 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1492 if (isModEnabled(
'stripe') && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc)) {
1493 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');
1494 $balance = \Stripe\Balance::retrieve(array(
"stripe_account" => $stripesupplieracc));
1495 print
'<table class="liste centpercent">'.
"\n";
1496 print
'<tr class="liste_titre">';
1497 print
'<td>'.$langs->trans(
'Currency').
'</td>';
1498 print
'<td>'.$langs->trans(
'Available').
'</td>';
1499 print
'<td>'.$langs->trans(
'Pending').
'</td>';
1500 print
'<td>'.$langs->trans(
'Total').
'</td>';
1503 $currencybalance = array();
1504 if (is_array($balance->available) && count($balance->available)) {
1505 foreach ($balance->available as $cpt) {
1506 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1507 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1508 $currencybalance[$cpt->currency][
'available'] = $cpt->amount / 100;
1510 $currencybalance[$cpt->currency][
'available'] = $cpt->amount;
1512 $currencybalance[$cpt->currency][
'currency'] = $cpt->currency;
1516 if (is_array($balance->pending) && count($balance->pending)) {
1517 foreach ($balance->pending as $cpt) {
1518 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1519 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1520 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount / 100;
1522 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount;
1527 if (is_array($currencybalance)) {
1528 foreach ($currencybalance as $cpt) {
1529 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>';
1539 if ($permissiontoaddupdatepaymentinformation) {
1540 $morehtmlright =
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"] .
'?socid=' .
$object->id .
'&action=create');
1543 print
load_fiche_titre($langs->trans(
"BankAccounts"), $morehtmlright,
'bank');
1547 $arrayofremoteban = array();
1549 $rib_list =
$object->get_all_rib();
1551 if (is_array($rib_list)) {
1552 print
'<div class="div-table-responsive-no-min">';
1553 print
'<table class="liste centpercent">';
1555 print
'<tr class="liste_titre">';
1557 print_liste_field_titre($form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")));
1562 if (isModEnabled(
'prelevement')) {
1573 $parameters = array(
'arrayfields' => array(),
'linetype' =>
'stripebantitle');
1574 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1575 print $hookmanager->resPrint;
1580 foreach ($rib_list as $rib) {
1581 $arrayofremoteban[$rib->stripe_card_ref] = $rib->stripe_card_ref;
1585 print
'<tr class="oddeven">';
1587 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->label).
'">'.
dol_escape_htmltag($rib->label).
'</td>';
1589 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->stripe_card_ref.(empty($rib->stripe_account) ?
'' :
' - '.$rib->stripe_account)).
'">';
1590 if (!empty($rib->stripe_card_ref) && !empty($rib->ext_payment_site)) {
1591 if (isModEnabled(
'stripe') && in_array($rib->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1593 if (!empty($stripeacc)) {
1594 $connect = $stripeacc.
'/';
1596 if ($rib->ext_payment_site ==
'StripeLive') {
1597 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$rib->stripe_card_ref;
1599 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$rib->stripe_card_ref;
1601 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1608 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->bank).
'">'.
dol_escape_htmltag($rib->bank).
'</td>';
1611 foreach ($rib->getFieldsToShow() as $val) {
1612 if ($val ==
'BankCode') {
1613 $string .= $rib->code_banque.
' ';
1614 } elseif ($val ==
'BankAccountNumber') {
1615 $string .= $rib->number.
' ';
1616 } elseif ($val ==
'DeskCode') {
1617 $string .= $rib->code_guichet.
' ';
1618 } elseif ($val ==
'BankAccountNumberKey') {
1619 $string .= $rib->cle_rib.
' ';
1628 if (!empty($rib->label) && $rib->number) {
1630 $string .=
' '.img_picto($langs->trans(
"ValueIsNotValid"),
'warning');
1632 $string .=
' '.img_picto($langs->trans(
"ValueIsValid"),
'info');
1635 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($string).
'">';
1639 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->iban).
'">';
1640 if (!empty($rib->iban)) {
1642 print
img_picto($langs->trans(
"IbanNotValid"),
'warning').
' ';
1649 if (!empty($rib->bic)) {
1651 print
img_picto($langs->trans(
"SwiftNotValid"),
'warning').
' ';
1657 if (isModEnabled(
'prelevement')) {
1660 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->rum).
'">'.
dol_escape_htmltag($rib->rum).
'</td>';
1662 print
'<td>'.dol_print_date($rib->date_rum,
'day').
'</td>';
1665 print
'<td>'.dol_escape_htmltag($rib->frstrecur).
'</td>';
1669 print
'<td class="center" width="70">';
1670 if (!$rib->default_rib) {
1671 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?socid='.((int)
$object->id).
'&ribid='.((int) $rib->id).
'&action=setasbankdefault&token='.
newToken().
'">';
1672 print
img_picto($langs->trans(
"Disabled"),
'off');
1675 print
img_picto($langs->trans(
"Enabled"),
'on');
1680 print
'<td class="center">';
1682 $buttonlabel = $langs->trans(
"BuildDoc");
1683 $forname =
'builddocrib'.$rib->id;
1685 include_once DOL_DOCUMENT_ROOT.
'/core/modules/bank/modules_bank.php';
1689 if (is_array($modellist) && count($modellist)) {
1690 $out .=
'<form action="'.$_SERVER[
"PHP_SELF"].(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#builddoc').
'" name="'.$forname.
'" id="'.$forname.
'_form" method="post">';
1691 $out .=
'<input type="hidden" name="action" value="builddocrib">';
1692 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1693 $out .=
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1694 $out .=
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1696 $modelselected =
'';
1697 if (count($modellist) == 1) {
1698 $arraykeys = array_keys($modellist);
1699 $modelselected = $arraykeys[0];
1705 $out .= $form->selectarray(
'modelrib'.$rib->id, $modellist, $modelselected, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth125');
1710 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
1712 $defaultlang = $langs->getDefaultLang();
1713 $morecss =
'maxwidth150';
1714 if ($conf->browser->layout ==
'phone') {
1715 $morecss =
'maxwidth100';
1717 $out .= $formadmin->select_language($defaultlang,
'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss);
1720 $out .=
'<input class="button buttongen reposition nomargintop nomarginbottom" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
1721 $out .=
' type="submit" value="'.$buttonlabel.
'"';
1729 $parameters = array(
'arrayfields' => array(),
'stripe_card_ref' => $rib->stripe_card_ref,
'stripe_account' => $rib->stripe_account,
'linetype' =>
'stripeban');
1730 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1731 print $hookmanager->resPrint;
1735 print
'<td class="width200">';
1736 $useonlinesignature = 1;
1737 if ($useonlinesignature) {
1738 require_once DOL_DOCUMENT_ROOT .
'/core/lib/signature.lib.php';
1739 print showOnlineSignatureUrl($companybankaccount->element, $rib->id, $rib,
'short');
1745 print
'<td class="right nowraponall">';
1746 if ($permissiontoaddupdatepaymentinformation) {
1747 if (isModEnabled(
'stripe')) {
1748 if (empty($rib->stripe_card_ref)) {
1751 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=syncsepatostripe&token='.
newToken().
'">';
1752 print
img_picto($langs->trans(
"CreateBANOnStripe"),
'stripe');
1755 print
'<span class="opacitymedium marginrightonly marginleftonly">';
1756 print
img_picto($langs->trans(
"ThirdPartyMustBeACustomerToCreateBANOnStripe"),
'stripe');
1762 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=edit">';
1763 print
img_picto($langs->trans(
"Modify"),
'edit');
1766 print
'<a class="marginrightonly marginleftonly reposition" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&id='.$rib->id.
'&action=deletebank&token='.
newToken().
'">';
1767 print
img_picto($langs->trans(
"Delete"),
'delete');
1777 foreach ($listofsources as $src) {
1778 if (!empty($arrayofremoteban[$src->id])) {
1783 if ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1784 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1785 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1786 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1793 print
'<tr class="oddeven">';
1797 print
'<td class="tdoverflowmax150">';
1799 if (!empty($stripeacc)) {
1800 $connect = $stripeacc.
'/';
1803 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1804 if ($servicestatus) {
1806 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1808 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1815 print
'<td valign="middle">';
1818 print
'<td valign="middle">';
1822 print
'<td valign="middle">';
1826 if (isModEnabled(
'prelevement')) {
1828 print
'<td valign="middle">';
1832 print
'<td valign="middle">';
1836 print
'<td valign="middle">';
1842 print
'<td class="center" width="50">';
1843 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1844 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1845 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1846 print
img_picto($langs->trans(
"Default"),
'off');
1849 print
img_picto($langs->trans(
"Default"),
'on');
1864 $parameters = array(
'arrayfields' => array(),
'stripe_card_ref' => $rib->stripe_card_ref,
'stripe_account' => $rib->stripe_account,
'linetype' =>
'stripebanremoteonly');
1865 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1866 print $hookmanager->resPrint;
1869 print
'<td class="right nowraponall">';
1870 if ($permissiontoaddupdatepaymentinformation) {
1871 print
'<a class="marginleftonly marginrightonly reposition" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.
$object->id.
'&source='.$src->id.
'&action=deletebank&token='.
newToken().
'">';
1872 print
img_picto($langs->trans(
"Delete"),
'delete');
1880 if ($nbremote == 0 && $nblocal == 0) {
1882 if (isModEnabled(
'prelevement')) {
1885 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoBANRecord").
'</span></td></tr>';
1895 $parameters = array(
'arrayfields' => array(),
'param' =>
'',
'sortfield' =>
'',
'sortorder' =>
'',
'linetype' =>
'');
1896 $reshook = $hookmanager->executeHooks(
'printNewTable', $parameters, $object);
1897 print $hookmanager->resPrint;
1902 print
'<div class="fichecenter"><div class="fichehalfleft">';
1903 print
'<a name="builddoc"></a>';
1908 $filedir = $conf->societe->multidir_output[
$object->entity].
'/'.
$object->id;
1909 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".
$object->id;
1911 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);
1918 $result = $companypaymentmodetemp->fetch(0,
null,
$object->id,
'ban');
1920 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1923 $result = $ecmfile->fetch(0,
'',
'',
'',
'', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
1925 $companybankaccounttemp->last_main_doc = $ecmfile->filepath.
'/'.$ecmfile->filename;
1926 print
'<br><!-- Link to download main doc -->'.
"\n";
1931 print
'</div><div class="fichehalfright">';
1934 print
'</div></div>';
1960if ($socid && $action ==
'edit' && $permissiontoaddupdatepaymentinformation) {
1963 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1965 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
1967 print
'<div class="underbanner clearboth"></div>';
1971 print
'<div class="div-table-responsive-no-min">';
1972 print
'<table class="border centpercent">';
1974 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Label").
'</td>';
1975 print
'<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.
'"></td></tr>';
1977 print
'<tr><td class="fieldrequired">'.$langs->trans(
"BankName").
'</td>';
1978 print
'<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.
'"></td></tr>';
1981 $bankaccount = $companybankaccount;
1983 foreach ($bankaccount->getFieldsToShow(1) as $val) {
1986 if ($val ==
'BankCode') {
1987 $name =
'code_banque';
1989 $content = $bankaccount->code_banque;
1990 } elseif ($val ==
'DeskCode') {
1991 $name =
'code_guichet';
1993 $content = $bankaccount->code_guichet;
1994 } elseif ($val ==
'BankAccountNumber') {
1997 $content = $bankaccount->number;
1998 } elseif ($val ==
'BankAccountNumberKey') {
2001 $content = $bankaccount->cle_rib;
2002 } elseif ($val ==
'IBAN') {
2005 $content = $bankaccount->iban;
2006 if ($bankaccount->needIBAN()) {
2009 $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';
2010 } elseif ($val ==
'BIC') {
2013 $content = $bankaccount->bic;
2014 if ($bankaccount->needIBAN()) {
2017 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2021 print
'<td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2023 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2025 print $langs->trans($val);
2028 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.$content.
'"></td>';
2032 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2033 print
'<textarea name="address" rows="4" cols="40" maxlength="255">';
2034 print $companybankaccount->address;
2035 print
"</textarea></td></tr>";
2037 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2038 print
'<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->owner_name.
'"></td></tr>';
2039 print
"</td></tr>\n";
2041 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2042 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" cols="40" maxlength="255">';
2043 print $companybankaccount->owner_address;
2044 print
"</textarea></td></tr>";
2049 if (isModEnabled(
'prelevement')) {
2052 print
'<div class="div-table-responsive-no-min">';
2053 print
'<table class="border centpercent">';
2055 if (empty($companybankaccount->rum)) {
2056 $companybankaccount->rum = $prelevement->buildRumNumber(
$object->code_client, $companybankaccount->datec, $companybankaccount->id);
2060 print
'<tr><td class="titlefield">'.$langs->trans(
"RUM").
'</td>';
2061 print
'<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).
'"></td></tr>';
2065 print
'<tr><td class="titlefield">'.$langs->trans(
"DateRUM").
'</td>';
2066 print
'<td>'.$form->selectDate($date_rum ? $date_rum : $companybankaccount->date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2068 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2069 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2070 print $form->selectarray(
"frstrecur", $tblArraychoice,
dol_escape_htmltag(
GETPOST(
'frstrecur',
'alpha') ?
GETPOST(
'frstrecur',
'alpha') : $companybankaccount->frstrecur), 0);
2073 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_...' or 'src_...')</td>";
2074 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
2083 print $form->buttonsSaveCancel(
"Modify");
2087if ($socid && $action ==
'editcard' && $permissiontoaddupdatepaymentinformation) {
2090 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2092 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2094 print
'<div class="nofichecenter">';
2096 print
'<div class="underbanner clearboth"></div>';
2100 print
'<table class="border centpercent">';
2102 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2103 print
'<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.
'"></td></tr>';
2105 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2106 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->proprio.
'"></td></tr>';
2108 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2109 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.
'"></td></tr>';
2111 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2113 print $formother->select_month($companypaymentmode->exp_date_month,
'exp_date_month', 1);
2114 print $formother->selectyear($companypaymentmode->exp_date_year,
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2117 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2118 print
'<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.
'"></td></tr>';
2120 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_... ".$langs->trans(
"or").
" card_....')</td>";
2121 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
2128 print $form->buttonsSaveCancel(
"Modify");
2133if ($socid && $action ==
'create' && $permissiontoaddupdatepaymentinformation) {
2136 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2138 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2140 print
'<div class="nofichecenter">';
2142 print
'<div class="underbanner clearboth"></div>';
2146 print
'<table class="border centpercent">';
2148 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2149 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.(GETPOSTISSET(
'label') ?
GETPOST(
'label') :
$object->
name).
'"></td></tr>';
2151 print
'<tr><td>'.$langs->trans(
"Bank").
'</td>';
2152 print
'<td><input class="minwidth200" type="text" id="bank" name="bank" value="'.GETPOST(
'bank').
'"></td></tr>';
2155 foreach ($companybankaccount->getFieldsToShow(1) as $val) {
2158 if ($val ==
'BankCode') {
2159 $name =
'code_banque';
2161 $content = $companybankaccount->code_banque;
2162 } elseif ($val ==
'DeskCode') {
2163 $name =
'code_guichet';
2165 $content = $companybankaccount->code_guichet;
2166 } elseif ($val ==
'BankAccountNumber') {
2169 $content = $companybankaccount->number;
2170 } elseif ($val ==
'BankAccountNumberKey') {
2173 $content = $companybankaccount->cle_rib;
2174 } elseif ($val ==
'IBAN') {
2177 $content = $companybankaccount->iban;
2178 if ($companybankaccount->needIBAN()) {
2181 $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';
2182 } elseif ($val ==
'BIC') {
2185 $content = $companybankaccount->bic;
2186 if ($companybankaccount->needIBAN()) {
2189 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2192 print
'<tr><td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2194 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2196 print $langs->trans($val);
2199 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.
GETPOST($name).
'"></td>';
2203 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2204 print
'<textarea name="address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2206 print
"</textarea></td></tr>";
2208 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2209 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio').
'"></td></tr>';
2210 print
"</td></tr>\n";
2212 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2213 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2214 print
GETPOST(
'owner_address');
2215 print
"</textarea></td></tr>";
2219 if (isModEnabled(
'prelevement')) {
2222 print
'<table class="border centpercent">';
2225 print
'<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans(
"RUM"), $langs->trans(
"RUMLong").
'<br>'.$langs->trans(
"RUMWillBeGenerated")).
'</td>';
2226 print
'<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST(
'rum',
'alpha').
'"></td></tr>';
2230 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DateRUM").
'</td>';
2231 print
'<td colspan="4">'.$form->selectDate($date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2233 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2234 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2235 print $form->selectarray(
"frstrecur", $tblArraychoice, (GETPOSTISSET(
'frstrecur') ?
GETPOST(
'frstrecur') :
'FRST'), 0);
2238 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('src_....')</td>";
2239 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2250 print $form->buttonsSaveCancel(
"Add");
2254if ($socid && $action ==
'createcard' && $permissiontoaddupdatepaymentinformation) {
2257 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2259 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2261 print
'<div class="nofichecenter">';
2263 print
'<div class="underbanner clearboth"></div>';
2267 print
'<table class="border centpercent">';
2269 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2270 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST(
'label',
'alpha').
'"></td></tr>';
2272 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2273 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio',
'alpha').
'"></td></tr>';
2275 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2276 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST(
'cardnumber',
'alpha').
'"></td></tr>';
2278 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2280 print $formother->select_month(
GETPOSTINT(
'exp_date_month'),
'exp_date_month', 1);
2281 print $formother->selectyear(
GETPOSTINT(
'exp_date_year'),
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2284 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2285 print
'<td><input class="width50" type="text" name="cvn" value="'.GETPOST(
'cvn',
'alpha').
'"></td></tr>';
2287 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('card_....')</td>";
2288 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2298 print $form->buttonsSaveCancel(
"Add");
2301if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
2304if ($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()
Empty header.
checkSwiftForAccount(Account $account=null, $swift=null)
Check SWIFT information for a bank account.
checkIbanForAccount(Account $account=null, $ibantocheck=null)
Check IBAN number information for a bank account.
checkBanForAccount($account)
Check account number 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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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.