30function 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';
65function 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';
100function 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';
147function getValidOnlinePaymentMethods($paymentmethod =
'')
149 global $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;
195function showOnlinePaymentUrl($type, $ref, $amount = 0)
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>';
222function getHtmlOnlinePaymentLink($type, $ref, $label =
'', $amount = 0)
224 $url = getOnlinePaymentUrl(0, $type, $ref, $amount);
225 $label = $label ? $label : $url;
226 return '<a href="'.$url.
'" target="_blank" rel="noopener noreferrer">'.$label.
'</a>';
241function getOnlinePaymentUrl($mode, $type, $ref =
'', $amount = 0, $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;
256 if ($localorexternal) {
257 $urltouse = $urlwithroot;
260 if ($type ==
'free') {
261 $out = $urltouse.
'/public/payment/newpayment.php?amount='.($mode ?
'<span style="color: #666666">' :
'').$amount.($mode ?
'</span>' :
'').
'&tag='.($mode ?
'<span style="color: #666666">' :
'').$freetag.($mode ?
'</span>' :
'');
262 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
263 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
264 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
266 $out .=
'&securekey='.urlencode(
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2));
270 } elseif ($type ==
'order') {
271 $out = $urltouse.
'/public/payment/newpayment.php?source='.$type.
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
276 $out .= urlencode($ref);
278 $out .= ($mode ?
'</span>' :
'');
279 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
280 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
281 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
283 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
285 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$type.
"' + order_ref)";
288 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
290 $out .= ($mode ?
'</span>' :
'');
293 } elseif ($type ==
'invoice') {
294 $out = $urltouse.
'/public/payment/newpayment.php?source='.$type.
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
296 $out .=
'invoice_ref';
299 $out .= urlencode($ref);
301 $out .= ($mode ?
'</span>' :
'');
302 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
303 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
304 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
306 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
308 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$type.
"' + invoice_ref)";
311 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
313 $out .= ($mode ?
'</span>' :
'');
316 } elseif ($type ==
'contractline') {
317 $out = $urltouse.
'/public/payment/newpayment.php?source='.$type.
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
319 $out .=
'contractline_ref';
322 $out .= urlencode($ref);
324 $out .= ($mode ?
'</span>' :
'');
325 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
326 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
327 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
329 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
331 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$type.
"' + contractline_ref)";
334 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
336 $out .= ($mode ?
'</span>' :
'');
339 } elseif ($type ==
'member' || $type ==
'membersubscription') {
341 $out = $urltouse.
'/public/payment/newpayment.php?source=member';
342 $out .=
'&amount='.$amount;
343 $out .=
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
345 $out .=
'member_ref';
348 $out .= urlencode($ref);
350 $out .= ($mode ?
'</span>' :
'');
351 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
352 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
353 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
355 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
357 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$newtype.
"' + member_ref)";
360 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$newtype.$ref, 2);
362 $out .= ($mode ?
'</span>' :
'');
365 } elseif ($type ==
'donation') {
366 $out = $urltouse.
'/public/payment/newpayment.php?source='.$type.
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
368 $out .=
'donation_ref';
371 $out .= urlencode($ref);
373 $out .= ($mode ?
'</span>' :
'');
374 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
375 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
376 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
378 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
380 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$type.
"' + donation_ref)";
383 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
385 $out .= ($mode ?
'</span>' :
'');
388 } elseif ($type ==
'boothlocation') {
389 $out = $urltouse.
'/public/payment/newpayment.php?source='.$type.
'&ref='.($mode ?
'<span style="color: #666666">' :
'');
391 $out .=
'invoice_ref';
394 $out .= urlencode($ref);
396 $out .= ($mode ?
'</span>' :
'');
397 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
398 if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
399 $out .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
401 $out .=
'&securekey='.($mode ?
'<span style="color: #666666">' :
'');
403 $out .=
"hash('".$conf->global->PAYMENT_SECURITY_TOKEN.
"' + '".$type.
"' + invoice_ref)";
406 $out .=
dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.$type.$ref, 2);
408 $out .= ($mode ?
'</span>' :
'');
414 if (!empty($out) && isModEnabled(
'multicompany')) {
415 $out .=
"&entity=".$conf->entity;
static count($dbs, $objecttype, $objectid)
Return nb of links.
Class to manage payments of customer invoices.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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).
dol_hash($chain, $type='0')
Returns a hash (non reversible encryption) of a string.