34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/societe/class/companypaymentmode.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
47$langs->loadLangs(array(
"companies",
"commercial",
"banks",
"bills",
'paypal',
'stripe',
'withdrawals'));
51$action =
GETPOST(
"action",
'alpha', 3);
52$cancel =
GETPOST(
'cancel',
'alpha');
53$backtopage =
GETPOST(
'backtopage');
56$source =
GETPOST(
"source",
"alpha");
57$ribid =
GETPOST(
"ribid",
"int");
60$socid =
GETPOST(
"socid",
"int");
62 $socid = $user->socid;
67$object->fetch($socid);
76$extrafields->fetch_name_optionals_label($object->table_element);
79$hookmanager->initHooks(array(
'thirdpartybancard',
'globalcard'));
82$permissiontoread = $user->hasRight(
'societe',
'lire');
83$permissiontoadd = $user->hasRight(
'societe',
'creer');
85$permissiontoaddupdatepaymentinformation = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $permissiontoadd) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->societe->thirdparty_paymentinformation_advance->write)));
93if (isModEnabled(
'stripe')) {
94 $service =
'StripeTest';
97 $service =
'StripeLive';
102 global $stripearrayofkeysbyenv;
103 $site_account = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
105 $stripe =
new Stripe($db);
106 $stripeacc = $stripe->getStripeAccount($service);
107 $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus, $site_account);
122$parameters = array(
'id'=>$socid);
123$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
128if (empty($reshook)) {
131 if (!empty($backtopage)) {
132 header(
"Location: ".$backtopage);
137 if ($action ==
'update') {
140 if (!
GETPOST(
'label',
'alpha')) {
141 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
143 if (!
GETPOST(
'bank',
'alpha')) {
144 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankName")),
null,
'errors');
149 $companybankaccount->fetch($id);
150 if ($companybankaccount->needIBAN() == 1) {
152 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
157 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
164 $companybankaccount->oldcopy =
dol_clone($companybankaccount);
166 $companybankaccount->socid = $object->id;
168 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
169 $companybankaccount->label =
GETPOST(
'label',
'alpha');
170 $companybankaccount->courant =
GETPOST(
'courant',
'alpha');
171 $companybankaccount->clos =
GETPOST(
'clos',
'alpha');
172 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
173 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
174 $companybankaccount->number =
GETPOST(
'number',
'alpha');
175 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
176 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
177 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
178 $companybankaccount->domiciliation =
GETPOST(
'domiciliation',
'alpha');
179 $companybankaccount->proprio =
GETPOST(
'proprio',
'alpha');
180 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
181 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
182 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
184 if (empty($companybankaccount->rum)) {
185 $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
188 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
190 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
192 $companybankaccount->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
194 $result = $companybankaccount->update($user);
197 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
201 if ($companybankaccount->default_rib) {
202 $companybankaccount->setAsDefault($id);
205 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
206 if ($companybankaccount->oldcopy->iban != $companybankaccount->iban) {
211 $url = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id;
212 header(
'Location: '.$url);
218 if ($action ==
'updatecard') {
220 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
221 if (!
GETPOST(
'label',
'alpha')) {
222 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
224 if (!
GETPOST(
'proprio',
'alpha')) {
225 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
228 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
229 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
232 $action =
'createcard';
236 $companypaymentmode->fetch($id);
238 $companybankaccount->oldcopy =
dol_clone($companybankaccount);
240 $companypaymentmode->fk_soc = $object->id;
242 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
243 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
244 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
245 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
246 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
247 $companypaymentmode->exp_date_month =
GETPOST(
'exp_date_month',
'int');
248 $companypaymentmode->exp_date_year =
GETPOST(
'exp_date_year',
'int');
249 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
250 $companypaymentmode->country_code = $object->country_code;
252 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
254 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
256 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
258 $result = $companypaymentmode->update($user);
260 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
263 if ($companypaymentmode->default_rib) {
264 $companypaymentmode->setAsDefault($id);
267 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
268 if ($companybankaccount->oldcopy->number != $companybankaccount->number) {
273 $url = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id;
274 header(
'Location: '.$url);
281 if ($action ==
'add') {
284 if (!
GETPOST(
'label',
'alpha')) {
285 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
294 $companybankaccount->socid = $object->id;
296 $companybankaccount->fetch_thirdparty();
298 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
299 $companybankaccount->label =
GETPOST(
'label',
'alpha');
300 $companybankaccount->courant =
GETPOST(
'courant',
'alpha');
301 $companybankaccount->clos =
GETPOST(
'clos',
'alpha');
302 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
303 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
304 $companybankaccount->number =
GETPOST(
'number',
'alpha');
305 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
306 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
307 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
308 $companybankaccount->domiciliation =
GETPOST(
'domiciliation',
'alpha');
309 $companybankaccount->proprio =
GETPOST(
'proprio',
'alpha');
310 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
311 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
312 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
314 $companybankaccount->datec =
dol_now();
315 $companybankaccount->status = 1;
317 $companybankaccount->bank = trim($companybankaccount->bank);
318 if (empty($companybankaccount->bank) && !empty($companybankaccount->thirdparty)) {
319 $companybankaccount->bank = $langs->trans(
"Bank").
' '.$companybankaccount->thirdparty->name;
321 $companybankaccount->bic = str_replace(
' ',
'', $companybankaccount->bic);
326 if ($companybankaccount->needIBAN() == 1) {
328 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
333 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
340 $result = $companybankaccount->create($user);
343 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
347 if (empty($companybankaccount->rum)) {
348 $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
353 $result = $companybankaccount->update($user);
356 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
364 $url = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id;
365 header(
'Location: '.$url);
374 if ($action ==
'addcard') {
377 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
378 if (!
GETPOST(
'label',
'alpha')) {
379 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
381 if (!
GETPOST(
'proprio',
'alpha')) {
382 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
385 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
386 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
389 $action =
'createcard';
397 $companypaymentmode->fk_soc = $object->id;
398 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
399 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
400 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
401 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
402 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
403 $companypaymentmode->exp_date_month =
GETPOST(
'exp_date_month',
'int');
404 $companypaymentmode->exp_date_year =
GETPOST(
'exp_date_year',
'int');
405 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
406 $companypaymentmode->datec =
dol_now();
407 $companypaymentmode->default_rib = 0;
408 $companypaymentmode->type =
'card';
409 $companypaymentmode->country_code = $object->country_code;
410 $companypaymentmode->status = $servicestatus;
412 if (
GETPOST(
'stripe_card_ref',
'alpha')) {
414 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
416 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
421 $result = $companypaymentmode->create($user);
424 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
425 $action =
'createcard';
432 $url = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id;
433 header(
'Location: '.$url);
441 if ($action ==
'setasbankdefault' &&
GETPOST(
'ribid',
'int') > 0) {
443 $res = $companybankaccount->setAsDefault(
GETPOST(
'ribid',
'int'));
445 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
446 header(
'Location: '.$url);
453 if ($action ==
'confirm_deletecard' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
456 if ($companypaymentmode->fetch($ribid ? $ribid : $id)) {
467 $result = $companypaymentmode->delete($user);
469 $url = $_SERVER[
'PHP_SELF'].
"?socid=".$object->id;
471 header(
'Location: '.$url);
474 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
477 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
480 if ($action ==
'confirm_deletebank' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
483 if ($companybankaccount->fetch($ribid ? $ribid : $id) > 0) {
494 $result = $companybankaccount->delete($user);
497 $url = $_SERVER[
'PHP_SELF'].
"?socid=".$object->id;
499 header(
'Location: '.$url);
502 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
505 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
512 if ($action ==
'builddocrib') {
513 $action =
'builddoc';
515 'use_companybankid'=>
GETPOST(
'companybankid'),
516 'force_dir_output'=>$conf->societe->multidir_output[$object->entity].
'/'.
dol_sanitizeFileName($object->id)
518 $_POST[
'lang_id'] =
GETPOST(
'lang_idrib'.
GETPOST(
'companybankid',
'int'),
'alpha');
519 $_POST[
'model'] =
GETPOST(
'modelrib'.
GETPOST(
'companybankid',
'int'),
'alpha');
523 $upload_dir = $conf->societe->multidir_output[$object->entity];
524 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
529 if (isModEnabled(
'stripe') && class_exists(
'Stripe')) {
530 if ($action ==
'synccustomertostripe' || $action ==
'synccustomertostripetest') {
531 if ($object->client == 0) {
535 if ($action ==
'synccustomertostripe') {
536 $tmpservicestatus = 1;
537 $tmpservice =
'StripeLive';
539 $tmpservicestatus = 0;
540 $tmpservice =
'StripeTest';
543 $stripe =
new Stripe($db);
544 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
547 $tmpcu = $stripe->customerStripe($object, $tmpstripeacc, $tmpservicestatus, 1);
553 if ($tmpservicestatus == $servicestatus) {
554 $stripecu = $tmpcu->id;
559 if ($action ==
'synccardtostripe') {
562 $companypaymentmode->fetch($id);
564 if ($companypaymentmode->type !=
'card') {
569 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
579 $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
587 if ($action ==
'syncsepatostripe') {
590 $companypaymentmode->fetch($id);
592 if ($companypaymentmode->type !=
'ban') {
594 $langs->load(
"errors");
598 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
602 $langs->load(
"errors");
603 setEventMessages($langs->trans(
"ErrorStripeCustomerNotFoundCreateFirst"),
null,
'errors');
607 $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
612 setEventMessages(
"", array(
"Bank Account on Stripe",
"BAN is now linked to the Stripe customer account !"));
619 if ($action ==
'setkey_account' || $action ==
'setkey_accounttest') {
622 $tmpservice =
'StripeTest';
623 $tmpservicestatus = 0;
624 if ($action ==
'setkey_account') {
625 $tmpservice =
'StripeLive';
626 $tmpservicestatus = 1;
630 global $stripearrayofkeysbyenv;
631 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
633 if ($action ==
'setkey_account') {
634 $newcu =
GETPOST(
'key_account',
'alpha');
636 $newcu =
GETPOST(
'key_accounttest',
'alpha');
642 $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;
644 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_account";
645 $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;
648 $resql = $db->query($sql);
649 $num = $db->num_rows($resql);
650 if (!empty($newcu)) {
653 $societeaccount->fk_soc = $object->id;
654 $societeaccount->login =
'';
655 $societeaccount->pass_encoding =
'';
656 $societeaccount->site =
'stripe';
657 $societeaccount->status = $servicestatus;
658 $societeaccount->key_account = $newcu;
659 $societeaccount->site_account = $tmpsite_account;
660 $result = $societeaccount->create($user);
665 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"societe_account";
666 $sql .=
" SET key_account = '".$db->escape($newcu).
"', site_account = '".$db->escape($tmpsite_account).
"'";
667 $sql .=
" WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($tmpsite_account).
"') AND fk_soc = ".((int) $object->id).
" AND status = ".((int) $tmpservicestatus).
" AND entity = ".$conf->entity;
668 $resql = $db->query($sql);
676 if ($tmpservicestatus == $servicestatus) {
686 if ($action ==
'setkey_account_supplier' || $action ==
'setkey_account_suppliertest') {
689 $tmpservice =
'StripeTest';
690 $tmpservicestatus = 0;
691 if ($action ==
'setkey_account_supplier') {
692 $tmpservice =
'StripeLive';
693 $tmpservicestatus = 1;
697 global $stripearrayofkeysbyenv;
698 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus][
'publishable_key'];
700 if ($action ==
'setkey_account_supplier') {
701 $newsup =
GETPOST(
'key_account_supplier',
'alpha');
703 $newsup =
GETPOST(
'key_account_suppliertest',
'alpha');
708 if (empty($newsup)) {
709 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"oauth_token WHERE fk_soc = ".$object->id.
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".$conf->entity;
714 $stripesup = \Stripe\Account::retrieve($newsup);
715 $tokenstring[
'stripe_user_id'] = $stripesup->id;
716 $tokenstring[
'type'] = $stripesup->type;
717 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"oauth_token";
718 $sql .=
" SET tokenstring = '".$db->escape(json_encode($tokenstring)).
"'";
719 $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;
721 $sql .=
" WHERE fk_soc = ".$object->id.
" AND service = '".$db->escape($tmpservice).
"' AND entity = ".$conf->entity;
728 $resql = $db->query($sql);
729 $num = $db->num_rows($resql);
730 if (empty($num) && !empty($newsup)) {
732 $stripesup = \Stripe\Account::retrieve($newsup);
733 $tokenstring[
'stripe_user_id'] = $stripesup->id;
734 $tokenstring[
'type'] = $stripesup->type;
735 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"oauth_token (service, fk_soc, entity, tokenstring)";
736 $sql .=
" VALUES ('".$db->escape($tmpservice).
"', ".((int) $object->id).
", ".((int) $conf->entity).
", '".$db->escape(json_encode($tokenstring)).
"')";
742 $resql = $db->query($sql);
746 if ($tmpservicestatus == $servicestatus) {
747 $stripesupplieracc = $newsup;
755 if ($action ==
'setlocalassourcedefault') {
757 $companypaymentmode->setAsDefault($id);
759 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
760 header(
'Location: '.$url);
766 } elseif ($action ==
'setassourcedefault') {
768 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
769 if (preg_match(
'/pm_|src_/', $source)) {
770 $cu->invoice_settings->default_payment_method = (string) $source;
772 $cu->default_source = (string) $source;
774 $result = $cu->save();
776 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
777 header(
'Location: '.$url);
783 } elseif ($action ==
'deletecard' && $source) {
786 if (preg_match(
'/pm_/', $source)) {
787 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
788 if ($payment_method) {
789 $payment_method->detach();
792 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
793 $card = $cu->sources->retrieve(
"$source");
796 if (method_exists($card,
'detach')) {
798 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
799 $sql .=
" SET stripe_card_ref = null";
800 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
801 $resql = $db->query($sql);
808 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
809 header(
'Location: '.$url);
815 } elseif ($action ==
'deletebank' && $source) {
818 if (preg_match(
'/pm_/', $source)) {
819 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
820 if ($payment_method) {
821 $payment_method->detach();
824 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
825 $card = $cu->sources->retrieve(
"$source");
828 if (method_exists($card,
'detach')) {
830 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
831 $sql .=
" SET stripe_card_ref = null";
832 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
833 $resql = $db->query($sql);
840 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
841 if (
GETPOST(
'page_y',
'int')) {
842 $url .=
'&page_y='.GETPOST(
'page_y',
'int');
845 header(
'Location: '.$url);
861$form =
new Form($db);
865$title = $langs->trans(
"ThirdParty");
866if (
getDolGlobalString(
'MAIN_HTML_TITLE') && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
867 $title = $object->name.
" - ".$langs->trans(
'PaymentInformation');
881 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'),
'',
'warning');
886 $companybankaccount->fetch(0, $object->id);
887 $companypaymentmode->fetch(0,
null, $object->id,
'card');
889 $companybankaccount->fetch($id);
890 $companypaymentmode->fetch($id);
892if (empty($companybankaccount->socid)) {
893 $companybankaccount->socid = $object->id;
896if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
897 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'" method="post">';
898 print
'<input type="hidden" name="token" value="'.newToken().
'">';
899 $actionforadd =
'update';
900 if ($action ==
'editcard') {
901 $actionforadd =
'updatecard';
903 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
904 print
'<input type="hidden" name="id" value="'.GETPOST(
"id",
"int").
'">';
906if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
907 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'" method="post">';
908 print
'<input type="hidden" name="token" value="'.newToken().
'">';
909 $actionforadd =
'add';
910 if ($action ==
'createcard') {
911 $actionforadd =
'addcard';
913 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
918if ($socid && $action !=
'edit' && $action !=
'create' && $action !=
'editcard' && $action !=
'createcard') {
922 if ($action ==
'deletebank') {
923 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);
926 if ($action ==
'deletecard') {
927 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);
930 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
932 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
934 print
'<div class="fichecenter">';
936 print
'<div class="underbanner clearboth"></div>';
937 print
'<table class="border tableforfield centpercent">';
940 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td colspan="2">';
941 print $object->getTypeUrl(1);
945 print
'<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="2">'.$object->prefix_comm.
'</td></tr>';
948 if ($object->client) {
949 print
'<tr><td class="titlefield">';
950 print $langs->trans(
'CustomerCode').
'</td><td colspan="2">';
952 $tmpcheck = $object->check_codeclient();
953 if ($tmpcheck != 0 && $tmpcheck != -5) {
954 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
957 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
958 $resql = $db->query($sql);
963 $obj = $db->fetch_object($resql);
964 $nbFactsClient = $obj->nb;
965 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
966 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
967 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
969 if (isModEnabled(
'commande') && $user->hasRight(
'commande',
'lire')) {
970 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
972 if (isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire')) {
973 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
975 if (isModEnabled(
'contrat') && $user->hasRight(
'contrat',
'lire')) {
976 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
979 if (isModEnabled(
'stripe')) {
981 global $stripearrayofkeysbyenv;
984 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
985 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
986 $tmpstripecu = $stripe->getStripeCustomerAccount($object->id, $tmpservice, $tmpsite_account);
989 print
'<tr><td class="titlefield">';
990 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
992 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Test)',
'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
993 if ($tmpstripecu && $action !=
'editkey_accounttest') {
995 if (!empty($stripeacc)) {
996 $connect = $stripeacc.
'/';
998 $url =
'https://dashboard.stripe.com/'.$connect.
'test/customers/'.$tmpstripecu;
999 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1001 print
'</td><td class="right">';
1002 if (empty($tmpstripecu)) {
1003 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1004 print
'<input type="hidden" name="action" value="synccustomertostripetest">';
1005 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1006 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1007 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1008 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomertest" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1014 $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice][
'publishable_key'];
1015 $tmpstripeacc = $stripe->getStripeAccount($tmpservice);
1016 $tmpstripecu = $stripe->getStripeCustomerAccount($object->id, $tmpservice, $tmpsite_account);
1019 print
'<tr><td class="titlefield">';
1020 print $form->editfieldkey($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1022 print $form->editfieldval($langs->trans(
"StripeCustomerId").
' (Live)',
'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1023 if ($tmpstripecu && $action !=
'editkey_account') {
1025 if (!empty($stripeacc)) {
1026 $connect = $stripeacc.
'/';
1028 $url =
'https://dashboard.stripe.com/'.$connect.
'customers/'.$tmpstripecu;
1029 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$tmpsite_account,
'globe').
'</a>';
1031 print
'</td><td class="right">';
1032 if (empty($tmpstripecu)) {
1033 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1034 print
'<input type="hidden" name="action" value="synccustomertostripe">';
1035 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1036 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1037 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
1038 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomer" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
1045 if ($object->fournisseur) {
1046 print
'<tr><td class="titlefield">';
1047 print $langs->trans(
'SupplierCode').
'</td><td colspan="2">';
1049 $tmpcheck = $object->check_codefournisseur();
1050 if ($tmpcheck != 0 && $tmpcheck != -5) {
1051 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
1054 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
1055 $resql = $db->query($sql);
1059 $obj = $db->fetch_object($resql);
1060 $nbFactsClient = $obj->nb;
1061 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
1062 if (isModEnabled(
'propal') && $user->hasRight(
'propal',
'lire')) {
1063 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
1065 if (isModEnabled(
'commande') && $user->hasRight(
'commande',
'lire')) {
1066 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
1068 if (isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire')) {
1069 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
1071 if (isModEnabled(
'contrat') && $user->hasRight(
'contrat',
'lire')) {
1072 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
1077 if (isModEnabled(
'stripe') && !empty($conf->stripeconnect->enabled) &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 2) {
1078 $stripesupplieracc = $stripe->getStripeAccount($service, $object->id);
1081 print
'<tr><td class="titlefield">';
1082 print $form->editfieldkey(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
1084 print $form->editfieldval(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
1085 if (isModEnabled(
'stripe') && $stripesupplieracc && $action !=
'editkey_account_supplier') {
1088 $url =
'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc;
1089 if ($servicestatus) {
1090 $url =
'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc;
1092 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key '.$site_account,
'globe').
'</a>';
1094 print
'</td><td class="right">';
1095 if (empty($stripesupplieracc)) {
1096 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1097 print
'<input type="hidden" name="action" value="syncsuppliertostripe">';
1098 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1099 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1100 print
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1114 $showcardpaymentmode = 0;
1115 if (isModEnabled(
'stripe')) {
1116 $showcardpaymentmode++;
1120 $listofsources = array();
1122 if (isset($stripe) && is_object($stripe)) {
1124 $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus);
1125 if (!empty($customerstripe->id)) {
1128 $listofsources = $customerstripe->sources->data;
1130 $service =
'StripeTest';
1133 $service =
'StripeLive';
1138 global $stripearrayofkeysbyenv;
1139 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
1142 if (empty($stripeacc)) {
1143 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"));
1144 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"));
1146 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"), array(
"stripe_account" => $stripeacc));
1147 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"), array(
"stripe_account" => $stripeacc));
1150 if ($paymentmethodobjsA->data !=
null && $paymentmethodobjsB->data !=
null) {
1151 $listofsources = array_merge((array) $paymentmethodobjsA->data, (array) $paymentmethodobjsB->data);
1152 } elseif ($paymentmethodobjsB->data !=
null) {
1153 $listofsources = $paymentmethodobjsB->data;
1155 $listofsources = $paymentmethodobjsA->data;
1164 dol_syslog(
"Error when searching/loading Stripe customer for thirdparty id =".$object->id);
1170 if ($showcardpaymentmode && $object->client) {
1171 $morehtmlright =
'';
1173 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=createcard');
1175 print
load_fiche_titre($langs->trans(
'CreditCard'), $morehtmlright,
'fa-credit-card');
1178 print
'<!-- List of card payments -->'.
"\n";
1179 print
'<div class="div-table-responsive-no-min">';
1180 print
'<table class="liste centpercent">'.
"\n";
1181 print
'<tr class="liste_titre">';
1182 print
'<td>'.$langs->trans(
'Label').
'</td>';
1183 print
'<td>'.$form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")).
'</td>';
1184 print
'<td>'.$langs->trans(
'Type').
'</td>';
1185 print
'<td>'.$langs->trans(
'Informations').
'</td>';
1187 print
'<td class="center">'.$langs->trans(
'Default').
'</td>';
1188 print
'<td>'.$langs->trans(
'Note').
'</td>';
1189 print
'<td>'.$langs->trans(
'DateModification').
'</td>';
1191 $parameters = array(
'arrayfields'=>array(),
'param'=>
'',
'sortfield'=>
'',
'sortorder'=>
'',
'linetype'=>
'stripetitle');
1192 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
1193 print $hookmanager->resPrint;
1200 $arrayofremotecard = array();
1207 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_rib";
1208 $sql .=
" WHERE type in ('card')";
1209 $sql .=
" AND fk_soc = ".((int) $object->id);
1210 $sql .=
" AND status = ".((int) $servicestatus);
1212 $resql = $db->query($sql);
1214 $num_rows = $db->num_rows($resql);
1217 while ($i < $num_rows) {
1220 $obj = $db->fetch_object($resql);
1222 $companypaymentmodetemp->fetch($obj->rowid);
1224 $arrayofremotecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref;
1226 print
'<tr class="oddeven" data-rowid="'.((int) $companypaymentmodetemp->id).
'">';
1228 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->label).
'">';
1232 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->stripe_card_ref.(empty($companypaymentmodetemp->stripe_account) ?
'' :
' - '.$companypaymentmodetemp->stripe_account)).
'">';
1233 if (!empty($companypaymentmodetemp->stripe_card_ref) && !empty($companypaymentmodetemp->ext_payment_site)) {
1234 if (isModEnabled(
'stripe') && in_array($companypaymentmodetemp->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1236 if (!empty($stripeacc)) {
1237 $connect = $stripeacc.
'/';
1239 if ($companypaymentmodetemp->ext_payment_site ==
'StripeLive') {
1240 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$companypaymentmodetemp->stripe_card_ref;
1242 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
1244 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe').
' - '.$companypaymentmodetemp->stripe_account,
'globe').
"</a> ";
1255 print
'<td class="minwidth100">';
1256 if ($companypaymentmodetemp->proprio) {
1257 print
'<span class="opacitymedium">'.$companypaymentmodetemp->proprio.
'</span><br>';
1259 if ($companypaymentmodetemp->last_four) {
1260 print
'....'.$companypaymentmodetemp->last_four;
1262 if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) {
1263 print
' - '.sprintf(
"%02d", $companypaymentmodetemp->exp_date_month).
'/'.$companypaymentmodetemp->exp_date_year;
1267 print
'<td class="tdoverflowmax100">';
1268 if ($companypaymentmodetemp->country_code) {
1270 print $img ? $img.
' ' :
'';
1271 print
getCountry($companypaymentmodetemp->country_code, 1);
1273 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1277 print
'<td class="center">';
1278 if (empty($companypaymentmodetemp->default_rib)) {
1279 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=setlocalassourcedefault&token='.newToken().
'">';
1280 print
img_picto($langs->trans(
"Default"),
'off');
1283 print
img_picto($langs->trans(
"Default"),
'on');
1286 if (empty($companypaymentmodetemp->stripe_card_ref)) {
1287 $s = $langs->trans(
"Local");
1289 $s = $langs->trans(
"LocalAndRemote");
1291 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1298 $parameters = array(
'arrayfields'=>array(),
'obj'=>$obj,
'linetype'=>
'stripecard');
1299 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1300 print $hookmanager->resPrint;
1302 print
'<td class="right minwidth50 nowraponall">';
1303 if ($permissiontoaddupdatepaymentinformation) {
1304 if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) {
1305 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=synccardtostripe&socid='.$object->id.
'&id='.$companypaymentmodetemp->id.
'" class="paddingrightonly marginrightonly">'.$langs->trans(
"CreateCardOnStripe").
'</a>';
1308 print
'<a class="editfielda marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=editcard&token='.newToken().
'">';
1309 print
img_picto($langs->trans(
"Modify"),
'edit');
1311 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=deletecard&token='.newToken().
'">';
1312 print
img_picto($langs->trans(
"Delete"),
'delete');
1327 if (is_array($listofsources) && count($listofsources)) {
1328 foreach ($listofsources as $src) {
1329 if (!empty($arrayofremotecard[$src->id])) {
1336 if ($src->object ==
'card') {
1338 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1340 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1342 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1344 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1348 print
'<tr class="oddeven">';
1352 print
'<td class="tdoverflowmax150">';
1354 if (!empty($stripeacc)) {
1355 $connect = $stripeacc.
'/';
1358 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1359 if ($servicestatus) {
1361 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1363 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1371 print
'<td valign="middle">';
1372 if ($src->object ==
'card') {
1373 print
'....'.$src->last4.
' - '.$src->exp_month.
'/'.$src->exp_year;
1375 if ($src->country) {
1377 print $img ? $img.
' ' :
'';
1380 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1382 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1383 print
'<span class="opacitymedium">'.$src->owner->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1386 if ($src->card->country) {
1388 print $img ? $img.
' ' :
'';
1391 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1393 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1394 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1396 if ($src->sepa_debit->country) {
1398 print $img ? $img.
' ' :
'';
1399 print
getCountry($src->sepa_debit->country, 1);
1401 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1403 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1404 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1407 if ($src->card->country) {
1409 print $img ? $img.
' ' :
'';
1412 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1414 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1415 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1417 if ($src->sepa_debit->country) {
1419 print $img ? $img.
' ' :
'';
1420 print
getCountry($src->sepa_debit->country, 1);
1422 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1429 print
'<td class="center" width="50">';
1430 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1431 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1432 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.newToken().
'">';
1433 print
img_picto($langs->trans(
"Default"),
'off');
1436 print
img_picto($langs->trans(
"Default"),
'on');
1440 print $langs->trans(
"Remote");
1449 $parameters = array(
'arrayfields'=>array(),
'stripesource'=>$src,
'linetype'=>
'stripecardremoteonly');
1450 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1451 print $hookmanager->resPrint;
1454 print
'<td class="right nowraponall">';
1455 if ($permissiontoaddupdatepaymentinformation) {
1456 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&source='.$src->id.
'&action=deletecard&token='.newToken().
'">';
1457 print
img_picto($langs->trans(
"Delete"),
'delete');
1466 if ($nbremote == 0 && $nblocal == 0) {
1468 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1476 if (isModEnabled(
'stripe') && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc)) {
1477 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');
1478 $balance = \Stripe\Balance::retrieve(array(
"stripe_account" => $stripesupplieracc));
1479 print
'<table class="liste centpercent">'.
"\n";
1480 print
'<tr class="liste_titre">';
1481 print
'<td>'.$langs->trans(
'Currency').
'</td>';
1482 print
'<td>'.$langs->trans(
'Available').
'</td>';
1483 print
'<td>'.$langs->trans(
'Pending').
'</td>';
1484 print
'<td>'.$langs->trans(
'Total').
'</td>';
1487 $currencybalance = array();
1488 if (is_array($balance->available) && count($balance->available)) {
1489 foreach ($balance->available as $cpt) {
1490 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1491 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1492 $currencybalance[$cpt->currency][
'available'] = $cpt->amount / 100;
1494 $currencybalance[$cpt->currency][
'available'] = $cpt->amount;
1496 $currencybalance[$cpt->currency][
'currency'] = $cpt->currency;
1500 if (is_array($balance->pending) && count($balance->pending)) {
1501 foreach ($balance->pending as $cpt) {
1502 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1503 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1504 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount / 100;
1506 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount;
1511 if (is_array($currencybalance)) {
1512 foreach ($currencybalance as $cpt) {
1513 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>';
1522 if ($permissiontoaddupdatepaymentinformation) {
1523 $morehtmlright =
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"] .
'?socid=' . $object->id .
'&action=create');
1526 print
load_fiche_titre($langs->trans(
"BankAccounts"), $morehtmlright,
'bank');
1530 $arrayofremoteban = array();
1532 $rib_list = $object->get_all_rib();
1534 if (is_array($rib_list)) {
1535 print
'<div class="div-table-responsive-no-min">';
1536 print
'<table class="liste centpercent">';
1538 print
'<tr class="liste_titre">';
1540 print_liste_field_titre($form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")));
1545 if (isModEnabled(
'prelevement')) {
1556 $parameters = array(
'arrayfields'=>array(),
'linetype'=>
'stripebantitle');
1557 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1558 print $hookmanager->resPrint;
1563 foreach ($rib_list as $rib) {
1564 $arrayofremoteban[$rib->stripe_card_ref] = $rib->stripe_card_ref;
1568 print
'<tr class="oddeven">';
1570 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->label).
'">'.
dol_escape_htmltag($rib->label).
'</td>';
1572 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->stripe_card_ref.(empty($rib->stripe_account) ?
'' :
' - '.$rib->stripe_account)).
'">';
1573 if (!empty($rib->stripe_card_ref) && !empty($rib->ext_payment_site)) {
1574 if (isModEnabled(
'stripe') && in_array($rib->ext_payment_site, array(
'StripeTest',
'StripeLive'))) {
1576 if (!empty($stripeacc)) {
1577 $connect = $stripeacc.
'/';
1579 if ($rib->ext_payment_site ==
'StripeLive') {
1580 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$rib->stripe_card_ref;
1582 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$rib->stripe_card_ref;
1584 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1591 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->bank).
'">'.
dol_escape_htmltag($rib->bank).
'</td>';
1594 foreach ($rib->getFieldsToShow() as $val) {
1595 if ($val ==
'BankCode') {
1596 $string .= $rib->code_banque.
' ';
1597 } elseif ($val ==
'BankAccountNumber') {
1598 $string .= $rib->number.
' ';
1599 } elseif ($val ==
'DeskCode') {
1600 $string .= $rib->code_guichet.
' ';
1601 } elseif ($val ==
'BankAccountNumberKey') {
1602 $string .= $rib->cle_rib.
' ';
1611 if (!empty($rib->label) && $rib->number) {
1613 $string .=
' '.img_picto($langs->trans(
"ValueIsNotValid"),
'warning');
1615 $string .=
' '.img_picto($langs->trans(
"ValueIsValid"),
'info');
1618 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($string).
'">';
1622 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->iban).
'">';
1623 if (!empty($rib->iban)) {
1625 print
img_picto($langs->trans(
"IbanNotValid"),
'warning').
' ';
1632 if (!empty($rib->bic)) {
1634 print
img_picto($langs->trans(
"SwiftNotValid"),
'warning').
' ';
1640 if (isModEnabled(
'prelevement')) {
1643 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->rum).
'">'.
dol_escape_htmltag($rib->rum).
'</td>';
1645 print
'<td>'.dol_print_date($rib->date_rum,
'day').
'</td>';
1648 print
'<td>'.dol_escape_htmltag($rib->frstrecur).
'</td>';
1652 print
'<td class="center" width="70">';
1653 if (!$rib->default_rib) {
1654 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?socid='.((int) $object->id).
'&ribid='.((int) $rib->id).
'&action=setasbankdefault&token='.newToken().
'">';
1655 print
img_picto($langs->trans(
"Disabled"),
'off');
1658 print
img_picto($langs->trans(
"Enabled"),
'on');
1663 print
'<td class="center">';
1665 $buttonlabel = $langs->trans(
"BuildDoc");
1666 $forname =
'builddocrib'.$rib->id;
1668 include_once DOL_DOCUMENT_ROOT.
'/core/modules/bank/modules_bank.php';
1672 if (is_array($modellist) && count($modellist)) {
1673 $out .=
'<form action="'.$_SERVER[
"PHP_SELF"].(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#builddoc').
'" name="'.$forname.
'" id="'.$forname.
'_form" method="post">';
1674 $out .=
'<input type="hidden" name="action" value="builddocrib">';
1675 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1676 $out .=
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1677 $out .=
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1679 if (is_array($modellist) && count($modellist) == 1) {
1680 $arraykeys = array_keys($modellist);
1681 $modelselected = $arraykeys[0];
1684 $modelselected = $conf->global->BANKADDON_PDF;
1687 $out .= $form->selectarray(
'modelrib'.$rib->id, $modellist, $modelselected, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth125');
1690 $allowgenifempty = 0;
1694 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
1696 $defaultlang = $langs->getDefaultLang();
1697 $morecss =
'maxwidth150';
1698 if ($conf->browser->layout ==
'phone') {
1699 $morecss =
'maxwidth100';
1701 $out .= $formadmin->select_language($defaultlang,
'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss);
1704 $genbutton =
'<input class="button buttongen reposition nomargintop nomarginbottom" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
1705 $genbutton .=
' type="submit" value="'.$buttonlabel.
'"';
1706 if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) {
1707 $genbutton .=
' disabled';
1710 if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') {
1711 $langs->load(
"errors");
1712 $genbutton .=
' '.img_warning($langs->transnoentitiesnoconv(
"WarningNoDocumentModelActivated"));
1714 if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') {
1717 if (empty($modellist) && !$showempty && $modulepart !=
'unpaid') {
1727 $parameters = array(
'arrayfields'=>array(),
'stripe_card_ref'=>$rib->stripe_card_ref,
'stripe_account'=>$rib->stripe_account,
'linetype'=>
'stripeban');
1728 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1729 print $hookmanager->resPrint;
1733 print
'<td class="right nowraponall">';
1734 $useonlinesignature = 1;
1735 if ($useonlinesignature) {
1736 require_once DOL_DOCUMENT_ROOT .
'/core/lib/signature.lib.php';
1737 print showOnlineSignatureUrl($companybankaccount->element, $rib->id);
1743 print
'<td class="right nowraponall">';
1744 if ($permissiontoaddupdatepaymentinformation) {
1745 if (isModEnabled(
'stripe')) {
1746 if (empty($rib->stripe_card_ref)) {
1747 if ($object->client) {
1749 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&id='.$rib->id.
'&action=syncsepatostripe&token='.newToken().
'">';
1750 print
img_picto($langs->trans(
"CreateBANOnStripe"),
'stripe');
1753 print
'<span class="opacitymedium marginrightonly marginleftonly">';
1754 print
img_picto($langs->trans(
"ThirdPartyMustBeACustomerToCreateBANOnStripe"),
'stripe');
1760 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&id='.$rib->id.
'&action=edit">';
1761 print
img_picto($langs->trans(
"Modify"),
'edit');
1764 print
'<a class="marginrightonly marginleftonly reposition" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&id='.$rib->id.
'&action=deletebank&token='.newToken().
'">';
1765 print
img_picto($langs->trans(
"Delete"),
'delete');
1775 foreach ($listofsources as $src) {
1776 if (!empty($arrayofremoteban[$src->id])) {
1781 if ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1782 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1783 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1784 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1791 print
'<tr class="oddeven">';
1795 print
'<td class="tdoverflowmax150">';
1797 if (!empty($stripeacc)) {
1798 $connect = $stripeacc.
'/';
1801 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1802 if ($servicestatus) {
1804 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1806 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1813 print
'<td valign="middle">';
1816 print
'<td valign="middle">';
1820 print
'<td valign="middle">';
1824 if (isModEnabled(
'prelevement')) {
1826 print
'<td valign="middle">';
1830 print
'<td valign="middle">';
1834 print
'<td valign="middle">';
1840 print
'<td class="center" width="50">';
1841 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1842 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1843 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.newToken().
'">';
1844 print
img_picto($langs->trans(
"Default"),
'off');
1847 print
img_picto($langs->trans(
"Default"),
'on');
1861 $parameters = array(
'arrayfields'=>array(),
'stripe_card_ref'=>$rib->stripe_card_ref,
'stripe_account'=>$rib->stripe_account,
'linetype'=>
'stripebanremoteonly');
1862 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1863 print $hookmanager->resPrint;
1866 print
'<td class="right nowraponall">';
1867 if ($permissiontoaddupdatepaymentinformation) {
1868 print
'<a class="marginleftonly marginrightonly reposition" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&source='.$src->id.
'&action=deletebank&token='.newToken().
'">';
1869 print
img_picto($langs->trans(
"Delete"),
'delete');
1877 if ($nbremote == 0 && $nblocal == 0) {
1879 if (isModEnabled(
'prelevement')) {
1882 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoBANRecord").
'</span></td></tr>';
1892 $parameters = array(
'arrayfields'=>array(),
'param'=>
'',
'sortfield'=>
'',
'sortorder'=>
'',
'linetype'=>
'');
1893 $reshook = $hookmanager->executeHooks(
'printNewTable', $parameters, $object);
1894 print $hookmanager->resPrint;
1899 print
'<div class="fichecenter"><div class="fichehalfleft">';
1900 print
'<a name="builddoc"></a>';
1905 $filedir = $conf->societe->multidir_output[$object->entity].
'/'.$object->id;
1906 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
1908 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);
1914 $result = $companypaymentmodetemp->fetch(0,
null, $object->id,
'ban');
1916 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1918 $result = $ecmfile->fetch(0,
'',
'',
'',
'', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
1920 $companybankaccounttemp->last_main_doc = $ecmfile->filepath.
'/'.$ecmfile->filename;
1921 print
'<br><!-- Link to download main doc -->'.
"\n";
1926 print
'</div><div class="fichehalfright">';
1929 print
'</div></div>';
1955if ($socid && $action ==
'edit' && $permissiontoaddupdatepaymentinformation) {
1958 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1960 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
1962 print
'<div class="underbanner clearboth"></div>';
1966 print
'<div class="div-table-responsive-no-min">';
1967 print
'<table class="border centpercent">';
1969 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Label").
'</td>';
1970 print
'<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.
'"></td></tr>';
1972 print
'<tr><td class="fieldrequired">'.$langs->trans(
"BankName").
'</td>';
1973 print
'<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.
'"></td></tr>';
1976 $bankaccount = $companybankaccount;
1978 foreach ($bankaccount->getFieldsToShow(1) as $val) {
1981 if ($val ==
'BankCode') {
1982 $name =
'code_banque';
1984 $content = $bankaccount->code_banque;
1985 } elseif ($val ==
'DeskCode') {
1986 $name =
'code_guichet';
1988 $content = $bankaccount->code_guichet;
1989 } elseif ($val ==
'BankAccountNumber') {
1992 $content = $bankaccount->number;
1993 } elseif ($val ==
'BankAccountNumberKey') {
1996 $content = $bankaccount->cle_rib;
1997 } elseif ($val ==
'IBAN') {
2000 $content = $bankaccount->iban;
2001 if ($bankaccount->needIBAN()) {
2004 $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';
2005 } elseif ($val ==
'BIC') {
2008 $content = $bankaccount->bic;
2009 if ($bankaccount->needIBAN()) {
2012 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2016 print
'<td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2018 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2020 print $langs->trans($val);
2023 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.$content.
'"></td>';
2027 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2028 print
'<textarea name="domiciliation" rows="4" cols="40" maxlength="255">';
2029 print $companybankaccount->domiciliation;
2030 print
"</textarea></td></tr>";
2032 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2033 print
'<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->proprio.
'"></td></tr>';
2034 print
"</td></tr>\n";
2036 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2037 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" cols="40" maxlength="255">';
2038 print $companybankaccount->owner_address;
2039 print
"</textarea></td></tr>";
2044 if (isModEnabled(
'prelevement')) {
2047 print
'<div class="div-table-responsive-no-min">';
2048 print
'<table class="border centpercent">';
2050 if (empty($companybankaccount->rum)) {
2051 $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
2055 print
'<tr><td class="titlefield">'.$langs->trans(
"RUM").
'</td>';
2056 print
'<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).
'"></td></tr>';
2060 print
'<tr><td class="titlefield">'.$langs->trans(
"DateRUM").
'</td>';
2061 print
'<td>'.$form->selectDate($date_rum ? $date_rum : $companybankaccount->date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2063 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2064 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2065 print $form->selectarray(
"frstrecur", $tblArraychoice,
dol_escape_htmltag(
GETPOST(
'frstrecur',
'alpha') ?
GETPOST(
'frstrecur',
'alpha') : $companybankaccount->frstrecur), 0);
2068 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_...' or 'src_...')</td>";
2069 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
2078 print $form->buttonsSaveCancel(
"Modify");
2082if ($socid && $action ==
'editcard' && $permissiontoaddupdatepaymentinformation) {
2085 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2087 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2089 print
'<div class="nofichecenter">';
2091 print
'<div class="underbanner clearboth"></div>';
2095 print
'<table class="border centpercent">';
2097 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2098 print
'<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.
'"></td></tr>';
2100 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2101 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->proprio.
'"></td></tr>';
2103 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2104 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.
'"></td></tr>';
2106 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2108 print $formother->select_month($companypaymentmode->exp_date_month,
'exp_date_month', 1);
2109 print $formother->selectyear($companypaymentmode->exp_date_year,
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2112 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2113 print
'<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.
'"></td></tr>';
2115 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_... ".$langs->trans(
"or").
" card_....')</td>";
2116 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
2123 print $form->buttonsSaveCancel(
"Modify");
2128if ($socid && $action ==
'create' && $permissiontoaddupdatepaymentinformation) {
2131 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2133 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2135 print
'<div class="nofichecenter">';
2137 print
'<div class="underbanner clearboth"></div>';
2141 print
'<table class="border centpercent">';
2143 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2144 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.(GETPOSTISSET(
'label') ?
GETPOST(
'label') : $object->
name).
'"></td></tr>';
2146 print
'<tr><td>'.$langs->trans(
"Bank").
'</td>';
2147 print
'<td><input class="minwidth200" type="text" id="bank" name="bank" value="'.GETPOST(
'bank').
'"></td></tr>';
2150 foreach ($companybankaccount->getFieldsToShow(1) as $val) {
2153 if ($val ==
'BankCode') {
2154 $name =
'code_banque';
2156 $content = $companybankaccount->code_banque;
2157 } elseif ($val ==
'DeskCode') {
2158 $name =
'code_guichet';
2160 $content = $companybankaccount->code_guichet;
2161 } elseif ($val ==
'BankAccountNumber') {
2164 $content = $companybankaccount->number;
2165 } elseif ($val ==
'BankAccountNumberKey') {
2168 $content = $companybankaccount->cle_rib;
2169 } elseif ($val ==
'IBAN') {
2172 $content = $companybankaccount->iban;
2173 if ($companybankaccount->needIBAN()) {
2176 $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';
2177 } elseif ($val ==
'BIC') {
2180 $content = $companybankaccount->bic;
2181 if ($companybankaccount->needIBAN()) {
2184 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2187 print
'<tr><td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2189 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2191 print $langs->trans($val);
2194 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.
GETPOST($name).
'"></td>';
2198 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2199 print
'<textarea name="domiciliation" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2200 print
GETPOST(
'domiciliation');
2201 print
"</textarea></td></tr>";
2203 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2204 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio').
'"></td></tr>';
2205 print
"</td></tr>\n";
2207 print
'<tr><td class="tdtop">'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2208 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2209 print
GETPOST(
'owner_address');
2210 print
"</textarea></td></tr>";
2214 if (isModEnabled(
'prelevement')) {
2217 print
'<table class="border centpercent">';
2220 print
'<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans(
"RUM"), $langs->trans(
"RUMLong").
'<br>'.$langs->trans(
"RUMWillBeGenerated")).
'</td>';
2221 print
'<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST(
'rum',
'alpha').
'"></td></tr>';
2225 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DateRUM").
'</td>';
2226 print
'<td colspan="4">'.$form->selectDate($date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2228 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2229 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RCUR" => $langs->trans(
"RECUR"));
2230 print $form->selectarray(
"frstrecur", $tblArraychoice, (GETPOSTISSET(
'frstrecur') ?
GETPOST(
'frstrecur') :
'FRST'), 0);
2233 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('src_....')</td>";
2234 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2245 print $form->buttonsSaveCancel(
"Add");
2249if ($socid && $action ==
'createcard' && $permissiontoaddupdatepaymentinformation) {
2252 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2254 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2256 print
'<div class="nofichecenter">';
2258 print
'<div class="underbanner clearboth"></div>';
2262 print
'<table class="border centpercent">';
2264 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2265 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST(
'label',
'alpha').
'"></td></tr>';
2267 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2268 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio',
'alpha').
'"></td></tr>';
2270 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2271 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST(
'cardnumber',
'alpha').
'"></td></tr>';
2273 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2275 print $formother->select_month(
GETPOST(
'exp_date_month',
'int'),
'exp_date_month', 1);
2276 print $formother->selectyear(
GETPOST(
'exp_date_year',
'int'),
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2279 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2280 print
'<td><input class="width50" type="text" name="cvn" value="'.GETPOST(
'cvn',
'alpha').
'"></td></tr>';
2282 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('card_....')</td>";
2283 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2293 print $form->buttonsSaveCancel(
"Add");
2296if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
2299if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
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 informations for a bank account.
checkIbanForAccount(Account $account=null, $ibantocheck=null)
Check IBAN number informations for a bank account.
checkBanForAccount($account)
Check account number informations 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...)
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $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_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
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 formated 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.
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.