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'));
52$source =
GETPOST(
"source",
"alpha");
53$ribid =
GETPOST(
"ribid",
"int");
54$action =
GETPOST(
"action",
'alpha', 3);
55$cancel =
GETPOST(
'cancel',
'alpha');
58$socid =
GETPOST(
"socid",
"int");
60 $socid = $user->socid;
65$object->fetch($socid);
74$extrafields->fetch_name_optionals_label($object->table_element);
77$hookmanager->initHooks(array(
'thirdpartybancard',
'globalcard'));
80$permissiontoread = $user->hasRight(
'societe',
'lire');
81$permissiontoadd = $user->hasRight(
'societe',
'creer');
83$permissiontoaddupdatepaymentinformation = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $permissiontoadd) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->societe->thirdparty_paymentinformation_advance->write)));
91if (isModEnabled(
'stripe')) {
92 $service =
'StripeTest';
94 if (!empty($conf->global->STRIPE_LIVE) && !
GETPOST(
'forcesandbox',
'alpha')) {
95 $service =
'StripeLive';
100 global $stripearrayofkeysbyenv;
101 $site_account = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
103 $stripe =
new Stripe($db);
104 $stripeacc = $stripe->getStripeAccount($service);
105 $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus, $site_account);
120$parameters = array(
'id'=>$socid);
121$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
126if (empty($reshook)) {
129 if (!empty($backtopage)) {
130 header(
"Location: ".$backtopage);
135 if ($action ==
'update') {
138 if (!
GETPOST(
'label',
'alpha')) {
139 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
141 if (!
GETPOST(
'bank',
'alpha')) {
142 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankName")),
null,
'errors');
147 $companybankaccount->fetch($id);
148 if ($companybankaccount->needIBAN() == 1) {
150 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
155 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
162 $companybankaccount->oldcopy =
dol_clone($companybankaccount);
164 $companybankaccount->socid = $object->id;
166 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
167 $companybankaccount->label =
GETPOST(
'label',
'alpha');
168 $companybankaccount->courant =
GETPOST(
'courant',
'alpha');
169 $companybankaccount->clos =
GETPOST(
'clos',
'alpha');
170 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
171 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
172 $companybankaccount->number =
GETPOST(
'number',
'alpha');
173 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
174 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
175 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
176 $companybankaccount->domiciliation =
GETPOST(
'domiciliation',
'alpha');
177 $companybankaccount->proprio =
GETPOST(
'proprio',
'alpha');
178 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
179 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
180 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
182 if (empty($companybankaccount->rum)) {
183 $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
186 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
188 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
190 $companybankaccount->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
192 $result = $companybankaccount->update($user);
195 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
199 if ($companybankaccount->default_rib) {
200 $companybankaccount->setAsDefault($id);
203 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
204 if ($companybankaccount->oldcopy->iban != $companybankaccount->iban) {
209 $url = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id;
210 header(
'Location: '.$url);
216 if ($action ==
'updatecard') {
218 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
219 if (!
GETPOST(
'label',
'alpha')) {
220 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
222 if (!
GETPOST(
'proprio',
'alpha')) {
223 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
226 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
227 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
230 $action =
'createcard';
234 $companypaymentmode->fetch($id);
236 $companybankaccount->oldcopy =
dol_clone($companybankaccount);
238 $companypaymentmode->fk_soc = $object->id;
240 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
241 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
242 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
243 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
244 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
245 $companypaymentmode->exp_date_month =
GETPOST(
'exp_date_month',
'int');
246 $companypaymentmode->exp_date_year =
GETPOST(
'exp_date_year',
'int');
247 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
248 $companypaymentmode->country_code = $object->country_code;
250 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
252 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
254 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
256 $result = $companypaymentmode->update($user);
258 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
261 if ($companypaymentmode->default_rib) {
262 $companypaymentmode->setAsDefault($id);
265 if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) {
266 if ($companybankaccount->oldcopy->number != $companybankaccount->number) {
271 $url = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id;
272 header(
'Location: '.$url);
279 if ($action ==
'add') {
282 if (!
GETPOST(
'label',
'alpha')) {
283 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
292 $companybankaccount->socid = $object->id;
294 $companybankaccount->fetch_thirdparty();
296 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
297 $companybankaccount->label =
GETPOST(
'label',
'alpha');
298 $companybankaccount->courant =
GETPOST(
'courant',
'alpha');
299 $companybankaccount->clos =
GETPOST(
'clos',
'alpha');
300 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
301 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
302 $companybankaccount->number =
GETPOST(
'number',
'alpha');
303 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
304 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
305 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
306 $companybankaccount->domiciliation =
GETPOST(
'domiciliation',
'alpha');
307 $companybankaccount->proprio =
GETPOST(
'proprio',
'alpha');
308 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
309 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
310 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
312 $companybankaccount->datec =
dol_now();
313 $companybankaccount->status = 1;
315 $companybankaccount->bank = trim($companybankaccount->bank);
316 if (empty($companybankaccount->bank) && !empty($companybankaccount->thirdparty)) {
317 $companybankaccount->bank = $langs->trans(
"Bank").
' '.$companybankaccount->thirdparty->name;
319 $companybankaccount->bic = str_replace(
' ',
'', $companybankaccount->bic);
324 if ($companybankaccount->needIBAN() == 1) {
326 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
331 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
338 $result = $companybankaccount->create($user);
341 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
345 if (empty($companybankaccount->rum)) {
346 $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
351 $result = $companybankaccount->update($user);
354 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
362 $url = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id;
363 header(
'Location: '.$url);
372 if ($action ==
'addcard') {
375 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
376 if (!
GETPOST(
'label',
'alpha')) {
377 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
379 if (!
GETPOST(
'proprio',
'alpha')) {
380 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
383 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
384 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
387 $action =
'createcard';
395 $companypaymentmode->fk_soc = $object->id;
396 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
397 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
398 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
399 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
400 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
401 $companypaymentmode->exp_date_month =
GETPOST(
'exp_date_month',
'int');
402 $companypaymentmode->exp_date_year =
GETPOST(
'exp_date_year',
'int');
403 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
404 $companypaymentmode->datec =
dol_now();
405 $companypaymentmode->default_rib = 0;
406 $companypaymentmode->type =
'card';
407 $companypaymentmode->country_code = $object->country_code;
408 $companypaymentmode->status = $servicestatus;
410 if (
GETPOST(
'stripe_card_ref',
'alpha')) {
412 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
414 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
419 $result = $companypaymentmode->create($user);
422 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
423 $action =
'createcard';
430 $url = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id;
431 header(
'Location: '.$url);
439 if ($action ==
'setasbankdefault' &&
GETPOST(
'ribid',
'int') > 0) {
441 $res = $companybankaccount->setAsDefault(
GETPOST(
'ribid',
'int'));
443 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
444 header(
'Location: '.$url);
451 if ($action ==
'confirm_deletecard' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
454 if ($companypaymentmode->fetch($ribid ? $ribid : $id)) {
465 $result = $companypaymentmode->delete($user);
467 $url = $_SERVER[
'PHP_SELF'].
"?socid=".$object->id;
469 header(
'Location: '.$url);
472 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
475 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
478 if ($action ==
'confirm_deletebank' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
481 if ($companybankaccount->fetch($ribid ? $ribid : $id)) {
492 $result = $companybankaccount->delete($user);
495 $url = $_SERVER[
'PHP_SELF'].
"?socid=".$object->id;
497 header(
'Location: '.$url);
500 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
503 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
510 if ($action ==
'builddocrib') {
511 $action =
'builddoc';
513 'use_companybankid'=>
GETPOST(
'companybankid'),
514 'force_dir_output'=>$conf->societe->multidir_output[$object->entity].
'/'.
dol_sanitizeFileName($object->id)
516 $_POST[
'lang_id'] =
GETPOST(
'lang_idrib'.
GETPOST(
'companybankid',
'int'),
'alpha');
517 $_POST[
'model'] =
GETPOST(
'modelrib'.
GETPOST(
'companybankid',
'int'),
'alpha');
521 $upload_dir = $conf->societe->multidir_output[$object->entity];
522 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
527 if (isModEnabled(
'stripe') && class_exists(
'Stripe')) {
528 if ($action ==
'synccustomertostripe') {
529 if ($object->client == 0) {
534 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1);
543 if ($action ==
'synccardtostripe') {
546 $companypaymentmode->fetch($id);
548 if ($companypaymentmode->type !=
'card') {
553 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
563 $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
571 if ($action ==
'syncsepatostripe') {
574 $companypaymentmode->fetch($id);
576 if ($companypaymentmode->type !=
'ban') {
578 $langs->load(
"errors");
582 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
586 $langs->load(
"errors");
587 setEventMessages($langs->trans(
"ErrorStripeCustomerNotFoundCreateFirst"),
null,
'errors');
591 $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
596 setEventMessages(
"", array(
"Bank Account on Stripe",
"BAN is now linked to the Stripe customer account !"));
602 if ($action ==
'setkey_account') {
605 $newcu =
GETPOST(
'key_account',
'alpha');
610 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"societe_account WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account).
"') AND fk_soc = ".$object->id.
" AND status = ".((int) $servicestatus).
" AND entity = ".$conf->entity;
612 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_account";
613 $sql .=
" WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account).
"') AND fk_soc = ".((int) $object->id).
" AND status = ".((int) $servicestatus).
" AND entity = ".$conf->entity;
616 $resql = $db->query($sql);
617 $num = $db->num_rows($resql);
618 if (!empty($newcu)) {
621 $societeaccount->fk_soc = $object->id;
622 $societeaccount->login =
'';
623 $societeaccount->pass_encoding =
'';
624 $societeaccount->site =
'stripe';
625 $societeaccount->status = $servicestatus;
626 $societeaccount->key_account = $newcu;
627 $societeaccount->site_account = $site_account;
628 $result = $societeaccount->create($user);
633 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"societe_account";
634 $sql .=
" SET key_account = '".$db->escape(
GETPOST(
'key_account',
'alpha')).
"', site_account = '".$db->escape($site_account).
"'";
635 $sql .=
" WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account).
"') AND fk_soc = ".((int) $object->id).
" AND status = ".((int) $servicestatus).
" AND entity = ".$conf->entity;
636 $resql = $db->query($sql);
651 if ($action ==
'setkey_account_supplier') {
654 $newsup =
GETPOST(
'key_account_supplier',
'alpha');
658 if (empty($newsup)) {
659 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"oauth_token WHERE fk_soc = ".$object->id.
" AND service = '".$db->escape($service).
"' AND entity = ".$conf->entity;
664 $stripesup = \Stripe\Account::retrieve($db->escape(
GETPOST(
'key_account_supplier',
'alpha')));
665 $tokenstring[
'stripe_user_id'] = $stripesup->id;
666 $tokenstring[
'type'] = $stripesup->type;
667 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"oauth_token";
668 $sql .=
" SET tokenstring = '".$db->escape(json_encode($tokenstring)).
"'";
669 $sql .=
" WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($site_account).
"') AND fk_soc = ".((int) $object->id).
" AND service = '".$db->escape($service).
"' AND entity = ".$conf->entity;
671 $sql .=
" WHERE fk_soc = ".$object->id.
" AND service = '".$db->escape($service).
"' AND entity = ".$conf->entity;
678 $resql = $db->query($sql);
679 $num = $db->num_rows($resql);
680 if (empty($num) && !empty($newsup)) {
682 $stripesup = \Stripe\Account::retrieve($db->escape(
GETPOST(
'key_account_supplier',
'alpha')));
683 $tokenstring[
'stripe_user_id'] = $stripesup->id;
684 $tokenstring[
'type'] = $stripesup->type;
685 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"oauth_token (service, fk_soc, entity, tokenstring)";
686 $sql .=
" VALUES ('".$db->escape($service).
"', ".((int) $object->id).
", ".((int) $conf->entity).
", '".$db->escape(json_encode($tokenstring)).
"')";
692 $resql = $db->query($sql);
696 $stripesupplieracc = $newsup;
703 if ($action ==
'setlocalassourcedefault') {
705 $companypaymentmode->setAsDefault($id);
707 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
708 header(
'Location: '.$url);
714 } elseif ($action ==
'setassourcedefault') {
716 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
717 if (preg_match(
'/pm_|src_/', $source)) {
718 $cu->invoice_settings->default_payment_method = (string) $source;
720 $cu->default_source = (string) $source;
722 $result = $cu->save();
724 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
725 header(
'Location: '.$url);
731 } elseif ($action ==
'deletecard' && $source) {
734 if (preg_match(
'/pm_/', $source)) {
735 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
736 if ($payment_method) {
737 $payment_method->detach();
740 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
741 $card = $cu->sources->retrieve(
"$source");
744 if (method_exists($card,
'detach')) {
746 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
747 $sql .=
" SET stripe_card_ref = null";
748 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
749 $resql = $db->query($sql);
756 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
757 header(
'Location: '.$url);
763 } elseif ($action ==
'deletebank' && $source) {
766 if (preg_match(
'/pm_/', $source)) {
767 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
768 if ($payment_method) {
769 $payment_method->detach();
772 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
773 $card = $cu->sources->retrieve(
"$source");
776 if (method_exists($card,
'detach')) {
778 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
779 $sql .=
" SET stripe_card_ref = null";
780 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
781 $resql = $db->query($sql);
788 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
789 header(
'Location: '.$url);
805$form =
new Form($db);
809$title = $langs->trans(
"ThirdParty");
810if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
811 $title = $object->name.
" - ".$langs->trans(
'PaymentInformation');
824if (isModEnabled(
'stripe') && (empty($conf->global->STRIPE_LIVE) ||
GETPOST(
'forcesandbox',
'alpha'))) {
825 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'),
'',
'warning');
830 $companybankaccount->fetch(0, $object->id);
831 $companypaymentmode->fetch(0,
null, $object->id,
'card');
833 $companybankaccount->fetch($id);
834 $companypaymentmode->fetch($id);
836if (empty($companybankaccount->socid)) {
837 $companybankaccount->socid = $object->id;
840if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
841 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'" method="post">';
842 print
'<input type="hidden" name="token" value="'.newToken().
'">';
843 $actionforadd =
'update';
844 if ($action ==
'editcard') {
845 $actionforadd =
'updatecard';
847 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
848 print
'<input type="hidden" name="id" value="'.GETPOST(
"id",
"int").
'">';
850if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
851 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'" method="post">';
852 print
'<input type="hidden" name="token" value="'.newToken().
'">';
853 $actionforadd =
'add';
854 if ($action ==
'createcard') {
855 $actionforadd =
'addcard';
857 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
862if ($socid && $action !=
'edit' && $action !=
'create' && $action !=
'editcard' && $action !=
'createcard') {
866 if ($action ==
'deletebank') {
867 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);
870 if ($action ==
'deletecard') {
871 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);
874 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
876 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
878 print
'<div class="fichecenter">';
880 print
'<div class="underbanner clearboth"></div>';
881 print
'<table class="border tableforfield centpercent">';
884 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td colspan="2">';
885 print $object->getTypeUrl(1);
888 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
889 print
'<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="2">'.$object->prefix_comm.
'</td></tr>';
892 if ($object->client) {
893 print
'<tr><td class="titlefield">';
894 print $langs->trans(
'CustomerCode').
'</td><td colspan="2">';
896 $tmpcheck = $object->check_codeclient();
897 if ($tmpcheck != 0 && $tmpcheck != -5) {
898 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
901 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
902 $resql = $db->query($sql);
907 $obj = $db->fetch_object($resql);
908 $nbFactsClient = $obj->nb;
909 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
910 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'lire')) {
911 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
913 if (isModEnabled(
'commande') && $user->hasRight(
'commande',
'lire')) {
914 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
916 if (isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire')) {
917 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
919 if (isModEnabled(
'contrat') && $user->hasRight(
'contrat',
'lire')) {
920 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
923 if (isModEnabled(
'stripe')) {
925 print
'<tr><td class="titlefield">';
926 print $form->editfieldkey(
"StripeCustomerId",
'key_account', $stripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
928 print $form->editfieldval(
"StripeCustomerId",
'key_account', $stripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
929 if (isModEnabled(
'stripe') && $stripecu && $action !=
'editkey_account') {
931 if (!empty($stripeacc)) {
932 $connect = $stripeacc.
'/';
934 $url =
'https://dashboard.stripe.com/'.$connect.
'test/customers/'.$stripecu;
935 if ($servicestatus) {
936 $url =
'https://dashboard.stripe.com/'.$connect.
'customers/'.$stripecu;
938 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$site_account,
'globe').
'</a>';
940 print
'</td><td class="right">';
941 if (empty($stripecu)) {
942 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
943 print
'<input type="hidden" name="action" value="synccustomertostripe">';
944 print
'<input type="hidden" name="token" value="'.newToken().
'">';
945 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
946 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
947 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomer" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
954 if ($object->fournisseur) {
955 print
'<tr><td class="titlefield">';
956 print $langs->trans(
'SupplierCode').
'</td><td colspan="2">';
958 $tmpcheck = $object->check_codefournisseur();
959 if ($tmpcheck != 0 && $tmpcheck != -5) {
960 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
963 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
964 $resql = $db->query($sql);
968 $obj = $db->fetch_object($resql);
969 $nbFactsClient = $obj->nb;
970 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
971 if (isModEnabled(
'propal') && $user->hasRight(
'propal',
'lire')) {
972 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
974 if (isModEnabled(
'commande') && $user->hasRight(
'commande',
'lire')) {
975 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
977 if (isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire')) {
978 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
980 if (isModEnabled(
'contrat') && $user->hasRight(
'contrat',
'lire')) {
981 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
985 if (isModEnabled(
'stripe') && !empty($conf->stripeconnect->enabled) &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 2) {
986 $stripesupplieracc = $stripe->getStripeAccount($service, $object->id);
989 print
'<tr><td class="titlefield">';
990 print $form->editfieldkey(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
992 print $form->editfieldval(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
993 if (isModEnabled(
'stripe') && $stripesupplieracc && $action !=
'editkey_account_supplier') {
996 $url =
'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc;
997 if ($servicestatus) {
998 $url =
'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc;
1000 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key '.$site_account,
'globe').
'</a>';
1002 print
'</td><td class="right">';
1003 if (empty($stripesupplieracc)) {
1004 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1005 print
'<input type="hidden" name="action" value="syncsuppliertostripe">';
1006 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1007 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1008 print
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1022 $showcardpaymentmode = 0;
1023 if (isModEnabled(
'stripe')) {
1024 $showcardpaymentmode++;
1028 $listofsources = array();
1030 if (isset($stripe) && is_object($stripe)) {
1032 $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus);
1033 if (!empty($customerstripe->id)) {
1035 if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
1036 $listofsources = $customerstripe->sources->data;
1038 $service =
'StripeTest';
1040 if (!empty($conf->global->STRIPE_LIVE) && !
GETPOST(
'forcesandbox',
'alpha')) {
1041 $service =
'StripeLive';
1046 global $stripearrayofkeysbyenv;
1047 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
1050 if (empty($stripeacc)) {
1051 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"));
1052 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"));
1054 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"), array(
"stripe_account" => $stripeacc));
1055 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"), array(
"stripe_account" => $stripeacc));
1058 if ($paymentmethodobjsA->data !=
null && $paymentmethodobjsB->data !=
null) {
1059 $listofsources = array_merge((array) $paymentmethodobjsA->data, (array) $paymentmethodobjsB->data);
1060 } elseif ($paymentmethodobjsB->data !=
null) {
1061 $listofsources = $paymentmethodobjsB->data;
1063 $listofsources = $paymentmethodobjsA->data;
1072 dol_syslog(
"Error when searching/loading Stripe customer for thirdparty id =".$object->id);
1078 if ($showcardpaymentmode && $object->client) {
1079 $morehtmlright =
'';
1080 if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) {
1081 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=createcard');
1083 print
load_fiche_titre($langs->trans(
'CreditCard'), $morehtmlright,
'fa-credit-card');
1086 print
'<!-- List of card payments -->'.
"\n";
1087 print
'<div class="div-table-responsive-no-min">';
1088 print
'<table class="liste centpercent">'.
"\n";
1089 print
'<tr class="liste_titre">';
1090 print
'<td>'.$langs->trans(
'Label').
'</td>';
1091 print
'<td>'.$form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")).
'</td>';
1092 print
'<td>'.$langs->trans(
'Type').
'</td>';
1093 print
'<td>'.$langs->trans(
'Informations').
'</td>';
1095 print
'<td class="center">'.$langs->trans(
'Default').
'</td>';
1096 print
'<td>'.$langs->trans(
'Note').
'</td>';
1097 print
'<td>'.$langs->trans(
'DateModification').
'</td>';
1099 $parameters = array(
'arrayfields'=>array(),
'param'=>
'',
'sortfield'=>
'',
'sortorder'=>
'',
'linetype'=>
'stripetitle');
1100 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
1101 print $hookmanager->resPrint;
1108 $arrayofremotecard = array();
1111 if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) {
1115 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_rib";
1116 $sql .=
" WHERE type in ('card')";
1117 $sql .=
" AND fk_soc = ".((int) $object->id);
1118 $sql .=
" AND status = ".((int) $servicestatus);
1120 $resql = $db->query($sql);
1122 $num_rows = $db->num_rows($resql);
1125 while ($i < $num_rows) {
1128 $obj = $db->fetch_object($resql);
1130 $companypaymentmodetemp->fetch($obj->rowid);
1132 $arrayofremotecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref;
1134 print
'<tr class="oddeven" data-rowid="'.((int) $companypaymentmodetemp->id).
'">';
1136 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->label).
'">';
1140 print
'<td class="tdoverflowmax150">';
1141 if (!empty($companypaymentmodetemp->stripe_card_ref)) {
1143 if (!empty($stripeacc)) {
1144 $connect = $stripeacc.
'/';
1146 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
1147 if ($servicestatus) {
1148 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$companypaymentmodetemp->stripe_card_ref;
1150 print
'<a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Customer and Publishable key = '.$companypaymentmodetemp->stripe_account,
'globe').
'</a> ';
1159 print
'<td class="minwidth100">';
1160 if ($companypaymentmodetemp->proprio) {
1161 print
'<span class="opacitymedium">'.$companypaymentmodetemp->proprio.
'</span><br>';
1163 if ($companypaymentmodetemp->last_four) {
1164 print
'....'.$companypaymentmodetemp->last_four;
1166 if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) {
1167 print
' - '.sprintf(
"%02d", $companypaymentmodetemp->exp_date_month).
'/'.$companypaymentmodetemp->exp_date_year;
1171 print
'<td class="tdoverflowmax100">';
1172 if ($companypaymentmodetemp->country_code) {
1174 print $img ? $img.
' ' :
'';
1175 print
getCountry($companypaymentmodetemp->country_code, 1);
1177 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1181 print
'<td class="center">';
1182 if (empty($companypaymentmodetemp->default_rib)) {
1183 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=setlocalassourcedefault&token='.newToken().
'">';
1184 print
img_picto($langs->trans(
"Default"),
'off');
1187 print
img_picto($langs->trans(
"Default"),
'on');
1190 if (empty($companypaymentmodetemp->stripe_card_ref)) {
1191 $s = $langs->trans(
"Local");
1193 $s = $langs->trans(
"LocalAndRemote");
1195 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1202 $parameters = array(
'arrayfields'=>array(),
'obj'=>$obj,
'linetype'=>
'stripecard');
1203 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1204 print $hookmanager->resPrint;
1206 print
'<td class="right minwidth50 nowraponall">';
1207 if ($permissiontoaddupdatepaymentinformation) {
1208 if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) {
1209 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=synccardtostripe&socid='.$object->id.
'&id='.$companypaymentmodetemp->id.
'" class="paddingrightonly marginrightonly">'.$langs->trans(
"CreateCardOnStripe").
'</a>';
1212 print
'<a class="editfielda marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=editcard&token='.newToken().
'">';
1213 print
img_picto($langs->trans(
"Modify"),
'edit');
1215 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=deletecard&token='.newToken().
'">';
1216 print
img_picto($langs->trans(
"Delete"),
'delete');
1231 if (is_array($listofsources) && count($listofsources)) {
1232 foreach ($listofsources as $src) {
1233 if (!empty($arrayofremotecard[$src->id])) {
1240 if ($src->object ==
'card') {
1242 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1244 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1246 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1248 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1252 print
'<tr class="oddeven">';
1256 print
'<td class="tdoverflowmax150">';
1258 if (!empty($stripeacc)) {
1259 $connect = $stripeacc.
'/';
1262 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1263 if ($servicestatus) {
1265 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1267 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1275 print
'<td valign="middle">';
1276 if ($src->object ==
'card') {
1277 print
'....'.$src->last4.
' - '.$src->exp_month.
'/'.$src->exp_year;
1279 if ($src->country) {
1281 print $img ? $img.
' ' :
'';
1284 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1286 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1287 print
'<span class="opacitymedium">'.$src->owner->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1290 if ($src->card->country) {
1292 print $img ? $img.
' ' :
'';
1295 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1297 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1298 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1300 if ($src->sepa_debit->country) {
1302 print $img ? $img.
' ' :
'';
1303 print
getCountry($src->sepa_debit->country, 1);
1305 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1307 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1308 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1311 if ($src->card->country) {
1313 print $img ? $img.
' ' :
'';
1316 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1318 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1319 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1321 if ($src->sepa_debit->country) {
1323 print $img ? $img.
' ' :
'';
1324 print
getCountry($src->sepa_debit->country, 1);
1326 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1333 print
'<td class="center" width="50">';
1334 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1335 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1336 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.newToken().
'">';
1337 print
img_picto($langs->trans(
"Default"),
'off');
1340 print
img_picto($langs->trans(
"Default"),
'on');
1344 print $langs->trans(
"Remote");
1353 $parameters = array(
'arrayfields'=>array(),
'stripesource'=>$src,
'linetype'=>
'stripecardremoteonly');
1354 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1355 print $hookmanager->resPrint;
1358 print
'<td class="right nowraponall">';
1359 if ($permissiontoaddupdatepaymentinformation) {
1360 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&source='.$src->id.
'&action=deletecard&token='.newToken().
'">';
1361 print
img_picto($langs->trans(
"Delete"),
'delete');
1370 if ($nbremote == 0 && $nblocal == 0) {
1371 $colspan = (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD) ? 10 : 9);
1372 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1380 if (isModEnabled(
'stripe') && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc)) {
1381 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');
1382 $balance = \Stripe\Balance::retrieve(array(
"stripe_account" => $stripesupplieracc));
1383 print
'<table class="liste centpercent">'.
"\n";
1384 print
'<tr class="liste_titre">';
1385 print
'<td>'.$langs->trans(
'Currency').
'</td>';
1386 print
'<td>'.$langs->trans(
'Available').
'</td>';
1387 print
'<td>'.$langs->trans(
'Pending').
'</td>';
1388 print
'<td>'.$langs->trans(
'Total').
'</td>';
1391 $currencybalance = array();
1392 if (is_array($balance->available) && count($balance->available)) {
1393 foreach ($balance->available as $cpt) {
1394 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1395 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1396 $currencybalance[$cpt->currency][
'available'] = $cpt->amount / 100;
1398 $currencybalance[$cpt->currency][
'available'] = $cpt->amount;
1400 $currencybalance[$cpt->currency][
'currency'] = $cpt->currency;
1404 if (is_array($balance->pending) && count($balance->pending)) {
1405 foreach ($balance->pending as $cpt) {
1406 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1407 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1408 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount / 100;
1410 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount;
1415 if (is_array($currencybalance)) {
1416 foreach ($currencybalance as $cpt) {
1417 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>';
1426 if ($permissiontoaddupdatepaymentinformation) {
1427 $morehtmlright =
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"] .
'?socid=' . $object->id .
'&action=create');
1430 print
load_fiche_titre($langs->trans(
"BankAccounts"), $morehtmlright,
'bank');
1432 $nblocal = 0; $nbremote = 0;
1433 $arrayofremoteban = array();
1435 $rib_list = $object->get_all_rib();
1437 if (is_array($rib_list)) {
1438 print
'<div class="div-table-responsive-no-min">';
1439 print
'<table class="liste centpercent">';
1441 print
'<tr class="liste_titre">';
1443 print_liste_field_titre($form->textwithpicto($langs->trans(
'ExternalSystemID'), $langs->trans(
"IDOfPaymentInAnExternalSystem")));
1448 if (isModEnabled(
'prelevement')) {
1456 $parameters = array(
'arrayfields'=>array(),
'linetype'=>
'stripebantitle');
1457 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1458 print $hookmanager->resPrint;
1463 foreach ($rib_list as $rib) {
1464 $arrayofremoteban[$rib->stripe_card_ref] = $rib->stripe_card_ref;
1468 print
'<tr class="oddeven">';
1470 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($rib->label).
'">'.
dol_escape_htmltag($rib->label).
'</td>';
1472 print
'<td class="tdoverflowmax150">';
1473 if ($rib->stripe_card_ref) {
1475 if (!empty($stripeacc)) {
1476 $connect = $stripeacc.
'/';
1479 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$rib->stripe_card_ref;
1480 if ($servicestatus) {
1482 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$rib->stripe_card_ref;
1484 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1486 print $rib->stripe_card_ref;
1489 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->bank).
'">'.
dol_escape_htmltag($rib->bank).
'</td>';
1492 foreach ($rib->getFieldsToShow() as $val) {
1493 if ($val ==
'BankCode') {
1494 $string .= $rib->code_banque.
' ';
1495 } elseif ($val ==
'BankAccountNumber') {
1496 $string .= $rib->number.
' ';
1497 } elseif ($val ==
'DeskCode') {
1498 $string .= $rib->code_guichet.
' ';
1499 } elseif ($val ==
'BankAccountNumberKey') {
1500 $string .= $rib->cle_rib.
' ';
1509 if (!empty($rib->label) && $rib->number) {
1511 $string .=
' '.img_picto($langs->trans(
"ValueIsNotValid"),
'warning');
1513 $string .=
' '.img_picto($langs->trans(
"ValueIsValid"),
'info');
1516 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($string).
'">';
1520 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->iban).
'">';
1521 if (!empty($rib->iban)) {
1523 print
img_picto($langs->trans(
"IbanNotValid"),
'warning').
' ';
1530 if (!empty($rib->bic)) {
1532 print
img_picto($langs->trans(
"SwiftNotValid"),
'warning').
' ';
1538 if (isModEnabled(
'prelevement')) {
1541 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->rum).
'">'.
dol_escape_htmltag($rib->rum).
'</td>';
1543 print
'<td>'.dol_print_date($rib->date_rum,
'day').
'</td>';
1546 print
'<td>'.$rib->frstrecur.
'</td>';
1550 print
'<td class="center" width="70">';
1551 if (!$rib->default_rib) {
1552 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&ribid='.$rib->id.
'&action=setasbankdefault&token='.newToken().
'">';
1553 print
img_picto($langs->trans(
"Disabled"),
'off');
1556 print
img_picto($langs->trans(
"Enabled"),
'on');
1561 print
'<td class="center">';
1563 $buttonlabel = $langs->trans(
"BuildDoc");
1564 $forname =
'builddocrib'.$rib->id;
1566 include_once DOL_DOCUMENT_ROOT.
'/core/modules/bank/modules_bank.php';
1570 if (is_array($modellist) && count($modellist)) {
1571 $out .=
'<form action="'.$_SERVER[
"PHP_SELF"].(empty($conf->global->MAIN_JUMP_TAG) ?
'' :
'#builddoc').
'" name="'.$forname.
'" id="'.$forname.
'_form" method="post">';
1572 $out .=
'<input type="hidden" name="action" value="builddocrib">';
1573 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1574 $out .=
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1575 $out .=
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1577 if (is_array($modellist) && count($modellist) == 1) {
1578 $arraykeys = array_keys($modellist);
1579 $modelselected = $arraykeys[0];
1581 if (!empty($conf->global->BANKADDON_PDF)) {
1582 $modelselected = $conf->global->BANKADDON_PDF;
1585 $out .= $form->selectarray(
'modelrib'.$rib->id, $modellist, $modelselected, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100 maxwidth125');
1588 $allowgenifempty = 0;
1592 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
1594 $defaultlang = $langs->getDefaultLang();
1595 $morecss =
'maxwidth150';
1596 if ($conf->browser->layout ==
'phone') {
1597 $morecss =
'maxwidth100';
1599 $out .= $formadmin->select_language($defaultlang,
'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss);
1602 $genbutton =
'<input class="button buttongen reposition nomargintop nomarginbottom" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
1603 $genbutton .=
' type="submit" value="'.$buttonlabel.
'"';
1604 if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) {
1605 $genbutton .=
' disabled';
1608 if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') {
1609 $langs->load(
"errors");
1610 $genbutton .=
' '.img_warning($langs->transnoentitiesnoconv(
"WarningNoDocumentModelActivated"));
1612 if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') {
1615 if (empty($modellist) && !$showempty && $modulepart !=
'unpaid') {
1625 $parameters = array(
'arrayfields'=>array(),
'stripe_card_ref'=>$rib->stripe_card_ref,
'stripe_account'=>$rib->stripe_account,
'linetype'=>
'stripeban');
1626 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1627 print $hookmanager->resPrint;
1630 print
'<td class="right nowraponall">';
1631 if ($permissiontoaddupdatepaymentinformation) {
1632 if (empty($rib->stripe_card_ref)) {
1634 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&id='.$rib->id.
'&action=syncsepatostripe&token='.newToken().
'">';
1635 print
img_picto($langs->trans(
"CreateBANOnStripe"),
'stripe');
1639 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&id='.$rib->id.
'&action=edit">';
1640 print
img_picto($langs->trans(
"Modify"),
'edit');
1643 print
'<a class="marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&id='.$rib->id.
'&action=deletebank&token='.newToken().
'">';
1644 print
img_picto($langs->trans(
"Delete"),
'delete');
1654 foreach ($listofsources as $src) {
1655 if (!empty($arrayofremoteban[$src->id])) {
1660 if ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1661 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1662 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1663 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1670 print
'<tr class="oddeven">';
1674 print
'<td class="tdoverflowmax150">';
1676 if (!empty($stripeacc)) {
1677 $connect = $stripeacc.
'/';
1680 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1681 if ($servicestatus) {
1683 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1685 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1692 print
'<td valign="middle">';
1695 print
'<td valign="middle">';
1699 print
'<td valign="middle">';
1703 if (isModEnabled(
'prelevement')) {
1705 print
'<td valign="middle">';
1709 print
'<td valign="middle">';
1713 print
'<td valign="middle">';
1719 print
'<td class="center" width="50">';
1720 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1721 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1722 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.newToken().
'">';
1723 print
img_picto($langs->trans(
"Default"),
'off');
1726 print
img_picto($langs->trans(
"Default"),
'on');
1740 $parameters = array(
'arrayfields'=>array(),
'stripe_card_ref'=>$rib->stripe_card_ref,
'stripe_account'=>$rib->stripe_account,
'linetype'=>
'stripebanremoteonly');
1741 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1742 print $hookmanager->resPrint;
1745 print
'<td class="right nowraponall">';
1746 if ($permissiontoaddupdatepaymentinformation) {
1747 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&source='.$src->id.
'&action=deletebank&token='.newToken().
'">';
1748 print
img_picto($langs->trans(
"Delete"),
'delete');
1756 if ($nbremote == 0 && $nblocal == 0) {
1758 if (isModEnabled(
'prelevement')) {
1761 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoBANRecord").
'</span></td></tr>';
1771 $parameters = array(
'arrayfields'=>array(),
'param'=>
'',
'sortfield'=>
'',
'sortorder'=>
'',
'linetype'=>
'');
1772 $reshook = $hookmanager->executeHooks(
'printNewTable', $parameters, $object);
1773 print $hookmanager->resPrint;
1775 if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) {
1778 print
'<div class="fichecenter"><div class="fichehalfleft">';
1779 print
'<a name="builddoc"></a>';
1784 $filedir = $conf->societe->multidir_output[$object->entity].
'/'.$object->id;
1785 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
1787 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);
1790 if (!empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) {
1793 $result = $companypaymentmodetemp->fetch(0,
null, $object->id,
'ban');
1795 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1797 $result = $ecmfile->fetch(0,
'',
'',
'',
'', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
1799 $companybankaccounttemp->last_main_doc = $ecmfile->filepath.
'/'.$ecmfile->filename;
1800 print
'<br><!-- Link to download main doc -->'.
"\n";
1805 print
'</div><div class="fichehalfright">';
1808 print
'</div></div>';
1834if ($socid && $action ==
'edit' && $permissiontoaddupdatepaymentinformation) {
1837 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1839 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
1841 print
'<div class="underbanner clearboth"></div>';
1845 print
'<div class="div-table-responsive-no-min">';
1846 print
'<table class="border centpercent">';
1848 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Label").
'</td>';
1849 print
'<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.
'"></td></tr>';
1851 print
'<tr><td class="fieldrequired">'.$langs->trans(
"BankName").
'</td>';
1852 print
'<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.
'"></td></tr>';
1855 foreach ($companybankaccount->getFieldsToShow(1) as $val) {
1858 if ($val ==
'BankCode') {
1859 $name =
'code_banque';
1861 $content = $companybankaccount->code_banque;
1862 } elseif ($val ==
'DeskCode') {
1863 $name =
'code_guichet';
1865 $content = $companybankaccount->code_guichet;
1866 } elseif ($val ==
'BankAccountNumber') {
1869 $content = $companybankaccount->number;
1870 } elseif ($val ==
'BankAccountNumberKey') {
1873 $content = $companybankaccount->cle_rib;
1874 } elseif ($val ==
'IBAN') {
1877 $content = $companybankaccount->iban;
1878 if ($companybankaccount->needIBAN()) {
1881 $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';
1882 } elseif ($val ==
'BIC') {
1885 $content = $companybankaccount->bic;
1886 if ($companybankaccount->needIBAN()) {
1889 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
1892 print
'<tr><td'.($require ?
' class="fieldrequired" ' :
'').
'>';
1894 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
1896 print $langs->trans($val);
1899 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.$content.
'"></td>';
1903 print
'<tr><td>'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
1904 print
'<textarea name="domiciliation" rows="4" cols="40" maxlength="255">';
1905 print $companybankaccount->domiciliation;
1906 print
"</textarea></td></tr>";
1908 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
1909 print
'<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->proprio.
'"></td></tr>';
1910 print
"</td></tr>\n";
1912 print
'<tr><td>'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
1913 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" cols="40" maxlength="255">';
1914 print $companybankaccount->owner_address;
1915 print
"</textarea></td></tr>";
1920 if (isModEnabled(
'prelevement')) {
1923 print
'<div class="div-table-responsive-no-min">';
1924 print
'<table class="border centpercent">';
1926 if (empty($companybankaccount->rum)) {
1927 $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
1931 print
'<tr><td class="titlefield">'.$langs->trans(
"RUM").
'</td>';
1932 print
'<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).
'"></td></tr>';
1936 print
'<tr><td class="titlefield">'.$langs->trans(
"DateRUM").
'</td>';
1937 print
'<td>'.$form->selectDate($date_rum ? $date_rum : $companybankaccount->date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
1939 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
1940 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RECUR" => $langs->trans(
"RECUR"));
1941 print $form->selectarray(
"frstrecur", $tblArraychoice,
dol_escape_htmltag(
GETPOST(
'frstrecur',
'alpha') ?
GETPOST(
'frstrecur',
'alpha') : $companybankaccount->frstrecur), 0);
1944 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_...' or 'src_...')</td>";
1945 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
1954 print $form->buttonsSaveCancel(
"Modify");
1958if ($socid && $action ==
'editcard' && $permissiontoaddupdatepaymentinformation) {
1961 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1963 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
1965 print
'<div class="nofichecenter">';
1967 print
'<div class="underbanner clearboth"></div>';
1971 print
'<table class="border centpercent">';
1973 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
1974 print
'<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.
'"></td></tr>';
1976 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
1977 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->proprio.
'"></td></tr>';
1979 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
1980 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.
'"></td></tr>';
1982 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
1984 print $formother->select_month($companypaymentmode->exp_date_month,
'exp_date_month', 1);
1985 print $formother->selectyear($companypaymentmode->exp_date_year,
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
1988 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
1989 print
'<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.
'"></td></tr>';
1991 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('pm_... ".$langs->trans(
"or").
" card_....')</td>";
1992 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
1999 print $form->buttonsSaveCancel(
"Modify");
2004if ($socid && $action ==
'create' && $permissiontoaddupdatepaymentinformation) {
2007 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2009 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2011 print
'<div class="nofichecenter">';
2013 print
'<div class="underbanner clearboth"></div>';
2017 print
'<table class="border centpercent">';
2019 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2020 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.(GETPOSTISSET(
'label') ?
GETPOST(
'label') : $object->
name).
'"></td></tr>';
2022 print
'<tr><td>'.$langs->trans(
"Bank").
'</td>';
2023 print
'<td><input class="minwidth200" type="text" id="bank" name="bank" value="'.GETPOST(
'bank').
'"></td></tr>';
2026 foreach ($companybankaccount->getFieldsToShow(1) as $val) {
2029 if ($val ==
'BankCode') {
2030 $name =
'code_banque';
2032 $content = $companybankaccount->code_banque;
2033 } elseif ($val ==
'DeskCode') {
2034 $name =
'code_guichet';
2036 $content = $companybankaccount->code_guichet;
2037 } elseif ($val ==
'BankAccountNumber') {
2040 $content = $companybankaccount->number;
2041 } elseif ($val ==
'BankAccountNumberKey') {
2044 $content = $companybankaccount->cle_rib;
2045 } elseif ($val ==
'IBAN') {
2048 $content = $companybankaccount->iban;
2049 if ($companybankaccount->needIBAN()) {
2052 $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';
2053 } elseif ($val ==
'BIC') {
2056 $content = $companybankaccount->bic;
2057 if ($companybankaccount->needIBAN()) {
2060 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2063 print
'<tr><td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2065 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2067 print $langs->trans($val);
2070 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.
GETPOST($name).
'"></td>';
2074 print
'<tr><td>'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2075 print
'<textarea name="domiciliation" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2076 print
GETPOST(
'domiciliation');
2077 print
"</textarea></td></tr>";
2079 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2080 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio').
'"></td></tr>';
2081 print
"</td></tr>\n";
2083 print
'<tr><td>'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2084 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2085 print
GETPOST(
'owner_address');
2086 print
"</textarea></td></tr>";
2090 if (isModEnabled(
'prelevement')) {
2093 print
'<table class="border centpercent">';
2096 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"RUM").
'</td>';
2097 print
'<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST(
'rum',
'alpha').
'"> <div class="opacitymedium">'.$langs->trans(
"RUMWillBeGenerated").
'</div></td></tr>';
2101 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DateRUM").
'</td>';
2102 print
'<td colspan="4">'.$form->selectDate($date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
2104 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
2105 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RECUR" => $langs->trans(
"RECUR"));
2106 print $form->selectarray(
"frstrecur", $tblArraychoice, (GETPOSTISSET(
'frstrecur') ?
GETPOST(
'frstrecur') :
'FRST'), 0);
2109 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('src_....')</td>";
2110 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2121 print $form->buttonsSaveCancel(
"Add");
2125if ($socid && $action ==
'createcard' && $permissiontoaddupdatepaymentinformation) {
2128 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2130 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2132 print
'<div class="nofichecenter">';
2134 print
'<div class="underbanner clearboth"></div>';
2138 print
'<table class="border centpercent">';
2140 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2141 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST(
'label',
'alpha').
'"></td></tr>';
2143 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2144 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio',
'alpha').
'"></td></tr>';
2146 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2147 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST(
'cardnumber',
'alpha').
'"></td></tr>';
2149 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2151 print $formother->select_month(
GETPOST(
'exp_date_month',
'int'),
'exp_date_month', 1);
2152 print $formother->selectyear(
GETPOST(
'exp_date_year',
'int'),
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2155 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2156 print
'<td><input class="width50" type="text" name="cvn" value="'.GETPOST(
'cvn',
'alpha').
'"></td></tr>';
2158 print
'<tr><td>'.$langs->trans(
"ExternalSystemID").
" ('card_....')</td>";
2159 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2169 print $form->buttonsSaveCancel(
"Add");
2172if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
2175if ($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.
checkIbanForAccount(Account $account)
Check IBAN number informations for a bank account.
checkBanForAccount($account)
Check account number informations for a bank account.
checkSwiftForAccount($account)
Check SWIFT 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 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.
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.