30 function payment_prepare_head(
Paiement $object)
37 $head[$h][0] = DOL_URL_ROOT.
'/compta/paiement/card.php?id='.$object->id;
38 $head[$h][1] = $langs->trans(
"Payment");
39 $head[$h][2] =
'payment';
48 $head[$h][0] = DOL_URL_ROOT.
'/compta/paiement/info.php?id='.$object->id;
49 $head[$h][1] = $langs->trans(
"Info");
50 $head[$h][2] =
'info';
65 function bankline_prepare_head($id)
72 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/line.php?rowid='.$id;
73 $head[$h][1] = $langs->trans(
'BankTransaction');
74 $head[$h][2] =
'bankline';
83 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/info.php?rowid='.$id;
84 $head[$h][1] = $langs->trans(
"Info");
85 $head[$h][2] =
'info';
100 function payment_supplier_prepare_head(
Paiement $object)
102 global $db, $langs, $conf;
107 $head[$h][0] = DOL_URL_ROOT.
'/fourn/paiement/card.php?id='.$object->id;
108 $head[$h][1] = $langs->trans(
"Payment");
109 $head[$h][2] =
'payment';
118 $head[$h][0] = DOL_URL_ROOT.
'/fourn/paiement/info.php?id='.$object->id;
119 $head[$h][1] = $langs->trans(
'Info');
120 $head[$h][2] =
'info';
123 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
124 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
125 $upload_dir = $conf->fournisseur->payment->dir_output.
'/'.$object->ref;
126 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
127 $nbLinks =
Link::count($db, $object->element, $object->id);
128 $head[$h][0] = DOL_URL_ROOT.
'/fourn/paiement/document.php?id='.$object->id;
129 $head[$h][1] = $langs->trans(
'Documents');
130 if (($nbFiles + $nbLinks) > 0) {
131 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
133 $head[$h][2] =
'documents';
147 function getValidOnlinePaymentMethods($paymentmethod =
'')
149 global $conf, $langs, $hookmanager, $action;
151 $validpaymentmethod = array();
153 if ((empty($paymentmethod) || $paymentmethod ==
'paypal') &&
isModEnabled(
'paypal')) {
154 $langs->load(
"paypal");
155 $validpaymentmethod[
'paypal'] =
'valid';
157 if ((empty($paymentmethod) || $paymentmethod ==
'paybox') &&
isModEnabled(
'paybox')) {
158 $langs->load(
"paybox");
159 $validpaymentmethod[
'paybox'] =
'valid';
161 if ((empty($paymentmethod) || $paymentmethod ==
'stripe') &&
isModEnabled(
'stripe')) {
162 $langs->load(
"stripe");
163 $validpaymentmethod[
'stripe'] =
'valid';
169 'paymentmethod' => $paymentmethod,
170 'validpaymentmethod' => &$validpaymentmethod
172 $tmpobject =
new stdClass();
173 $hookmanager->executeHooks(
'doValidatePayment', $parameters, $tmpobject, $action);
175 return $validpaymentmethod;
186 function showOnlinePaymentUrl($type, $ref, $amount =
'9.99')
191 $langs->loadLangs(array(
'payment',
'stripe'));
195 $out =
img_picto(
'',
'globe').
' <span class="opacitymedium">'.$langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
'</span><br>';
196 $url = getOnlinePaymentUrl(0, $type, $ref, $amount);
197 $out .=
'<div class="urllink"><input type="text" id="onlinepaymenturl" class="quatrevingtpercentminusx" value="'.$url.
'">';
198 $out .=
'<a class="" href="'.$url.
'" target="_blank" rel="noopener noreferrer">'.
img_picto(
'',
'globe',
'class="paddingleft"').
'</a>';
213 function getHtmlOnlinePaymentLink($type, $ref, $label =
'', $amount =
'9.99')
215 $url = getOnlinePaymentUrl(0, $type, $ref, $amount);
216 $label = $label ? $label : $url;
217 return '<a href="'.$url.
'" target="_blank" rel="noopener noreferrer">'.$label.
'</a>';
232 function getOnlinePaymentUrl($mode, $type, $ref =
'', $amount =
'9.99', $freetag =
'your_tag', $localorexternal = 1)
234 global $conf, $dolibarr_main_url_root;
236 $ref = str_replace(
' ',
'', $ref);
240 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
241 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
244 $urltouse = DOL_MAIN_URL_ROOT;
245 if ($localorexternal) {
246 $urltouse = $urlwithroot;
249 if ($type ==
'free') {
250 $out = $urltouse.
'/public/payment/newpayment.php?amount='.($mode ?
'<span style="color: #666666">' :
'').$amount.($mode ?
'</span>' :
'').
'&tag='.($mode ?
'<span style="color: #666666">' :
'').$freetag.($mode ?
'</span>' :
'');
251 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
252 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
253 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
255 $out .=
'&securekey='.urlencode(
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2));
259 } elseif ($type ==
'order') {
260 $out = $urltouse.
'/public/payment/newpayment.php?source='.$type.
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
265 $out .= urlencode($ref);
267 $out .= ($mode ?
'</span>' :
'');
268 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
269 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
270 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
272 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
274 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$type.
"' + order_ref)";
277 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
279 $out .= ($mode ?
'</span>' :
'');
282 } elseif ($type ==
'invoice') {
283 $out = $urltouse.
'/public/payment/newpayment.php?source='.$type.
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
285 $out .=
'invoice_ref';
288 $out .= urlencode($ref);
290 $out .= ($mode ?
'</span>' :
'');
291 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
292 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
293 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
295 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
297 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$type.
"' + invoice_ref)";
300 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
302 $out .= ($mode ?
'</span>' :
'');
305 } elseif ($type ==
'contractline') {
306 $out = $urltouse.
'/public/payment/newpayment.php?source='.$type.
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
308 $out .=
'contractline_ref';
311 $out .= urlencode($ref);
313 $out .= ($mode ?
'</span>' :
'');
314 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
315 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
316 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
318 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
320 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$type.
"' + contractline_ref)";
323 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
325 $out .= ($mode ?
'</span>' :
'');
328 } elseif ($type ==
'member' || $type ==
'membersubscription') {
330 $out = $urltouse.
'/public/payment/newpayment.php?source=member';
331 $out .=
'&amount='.$amount;
332 $out .=
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
334 $out .=
'member_ref';
337 $out .= urlencode($ref);
339 $out .= ($mode ?
'</span>' :
'');
340 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
341 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
342 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
344 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
346 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$newtype.
"' + member_ref)";
349 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$newtype.$ref, 2);
351 $out .= ($mode ?
'</span>' :
'');
354 } elseif ($type ==
'donation') {
355 $out = $urltouse.
'/public/payment/newpayment.php?source='.$type.
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
357 $out .=
'donation_ref';
360 $out .= urlencode($ref);
362 $out .= ($mode ?
'</span>' :
'');
363 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
364 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
365 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
367 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
369 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$type.
"' + donation_ref)";
372 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
374 $out .= ($mode ?
'</span>' :
'');
377 } elseif ($type ==
'boothlocation') {
378 $out = $urltouse.
'/public/payment/newpayment.php?source='.$type.
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
380 $out .=
'invoice_ref';
383 $out .= urlencode($ref);
385 $out .= ($mode ?
'</span>' :
'');
386 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
387 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
388 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
390 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
392 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$type.
"' + invoice_ref)";
395 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
397 $out .= ($mode ?
'</span>' :
'');
404 $out .=
"&entity=".$conf->entity;
422 function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, $suffix =
'', $object =
null)
428 if ($fromcompany->forme_juridique_code) {
432 if ($fromcompany->capital) {
433 $line1 .= ($line1 ?
" - " :
"").$langs->transnoentities(
"CapitalOf", $fromcompany->capital).
" ".$langs->transnoentities(
"Currency".$conf->currency);
436 if ($fromcompany->idprof1 && ($fromcompany->country_code !=
'FR' || !$fromcompany->idprof2)) {
437 $field = $langs->transcountrynoentities(
"ProfId1", $fromcompany->country_code);
438 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
441 $line1 .= ($line1 ?
" - " :
"").$field.
": ".$fromcompany->idprof1;
444 if ($fromcompany->idprof2) {
445 $field = $langs->transcountrynoentities(
"ProfId2", $fromcompany->country_code);
446 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
449 $line1 .= ($line1 ?
" - " :
"").$field.
": ".$fromcompany->idprof2;
455 if ($fromcompany->idprof3) {
456 $field = $langs->transcountrynoentities(
"ProfId3", $fromcompany->country_code);
457 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
460 $line2 .= ($line2 ?
" - " :
"").$field.
": ".$fromcompany->idprof3;
463 if ($fromcompany->idprof4) {
464 $field = $langs->transcountrynoentities(
"ProfId4", $fromcompany->country_code);
465 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
468 $line2 .= ($line2 ?
" - " :
"").$field.
": ".$fromcompany->idprof4;
471 if ($fromcompany->tva_intra !=
'') {
472 $line2 .= ($line2 ?
" - " :
"").$langs->transnoentities(
"VATIntraShort").
": ".$fromcompany->tva_intra;
475 print
'<!-- htmlPrintOnlinePaymentFooter -->'.
"\n";
479 print
'<div class="center paddingleft paddingright">'.
"\n";
480 if ($addformmessage) {
481 print
'<!-- object = '.(empty($object) ?
'undefined' : $object->element).
' -->';
484 $parammessageform =
'ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix;
485 if (!empty($conf->global->$parammessageform)) {
486 print $langs->transnoentities($conf->global->$parammessageform);
487 } elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) {
488 print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM);
492 if (!empty($object->total_vat) || !empty($object->total_tva)) {
493 $parammessageform =
'ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix;
494 if (!empty($conf->global->$parammessageform)) {
495 print $langs->transnoentities($conf->global->$parammessageform);
496 } elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) {
497 print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT);
502 print
'<span style="font-size: 10px;"><br><hr>'.
"\n";
503 print $fromcompany->name.
'<br>';
505 if (strlen($line1.$line2) > 50) {
511 print
'</span></div>'.
"\n";
static count($dbs, $objecttype, $objectid)
Return nb of links.
Class to manage payments of customer invoices.
getFormeJuridiqueLabel($code)
Retourne le nom traduit de la forme juridique.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
isModEnabled($module)
Is Dolibarr module enabled.
dol_hash($chain, $type='0')
Returns a hash (non reversible encryption) of a string.