31 require
'../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companypaymentmode.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
42 $langs->loadLangs(array(
"companies",
"commercial",
"banks",
"bills",
'paypal',
'stripe',
'withdrawals'));
46 $socid =
GETPOST(
"socid",
"int");
47 if ($user->socid) $socid = $user->socid;
51 $source =
GETPOST(
"source",
"alpha");
52 $ribid =
GETPOST(
"ribid",
"int");
53 $action =
GETPOST(
"action",
'alpha', 3);
54 $cancel =
GETPOST(
'cancel',
'alpha');
57 $object->fetch($socid);
66 $extrafields->fetch_name_optionals_label($object->table_element);
69 $hookmanager->initHooks(array(
'thirdpartybancard',
'globalcard'));
72 if (!empty($conf->stripe->enabled))
74 $service =
'StripeTest';
76 if (!empty($conf->global->STRIPE_LIVE) && !
GETPOST(
'forcesandbox',
'alpha'))
78 $service =
'StripeLive';
83 global $stripearrayofkeysbyenv;
84 $site_account = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
87 $stripeacc = $stripe->getStripeAccount($service);
88 $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus, $site_account);
102 $parameters = array(
'id'=>$socid,
'objcanvas'=>$objcanvas);
103 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
104 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
111 if (!empty($backtopage))
113 header(
"Location: ".$backtopage);
118 if ($action ==
'update')
123 if (!
GETPOST(
'label',
'alpha'))
setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")), null,
'errors');
124 if (!
GETPOST(
'bank',
'alpha'))
setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankName")), null,
'errors');
128 if ($companybankaccount->needIBAN() == 1)
132 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")), null,
'errors');
138 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")), null,
'errors');
144 $companybankaccount->fetch($id);
147 $companybankaccount->socid = $object->id;
149 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
150 $companybankaccount->label =
GETPOST(
'label',
'alpha');
151 $companybankaccount->courant =
GETPOST(
'courant',
'alpha');
152 $companybankaccount->clos =
GETPOST(
'clos',
'alpha');
153 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
154 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
155 $companybankaccount->number =
GETPOST(
'number',
'alpha');
156 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
157 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
158 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
159 $companybankaccount->domiciliation =
GETPOST(
'domiciliation',
'alpha');
160 $companybankaccount->proprio =
GETPOST(
'proprio',
'alpha');
161 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
162 $companybankaccount->frstrecur =
GETPOST(
'frstrecur',
'alpha');
163 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
165 if (empty($companybankaccount->rum))
167 $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
169 if (empty($companybankaccount->date_rum))
171 $companybankaccount->date_rum =
dol_now();
174 $result = $companybankaccount->update($user);
177 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
180 if ($companybankaccount->default_rib)
182 $companybankaccount->setAsDefault($id);
185 $url =
$_SERVER[
"PHP_SELF"].
'?socid='.$object->id;
186 header(
'Location: '.$url);
192 if ($action ==
'updatecard')
195 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha'))
197 if (!
GETPOST(
'label',
'alpha'))
setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")), null,
'errors');
198 if (!
GETPOST(
'proprio',
'alpha'))
setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")), null,
'errors');
200 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0))
setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")), null,
'errors');
202 $action =
'createcard';
206 $companypaymentmode->fetch($id);
209 $companypaymentmode->fk_soc = $object->id;
211 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
212 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
213 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
214 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
215 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
216 $companypaymentmode->exp_date_month =
GETPOST(
'exp_date_month',
'int');
217 $companypaymentmode->exp_date_year =
GETPOST(
'exp_date_year',
'int');
218 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
219 $companypaymentmode->country_code = $object->country_code;
221 if (
GETPOST(
'stripe_card_ref',
'alpha') &&
GETPOST(
'stripe_card_ref',
'alpha') != $companypaymentmode->stripe_card_ref) {
223 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
225 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
227 $result = $companypaymentmode->update($user);
230 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
233 if ($companypaymentmode->default_rib)
235 $companypaymentmode->setAsDefault($id);
238 $url =
$_SERVER[
"PHP_SELF"].
'?socid='.$object->id;
239 header(
'Location: '.$url);
245 if ($action ==
'add')
251 if (!
GETPOST(
'label',
'alpha'))
setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")), null,
'errors');
252 if (!
GETPOST(
'bank',
'alpha'))
setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankName")), null,
'errors');
262 $companybankaccount->socid = $object->id;
264 $companybankaccount->bank =
GETPOST(
'bank',
'alpha');
265 $companybankaccount->label =
GETPOST(
'label',
'alpha');
266 $companybankaccount->courant =
GETPOST(
'courant',
'alpha');
267 $companybankaccount->clos =
GETPOST(
'clos',
'alpha');
268 $companybankaccount->code_banque =
GETPOST(
'code_banque',
'alpha');
269 $companybankaccount->code_guichet =
GETPOST(
'code_guichet',
'alpha');
270 $companybankaccount->number =
GETPOST(
'number',
'alpha');
271 $companybankaccount->cle_rib =
GETPOST(
'cle_rib',
'alpha');
272 $companybankaccount->bic =
GETPOST(
'bic',
'alpha');
273 $companybankaccount->iban =
GETPOST(
'iban',
'alpha');
274 $companybankaccount->domiciliation =
GETPOST(
'domiciliation',
'alpha');
275 $companybankaccount->proprio =
GETPOST(
'proprio',
'alpha');
276 $companybankaccount->owner_address =
GETPOST(
'owner_address',
'alpha');
277 $companybankaccount->frstrecur =
GETPOST(
'frstrecur');
278 $companybankaccount->rum =
GETPOST(
'rum',
'alpha');
280 $companybankaccount->datec =
dol_now();
281 $companybankaccount->status = 1;
286 if ($companybankaccount->needIBAN() == 1)
290 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"IBAN")), null,
'errors');
296 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BIC")), null,
'errors');
304 $result = $companybankaccount->create($user);
308 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
312 if (empty($companybankaccount->rum))
314 $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
315 $companybankaccount->date_rum =
dol_now();
321 $result = $companybankaccount->update($user);
325 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
334 $url =
$_SERVER[
"PHP_SELF"].
'?socid='.$object->id;
335 header(
'Location: '.$url);
343 if ($action ==
'addcard')
347 if (!
GETPOST(
'label',
'alpha') || !
GETPOST(
'proprio',
'alpha') || !
GETPOST(
'exp_date_month',
'alpha') || !
GETPOST(
'exp_date_year',
'alpha'))
349 if (!
GETPOST(
'label',
'alpha'))
setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")), null,
'errors');
350 if (!
GETPOST(
'proprio',
'alpha'))
setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NameOnCard")), null,
'errors');
352 if (!(
GETPOST(
'exp_date_month',
'alpha') > 0) || !(
GETPOST(
'exp_date_year',
'alpha') > 0))
setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ExpiryDate")), null,
'errors');
354 $action =
'createcard';
363 $companypaymentmode->fk_soc = $object->id;
364 $companypaymentmode->bank =
GETPOST(
'bank',
'alpha');
365 $companypaymentmode->label =
GETPOST(
'label',
'alpha');
366 $companypaymentmode->number =
GETPOST(
'cardnumber',
'alpha');
367 $companypaymentmode->last_four = substr(
GETPOST(
'cardnumber',
'alpha'), -4);
368 $companypaymentmode->proprio =
GETPOST(
'proprio',
'alpha');
369 $companypaymentmode->exp_date_month =
GETPOST(
'exp_date_month',
'int');
370 $companypaymentmode->exp_date_year =
GETPOST(
'exp_date_year',
'int');
371 $companypaymentmode->cvn =
GETPOST(
'cvn',
'alpha');
372 $companypaymentmode->datec =
dol_now();
373 $companypaymentmode->default_rib = 0;
374 $companypaymentmode->type =
'card';
375 $companypaymentmode->country_code = $object->country_code;
376 $companypaymentmode->status = $servicestatus;
378 if (
GETPOST(
'stripe_card_ref',
'alpha')) {
380 $companypaymentmode->stripe_account = $stripecu.
'@'.$site_account;
382 $companypaymentmode->stripe_card_ref =
GETPOST(
'stripe_card_ref',
'alpha');
388 $result = $companypaymentmode->create($user);
392 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
393 $action =
'createcard';
401 $url =
$_SERVER[
"PHP_SELF"].
'?socid='.$object->id;
402 header(
'Location: '.$url);
410 if ($action ==
'setasbankdefault' &&
GETPOST(
'ribid',
'int') > 0)
413 $res = $companybankaccount->setAsDefault(
GETPOST(
'ribid',
'int'));
416 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
417 header(
'Location: '.$url);
424 if ($action ==
'confirm_deletecard' &&
GETPOST(
'confirm',
'alpha') ==
'yes')
427 if ($companypaymentmode->fetch($ribid ? $ribid : $id))
438 $result = $companypaymentmode->delete($user);
441 $url =
$_SERVER[
'PHP_SELF'].
"?socid=".$object->id;
442 header(
'Location: '.$url);
445 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
448 setEventMessages($companypaymentmode->error, $companypaymentmode->errors,
'errors');
451 if ($action ==
'confirm_delete' &&
GETPOST(
'confirm',
'alpha') ==
'yes')
454 if ($companybankaccount->fetch($ribid ? $ribid : $id))
456 $result = $companybankaccount->delete($user);
459 $url =
$_SERVER[
'PHP_SELF'].
"?socid=".$object->id;
460 header(
'Location: '.$url);
463 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
466 setEventMessages($companybankaccount->error, $companybankaccount->errors,
'errors');
473 if ($action ==
'builddocrib')
475 $action =
'builddoc';
477 'use_companybankid'=>
GETPOST(
'companybankid'),
478 'force_dir_output'=>$conf->societe->multidir_output[$object->entity].
'/'.
dol_sanitizeFileName($object->id)
480 $_POST[
'lang_id'] =
GETPOST(
'lang_idrib'.
GETPOST(
'companybankid',
'int'),
'alpha');
481 $_POST[
'model'] =
GETPOST(
'modelrib'.
GETPOST(
'companybankid',
'int'),
'alpha');
485 $upload_dir = $conf->societe->multidir_output[$object->entity];
486 $permissiontoadd = $user->rights->societe->creer;
487 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
492 if (!empty($conf->stripe->enabled) && class_exists(
'Stripe'))
494 if ($action ==
'synccustomertostripe')
496 if ($object->client == 0)
502 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1);
512 if ($action ==
'synccardtostripe')
515 $companypaymentmode->fetch($id);
517 if ($companypaymentmode->type !=
'card')
523 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
535 $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1);
545 if ($action ==
'setkey_account')
549 $newcu =
GETPOST(
'key_account',
'alpha');
554 $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 = ".$servicestatus.
" AND entity = ".$conf->entity;
556 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_account";
557 $sql .=
" 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 = ".$servicestatus.
" AND entity = ".$conf->entity;
560 $resql = $db->query($sql);
561 $num = $db->num_rows(
$resql);
562 if (!empty($newcu)) {
566 $societeaccount->fk_soc = $object->id;
567 $societeaccount->login =
'';
568 $societeaccount->pass_encoding =
'';
569 $societeaccount->site =
'stripe';
570 $societeaccount->status = $servicestatus;
571 $societeaccount->key_account = $newcu;
572 $societeaccount->site_account = $site_account;
573 $result = $societeaccount->create($user);
579 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"societe_account";
580 $sql .=
" SET key_account = '".$db->escape(
GETPOST(
'key_account',
'alpha')).
"', site_account = '".$db->escape($site_account).
"'";
581 $sql .=
" 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 = ".$servicestatus.
" AND entity = ".$conf->entity;
582 $resql = $db->query($sql);
596 if ($action ==
'setkey_account_supplier')
600 $newsup =
GETPOST(
'key_account_supplier',
'alpha');
604 if (empty($newsup)) {
605 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"oauth_token WHERE fk_soc = ".$object->id.
" AND service = '".$db->escape($service).
"' AND entity = ".$conf->entity;
610 $stripesup = \Stripe\Account::retrieve($db->escape(
GETPOST(
'key_account_supplier',
'alpha')));
611 $tokenstring[
'stripe_user_id'] = $stripesup->id;
612 $tokenstring[
'type'] = $stripesup->type;
613 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"oauth_token";
614 $sql .=
" SET tokenstring = '".$db->escape(json_encode($tokenstring)).
"'";
615 $sql .=
" WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($site_account).
"') AND fk_soc = ".$object->id.
" AND service = '".$db->escape($service).
"' AND entity = ".$conf->entity;
617 $sql .=
" WHERE fk_soc = ".$object->id.
" AND service = '".$db->escape($service).
"' AND entity = ".$conf->entity;
624 $resql = $db->query($sql);
625 $num = $db->num_rows(
$resql);
626 if (empty($num) && !empty($newsup))
629 $stripesup = \Stripe\Account::retrieve($db->escape(
GETPOST(
'key_account_supplier',
'alpha')));
630 $tokenstring[
'stripe_user_id'] = $stripesup->id;
631 $tokenstring[
'type'] = $stripesup->type;
632 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"oauth_token (service, fk_soc, entity, tokenstring)";
633 $sql .=
" VALUES ('".$db->escape($service).
"', ".$object->id.
", ".$conf->entity.
", '".$db->escape(json_encode($tokenstring)).
"')";
639 $resql = $db->query($sql);
644 $stripesupplieracc = $newsup;
651 if ($action ==
'setlocalassourcedefault')
654 $companypaymentmode->setAsDefault($id);
656 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
657 header(
'Location: '.$url);
664 } elseif ($action ==
'setassourcedefault')
667 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
668 if (preg_match(
'/pm_/', $source))
670 $cu->invoice_settings->default_payment_method = (string) $source;
672 $cu->default_source = (string) $source;
674 $result = $cu->save();
676 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
677 header(
'Location: '.$url);
684 } elseif ($action ==
'deletecard' && $source)
687 if (preg_match(
'/pm_/', $source))
689 $payment_method = \Stripe\PaymentMethod::retrieve($source, array(
"stripe_account" => $stripeacc));
692 $payment_method->detach();
695 $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
696 $card = $cu->sources->retrieve(
"$source");
699 if (method_exists($card,
'detach')) {
707 $url = DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id;
708 header(
'Location: '.$url);
725 $form =
new Form($db);
738 if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) ||
GETPOST(
'forcesandbox',
'alpha')))
740 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'),
'',
'warning');
746 $companybankaccount->fetch(0, $object->id);
747 $companypaymentmode->fetch(0, null, $object->id,
'card');
749 $companybankaccount->fetch($id);
750 $companypaymentmode->fetch($id);
752 if (empty($companybankaccount->socid)) $companybankaccount->socid = $object->id;
754 if ($socid && ($action ==
'edit' || $action ==
'editcard') && $user->rights->societe->creer)
756 print '<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'" method="post">';
757 print '<input type="hidden" name="token" value="'.newToken().
'">';
758 $actionforadd =
'update';
759 if ($action ==
'editcard') $actionforadd =
'updatecard';
760 print '<input type="hidden" name="action" value="'.$actionforadd.
'">';
761 print '<input type="hidden" name="id" value="'.GETPOST(
"id",
"int").
'">';
763 if ($socid && ($action ==
'create' || $action ==
'createcard') && $user->rights->societe->creer)
765 print '<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'" method="post">';
766 print '<input type="hidden" name="token" value="'.newToken().
'">';
767 $actionforadd =
'add';
768 if ($action ==
'createcard') $actionforadd =
'addcard';
769 print '<input type="hidden" name="action" value="'.$actionforadd.
'">';
774 if ($socid && $action !=
'edit' && $action !=
'create' && $action !=
'editcard' && $action !=
'createcard')
779 if ($action ==
'delete')
781 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);
784 if ($action ==
'deletecard')
786 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);
789 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
791 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
794 if (!empty($conf->global->SOCIETE_USEPREFIX))
796 print '<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.$object->prefix_comm.
'</td></tr>';
801 print '<div class="fichecenter">';
803 print '<div class="underbanner clearboth"></div>';
804 print '<table class="border tableforfield centpercent">';
808 print '<tr><td class="titlefield">';
809 print $langs->trans(
'CustomerCode').
'</td><td colspan="2">';
810 print $object->code_client;
811 $tmpcheck = $object->check_codeclient();
812 if ($tmpcheck != 0 && $tmpcheck != -5) {
813 print ' <font class="error">('.$langs->trans(
"WrongCustomerCode").
')</font>';
816 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".$socid;
817 $resql = $db->query($sql);
820 $obj = $db->fetch_object(
$resql);
821 $nbFactsClient = $obj->nb;
822 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
823 if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
824 if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
825 if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
826 if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
828 if (!empty($conf->stripe->enabled))
830 $permissiontowrite = $user->rights->societe->creer;
832 print '<tr><td class="titlefield">';
833 print $form->editfieldkey(
"StripeCustomerId",
'key_account', $stripecu, $object, $permissiontowrite,
'string',
'', 0, 2,
'socid');
835 print $form->editfieldval(
"StripeCustomerId",
'key_account', $stripecu, $object, $permissiontowrite,
'string',
'', null, null,
'', 2,
'',
'socid');
836 if (!empty($conf->stripe->enabled) && $stripecu && $action !=
'editkey_account')
839 if (!empty($stripeacc)) $connect = $stripeacc.
'/';
840 $url =
'https://dashboard.stripe.com/'.$connect.
'test/customers/'.$stripecu;
843 $url =
'https://dashboard.stripe.com/'.$connect.
'customers/'.$stripecu;
845 print ' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key = '.$site_account,
'globe').
'</a>';
847 print '</td><td class="right">';
848 if (empty($stripecu))
850 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
851 print '<input type="hidden" name="action" value="synccustomertostripe">';
852 print '<input type="hidden" name="token" value="'.newToken().
'">';
853 print '<input type="hidden" name="socid" value="'.$object->id.
'">';
854 print '<input type="submit" class="button buttongen" name="syncstripecustomer" value="'.$langs->trans(
"CreateCustomerOnStripe").
'">';
861 if ($object->fournisseur)
863 print '<tr><td class="titlefield">';
864 print $langs->trans(
'SupplierCode').
'</td><td colspan="2">';
865 print $object->code_fournisseur;
866 $tmpcheck = $object->check_codefournisseur();
867 if ($tmpcheck != 0 && $tmpcheck != -5) {
868 print ' <font class="error">('.$langs->trans(
"WrongSupplierCode").
')</font>';
871 $sql =
"SELECT count(*) as nb from ".MAIN_DB_PREFIX.
"facture where fk_soc = ".$socid;
872 $resql = $db->query($sql);
874 $obj = $db->fetch_object(
$resql);
875 $nbFactsClient = $obj->nb;
876 $thirdTypeArray[
'customer'] = $langs->trans(
"customer");
877 if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray[
'propal'] = $langs->transnoentitiesnoconv(
'Proposals');
878 if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray[
'order'] = $langs->transnoentitiesnoconv(
'Orders');
879 if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray[
'invoice'] = $langs->transnoentitiesnoconv(
'Invoices');
880 if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray[
'contract'] = $langs->transnoentitiesnoconv(
'Contracts');
883 if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2)
885 $permissiontowrite = $user->rights->societe->creer;
886 $stripesupplieracc = $stripe->getStripeAccount($service, $object->id);
889 print '<tr><td class="titlefield">';
890 print $form->editfieldkey(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite,
'string',
'', 0, 2,
'socid');
892 print $form->editfieldval(
"StripeConnectAccount",
'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite,
'string',
'', null, null,
'', 2,
'',
'socid');
893 if (!empty($conf->stripe->enabled) && $stripesupplieracc && $action !=
'editkey_account_supplier')
897 $url =
'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc;
900 $url =
'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc;
902 print ' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Publishable key '.$site_account,
'globe').
'</a>';
904 print '</td><td class="right">';
905 if (empty($stripesupplieracc))
907 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
908 print '<input type="hidden" name="action" value="syncsuppliertostripe">';
909 print '<input type="hidden" name="token" value="'.newToken().
'">';
910 print '<input type="hidden" name="socid" value="'.$object->id.
'">';
911 print '<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
926 if (!(empty($conf->stripe->enabled)) && $object->client)
929 if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
931 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle',
$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=createcard');
933 print load_fiche_titre($langs->trans(
'StripePaymentModes').($stripeacc ?
' (Stripe connection with StripeConnect account '.$stripeacc.
')' :
' (Stripe connection with keys from Stripe module setup)'), $morehtmlright,
'stripe-s');
935 $listofsources = array();
936 if (is_object($stripe))
939 $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus);
940 if ($customerstripe->id) {
942 if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
944 $listofsources = $customerstripe->sources->data;
946 $service =
'StripeTest';
948 if (!empty($conf->global->STRIPE_LIVE) && !
GETPOST(
'forcesandbox',
'alpha'))
950 $service =
'StripeLive';
955 global $stripearrayofkeysbyenv;
956 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
959 if (empty($stripeacc)) {
960 $paymentmethodobjs = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"));
962 $paymentmethodobjs = \Stripe\PaymentMethod::all(array(
"customer" => $customerstripe->id,
"type" =>
"card"), array(
"stripe_account" => $stripeacc));
965 $listofsources = $paymentmethodobjs->data;
975 dol_syslog(
"Error when searching/loading Stripe customer for thirdparty id =".$object->id);
979 print '<!-- List of stripe payments -->'.
"\n";
980 print '<div class="div-table-responsive-no-min">';
981 print '<table class="liste centpercent">'.
"\n";
982 print '<tr class="liste_titre">';
983 if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
985 print '<td>'.$langs->trans(
'LocalID').
'</td>';
987 print '<td>'.$langs->trans(
'Label').
'</td>';
988 print '<td>'.$langs->trans(
'StripeID').
'</td>';
989 print '<td>'.$langs->trans(
'Type').
'</td>';
990 print '<td>'.$langs->trans(
'Informations').
'</td>';
992 print '<td class="center">'.$langs->trans(
'Default').
'</td>';
993 print '<td>'.$langs->trans(
'Note').
'</td>';
994 print '<td>'.$langs->trans(
'DateModification').
'</td>';
996 $parameters = array(
'arrayfields'=>array(),
'param'=>
'',
'sortfield'=>
'',
'sortorder'=>
'',
'linetype'=>
'stripetitle');
997 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
998 print $hookmanager->resPrint;
1005 $arrayofstripecard = array();
1008 if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
1013 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
"societe_rib";
1014 $sql .=
" WHERE type in ('card')";
1015 $sql .=
" AND fk_soc = ".$object->id;
1016 $sql .=
" AND status = ".$servicestatus;
1018 $resql = $db->query($sql);
1021 $num_rows = $db->num_rows(
$resql);
1025 while ($i < $num_rows)
1029 $obj = $db->fetch_object(
$resql);
1032 $companypaymentmodetemp->fetch($obj->rowid);
1034 $arrayofstripecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref;
1036 print '<tr class="oddeven">';
1038 print $companypaymentmodetemp->id;
1041 print $companypaymentmodetemp->label;
1044 print $companypaymentmodetemp->stripe_card_ref;
1045 if ($companypaymentmodetemp->stripe_card_ref)
1048 if (!empty($stripeacc)) $connect = $stripeacc.
'/';
1049 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$companypaymentmodetemp->stripe_card_ref;
1052 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$companypaymentmodetemp->stripe_card_ref;
1054 print ' <a href="'.$url.
'" target="_stripe">'.
img_picto($langs->trans(
'ShowInStripe').
' - Customer and Publishable key = '.$companypaymentmodetemp->stripe_account,
'globe').
'</a>';
1061 if ($companypaymentmodetemp->proprio)
print '<span class="opacitymedium">'.$companypaymentmodetemp->proprio.
'</span><br>';
1062 if ($companypaymentmodetemp->last_four)
print '....'.$companypaymentmodetemp->last_four;
1063 if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year)
print ' - '.sprintf(
"%02d", $companypaymentmodetemp->exp_date_month).
'/'.$companypaymentmodetemp->exp_date_year.
'';
1065 if ($companypaymentmodetemp->country_code)
1068 print $img ? $img.
' ' :
'';
1070 }
else print img_warning().
' <font class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</font>';
1073 print '<td class="center">';
1074 if (empty($companypaymentmodetemp->default_rib))
1076 print '<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=setlocalassourcedefault&token='.
newToken().
'">';
1084 if (empty($companypaymentmodetemp->stripe_card_ref))
print $langs->trans(
"Local");
1085 else print $langs->trans(
"LocalAndRemote");
1091 $parameters = array(
'arrayfields'=>array(),
'obj'=>$obj,
'linetype'=>
'stripecard');
1092 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1093 print $hookmanager->resPrint;
1095 print '<td class="right nowraponall">';
1096 if ($user->rights->societe->creer)
1098 if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref))
1100 print '<a href="'.$_SERVER[
'PHP_SELF'].
'?action=synccardtostripe&socid='.$object->id.
'&id='.$companypaymentmodetemp->id.
'" class="paddingrightonly marginrightonly">'.$langs->trans(
"CreateCardOnStripe").
'</a>';
1103 print '<a class="editfielda marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=editcard&token='.
newToken().
'">';
1107 print
'<a class="marginleftonly marginrightonly" href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&id='.$companypaymentmodetemp->id.
'&action=deletecard&token='.
newToken().
'">';
1108 print
img_picto($langs->trans(
"Delete"),
'delete');
1121 if (is_array($listofsources) && count($listofsources))
1123 foreach ($listofsources as $src)
1125 if (!empty($arrayofstripecard[$src->id]))
continue;
1129 print '<tr class="oddeven">';
1131 if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD))
1142 if (!empty($stripeacc)) $connect = $stripeacc.
'/';
1144 $url =
'https://dashboard.stripe.com/'.$connect.
'test/search?query='.$src->id;
1148 $url =
'https://dashboard.stripe.com/'.$connect.
'search?query='.$src->id;
1150 print " <a href='".$url.
"' target='_stripe'>".
img_picto($langs->trans(
'ShowInStripe'),
'globe').
"</a>";
1154 if ($src->object ==
'card')
1157 } elseif ($src->object ==
'source' && $src->type ==
'card')
1160 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit')
1162 print
'<span class="fa fa-university fa-2x fa-fw"></span>';
1163 } elseif ($src->object ==
'payment_method' && $src->type ==
'card')
1166 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit')
1168 print
'<span class="fa fa-university fa-2x fa-fw"></span>';
1172 print
'<td valign="middle">';
1173 if ($src->object ==
'card')
1175 print
'....'.$src->last4.
' - '.$src->exp_month.
'/'.$src->exp_year.
'';
1180 print $img ? $img.
' ' :
'';
1182 }
else print
img_warning().
' <font class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</font>';
1183 } elseif ($src->object ==
'source' && $src->type ==
'card')
1185 print
'<span class="opacitymedium">'.$src->owner->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year.
'';
1188 if ($src->card->country)
1191 print $img ? $img.
' ' :
'';
1193 }
else print
img_warning().
' <font class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</font>';
1194 } elseif ($src->object ==
'source' && $src->type ==
'sepa_debit')
1198 if ($src->sepa_debit->country)
1201 print $img ? $img.
' ' :
'';
1202 print
getCountry($src->sepa_debit->country, 1);
1203 }
else print
img_warning().
' <font class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</font>';
1204 } elseif ($src->object ==
'payment_method' && $src->type ==
'card')
1206 print
'<span class="opacitymedium">'.$src->billing_details->name.
'</span><br>....'.$src->card->last4.
' - '.$src->card->exp_month.
'/'.$src->card->exp_year.
'';
1209 if ($src->card->country)
1212 print $img ? $img.
' ' :
'';
1214 }
else print
img_warning().
' <font class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</font>';
1215 } elseif ($src->object ==
'payment_method' && $src->type ==
'sepa_debit')
1219 if ($src->sepa_debit->country)
1222 print $img ? $img.
' ' :
'';
1223 print
getCountry($src->sepa_debit->country, 1);
1224 }
else print
img_warning().
' <font class="error">'.$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CompanyCountry")).
'</font>';
1230 print
'<td class="center" width="50">';
1231 if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) ||
1232 (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id))
1234 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&source='.$src->id.
'&action=setassourcedefault&token='.
newToken().
'">';
1235 print
img_picto($langs->trans(
"Default"),
'off');
1238 print
img_picto($langs->trans(
"Default"),
'on');
1242 print $langs->trans(
"Remote");
1250 $parameters = array(
'arrayfields'=>array(),
'stripesource'=>$src,
'linetype'=>
'stripecardremoteonly');
1251 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
1252 print $hookmanager->resPrint;
1254 print
'<td class="right nowraponall">';
1255 if ($user->rights->societe->creer)
1257 print
'<a href="'.DOL_URL_ROOT.
'/societe/paymentmodes.php?socid='.$object->id.
'&source='.$src->id.
'&action=deletecard&token='.
newToken().
'">';
1258 print
img_picto($langs->trans(
"Delete"),
'delete');
1267 if ($nbremote == 0 && $nblocal == 0)
1270 if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) $colspan++;
1271 print
'<tr><td class="opacitymedium" colspan="'.$colspan.
'">'.$langs->trans(
"None").
'</td></tr>';
1279 if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc))
1281 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');
1282 $balance = \Stripe\Balance::retrieve(array(
"stripe_account" => $stripesupplieracc));
1283 print
'<table class="liste centpercent">'.
"\n";
1284 print
'<tr class="liste_titre">';
1285 print
'<td>'.$langs->trans(
'Currency').
'</td>';
1286 print
'<td>'.$langs->trans(
'Available').
'</td>';
1287 print
'<td>'.$langs->trans(
'Pending').
'</td>';
1288 print
'<td>'.$langs->trans(
'Total').
'</td>';
1291 $currencybalance = array();
1292 if (is_array($balance->available) && count($balance->available))
1294 foreach ($balance->available as $cpt)
1296 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1297 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1298 $currencybalance[$cpt->currency][
'available'] = $cpt->amount / 100;
1300 $currencybalance[$cpt->currency][
'available'] = $cpt->amount;
1302 $currencybalance[$cpt->currency][
'currency'] = $cpt->currency;
1306 if (is_array($balance->pending) && count($balance->pending))
1308 foreach ($balance->pending as $cpt)
1310 $arrayzerounitcurrency = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
1311 if (!in_array($cpt->currency, $arrayzerounitcurrency)) {
1312 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount / 100;
1314 $currencybalance[$cpt->currency][
'pending'] = $currencybalance[$cpt->currency][
'available'] + $cpt->amount;
1319 if (is_array($currencybalance))
1321 foreach ($currencybalance as $cpt)
1323 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>';
1333 $morehtmlright =
dolGetButtonTitle($langs->trans(
'Add'),
'',
'fa fa-plus-circle',
$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=create');
1335 print
load_fiche_titre($langs->trans(
"BankAccounts"), $morehtmlright,
'bank');
1337 $rib_list = $object->get_all_rib();
1338 if (is_array($rib_list))
1340 print
'<div class="div-table-responsive-no-min">';
1341 print
'<table class="liste centpercent">';
1343 print
'<tr class="liste_titre">';
1349 if (!empty($conf->prelevement->enabled))
1360 foreach ($rib_list as $rib)
1362 print
'<tr class="oddeven">';
1364 print
'<td>'.$rib->label.
'</td>';
1366 print
'<td>'.$rib->bank.
'</td>';
1370 foreach ($rib->getFieldsToShow() as $val) {
1371 if ($val ==
'BankCode') {
1372 $string .= $rib->code_banque.
' ';
1373 } elseif ($val ==
'BankAccountNumber') {
1374 $string .= $rib->number.
' ';
1375 } elseif ($val ==
'DeskCode') {
1376 $string .= $rib->code_guichet.
' ';
1377 } elseif ($val ==
'BankAccountNumberKey') {
1378 $string .= $rib->cle_rib.
' ';
1387 if (!empty($rib->label) && $rib->number) {
1389 $string .=
' '.img_picto($langs->trans(
"ValueIsNotValid"),
'warning');
1391 $string .=
' '.img_picto($langs->trans(
"ValueIsValid"),
'info');
1398 print
'<td>'.$rib->iban;
1399 if (!empty($rib->iban)) {
1401 print
' '.img_picto($langs->trans(
"IbanNotValid"),
'warning');
1406 print
'<td>'.$rib->bic;
1407 if (!empty($rib->bic)) {
1409 print
' '.img_picto($langs->trans(
"SwiftNotValid"),
'warning');
1414 if (!empty($conf->prelevement->enabled))
1418 print
'<td>'.$rib->rum.
'</td>';
1420 print
'<td>'.dol_print_date($rib->date_rum,
'day').
'</td>';
1423 print
'<td>'.$rib->frstrecur.
'</td>';
1427 print
'<td class="center" width="70">';
1428 if (!$rib->default_rib) {
1429 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&ribid='.$rib->id.
'&action=setasbankdefault&token='.
newToken().
'">';
1430 print
img_picto($langs->trans(
"Disabled"),
'off');
1433 print
img_picto($langs->trans(
"Enabled"),
'on');
1438 print
'<td class="center">';
1440 $buttonlabel = $langs->trans(
"BuildDoc");
1441 $forname =
'builddocrib'.$rib->id;
1443 include_once DOL_DOCUMENT_ROOT.
'/core/modules/bank/modules_bank.php';
1447 if (is_array($modellist) && count($modellist))
1449 $out .=
'<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG) ?
'' :
'#builddoc').
'" name="'.$forname.
'" id="'.$forname.
'_form" method="post">';
1450 $out .=
'<input type="hidden" name="action" value="builddocrib">';
1451 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1452 $out .=
'<input type="hidden" name="socid" value="'.$object->id.
'">';
1453 $out .=
'<input type="hidden" name="companybankid" value="'.$rib->id.
'">';
1455 if (is_array($modellist) && count($modellist) == 1)
1457 $arraykeys = array_keys($modellist);
1458 $modelselected = $arraykeys[0];
1460 if (!empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF;
1462 $out .= $form->selectarray(
'modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0,
'', 0, 0, 0,
'',
'minwidth100');
1466 if ($conf->global->MAIN_MULTILANGS)
1468 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
1470 $defaultlang = $codelang ? $codelang : $langs->getDefaultLang();
1471 $morecss =
'maxwidth150';
1472 if ($conf->browser->layout ==
'phone') $morecss =
'maxwidth100';
1473 $out .= $formadmin->select_language($defaultlang,
'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss);
1476 $genbutton =
'<input class="button buttongen" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
1477 $genbutton .=
' type="submit" value="'.$buttonlabel.
'"';
1478 if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) $genbutton .=
' disabled';
1480 if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart !=
'unpaid')
1482 $langs->load(
"errors");
1483 $genbutton .=
' '.img_warning($langs->transnoentitiesnoconv(
"WarningNoDocumentModelActivated"));
1485 if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') $genbutton =
'';
1486 if (empty($modellist) && !$showempty && $modulepart !=
'unpaid') $genbutton =
'';
1494 print
'<td class="right nowraponall">';
1495 if ($user->rights->societe->creer)
1497 print
'<a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&id='.$rib->id.
'&action=edit">';
1498 print
img_picto($langs->trans(
"Modify"),
'edit');
1501 print
'<a class="marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&id='.$rib->id.
'&action=delete&token='.
newToken().
'">';
1502 print
img_picto($langs->trans(
"Delete"),
'delete');
1510 if (count($rib_list) == 0)
1513 if (!empty($conf->prelevement->enabled)) $colspan += 2;
1514 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoBANRecord").
'</td></tr>';
1524 if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC))
1528 print
'<div class="fichecenter"><div class="fichehalfleft">';
1529 print
'<a name="builddoc"></a>';
1534 $filedir = $conf->societe->multidir_output[$object->entity].
'/'.$object->id;
1535 $urlsource =
$_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
1536 $genallowed = $user->rights->societe->lire;
1537 $delallowed = $user->rights->societe->creer;
1539 print $formfile->showdocuments(
'company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0,
'entity='.$object->entity, 0,
'', $object->default_lang);
1542 if (!empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD))
1546 $result = $companypaymentmodetemp->fetch(0, null, $object->id,
'ban');
1548 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
1550 $result = $ecmfile->fetch(0,
'',
'',
'',
'', $companybankaccounttemp->table_element, $companypaymentmodetemp->id);
1553 $companybankaccounttemp->last_main_doc = $ecmfile->filepath.
'/'.$ecmfile->filename;
1554 print
'<br><!-- Link to download main doc -->'.
"\n";
1559 print
'</div><div class="fichehalfright"><div class="ficheaddleft">';
1562 print
'</div></div></div>';
1588 if ($socid && $action ==
'edit' && $user->rights->societe->creer)
1592 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1594 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
1596 print
'<div class="underbanner clearboth"></div>';
1598 print
'<div class="div-table-responsive-no-min">';
1599 print
'<table class="border centpercent">';
1601 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
"LabelRIB").
'</td>';
1602 print
'<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.
'"></td></tr>';
1604 print
'<tr><td class="fieldrequired">'.$langs->trans(
"BankName").
'</td>';
1605 print
'<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.
'"></td></tr>';
1608 foreach ($companybankaccount->getFieldsToShow(1) as $val) {
1611 if ($val ==
'BankCode') {
1612 $name =
'code_banque';
1614 $content = $companybankaccount->code_banque;
1615 } elseif ($val ==
'DeskCode') {
1616 $name =
'code_guichet';
1618 $content = $companybankaccount->code_guichet;
1619 } elseif ($val ==
'BankAccountNumber') {
1622 $content = $companybankaccount->number;
1623 } elseif ($val ==
'BankAccountNumberKey') {
1626 $content = $companybankaccount->cle_rib;
1627 } elseif ($val ==
'IBAN') {
1630 $content = $companybankaccount->iban;
1631 if ($companybankaccount->needIBAN()) $require =
true;
1632 $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';
1633 } elseif ($val ==
'BIC') {
1636 $content = $companybankaccount->bic;
1637 if ($companybankaccount->needIBAN()) $require =
true;
1638 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
1641 print
'<tr><td'.($require ?
' class="fieldrequired" ' :
'').
'>';
1643 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
1645 print $langs->trans($val);
1648 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.$content.
'"></td>';
1652 print
'<tr><td>'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
1653 print
'<textarea name="domiciliation" rows="4" cols="40" maxlength="255">';
1654 print $companybankaccount->domiciliation;
1655 print
"</textarea></td></tr>";
1657 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
1658 print
'<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->proprio.
'"></td></tr>';
1659 print
"</td></tr>\n";
1661 print
'<tr><td>'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
1662 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" cols="40" maxlength="255">';
1663 print $companybankaccount->owner_address;
1664 print
"</textarea></td></tr>";
1669 if ($conf->prelevement->enabled)
1673 print
'<div class="div-table-responsive-no-min">';
1674 print
'<table class="border centpercent">';
1676 if (empty($companybankaccount->rum)) $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
1679 print
'<tr><td class="titlefield">'.$langs->trans(
"RUM").
'</td>';
1680 print
'<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).
'"></td></tr>';
1682 print
'<tr><td class="titlefield">'.$langs->trans(
"DateRUM").
'</td>';
1683 print
'<td>'.$form->selectDate(
GETPOST(
'date_rum') ?
GETPOST(
'date_rum') : $companybankaccount->date_rum,
'date_rum', 0, 0, 1,
'date_rum').
'</td></tr>';
1685 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
1686 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RECUR" => $langs->trans(
"RECUR"));
1687 print $form->selectarray(
"frstrecur", $tblArraychoice,
dol_escape_htmltag(
GETPOST(
'frstrecur',
'alpha') ?
GETPOST(
'frstrecur',
'alpha') : $companybankaccount->frstrecur), 0);
1697 print
'<div class="center">';
1698 print
'<input class="button" value="'.$langs->trans(
"Modify").
'" type="submit">';
1699 print
' ';
1700 print
'<input class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
1705 if ($socid && $action ==
'editcard' && $user->rights->societe->creer)
1709 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1711 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
1713 print
'<div class="fichecenter">';
1715 print
'<div class="underbanner clearboth"></div>';
1716 print
'<table class="border centpercent">';
1718 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
1719 print
'<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.
'"></td></tr>';
1721 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
1722 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->proprio.
'"></td></tr>';
1724 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
1725 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.
'"></td></tr>';
1727 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
1729 print $formother->select_month($companypaymentmode->exp_date_month,
'exp_date_month', 1);
1730 print $formother->select_year($companypaymentmode->exp_date_year,
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
1733 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
1734 print
'<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.
'"></td></tr>';
1736 print
'<tr><td>'.$langs->trans(
"StripeID").
" ('card_....')</td>";
1737 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.
'"></td></tr>';
1744 print
'<div class="center">';
1745 print
'<input class="button" value="'.$langs->trans(
"Modify").
'" type="submit">';
1746 print
' ';
1747 print
'<input class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
1753 if ($socid && $action ==
'create' && $user->rights->societe->creer)
1757 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1759 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
1761 print
'<div class="nofichecenter">';
1763 print
'<div class="underbanner clearboth"></div>';
1764 print
'<table class="border centpercent">';
1766 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"LabelRIB").
'</td>';
1767 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST(
'label').
'"></td></tr>';
1769 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Bank").
'</td>';
1770 print
'<td><input class="minwidth200" type="text" name="bank" value="'.GETPOST(
'bank').
'"></td></tr>';
1773 foreach ($companybankaccount->getFieldsToShow(1) as $val) {
1776 if ($val ==
'BankCode') {
1777 $name =
'code_banque';
1779 $content = $companybankaccount->code_banque;
1780 } elseif ($val ==
'DeskCode') {
1781 $name =
'code_guichet';
1783 $content = $companybankaccount->code_guichet;
1784 } elseif ($val ==
'BankAccountNumber') {
1787 $content = $companybankaccount->number;
1788 } elseif ($val ==
'BankAccountNumberKey') {
1791 $content = $companybankaccount->cle_rib;
1792 } elseif ($val ==
'IBAN') {
1795 $content = $companybankaccount->iban;
1796 if ($companybankaccount->needIBAN()) $require =
true;
1797 $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';
1798 } elseif ($val ==
'BIC') {
1801 $content = $companybankaccount->bic;
1802 if ($companybankaccount->needIBAN()) $require =
true;
1803 $tooltip = $langs->trans(
"Example").
': LIABLT2XXXX';
1806 print
'<tr><td'.($require ?
' class="fieldrequired" ' :
'').
'>';
1808 print $form->textwithpicto($langs->trans($val), $tooltip, 4,
'help',
'', 0, 3, $name);
1810 print $langs->trans($val);
1813 print
'<td><input size="'.$size.
'" type="text" class="flat" name="'.$name.
'" value="'.
GETPOST($name).
'"></td>';
1817 print
'<tr><td>'.$langs->trans(
"BankAccountDomiciliation").
'</td><td>';
1818 print
'<textarea name="domiciliation" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
1819 print
GETPOST(
'domiciliation');
1820 print
"</textarea></td></tr>";
1822 print
'<tr><td>'.$langs->trans(
"BankAccountOwner").
'</td>';
1823 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio').
'"></td></tr>';
1824 print
"</td></tr>\n";
1826 print
'<tr><td>'.$langs->trans(
"BankAccountOwnerAddress").
'</td><td>';
1827 print
'<textarea name="owner_address" rows="'.ROWS_4.
'" class="quatrevingtpercent" maxlength="255">';
1828 print
GETPOST(
'owner_address');
1829 print
"</textarea></td></tr>";
1833 if ($conf->prelevement->enabled)
1837 print
'<table class="border centpercent">';
1840 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"RUM").
'</td>';
1841 print
'<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST(
'rum',
'alpha').
'"> <div class="opacitymedium">'.$langs->trans(
"RUMWillBeGenerated").
'</div></td></tr>';
1843 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DateRUM").
'</td>';
1844 print
'<td colspan="4">'.$form->selectDate(
GETPOST(
'date_rum'),
'date_rum', 0, 0, 1,
'date_rum').
'</td></tr>';
1846 print
'<tr><td>'.$langs->trans(
"WithdrawMode").
'</td><td>';
1847 $tblArraychoice = array(
"FRST" => $langs->trans(
"FRST"),
"RECUR" => $langs->trans(
"RECUR"));
1848 print $form->selectarray(
"frstrecur", $tblArraychoice, (
GETPOSTISSET(
'frstrecur') ?
GETPOST(
'frstrecur') :
'FRST'), 0);
1860 print
'<div class="center">';
1861 print
'<input class="button" value="'.$langs->trans(
"Add").
'" type="submit">';
1862 print
' ';
1863 print
'<input name="cancel" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
1868 if ($socid && $action ==
'createcard' && $user->rights->societe->creer)
1872 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1874 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
1876 print
'<div class="nofichecenter">';
1878 print
'<div class="underbanner clearboth"></div>';
1879 print
'<table class="border centpercent">';
1881 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td>';
1882 print
'<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST(
'label',
'alpha').
'"></td></tr>';
1884 print
'<tr><td class="fieldrequired">'.$langs->trans(
"NameOnCard").
'</td>';
1885 print
'<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST(
'proprio',
'alpha').
'"></td></tr>';
1887 print
'<tr><td>'.$langs->trans(
"CardNumber").
'</td>';
1888 print
'<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST(
'cardnumber',
'alpha').
'"></td></tr>';
1890 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpiryDate").
'</td>';
1892 print $formother->select_month(
GETPOST(
'exp_date_month',
'int'),
'exp_date_month', 1);
1893 print $formother->select_year(
GETPOST(
'exp_date_year',
'int'),
'exp_date_year', 1, 5, 10, 0, 0,
'',
'marginleftonly');
1896 print
'<tr><td>'.$langs->trans(
"CVN").
'</td>';
1897 print
'<td><input class="width50" type="text" name="cvn" value="'.GETPOST(
'cvn',
'alpha').
'"></td></tr>';
1899 print
'<tr><td>'.$langs->trans(
"StripeID").
" ('card_....')</td>";
1900 print
'<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST(
'stripe_card_ref',
'alpha').
'"></td></tr>';
1910 print
'<div class="center">';
1911 print
'<input class="button" value="'.$langs->trans(
"Add").
'" type="submit">';
1912 print
' ';
1913 print
'<input name="cancel" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" type="submit">';
1917 if ($socid && ($action ==
'edit' || $action ==
'editcard') && $user->rights->societe->creer)
1921 if ($socid && ($action ==
'create' || $action ==
'createcard') && $user->rights->societe->creer)
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
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.
img_credit_card($brand, $morecss=null)
Return image of a credit card according to its brand name.
dol_now($mode= 'auto')
Return date for now.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage bank accounts description of third parties.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
Class for SocieteAccount.
checkSwiftForAccount($account)
Check SWIFT informations for a bank account.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
showDirectDownloadLink($object)
Return string with full Url.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Class to manage withdrawal receipts.
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_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
print $_SERVER["PHP_SELF"]
Edit parameters.
Class for CompanyPaymentMode.
checkBanForAccount($account)
Check account number informations for a bank account.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_htmloutput_mesg($mesgstring= '', $mesgarray=array(), $style= 'ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
checkIbanForAccount($account)
Check IBAN number informations for a bank account.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
Class to manage ECM files.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
picto_from_langcode($codelang, $moreatt= '')
Return img flag of country for a language code or country code.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...