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 $reshook = $hookmanager->executeHooks(
'getValidPayment', $parameters, $tmpobject, $action);
176 } elseif (!empty($hookmanager->resArray[
'validpaymentmethod'])) {
178 $validpaymentmethod = array_merge($validpaymentmethod, $hookmanager->resArray[
'validpaymentmethod']);
180 $validpaymentmethod = $hookmanager->resArray[
'validpaymentmethod'];
184 return $validpaymentmethod;
195 function showOnlinePaymentUrl($type, $ref, $amount =
'9.99')
200 $langs->loadLangs(array(
'payment',
'stripe'));
204 $out =
img_picto(
'',
'globe').
' <span class="opacitymedium">'.$langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
'</span><br>';
205 $url = getOnlinePaymentUrl(0, $type, $ref, $amount);
206 $out .=
'<div class="urllink"><input type="text" id="onlinepaymenturl" class="quatrevingtpercentminusx" value="'.$url.
'">';
207 $out .=
'<a class="" href="'.$url.
'" target="_blank" rel="noopener noreferrer">'.
img_picto(
'',
'globe',
'class="paddingleft"').
'</a>';
222 function getHtmlOnlinePaymentLink($type, $ref, $label =
'', $amount =
'9.99')
224 $url = getOnlinePaymentUrl(0, $type, $ref, $amount);
225 $label = $label ? $label : $url;
226 return '<a href="'.$url.
'" target="_blank" rel="noopener noreferrer">'.$label.
'</a>';
241 function getOnlinePaymentUrl($mode, $type, $ref =
'', $amount =
'9.99', $freetag =
'your_tag', $localorexternal = 1)
243 global $conf, $dolibarr_main_url_root;
245 $ref = str_replace(
' ',
'', $ref);
249 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
250 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
253 $urltouse = DOL_MAIN_URL_ROOT;
254 if ($localorexternal) {
255 $urltouse = $urlwithroot;
258 if ($type ==
'free') {
259 $out = $urltouse.
'/public/payment/newpayment.php?amount='.($mode ?
'<span style="color: #666666">' :
'').$amount.($mode ?
'</span>' :
'').
'&tag='.($mode ?
'<span style="color: #666666">' :
'').$freetag.($mode ?
'</span>' :
'');
260 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
261 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
262 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
264 $out .=
'&securekey='.urlencode(
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2));
268 } elseif ($type ==
'order') {
269 $out = $urltouse.
'/public/payment/newpayment.php?source='.$type.
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
274 $out .= urlencode($ref);
276 $out .= ($mode ?
'</span>' :
'');
277 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
278 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
279 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
281 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
283 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$type.
"' + order_ref)";
286 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
288 $out .= ($mode ?
'</span>' :
'');
291 } elseif ($type ==
'invoice') {
292 $out = $urltouse.
'/public/payment/newpayment.php?source='.$type.
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
294 $out .=
'invoice_ref';
297 $out .= urlencode($ref);
299 $out .= ($mode ?
'</span>' :
'');
300 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
301 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
302 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
304 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
306 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$type.
"' + invoice_ref)";
309 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
311 $out .= ($mode ?
'</span>' :
'');
314 } elseif ($type ==
'contractline') {
315 $out = $urltouse.
'/public/payment/newpayment.php?source='.$type.
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
317 $out .=
'contractline_ref';
320 $out .= urlencode($ref);
322 $out .= ($mode ?
'</span>' :
'');
323 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
324 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
325 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
327 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
329 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$type.
"' + contractline_ref)";
332 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
334 $out .= ($mode ?
'</span>' :
'');
337 } elseif ($type ==
'member' || $type ==
'membersubscription') {
339 $out = $urltouse.
'/public/payment/newpayment.php?source=member';
340 $out .=
'&amount='.$amount;
341 $out .=
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
343 $out .=
'member_ref';
346 $out .= urlencode($ref);
348 $out .= ($mode ?
'</span>' :
'');
349 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
350 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
351 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
353 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
355 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$newtype.
"' + member_ref)";
358 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$newtype.$ref, 2);
360 $out .= ($mode ?
'</span>' :
'');
363 } elseif ($type ==
'donation') {
364 $out = $urltouse.
'/public/payment/newpayment.php?source='.$type.
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
366 $out .=
'donation_ref';
369 $out .= urlencode($ref);
371 $out .= ($mode ?
'</span>' :
'');
372 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
373 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
374 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
376 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
378 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$type.
"' + donation_ref)";
381 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
383 $out .= ($mode ?
'</span>' :
'');
386 } elseif ($type ==
'boothlocation') {
387 $out = $urltouse.
'/public/payment/newpayment.php?source='.$type.
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
389 $out .=
'invoice_ref';
392 $out .= urlencode($ref);
394 $out .= ($mode ?
'</span>' :
'');
395 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
396 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
397 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
399 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
401 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$type.
"' + invoice_ref)";
404 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
406 $out .= ($mode ?
'</span>' :
'');
413 $out .=
"&entity=".$conf->entity;
431 function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, $suffix =
'', $object =
null)
437 if ($fromcompany->forme_juridique_code) {
441 if ($fromcompany->capital) {
442 $line1 .= ($line1 ?
" - " :
"").$langs->transnoentities(
"CapitalOf", $fromcompany->capital).
" ".$langs->transnoentities(
"Currency".$conf->currency);
445 if ($fromcompany->idprof1 && ($fromcompany->country_code !=
'FR' || !$fromcompany->idprof2)) {
446 $field = $langs->transcountrynoentities(
"ProfId1", $fromcompany->country_code);
447 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
450 $line1 .= ($line1 ?
" - " :
"").$field.
": ".$fromcompany->idprof1;
453 if ($fromcompany->idprof2) {
454 $field = $langs->transcountrynoentities(
"ProfId2", $fromcompany->country_code);
455 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
458 $line1 .= ($line1 ?
" - " :
"").$field.
": ".$fromcompany->idprof2;
464 if ($fromcompany->idprof3) {
465 $field = $langs->transcountrynoentities(
"ProfId3", $fromcompany->country_code);
466 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
469 $line2 .= ($line2 ?
" - " :
"").$field.
": ".$fromcompany->idprof3;
472 if ($fromcompany->idprof4) {
473 $field = $langs->transcountrynoentities(
"ProfId4", $fromcompany->country_code);
474 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
477 $line2 .= ($line2 ?
" - " :
"").$field.
": ".$fromcompany->idprof4;
480 if ($fromcompany->tva_intra !=
'') {
481 $line2 .= ($line2 ?
" - " :
"").$langs->transnoentities(
"VATIntraShort").
": ".$fromcompany->tva_intra;
484 print
'<!-- htmlPrintOnlinePaymentFooter -->'.
"\n";
488 print
'<div class="center paddingleft paddingright">'.
"\n";
489 if ($addformmessage) {
490 print
'<!-- object = '.(empty($object) ?
'undefined' : $object->element).
' -->';
493 $parammessageform =
'ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix;
494 if (!empty($conf->global->$parammessageform)) {
495 print $langs->transnoentities($conf->global->$parammessageform);
496 } elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) {
497 print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM);
501 if (!empty($object->total_vat) || !empty($object->total_tva)) {
502 $parammessageform =
'ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix;
503 if (!empty($conf->global->$parammessageform)) {
504 print $langs->transnoentities($conf->global->$parammessageform);
505 } elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) {
506 print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT);
511 print
'<span style="font-size: 10px;"><br><hr>'.
"\n";
512 print $fromcompany->name.
'<br>';
514 if (strlen($line1.$line2) > 50) {
520 print
'</span></div>'.
"\n";