34 require
'../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companypaymentmode.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
47 $langs->loadLangs(array(
"companies",
"commercial",
"banks",
"bills",
'paypal',
'stripe',
'withdrawals'));
51 $socid =
GETPOST(
"socid",
"int");
53 $socid = $user->socid;
60 $source =
GETPOST(
"source",
"alpha");
61 $ribid =
GETPOST(
"ribid",
"int");
62 $action =
GETPOST(
"action",
'alpha', 3);
63 $cancel =
GETPOST(
'cancel',
'alpha');
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 = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $permissiontoadd) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->societe->thirdparty_paymentinformation_advance->write)));
88 $service =
'StripeTest';
90 if (!empty($conf->global->STRIPE_LIVE) && !
GETPOST(
'forcesandbox',
'alpha')) {
91 $service =
'StripeLive';
96 global $stripearrayofkeysbyenv;
97 $site_account = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
100 $stripeacc = $stripe->getStripeAccount($service);
101 $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus, $site_account);
115 $parameters = array(
'id'=>$socid);
116 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
121 if (empty($reshook)) {
124 if (!empty($backtopage)) {
125 header(
"Location: ".$backtopage);
130 if ($action ==
'update') {
133 if (!
GETPOST(
'label',
'alpha')) {
134 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
136 if (!
GETPOST(
'bank',
'alpha')) {
137 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankName")),
null,
'errors');
142 $companybankaccount->fetch($id);
143 if ($companybankaccount->needIBAN() == 1) {
145 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
150 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
157 $companybankaccount->socid = $object->id;
159 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
160 $companybankaccount->label =
GETPOST(
'label',
'alpha');
161 $companybankaccount->courant =
GETPOST(
'courant',
'alpha');
162 $companybankaccount->clos =
GETPOST(
'clos',
'alpha');
163 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
164 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
165 $companybankaccount->number =
GETPOST(
'number',
'alpha');
166 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
167 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
168 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
169 $companybankaccount->domiciliation =
GETPOST(
'domiciliation',
'alpha');
170 $companybankaccount->proprio =
GETPOST(
'proprio',
'alpha');
171 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
172 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
173 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
175 if (empty($companybankaccount->rum)) {
176 $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
179 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
181 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
183 $companybankaccount->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
185 $result = $companybankaccount->update($user);
187 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
190 if ($companybankaccount->default_rib) {
191 $companybankaccount->setAsDefault($id);
194 $url = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id;
195 header(
'Location: '.$url);
201 if ($action ==
'updatecard') {
203 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
204 if (!
GETPOST(
'label',
'alpha')) {
205 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
207 if (!
GETPOST(
'proprio',
'alpha')) {
208 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
211 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
212 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
215 $action =
'createcard';
219 $companypaymentmode->fetch($id);
221 $companypaymentmode->fk_soc = $object->id;
223 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
224 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
225 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
226 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
227 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
228 $companypaymentmode->exp_date_month =
GETPOST(
'exp_date_month',
'int');
229 $companypaymentmode->exp_date_year =
GETPOST(
'exp_date_year',
'int');
230 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
231 $companypaymentmode->country_code = $object->country_code;
233 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
235 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
237 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
239 $result = $companypaymentmode->update($user);
241 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
244 if ($companypaymentmode->default_rib) {
245 $companypaymentmode->setAsDefault($id);
248 $url = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id;
249 header(
'Location: '.$url);
255 if ($action ==
'add') {
259 if (!
GETPOST(
'label',
'alpha')) {
260 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
262 if (!
GETPOST(
'bank',
'alpha')) {
263 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankName")),
null,
'errors');
273 $companybankaccount->socid = $object->id;
275 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
276 $companybankaccount->label =
GETPOST(
'label',
'alpha');
277 $companybankaccount->courant =
GETPOST(
'courant',
'alpha');
278 $companybankaccount->clos =
GETPOST(
'clos',
'alpha');
279 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
280 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
281 $companybankaccount->number =
GETPOST(
'number',
'alpha');
282 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
283 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
284 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
285 $companybankaccount->domiciliation =
GETPOST(
'domiciliation',
'alpha');
286 $companybankaccount->proprio =
GETPOST(
'proprio',
'alpha');
287 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
288 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
289 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
291 $companybankaccount->datec =
dol_now();
292 $companybankaccount->status = 1;
297 if ($companybankaccount->needIBAN() == 1) {
299 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")),
null,
'errors');
304 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")),
null,
'errors');
311 $result = $companybankaccount->create($user);
314 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
318 if (empty($companybankaccount->rum)) {
319 $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
324 $result = $companybankaccount->update($user);
327 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
335 $url = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id;
336 header(
'Location: '.$url);
344 if ($action ==
'addcard') {
347 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha')) {
348 if (!
GETPOST(
'label',
'alpha')) {
349 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
351 if (!
GETPOST(
'proprio',
'alpha')) {
352 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")),
null,
'errors');
355 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0)) {
356 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")),
null,
'errors');
359 $action =
'createcard';
367 $companypaymentmode->fk_soc = $object->id;
368 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
369 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
370 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
371 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
372 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
373 $companypaymentmode->exp_date_month =
GETPOST(
'exp_date_month',
'int');
374 $companypaymentmode->exp_date_year =
GETPOST(
'exp_date_year',
'int');
375 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
376 $companypaymentmode->datec =
dol_now();
377 $companypaymentmode->default_rib = 0;
378 $companypaymentmode->type =
'card';
379 $companypaymentmode->country_code = $object->country_code;
380 $companypaymentmode->status = $servicestatus;
382 if (
GETPOST(
'stripe_card_ref',
'alpha')) {
384 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
386 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
391 $result = $companypaymentmode->create($user);
394 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
395 $action =
'createcard';
402 $url = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id;
403 header(
'Location: '.$url);
411 if ($action ==
'setasbankdefault' &&
GETPOST(
'ribid',
'int') > 0) {
413 $res = $companybankaccount->setAsDefault(
GETPOST(
'ribid',
'int'));
415 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
416 header(
'Location: '.$url);
423 if ($action ==
'confirm_deletecard' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
425 if ($companypaymentmode->fetch($ribid ? $ribid : $id)) {
436 $result = $companypaymentmode->delete($user);
438 $url = $_SERVER[
'PHP_SELF'].
"?socid=".$object->id;
440 header(
'Location: '.$url);
443 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
446 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
449 if ($action ==
'confirm_delete' &&
GETPOST(
'confirm',
'alpha') ==
'yes') {
451 if ($companybankaccount->fetch($ribid ? $ribid : $id)) {
462 $result = $companybankaccount->delete($user);
465 $url = $_SERVER[
'PHP_SELF'].
"?socid=".$object->id;
467 header(
'Location: '.$url);
470 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
473 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
480 if ($action ==
'builddocrib') {
481 $action =
'builddoc';
483 'use_companybankid'=>
GETPOST(
'companybankid'),
484 'force_dir_output'=>$conf->societe->multidir_output[$object->entity].
'/'.
dol_sanitizeFileName($object->id)
486 $_POST[
'lang_id'] =
GETPOST(
'lang_idrib'.
GETPOST(
'companybankid',
'int'),
'alpha');
487 $_POST[
'model'] =
GETPOST(
'modelrib'.
GETPOST(
'companybankid',
'int'),
'alpha');
491 $upload_dir = $conf->societe->multidir_output[$object->entity];
492 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
498 if ($action ==
'synccustomertostripe') {
499 if ($object->client == 0) {
504 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1);
513 if ($action ==
'synccardtostripe') {
515 $companypaymentmode->fetch($id);
517 if ($companypaymentmode->type !=
'card') {
522 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
532 $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
540 if ($action ==
'syncsepatostripe') {
542 $companypaymentmode->fetch($id);
544 if ($companypaymentmode->type !=
'ban') {
546 $langs->load(
"errors");
550 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
554 $langs->load(
"errors");
555 setEventMessages($langs->trans(
"ErrorStripeCustomerNotFoundCreateFirst"),
null,
'errors');
559 $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
564 setEventMessages(
"", array(
"Bank Account on Stripe",
"BAN is now linked to the Stripe customer account !"));
570 if ($action ==
'setkey_account') {
573 $newcu =
GETPOST(
'key_account',
'alpha');
578 $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;
580 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_account";
581 $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;
584 $resql = $db->query($sql);
585 $num = $db->num_rows(
$resql);
586 if (!empty($newcu)) {
589 $societeaccount->fk_soc = $object->id;
590 $societeaccount->login =
'';
591 $societeaccount->pass_encoding =
'';
592 $societeaccount->site =
'stripe';
593 $societeaccount->status = $servicestatus;
594 $societeaccount->key_account = $newcu;
595 $societeaccount->site_account = $site_account;
596 $result = $societeaccount->create($user);
601 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"societe_account";
602 $sql .=
" SET key_account = '".$db->escape(
GETPOST(
'key_account',
'alpha')).
"', site_account = '".$db->escape($site_account).
"'";
603 $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;
604 $resql = $db->query($sql);
619 if ($action ==
'setkey_account_supplier') {
622 $newsup =
GETPOST(
'key_account_supplier',
'alpha');
626 if (empty($newsup)) {
627 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"oauth_token WHERE fk_soc = ".$object->id.
" AND service = '".$db->escape($service).
"' AND entity = ".$conf->entity;
632 $stripesup = \Stripe\Account::retrieve($db->escape(
GETPOST(
'key_account_supplier',
'alpha')));
633 $tokenstring[
'stripe_user_id'] = $stripesup->id;
634 $tokenstring[
'type'] = $stripesup->type;
635 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"oauth_token";
636 $sql .=
" SET tokenstring = '".$db->escape(json_encode($tokenstring)).
"'";
637 $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;
639 $sql .=
" WHERE fk_soc = ".$object->id.
" AND service = '".$db->escape($service).
"' AND entity = ".$conf->entity;
646 $resql = $db->query($sql);
647 $num = $db->num_rows(
$resql);
648 if (empty($num) && !empty($newsup)) {
650 $stripesup = \Stripe\Account::retrieve($db->escape(
GETPOST(
'key_account_supplier',
'alpha')));
651 $tokenstring[
'stripe_user_id'] = $stripesup->id;
652 $tokenstring[
'type'] = $stripesup->type;
653 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"oauth_token (service, fk_soc, entity, tokenstring)";
654 $sql .=
" VALUES ('".$db->escape($service).
"', ".((int) $object->id).
", ".((int) $conf->entity).
", '".$db->escape(json_encode($tokenstring)).
"')";
660 $resql = $db->query($sql);
664 $stripesupplieracc = $newsup;
671 if ($action ==
'setlocalassourcedefault') {
673 $companypaymentmode->setAsDefault($id);
675 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
676 header(
'Location: '.$url);
682 } elseif ($action ==
'setassourcedefault') {
684 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
685 if (preg_match(
'/pm_|src_/', $source)) {
686 $cu->invoice_settings->default_payment_method = (string) $source;
688 $cu->default_source = (string) $source;
690 $result = $cu->save();
692 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
693 header(
'Location: '.$url);
699 } elseif ($action ==
'deletecard' && $source) {
701 if (preg_match(
'/pm_/', $source)) {
702 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
703 if ($payment_method) {
704 $payment_method->detach();
707 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
708 $card = $cu->sources->retrieve(
"$source");
711 if (method_exists($card,
'detach')) {
713 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
714 $sql .=
" SET stripe_card_ref = null";
715 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
716 $resql = $db->query($sql);
723 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
724 header(
'Location: '.$url);
730 } elseif ($action ==
'delete' && $source) {
732 if (preg_match(
'/pm_/', $source)) {
733 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
734 if ($payment_method) {
735 $payment_method->detach();
738 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
739 $card = $cu->sources->retrieve(
"$source");
742 if (method_exists($card,
'detach')) {
744 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"societe_rib as sr ";
745 $sql .=
" SET stripe_card_ref = null";
746 $sql .=
" WHERE sr.stripe_card_ref = '".$db->escape($source).
"'";
747 $resql = $db->query($sql);
754 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
755 header(
'Location: '.$url);
775 $title = $langs->trans(
"ThirdParty");
776 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
777 $title = $object->name.
" - ".$langs->trans(
'PaymentInformation');
790 if (
isModEnabled(
'stripe') && (empty($conf->global->STRIPE_LIVE) ||
GETPOST(
'forcesandbox',
'alpha'))) {
791 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'),
'',
'warning');
796 $companybankaccount->fetch(0, $object->id);
797 $companypaymentmode->fetch(0,
null, $object->id,
'card');
799 $companybankaccount->fetch($id);
800 $companypaymentmode->fetch($id);
802 if (empty($companybankaccount->socid)) {
803 $companybankaccount->socid = $object->id;
806 if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
807 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'" method="post">';
808 print
'<input type="hidden" name="token" value="'.newToken().
'">';
809 $actionforadd =
'update';
810 if ($action ==
'editcard') {
811 $actionforadd =
'updatecard';
813 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
814 print
'<input type="hidden" name="id" value="'.GETPOST(
"id",
"int").
'">';
816 if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
817 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'" method="post">';
818 print
'<input type="hidden" name="token" value="'.newToken().
'">';
819 $actionforadd =
'add';
820 if ($action ==
'createcard') {
821 $actionforadd =
'addcard';
823 print
'<input type="hidden" name="action" value="'.$actionforadd.
'">';
828 if ($socid && $action !=
'edit' && $action !=
'create' && $action !=
'editcard' && $action !=
'createcard') {
832 if ($action ==
'delete') {
833 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".$object->id.
"&ribid=".($ribid ? $ribid : $id), $langs->trans(
"DeleteARib"), $langs->trans(
"ConfirmDeleteRib", $companybankaccount->getRibLabel()),
"confirm_delete",
'', 0, 1);
836 if ($action ==
'deletecard') {
837 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);
840 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
842 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
844 print
'<div class="fichecenter">';
846 print
'<div class="underbanner clearboth"></div>';
847 print
'<table class="border tableforfield centpercent">';
850 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td colspan="2">';
851 print $object->getTypeUrl(1);
854 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
855 print
'<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="2">'.$object->prefix_comm.
'</td></tr>';
858 if ($object->client) {
859 print
'<tr><td class="titlefield">';
860 print $langs->trans(
'CustomerCode').
'</td><td colspan="2">';
862 $tmpcheck = $object->check_codeclient();
863 if ($tmpcheck != 0 && $tmpcheck != -5) {
864 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
867 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
868 $resql = $db->query($sql);
873 $obj = $db->fetch_object(
$resql);
874 $nbFactsClient = $obj->nb;
875 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
876 if (
isModEnabled(
"propal") && $user->rights->propal->lire) {
877 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
879 if (
isModEnabled(
'commande') && $user->rights->commande->lire) {
880 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
882 if (
isModEnabled(
'facture') && $user->rights->facture->lire) {
883 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
885 if (
isModEnabled(
'contrat') && $user->rights->contrat->lire) {
886 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
891 print
'<tr><td class="titlefield">';
892 print
$form->editfieldkey(
"StripeCustomerId",
'key_account', $stripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
894 print
$form->editfieldval(
"StripeCustomerId",
'key_account', $stripecu, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
895 if (
isModEnabled(
'stripe') && $stripecu && $action !=
'editkey_account') {
897 if (!empty($stripeacc)) {
898 $connect = $stripeacc.
'/';
900 $url =
'https://dashboard.stripe.com/'.$connect.
'test/customers/'.$stripecu;
901 if ($servicestatus) {
902 $url =
'https://dashboard.stripe.com/'.$connect.
'customers/'.$stripecu;
904 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$site_account,
'globe').
'</a>';
906 print
'</td><td class="right">';
907 if (empty($stripecu)) {
908 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
909 print
'<input type="hidden" name="action" value="synccustomertostripe">';
910 print
'<input type="hidden" name="token" value="'.newToken().
'">';
911 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
912 print
img_picto($langs->trans(
"CreateCustomerOnStripe"),
'stripe');
913 print
'<input type="submit" class="buttonlink nomargintop nomarginbottom noborderbottom nopaddingtopimp nopaddingbottomimp" name="syncstripecustomer" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
920 if ($object->fournisseur) {
921 print
'<tr><td class="titlefield">';
922 print $langs->trans(
'SupplierCode').
'</td><td colspan="2">';
924 $tmpcheck = $object->check_codefournisseur();
925 if ($tmpcheck != 0 && $tmpcheck != -5) {
926 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
929 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".((int) $socid);
930 $resql = $db->query($sql);
934 $obj = $db->fetch_object(
$resql);
935 $nbFactsClient = $obj->nb;
936 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
937 if (
isModEnabled(
'propal') && $user->rights->propal->lire) {
938 $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
940 if (
isModEnabled(
'commande') && $user->rights->commande->lire) {
941 $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
943 if (
isModEnabled(
'facture') && $user->rights->facture->lire) {
944 $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
946 if (
isModEnabled(
'contrat') && $user->rights->contrat->lire) {
947 $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
952 $stripesupplieracc = $stripe->getStripeAccount($service, $object->id);
955 print
'<tr><td class="titlefield">';
956 print
$form->editfieldkey(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'', 0, 2,
'socid');
958 print
$form->editfieldval(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation,
'string',
'',
null,
null,
'', 2,
'',
'socid');
959 if (
isModEnabled(
'stripe') && $stripesupplieracc && $action !=
'editkey_account_supplier') {
962 $url =
'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc;
963 if ($servicestatus) {
964 $url =
'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc;
966 print
' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key '.$site_account,
'globe').
'</a>';
968 print
'</td><td class="right">';
969 if (empty($stripesupplieracc)) {
970 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
971 print
'<input type="hidden" name="action" value="syncsuppliertostripe">';
972 print
'<input type="hidden" name="token" value="'.newToken().
'">';
973 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
974 print
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
988 $showcardpaymentmode = 0;
990 $showcardpaymentmode++;
994 $listofsources = array();
996 if (is_object($stripe)) {
998 $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus);
999 if (!empty($customerstripe->id)) {
1001 if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
1002 $listofsources = $customerstripe->sources->data;
1004 $service =
'StripeTest';
1006 if (!empty($conf->global->STRIPE_LIVE) && !
GETPOST(
'forcesandbox',
'alpha')) {
1007 $service =
'StripeLive';
1012 global $stripearrayofkeysbyenv;
1013 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
1016 if (empty($stripeacc)) {
1017 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"));
1018 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"));
1020 $paymentmethodobjsA = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"), array(
"stripe_account" => $stripeacc));
1021 $paymentmethodobjsB = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"sepa_debit"), array(
"stripe_account" => $stripeacc));
1024 if ($paymentmethodobjsA->data !=
null && $paymentmethodobjsB->data !=
null) {
1025 $listofsources = array_merge((array) $paymentmethodobjsA->data, (array) $paymentmethodobjsB->data);
1026 } elseif ($paymentmethodobjsB->data !=
null) {
1027 $listofsources = $paymentmethodobjsB->data;
1029 $listofsources = $paymentmethodobjsA->data;
1038 dol_syslog(
"Error when searching/loading Stripe customer for thirdparty id =".$object->id);
1044 if ($showcardpaymentmode && $object->client) {
1045 $morehtmlright =
'';
1046 if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) {
1047 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=createcard');
1049 print
load_fiche_titre($langs->trans(
'CreditCard').($stripeacc ?
' (Stripe connection with StripeConnect account '.$stripeacc.
')' :
' (Stripe connection with keys from Stripe module setup)'), $morehtmlright,
'fa-credit-card');
1051 print
'<!-- List of card payments -->'.
"\n";
1052 print
'<div class="div-table-responsive-no-min">';
1053 print
'<table class="liste centpercent">'.
"\n";
1054 print
'<tr class="liste_titre">';
1055 print
'<td>'.$langs->trans(
'Label').
'</td>';
1056 print
'<td>'.$langs->trans(
'StripeID').
'</td>';
1057 print
'<td>'.$langs->trans(
'Type').
'</td>';
1058 print
'<td>'.$langs->trans(
'Informations').
'</td>';
1060 print
'<td class="center">'.$langs->trans(
'Default').
'</td>';
1061 print
'<td>'.$langs->trans(
'Note').
'</td>';
1062 print
'<td>'.$langs->trans(
'DateModification').
'</td>';
1064 $parameters = array(
'arrayfields'=>array(),
'param'=>
'',
'sortfield'=>
'',
'sortorder'=>
'',
'linetype'=>
'stripetitle');
1065 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
1066 print $hookmanager->resPrint;
1073 $arrayofremotecard = array();
1076 if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) {
1080 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_rib";
1081 $sql .=
" WHERE type in ('card')";
1082 $sql .=
" AND fk_soc = ".((int) $object->id);
1083 $sql .=
" AND status = ".((int) $servicestatus);
1085 $resql = $db->query($sql);
1087 $num_rows = $db->num_rows(
$resql);
1090 while ($i < $num_rows) {
1093 $obj = $db->fetch_object(
$resql);
1095 $companypaymentmodetemp->fetch($obj->rowid);
1097 $arrayofremotecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref;
1099 print
'<tr class="oddeven" data-rowid="'.((int) $companypaymentmodetemp->id).
'">';
1101 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companypaymentmodetemp->label).
'">';
1105 print
'<td class="tdoverflowmax150">';
1106 if (!empty($companypaymentmodetemp->stripe_card_ref)) {
1108 if (!empty($stripeacc)) {
1109 $connect = $stripeacc.
'/';
1111 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
1112 if ($servicestatus) {
1113 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$companypaymentmodetemp->stripe_card_ref;
1115 print
'<a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Customer and Publishable key = '.$companypaymentmodetemp->stripe_account,
'globe').
'</a> ';
1117 print $companypaymentmodetemp->stripe_card_ref;
1125 if ($companypaymentmodetemp->proprio) {
1126 print
'<span class="opacitymedium">'.$companypaymentmodetemp->proprio.
'</span><br>';
1128 if ($companypaymentmodetemp->last_four) {
1129 print
'....'.$companypaymentmodetemp->last_four;
1131 if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) {
1132 print
' - '.sprintf(
"%02d", $companypaymentmodetemp->exp_date_month).
'/'.$companypaymentmodetemp->exp_date_year;
1135 if ($companypaymentmodetemp->country_code) {
1137 print $img ? $img.
' ' :
'';
1138 print
getCountry($companypaymentmodetemp->country_code, 1);
1140 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1144 print
'<td class="center">';
1145 if (empty($companypaymentmodetemp->default_rib)) {
1146 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=setlocalassourcedefault&token='.
newToken().
'">';
1147 print
img_picto($langs->trans(
"Default"),
'off');
1150 print
img_picto($langs->trans(
"Default"),
'on');
1154 if (empty($companypaymentmodetemp->stripe_card_ref)) {
1155 print $langs->trans(
"Local");
1157 print $langs->trans(
"LocalAndRemote");
1164 $parameters = array(
'arrayfields'=>array(),
'obj'=>$obj,
'linetype'=>
'stripecard');
1165 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1166 print $hookmanager->resPrint;
1168 print
'<td class="right nowraponall">';
1169 if ($permissiontoaddupdatepaymentinformation) {
1170 if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) {
1171 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=synccardtostripe&socid='.$object->id.
'&id='.$companypaymentmodetemp->id.
'" class="paddingrightonly marginrightonly">'.$langs->trans(
"CreateCardOnStripe").
'</a>';
1174 print
'<a class="editfielda marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=editcard&token='.
newToken().
'">';
1175 print
img_picto($langs->trans(
"Modify"),
'edit');
1177 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=deletecard&token='.
newToken().
'">';
1178 print
img_picto($langs->trans(
"Delete"),
'delete');
1193 if (is_array($listofsources) && count($listofsources)) {
1194 foreach ($listofsources as $src) {
1195 if (!empty($arrayofremotecard[$src->id])) {
1202 if ($src->object ==
'card') {
1204 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1206 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1208 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1210 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1214 print
'<tr class="oddeven">';
1218 print
'<td class="tdoverflowmax150">';
1220 if (!empty($stripeacc)) {
1221 $connect = $stripeacc.
'/';
1224 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1225 if ($servicestatus) {
1227 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1229 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1237 print
'<td valign="middle">';
1238 if ($src->object ==
'card') {
1239 print
'....'.$src->last4.
' - '.$src->exp_month.
'/'.$src->exp_year;
1241 if ($src->country) {
1243 print $img ? $img.
' ' :
'';
1246 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1248 } elseif ($src->object ==
'source' && $src->type ==
'card') {
1249 print
'<span class="opacitymedium">'.$src->owner->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1252 if ($src->card->country) {
1254 print $img ? $img.
' ' :
'';
1257 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1259 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1260 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1262 if ($src->sepa_debit->country) {
1264 print $img ? $img.
' ' :
'';
1265 print
getCountry($src->sepa_debit->country, 1);
1267 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1269 } elseif ($src->object ==
'payment_method' && $src->type ==
'card') {
1270 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year;
1273 if ($src->card->country) {
1275 print $img ? $img.
' ' :
'';
1278 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1280 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1281 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->sepa_debit->last4;
1283 if ($src->sepa_debit->country) {
1285 print $img ? $img.
' ' :
'';
1286 print
getCountry($src->sepa_debit->country, 1);
1288 print
img_warning().
' <span class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</span>';
1295 print
'<td class="center" width="50">';
1296 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1297 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1298 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1299 print
img_picto($langs->trans(
"Default"),
'off');
1302 print
img_picto($langs->trans(
"Default"),
'on');
1306 print $langs->trans(
"Remote");
1315 $parameters = array(
'arrayfields'=>array(),
'stripesource'=>$src,
'linetype'=>
'stripecardremoteonly');
1316 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1317 print $hookmanager->resPrint;
1320 print
'<td class="right nowraponall">';
1321 if ($permissiontoaddupdatepaymentinformation) {
1322 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&source='.$src->id.
'&action=deletecard&token='.
newToken().
'">';
1323 print
img_picto($langs->trans(
"Delete"),
'delete');
1332 if ($nbremote == 0 && $nblocal == 0) {
1333 $colspan = (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD) ? 10 : 9);
1334 print
'<tr><td colspan="'.$colspan.
'"<span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
1342 if (
isModEnabled(
'stripe') && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc)) {
1343 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');
1344 $balance = \Stripe\Balance::retrieve(array(
"stripe_account" => $stripesupplieracc));
1345 print
'<table class="liste centpercent">'.
"\n";
1346 print
'<tr class="liste_titre">';
1347 print
'<td>'.$langs->trans(
'Currency').
'</td>';
1348 print
'<td>'.$langs->trans(
'Available').
'</td>';
1349 print
'<td>'.$langs->trans(
'Pending').
'</td>';
1350 print
'<td>'.$langs->trans(
'Total').
'</td>';
1353 $currencybalance = array();
1354 if (is_array($balance->available) && count($balance->available)) {
1355 foreach ($balance->available as $cpt) {
1356 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1357 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1358 $currencybalance[$cpt->currency][
'available'] = $cpt->amount / 100;
1360 $currencybalance[$cpt->currency][
'available'] = $cpt->amount;
1362 $currencybalance[$cpt->currency][
'currency'] = $cpt->currency;
1366 if (is_array($balance->pending) && count($balance->pending)) {
1367 foreach ($balance->pending as $cpt) {
1368 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1369 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1370 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount / 100;
1372 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount;
1377 if (is_array($currencybalance)) {
1378 foreach ($currencybalance as $cpt) {
1379 print
'<tr><td>'.$langs->trans(
"Currency".strtoupper($cpt[
'currency'])).
'</td><td>'.
price($cpt[
'available'], 0,
'', 1, - 1, - 1, strtoupper($cpt[
'currency'])).
'</td><td>'.
price($cpt->pending, 0,
'', 1, - 1, - 1, strtoupper($cpt[
'currency'])).
'</td><td>'.
price($cpt[
'available'] + $cpt->pending, 0,
'', 1, - 1, - 1, strtoupper($cpt[
'currency'])).
'</td></tr>';
1388 if ($permissiontoaddupdatepaymentinformation) {
1389 $morehtmlright =
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"] .
'?socid=' . $object->id .
'&action=create');
1392 print
load_fiche_titre($langs->trans(
"BankAccounts"), $morehtmlright,
'bank');
1394 $nblocal = 0; $nbremote = 0;
1395 $arrayofremoteban = array();
1397 $rib_list = $object->get_all_rib();
1399 if (is_array($rib_list)) {
1400 print
'<div class="div-table-responsive-no-min">';
1401 print
'<table class="liste centpercent">';
1403 print
'<tr class="liste_titre">';
1410 if (!empty($conf->prelevement->enabled)) {
1418 $parameters = array(
'arrayfields'=>array(),
'linetype'=>
'stripebantitle');
1419 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1420 print $hookmanager->resPrint;
1425 foreach ($rib_list as $rib) {
1426 $arrayofremoteban[$rib->stripe_card_ref] = $rib->stripe_card_ref;
1430 print
'<tr class="oddeven">';
1432 print
'<td>'.dol_escape_htmltag($rib->label).
'</td>';
1434 print
'<td class="tdoverflowmax150">';
1435 if ($rib->stripe_card_ref) {
1437 if (!empty($stripeacc)) {
1438 $connect = $stripeacc.
'/';
1441 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$rib->stripe_card_ref;
1442 if ($servicestatus) {
1444 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$rib->stripe_card_ref;
1446 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1448 print $rib->stripe_card_ref;
1451 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->bank).
'">'.
dol_escape_htmltag($rib->bank).
'</td>';
1455 foreach ($rib->getFieldsToShow() as $val) {
1456 if ($val ==
'BankCode') {
1457 $string .= $rib->code_banque.
' ';
1458 } elseif ($val ==
'BankAccountNumber') {
1459 $string .= $rib->number.
' ';
1460 } elseif ($val ==
'DeskCode') {
1461 $string .= $rib->code_guichet.
' ';
1462 } elseif ($val ==
'BankAccountNumberKey') {
1463 $string .= $rib->cle_rib.
' ';
1472 if (!empty($rib->label) && $rib->number) {
1474 $string .=
' '.img_picto($langs->trans(
"ValueIsNotValid"),
'warning');
1476 $string .=
' '.img_picto($langs->trans(
"ValueIsValid"),
'info');
1483 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->iban).
'">';
1484 if (!empty($rib->iban)) {
1486 print
img_picto($langs->trans(
"IbanNotValid"),
'warning').
' ';
1493 if (!empty($rib->bic)) {
1495 print
img_picto($langs->trans(
"SwiftNotValid"),
'warning').
' ';
1501 if (!empty($conf->prelevement->enabled)) {
1504 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->rum).
'">'.
dol_escape_htmltag($rib->rum).
'</td>';
1506 print
'<td>'.dol_print_date($rib->date_rum,
'day').
'</td>';
1509 print
'<td>'.$rib->frstrecur.
'</td>';
1513 print
'<td class="center" width="70">';
1514 if (!$rib->default_rib) {
1515 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&ribid='.$rib->id.
'&action=setasbankdefault&token='.
newToken().
'">';
1516 print
img_picto($langs->trans(
"Disabled"),
'off');
1519 print
img_picto($langs->trans(
"Enabled"),
'on');
1524 print
'<td class="center">';
1526 $buttonlabel = $langs->trans(
"BuildDoc");
1527 $forname =
'builddocrib'.$rib->id;
1529 include_once DOL_DOCUMENT_ROOT.
'/core/modules/bank/modules_bank.php';
1533 if (is_array($modellist) && count($modellist)) {
1534 $out .=
'<form action="'.$_SERVER[
"PHP_SELF"].(empty($conf->global->MAIN_JUMP_TAG) ?
'' :
'#builddoc').
'" name="'.$forname.
'" id="'.$forname.
'_form" method="post">';
1535 $out .=
'<input type="hidden" name="action" value="builddocrib">';
1536 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1537 $out .=
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1538 $out .=
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1540 if (is_array($modellist) && count($modellist) == 1) {
1541 $arraykeys = array_keys($modellist);
1542 $modelselected = $arraykeys[0];
1544 if (!empty($conf->global->BANKADDON_PDF)) {
1545 $modelselected = $conf->global->BANKADDON_PDF;
1548 $out .=
$form->selectarray(
'modelrib'.$rib->id, $modellist, $modelselected, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100');
1551 $allowgenifempty = 0;
1555 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
1557 $defaultlang = $langs->getDefaultLang();
1558 $morecss =
'maxwidth150';
1559 if ($conf->browser->layout ==
'phone') {
1560 $morecss =
'maxwidth100';
1562 $out .= $formadmin->select_language($defaultlang,
'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss);
1565 $genbutton =
'<input class="button buttongen reposition nomargintop nomarginbottom" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
1566 $genbutton .=
' type="submit" value="'.$buttonlabel.
'"';
1567 if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) {
1568 $genbutton .=
' disabled';
1571 if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') {
1572 $langs->load(
"errors");
1573 $genbutton .=
' '.img_warning($langs->transnoentitiesnoconv(
"WarningNoDocumentModelActivated"));
1575 if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') {
1578 if (empty($modellist) && !$showempty && $modulepart !=
'unpaid') {
1588 $parameters = array(
'arrayfields'=>array(),
'stripe_card_ref'=>$rib->stripe_card_ref,
'stripe_account'=>$rib->stripe_account,
'linetype'=>
'stripeban');
1589 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1590 print $hookmanager->resPrint;
1593 print
'<td class="right nowraponall">';
1594 if ($permissiontoaddupdatepaymentinformation) {
1595 if (empty($rib->stripe_card_ref)) {
1597 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&id='.$rib->id.
'&action=syncsepatostripe&token='.
newToken().
'">';
1598 print
img_picto($langs->trans(
"CreateBANOnStripe"),
'stripe');
1602 print
'<a class="editfielda marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&id='.$rib->id.
'&action=edit">';
1603 print
img_picto($langs->trans(
"Modify"),
'edit');
1606 print
'<a class="marginrightonly marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&id='.$rib->id.
'&action=delete&token='.
newToken().
'">';
1607 print
img_picto($langs->trans(
"Delete"),
'delete');
1617 foreach ($listofsources as $src) {
1618 if (!empty($arrayofremoteban[$src->id])) {
1623 if ($src->object ==
'source' && $src->type ==
'sepa_debit') {
1624 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1625 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit') {
1626 $imgline =
'<span class="fa fa-university fa-2x fa-fw"></span>';
1633 print
'<tr class="oddeven">';
1637 print
'<td class="tdoverflowmax150">';
1639 if (!empty($stripeacc)) {
1640 $connect = $stripeacc.
'/';
1643 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1644 if ($servicestatus) {
1646 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1648 print
"<a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a> ";
1655 print
'<td valign="middle">';
1658 print
'<td valign="middle">';
1662 print
'<td valign="middle">';
1666 if (!empty($conf->prelevement->enabled)) {
1668 print
'<td valign="middle">';
1672 print
'<td valign="middle">';
1676 print
'<td valign="middle">';
1682 print
'<td class="center" width="50">';
1683 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1684 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) {
1685 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1686 print
img_picto($langs->trans(
"Default"),
'off');
1689 print
img_picto($langs->trans(
"Default"),
'on');
1703 $parameters = array(
'arrayfields'=>array(),
'stripe_card_ref'=>$rib->stripe_card_ref,
'stripe_account'=>$rib->stripe_account,
'linetype'=>
'stripebanremoteonly');
1704 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1705 print $hookmanager->resPrint;
1708 print
'<td class="right nowraponall">';
1709 if ($permissiontoaddupdatepaymentinformation) {
1710 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&source='.$src->id.
'&action=delete&token='.
newToken().
'">';
1711 print
img_picto($langs->trans(
"Delete"),
'delete');
1719 if ($nbremote == 0 && $nblocal == 0) {
1724 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoBANRecord").
'</span></td></tr>';
1734 if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) {
1737 print
'<div class="fichecenter"><div class="fichehalfleft">';
1738 print
'<a name="builddoc"></a>';
1743 $filedir = $conf->societe->multidir_output[$object->entity].
'/'.$object->id;
1744 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
1746 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);
1749 if (!empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) {
1752 $result = $companypaymentmodetemp->fetch(0,
null, $object->id,
'ban');
1754 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1756 $result = $ecmfile->fetch(0,
'',
'',
'',
'', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
1758 $companybankaccounttemp->last_main_doc = $ecmfile->filepath.
'/'.$ecmfile->filename;
1759 print
'<br><!-- Link to download main doc -->'.
"\n";
1764 print
'</div><div class="fichehalfright">';
1767 print
'</div></div>';
1793 if ($socid && $action ==
'edit' && $permissiontoaddupdatepaymentinformation) {
1796 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1798 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
1800 print
'<div class="underbanner clearboth"></div>';
1804 print
'<div class="div-table-responsive-no-min">';
1805 print
'<table class="border centpercent">';
1807 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"Label").
'</td>';
1808 print
'<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.
'"></td></tr>';
1810 print
'<tr><td class="fieldrequired">'.$langs->trans(
"BankName").
'</td>';
1811 print
'<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.
'"></td></tr>';
1814 foreach ($companybankaccount->getFieldsToShow(1) as $val) {
1817 if ($val ==
'BankCode') {
1818 $name =
'code_banque';
1820 $content = $companybankaccount->code_banque;
1821 } elseif ($val ==
'DeskCode') {
1822 $name =
'code_guichet';
1824 $content = $companybankaccount->code_guichet;
1825 } elseif ($val ==
'BankAccountNumber') {
1828 $content = $companybankaccount->number;
1829 } elseif ($val ==
'BankAccountNumberKey') {
1832 $content = $companybankaccount->cle_rib;
1833 } elseif ($val ==
'IBAN') {
1836 $content = $companybankaccount->iban;
1837 if ($companybankaccount->needIBAN()) {
1840 $tooltip = $langs->trans(
"Example").
':<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';
1841 } elseif ($val ==
'BIC') {
1844 $content = $companybankaccount->bic;
1845 if ($companybankaccount->needIBAN()) {
1848 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
1851 print
'<tr><td'.($require ?
' class="fieldrequired" ' :
'').
'>';
1853 print
$form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
1855 print $langs->trans($val);
1858 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.$content.
'"></td>';
1862 print
'<tr><td>'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
1863 print
'<textarea name="domiciliation" rows="4" cols="40" maxlength="255">';
1864 print $companybankaccount->domiciliation;
1865 print
"</textarea></td></tr>";
1867 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
1868 print
'<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->proprio.
'"></td></tr>';
1869 print
"</td></tr>\n";
1871 print
'<tr><td>'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
1872 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" cols="40" maxlength="255">';
1873 print $companybankaccount->owner_address;
1874 print
"</textarea></td></tr>";
1882 print
'<div class="div-table-responsive-no-min">';
1883 print
'<table class="border centpercent">';
1885 if (empty($companybankaccount->rum)) {
1886 $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
1890 print
'<tr><td class="titlefield">'.$langs->trans(
"RUM").
'</td>';
1891 print
'<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).
'"></td></tr>';
1895 print
'<tr><td class="titlefield">'.$langs->trans(
"DateRUM").
'</td>';
1896 print
'<td>'.$form->selectDate($date_rum ? $date_rum : $companybankaccount->date_rum,
'date_rum', 0, 0, 1,
'date_rum', 1, 1).
'</td></tr>';
1898 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
1899 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RECUR" => $langs->trans(
"RECUR"));
1903 print
'<tr><td>'.$langs->trans(
"StripeID").
" ('src_....')</td>";
1904 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
1913 print
$form->buttonsSaveCancel(
"Modify");
1917 if ($socid && $action ==
'editcard' && $permissiontoaddupdatepaymentinformation) {
1920 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1922 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
1924 print
'<div class="nofichecenter">';
1926 print
'<div class="underbanner clearboth"></div>';
1930 print
'<table class="border centpercent">';
1932 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
1933 print
'<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.
'"></td></tr>';
1935 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
1936 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->proprio.
'"></td></tr>';
1938 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
1939 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.
'"></td></tr>';
1941 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
1943 print $formother->select_month($companypaymentmode->exp_date_month,
'exp_date_month', 1);
1944 print $formother->selectyear($companypaymentmode->exp_date_year,
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
1947 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
1948 print
'<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.
'"></td></tr>';
1950 print
'<tr><td>'.$langs->trans(
"StripeID").
" ('card_....')</td>";
1951 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
1958 print
$form->buttonsSaveCancel(
"Modify");
1963 if ($socid && $action ==
'create' && $permissiontoaddupdatepaymentinformation) {
1966 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1968 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
1970 print
'<div class="nofichecenter">';
1972 print
'<div class="underbanner clearboth"></div>';
1976 print
'<table class="border centpercent">';
1978 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
1979 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.(GETPOSTISSET(
'label') ?
GETPOST(
'label') : $object->
name).
'"></td></tr>';
1981 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Bank").
'</td>';
1982 print
'<td><input class="minwidth200" type="text" id="bank" name="bank" value="'.GETPOST(
'bank').
'"></td></tr>';
1985 foreach ($companybankaccount->getFieldsToShow(1) as $val) {
1988 if ($val ==
'BankCode') {
1989 $name =
'code_banque';
1991 $content = $companybankaccount->code_banque;
1992 } elseif ($val ==
'DeskCode') {
1993 $name =
'code_guichet';
1995 $content = $companybankaccount->code_guichet;
1996 } elseif ($val ==
'BankAccountNumber') {
1999 $content = $companybankaccount->number;
2000 } elseif ($val ==
'BankAccountNumberKey') {
2003 $content = $companybankaccount->cle_rib;
2004 } elseif ($val ==
'IBAN') {
2007 $content = $companybankaccount->iban;
2008 if ($companybankaccount->needIBAN()) {
2011 $tooltip = $langs->trans(
"Example").
':<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';
2012 } elseif ($val ==
'BIC') {
2015 $content = $companybankaccount->bic;
2016 if ($companybankaccount->needIBAN()) {
2019 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
2022 print
'<tr><td'.($require ?
' class="fieldrequired" ' :
'').
'>';
2024 print
$form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
2026 print $langs->trans($val);
2029 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.
GETPOST($name).
'"></td>';
2033 print
'<tr><td>'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
2034 print
'<textarea name="domiciliation" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2035 print
GETPOST(
'domiciliation');
2036 print
"</textarea></td></tr>";
2038 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
2039 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio').
'"></td></tr>';
2040 print
"</td></tr>\n";
2042 print
'<tr><td>'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
2043 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
2044 print
GETPOST(
'owner_address');
2045 print
"</textarea></td></tr>";
2052 print
'<table class="border centpercent">';
2055 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"RUM").
'</td>';
2056 print
'<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST(
'rum',
'alpha').
'"> <div class="opacitymedium">'.$langs->trans(
"RUMWillBeGenerated").
'</div></td></tr>';
2060 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DateRUM").
'</td>';
2061 print
'<td colspan="4">'.$form->selectDate($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"),
"RECUR" => $langs->trans(
"RECUR"));
2065 print
$form->selectarray(
"frstrecur", $tblArraychoice, (
GETPOSTISSET(
'frstrecur') ?
GETPOST(
'frstrecur') :
'FRST'), 0);
2068 print
'<tr><td>'.$langs->trans(
"StripeID").
" ('src_....')</td>";
2069 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2080 print
$form->buttonsSaveCancel(
"Add");
2084 if ($socid && $action ==
'createcard' && $permissiontoaddupdatepaymentinformation) {
2087 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2089 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2091 print
'<div class="nofichecenter">';
2093 print
'<div class="underbanner clearboth"></div>';
2097 print
'<table class="border centpercent">';
2099 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
2100 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST(
'label',
'alpha').
'"></td></tr>';
2102 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
2103 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio',
'alpha').
'"></td></tr>';
2105 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
2106 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST(
'cardnumber',
'alpha').
'"></td></tr>';
2108 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
2110 print $formother->select_month(
GETPOST(
'exp_date_month',
'int'),
'exp_date_month', 1);
2111 print $formother->selectyear(
GETPOST(
'exp_date_year',
'int'),
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
2114 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
2115 print
'<td><input class="width50" type="text" name="cvn" value="'.GETPOST(
'cvn',
'alpha').
'"></td></tr>';
2117 print
'<tr><td>'.$langs->trans(
"StripeID").
" ('card_....')</td>";
2118 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
2128 print
$form->buttonsSaveCancel(
"Add");
2131 if ($socid && ($action ==
'edit' || $action ==
'editcard') && $permissiontoaddupdatepaymentinformation) {
2134 if ($socid && ($action ==
'create' || $action ==
'createcard') && $permissiontoaddupdatepaymentinformation) {
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
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_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
showDirectDownloadLink($object)
Return string with full Url.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print 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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
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.
$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.