32if (!defined(
'NOTOKENRENEWAL')) {
33 define(
'NOTOKENRENEWAL',
'1');
35if (!defined(
'NOREQUIREMENU')) {
36 define(
'NOREQUIREMENU',
'1');
38if (!defined(
'NOREQUIREHTML')) {
39 define(
'NOREQUIREHTML',
'1');
43require
'../main.inc.php';
52require_once DOL_DOCUMENT_ROOT.
'/blockedlog/lib/blockedlog.lib.php';
53require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
57$langs->loadLangs(array(
"main",
"bills",
"cashdesk",
"banks"));
59$action =
GETPOST(
'action',
'aZ09');
61$place = (
GETPOST(
'place',
'aZ09') ?
GETPOST(
'place',
'aZ09') :
'0');
65$hookmanager->initHooks(array(
'takepospay'));
67if (!$user->hasRight(
'takepos',
'run')) {
76$arrayofcss = array(
'/takepos/css/pos.css.php');
84$head =
'<link rel="stylesheet" href="css/pos.css.php">';
86 $head .=
'<link rel="stylesheet" href="css/colorful.css">';
89top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
95$usestripeterminals = 0;
96$keyforstripeterminalbank =
'';
102 $service =
'StripeTest';
105 $service =
'StripeLive';
110 global $stripearrayofkeysbyenv;
111 $site_account = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
113 $stripe =
new Stripe($db);
114 $stripeacc = $stripe->getStripeAccount($service);
116 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
117 $invoicetmp =
new Facture($db);
118 $invoicetmp->fetch($invoiceid);
119 $stripecu = $stripe->getStripeCustomerAccount($invoicetmp->socid, $servicestatus, $site_account);
120 $keyforstripeterminalbank =
"CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".(empty($_SESSION[
'takeposterminal']) ?
'' : $_SESSION[
'takeposterminal']);
124 if ($usestripeterminals) {
126<script src=
"https://js.stripe.com/terminal/v1/"></script>
128var terminal = StripeTerminal.create({
129 onFetchConnectionToken: fetchConnectionToken,
130 onUnexpectedReaderDisconnect: unexpectedDisconnect,
133function unexpectedDisconnect() {
136 console.log(
"Disconnected from reader")
139function fetchConnectionToken() {
141 $urlconnexiontoken = DOL_URL_ROOT.
'/stripe/ajax/ajax.php?action=getConnexionToken&token='.
newToken().
'&servicestatus='.urlencode((
string) ($servicestatus));
145 if (!empty($stripeacc)) {
146 $urlconnexiontoken .=
'&stripeacc='.urlencode($stripeacc);
149 return fetch(
'<?php echo $urlconnexiontoken; ?>', { method:
"POST" })
150 .then(
function(response) {
151 return response.json();
153 .then(
function(data) {
164 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'), [],
'warning', 1);
169 $invoice->fetch($invoiceid);
171 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
172 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
173 $sql .=
" AND ref = '(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
174 $resql = $db->query($sql);
175 $obj = $db->fetch_object($resql);
177 $invoiceid = $obj->rowid;
182 $invoice->fetch($invoiceid);
189if ($usestripeterminals && $invoice->type != $invoice::TYPE_CREDIT_NOTE) {
190 if (!
getDolGlobalString((
string) $keyforstripeterminalbank) || $stripeacc ===
null) { ?>
192 simulated: <?php
if (empty($servicestatus) &&
getDolGlobalString(
'STRIPE_TERMINAL_SIMULATED')) { ?>
true <?php }
else { ?> false <?php } ?>
193 <?php
if (
getDolGlobalString(
'STRIPE_LOCATION')) { ?>, location:
'<?php echo dol_escape_js(getDolGlobalString('STRIPE_LOCATION
')); ?>'<?php } ?>
195 terminal.discoverReaders(config).then(
function(discoverResult) {
196 if (discoverResult.error) {
197 console.log(
'Failed to discover: ', discoverResult.error);
198 }
else if (discoverResult.discoveredReaders.length === 0) {
199 console.log(
'No available readers.');
203 selectedReader = discoverResult.discoveredReaders[0];
206 terminal.connectReader(selectedReader).then(function(connectResult) {
207 if (connectResult.error) {
208 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error">'+connectResult.error.message+
'</div>';
209 console.log(
'Failed to connect: ', connectResult.error);
211 document.getElementById(
"card-present-alert").innerHTML =
'';
212 console.log(
'Connected to reader: ', connectResult.reader.label);
213 if (document.getElementById(
"StripeTerminal")) {
214 document.getElementById(
"StripeTerminal").innerHTML =
'<button type="button" class="calcbutton2" onclick="ValidateStripeTerminal();"><span class="fa fa-2x fa-credit-card iconwithlabel"></span><br>'+connectResult.reader.label+
'</button>';
221 terminal.connectReader(<?php echo json_encode($stripe->getSelectedReader(
getDolGlobalString((
string) $keyforstripeterminalbank), $stripeacc, $servicestatus)); ?>).then(
function(connectResult) {
222 if (connectResult.error) {
223 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error clearboth">'+connectResult.error.message+
'</div>';
224 console.log(
'Failed to connect: ', connectResult.error);
226 document.getElementById(
"card-present-alert").innerHTML =
'';
227 console.log(
'Connected to reader: ', connectResult.reader.label);
228 if (document.getElementById(
"StripeTerminal")) {
229 document.getElementById(
"StripeTerminal").innerHTML =
'<button type="button" class="calcbutton2" onclick="ValidateStripeTerminal();"><span class="fa fa-2x fa-credit-card iconwithlabel"></span><br>'+connectResult.reader.label+
'</button>';
240$arrayOfValidPaymentModes = array();
241$arrayOfValidBankAccount = array();
243$sql =
"SELECT code, libelle as label FROM ".MAIN_DB_PREFIX.
"c_paiement";
244$sql .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
245$sql .=
" AND active = 1";
249 $sql .=
" AND code IN ('LIQ', 'CB', 'CHQ')";
251$sql .=
" ORDER BY libelle";
252$resql = $db->query($sql);
255 while ($obj = $db->fetch_object($resql)) {
256 $paycode = $obj->code;
257 if ($paycode ==
'LIQ') {
260 if ($paycode ==
'CB') {
263 if ($paycode ==
'CHQ') {
267 $accountname =
"CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION[
"takeposterminal"];
270 $arrayOfValidPaymentModes[] = $obj;
273 if ($paycode ==
'CASH' || $paycode ==
'CB') {
274 $arrayOfValidPaymentModes[] = $obj;
285if ($invoice->id > 0) {
286 $remaintopay = $invoice->getRemainToPay();
288$alreadypayed = (is_object($invoice) ? ($invoice->total_ttc - $remaintopay) : 0);
291 print
"var received='';";
293 print
"var received=0;";
297 var alreadypayed = <?php echo $alreadypayed ?>;
299 function addreceived(
price)
303 print
'received+=String(price);'.
"\n";
305 print
'received+=parseFloat(price);'.
"\n";
308 $(
'.change1').html(
pricejs(parseFloat(received),
'MT'));
309 $(
'.change1').val(parseFloat(received));
310 console.log(alreadypayed);
311 console.log(received);
312 alreadypaydplusreceived =
price2numjs(alreadypayed + parseFloat(received));
315 if (alreadypaydplusreceived > <?php echo (
float) $invoice->total_ttc; ?>)
317 var change=parseFloat(alreadypayed + parseFloat(received) - <?php echo (
float) $invoice->total_ttc; ?>);
318 $(
'.change2').html(
pricejs(change,
'MT'));
319 $(
'.change2').val(change);
320 $(
'.change1').removeClass(
'colorred');
321 $(
'.change1').addClass(
'colorgreen');
322 $(
'.change2').removeClass(
'colorwhite');
323 $(
'.change2').addClass(
'colorred');
327 $(
'.change2').html(
pricejs(0,
'MT'));
328 $(
'.change2').val(0);
329 if (alreadypaydplusreceived == <?php echo (
float) $invoice->total_ttc; ?>) {
330 $(
'.change1').removeClass(
'colorred');
331 $(
'.change1').addClass(
'colorgreen');
332 $(
'.change2').removeClass(
'colorred');
333 $(
'.change2').addClass(
'colorwhite');
335 $(
'.change1').removeClass(
'colorgreen');
336 $(
'.change1').addClass(
'colorred');
337 $(
'.change2').removeClass(
'colorred');
338 $(
'.change2').addClass(
'colorwhite');
348 $(
'.change1').html(
pricejs(received,
'MT'));
350 $(
'.change2').html(
pricejs(received,
'MT'));
352 $(
'.change1').removeClass(
'colorgreen');
353 $(
'.change1').addClass(
'colorred');
354 $(
'.change2').removeClass(
'colorred');
355 $(
'.change2').addClass(
'colorwhite');
360 console.log(
"Launch Validate");
362 var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
363 var accountid = $(
"#selectaccountid").val();
364 var amountpayed = $(
"#change1").val();
365 var excess = $(
"#change2").val();
366 if (amountpayed > <?php echo (
float) $invoice->total_ttc; ?>) {
367 amountpayed = <?php echo (
float) $invoice->total_ttc; ?>;
369 console.log(
"We click on the payment mode to pay amount = "+amountpayed);
370 parent.$(
"#poslines").load(
"invoice.php?place=<?php echo $place; ?>&action=valid&token=<?php echo newToken(); ?>&pay="+payment+
"&amount="+amountpayed+
"&excess="+excess+
"&invoiceid="+invoiceid+
"&accountid="+accountid,
function() {
371 if (amountpayed > <?php echo (
float) $remaintopay; ?> || amountpayed == <?php echo (
float) $remaintopay; ?> || amountpayed == 0 ) {
372 console.log(
"Close popup");
373 parent.$(
'#invoiceid').val(
"");
374 parent.$.colorbox.close();
376 console.log(
"Amount is not complete, so we do NOT close popup and reload it.");
384 function fetchPaymentIntentClientSecret(
amount, invoiceid) {
385 const bodyContent = JSON.stringify({
amount :
amount, invoiceid : invoiceid });
387 $urlpaymentintent = DOL_URL_ROOT.
'/stripe/ajax/ajax.php?action=createPaymentIntent&token='.
newToken().
'&servicestatus='.urlencode((
string) $servicestatus);
388 if (!empty($stripeacc)) {
389 $urlpaymentintent .=
'&stripeacc='.$stripeacc;
392 return fetch(
'<?php echo $urlpaymentintent; ?>', {
395 'Content-Type':
'application/json'
399 .then(
function(response) {
400 return response.json();
402 .then(
function(data) {
403 return data.client_secret;
408 function capturePaymentIntent(paymentIntentId) {
409 const bodyContent = JSON.stringify({
"id": paymentIntentId})
411 $urlpaymentintent = DOL_URL_ROOT.
'/stripe/ajax/ajax.php?action=capturePaymentIntent&token='.
newToken().
'&servicestatus='.urlencode((
string) ($servicestatus));
412 if (!empty($stripeacc)) {
413 $urlpaymentintent .=
'&stripeacc='.urlencode($stripeacc);
416 return fetch(
'<?php echo $urlpaymentintent; ?>', {
419 'Content-Type':
'application/json'
423 .then(
function(response) {
424 return response.json();
426 .then(
function(data) {
427 return data.client_secret;
432 function ValidateStripeTerminal() {
433 console.log(
"Launch ValidateStripeTerminal");
434 var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
435 var accountid = $(
"#selectaccountid").val();
436 var amountpayed = $(
"#change1").val();
437 var excess = $(
"#change2").val();
438 if (amountpayed > <?php echo (
float) $invoice->getRemainToPay(); ?>) {
439 amountpayed = <?php echo (
float) $invoice->getRemainToPay(); ?>;
441 if (amountpayed == 0) {
442 amountpayed = <?php echo (
float) $invoice->getRemainToPay(); ?>;
445 console.log(
"Pay with terminal ", amountpayed);
447 fetchPaymentIntentClientSecret(amountpayed, invoiceid).then(
function(client_secret) {
448 <?php
if (empty($servicestatus) &&
getDolGlobalString(
'STRIPE_TERMINAL_SIMULATED')) { ?>
449 terminal.setSimulatorConfiguration({testCardNumber:
'<?php echo dol_escape_js(getDolGlobalString('STRIPE_TERMINAL_SIMULATED
')); ?>'});
451 document.getElementById(
"card-present-alert").innerHTML =
'<div class="warning clearboth"><?php echo $langs->trans('PaymentSendToStripeTerminal
'); ?></div>';
452 terminal.collectPaymentMethod(client_secret).then(
function(result) {
455 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error clearboth">'+result.error.message+
'</div>';
457 document.getElementById(
"card-present-alert").innerHTML =
'<div class="warning clearboth"><?php echo $langs->trans('PaymentBeingProcessed
'); ?></div>';
458 console.log(
'terminal.collectPaymentMethod', result.paymentIntent);
459 terminal.processPayment(result.paymentIntent).then(function(result) {
461 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error clearboth">'+result.error.message+
'</div>';
462 console.log(result.error)
463 } else if (result.paymentIntent) {
464 paymentIntentId = result.paymentIntent.id;
465 console.log(
'terminal.processPayment', result.paymentIntent);
466 capturePaymentIntent(paymentIntentId).then(function(client_secret) {
469 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error clearboth">'+result.error.message+
'</div>';
470 console.log(
"error when capturing paymentIntent", result.error);
472 document.getElementById(
"card-present-alert").innerHTML =
'<div class="warning clearboth"><?php echo $langs->trans('PaymentValidated
'); ?></div>';
473 console.log(
"Capture paymentIntent successful "+paymentIntentId);
474 parent.$(
"#poslines").load(
"invoice.php?place=<?php echo $place; ?>&action=valid&token=<?php echo newToken(); ?>&pay=CB&amount="+amountpayed+
"&excess="+excess+
"&invoiceid="+invoiceid+
"&accountid="+accountid, function() {
475 if (amountpayed > <?php echo (float) $remaintopay; ?> || amountpayed == <?php echo (float) $remaintopay; ?> || amountpayed == 0 ) {
476 console.log(
"Close popup");
477 parent.$.colorbox.close();
480 console.log(
"Amount is not comple, so we do NOT close popup and reload it.");
494 function ValidateSumup() {
495 console.log(
"Launch ValidateSumup");
496 <?php $_SESSION[
'SMP_CURRENT_PAYMENT'] =
"NEW" ?>
497 var invoiceid = <?php echo ($invoiceid > 0 ? $invoiceid : 0); ?>;
498 var amountpayed = $(
"#change1").val();
499 if (amountpayed > <?php echo (
float) $invoice->total_ttc; ?>) {
500 amountpayed = <?php echo (
float) $invoice->total_ttc; ?>;
502 if (amountpayed == 0) {
503 amountpayed = <?php echo (
float) $invoice->total_ttc; ?>;
505 var currencycode =
"<?php echo $invoice->multicurrency_code; ?>";
508 window.open(
'sumupmerchant://pay/1.0?affiliate-key=<?php echo urlencode(getDolGlobalString('TAKEPOS_SUMUP_AFFILIATE
')) ?>&app-id=<?php echo urlencode(getDolGlobalString('TAKEPOS_SUMUP_APPID
')) ?>&amount=' + amountpayed +
'¤cy=' + currencycode +
'&title=' + invoiceid +
'&callback=<?php echo DOL_MAIN_URL_ROOT ?>/takepos/smpcb.php');
510 var loop = window.setInterval(
function () {
513 data: { token:
'<?php echo currentToken(); ?>' },
514 url:
'<?php echo DOL_URL_ROOT ?>/takepos/smpcb.php?status' }).done(
function (data) {
516 if (data ===
"SUCCESS") {
517 parent.$(
"#poslines").load(
"invoice.php?place=<?php echo urlencode($place); ?>&action=valid&token=<?php echo newToken(); ?>&pay=CB&amount=" + amountpayed +
"&invoiceid=" + invoiceid,
function () {
519 parent.$.colorbox.close();
523 }
else if (data ===
"FAILED") {
524 parent.$.colorbox.close();
533 echo
"var line1='".$langs->trans(
'TotalTTC').
"'.substring(0,20);";
534 echo
"line1=line1.padEnd(20);";
535 echo
"var line2='".price($invoice->total_ttc, 1,
'', 1, -1, -1).
"'.substring(0,20);";
536 echo
"line2=line2.padEnd(20);";
539 data: { text: line1+line2 },
540 url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER').
"/display/index.php',
547$sessioncurrency = $_SESSION[
"takeposcustomercurrency"] ??
'';
548print
'<!-- conf->currency = '.$conf->currency.
' - sessioncurrency = '.$sessioncurrency.
' -->'.
"\n";
549$multicurrency =
null;
550if (
isModEnabled(
'multicurrency') && $sessioncurrency !=
"" && $conf->currency != $sessioncurrency) {
552 include_once DOL_DOCUMENT_ROOT .
'/multicurrency/class/multicurrency.class.php';
554 $multicurrency->fetch(0, $sessioncurrency);
558<div style=
"position:relative; padding-top: 20px; left:5%; height:140px; width:90%;">
559 <div
class=
"paymentbordline paymentbordlinetotal center">
560 <span
class=
"takepospay colorwhite"><?php echo $langs->trans(
'TotalTTC'); ?>: <span
id=
"totaldisplay" class=
"colorwhite"><?php
561 echo
price($invoice->total_ttc, 1,
'', 1, -1, -1, $conf->currency);
562 if ($multicurrency !==
null) {
563 print
' <span id="linecolht-span-total opacitymedium" style="font-size:0.9em; font-style:italic;">(' .
price($invoice->total_ht * $multicurrency->rate->rate) .
' ' . $sessioncurrency .
')</span>';
567 <?php
if ($remaintopay != $invoice->total_ttc) { ?>
568 <div
class=
"paymentbordline paymentbordlineremain center">
569 <span
class=
"takepospay colorwhite"><?php echo $langs->trans(
'RemainToPay'); ?>: <span
id=
"remaintopaydisplay" class=
"colorwhite"><?php
570 echo
price($remaintopay, 1,
'', 1, -1, -1, $conf->currency);
571 if ($multicurrency !==
null) {
572 print
' <span id="linecolht-span-total opacitymedium" style="font-size:0.9em; font-style:italic;">(' .
price($remaintopay * $multicurrency->rate->rate) .
' ' . $sessioncurrency .
')</span>';
577 <div
class=
"paymentbordline paymentbordlinereceived center">
578 <span
class=
"takepospay colorwhite"><?php echo $langs->trans(
"Received"); ?>: <span
class=
"change1 colorred"><?php
579 echo
price(0, 1,
'', 1, -1, -1, $conf->currency);
580 if ($multicurrency !==
null) {
581 print
' <span id="linecolht-span-total opacitymedium" style="font-size:0.9em; font-style:italic;">(' .
price(0 * $multicurrency->rate->rate) .
' ' . $sessioncurrency .
')</span>';
583 ?></span><input
type=
"hidden" id=
"change1" class=
"change1" value=
"0"></span>
585 <div
class=
"paymentbordline paymentbordlinechange center">
586 <span
class=
"takepospay colorwhite"><?php echo $langs->trans(
"Change"); ?>: <span
class=
"change2 colorwhite"><?php
587 echo
price(0, 1,
'', 1, -1, -1, $conf->currency);
588 if ($multicurrency !==
null) {
589 print
' <span id="linecolht-span-total opacitymedium" style="font-size:0.9em; font-style:italic;">(' .
price(0 * $multicurrency->rate->rate) .
' ' . $sessioncurrency .
')</span>';
591 ?></span><input
type=
"hidden" id=
"change2" class=
"change2" value=
"0"></span>
595 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
596 print
'<div class="paymentbordline paddingtop paddingbottom center">';
598 $form =
new Form($db);
599 print
'<span class="takepospay colorwhite">'.$langs->trans(
"BankAccount").
': </span>';
600 $form->select_comptes(0,
'accountid', 0, $filter, 1,
'');
606<div style=
"position:absolute; left:5%; height:52%; width:90%;">
608$action_buttons = array(
610"function" =>
"reset()",
611"span" =>
"style='font-size: 150%;'",
613"class" =>
"poscolorblue"
616"function" =>
"parent.$.colorbox.close();",
617"span" =>
"id='printtext' style='font-weight: bold; font-size: 18pt;'",
619"class" =>
"poscolordelete"
624 print
'<span id="card-present-alert">';
625 dol_htmloutput_mesg($langs->trans(
'ConnectingToStripeTerminal',
'Stripe'), [],
'warning', 1);
628print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'7' :
'10').
')">'.($numpad == 0 ?
'7' :
'10').
'</button>';
629print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'8' :
'20').
')">'.($numpad == 0 ?
'8' :
'20').
'</button>';
630print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'9' :
'50').
')">'.($numpad == 0 ?
'9' :
'50').
'</button>';
632<?php
if (count($arrayOfValidPaymentModes) > 0) {
633 $paycode = $arrayOfValidPaymentModes[0]->code;
635 if ($paycode ==
'LIQ') {
636 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) ||
getDolGlobalString(
'TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
639 } elseif ($paycode ==
'CB') {
640 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) ||
getDolGlobalString(
'TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
641 $payIcon =
'credit-card';
643 } elseif ($paycode ==
'CHQ') {
644 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) ||
getDolGlobalString(
'TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
645 $payIcon =
'money-check';
649 print
'<button type="button" class="calcbutton2" onclick="Validate(\''.dol_escape_js($paycode).
'\')
">'.(!empty($payIcon) ? '<span class="fa fa-2x fa-
'.$payIcon.' iconwithlabel
"></span><span class="hideonsmartphone
"><br>'.$langs->trans("PaymentTypeShort
".$arrayOfValidPaymentModes[0]->code) : $langs->trans("PaymentTypeShort
".$arrayOfValidPaymentModes[0]->code)).'</span></button>';
651 print '<button type="button" class="calcbutton2
">'.$langs->trans("NoPaimementModesDefined
").'</button>';
654print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '4
' : '1
').')
">'.($numpad == 0 ? '4' : '1').'</button>';
655print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '5
' : '2
').')
">'.($numpad == 0 ? '5' : '2').'</button>';
656print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '6
' : '5
').')
">'.($numpad == 0 ? '6' : '5').'</button>';
658<?php if (count($arrayOfValidPaymentModes) > 1) {
659 $paycode = $arrayOfValidPaymentModes[1]->code;
661 if ($paycode == 'LIQ') {
662 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
665 } elseif ($paycode == 'CB') {
666 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
667 $payIcon = 'credit-card';
669 } elseif ($paycode == 'CHQ') {
670 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
671 $payIcon = 'money-check';
675 print '<button type="button" class="calcbutton2
" onclick="Validate(\
''.
dol_escape_js($paycode).
'\')
">'.(!empty($payIcon) ? '<span class="fa fa-2x fa-
'.$payIcon.' iconwithlabel
"></span><br> '.$langs->trans("PaymentTypeShort
".$arrayOfValidPaymentModes[1]->code) : $langs->trans("PaymentTypeShort
".$arrayOfValidPaymentModes[1]->code)).'</button>';
677 $button = array_pop($action_buttons);
678 print '<button type="button" class="calcbutton2
" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
681print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '1
' : '0.10
').')
">'.($numpad == 0 ? '1' : '0.10').'</button>';
682print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '2
' : '0.20
').')
">'.($numpad == 0 ? '2' : '0.20').'</button>';
683print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '3
' : '0.50
').')
">'.($numpad == 0 ? '3' : '0.50').'</button>';
685<?php if (count($arrayOfValidPaymentModes) > 2) {
686 $paycode = $arrayOfValidPaymentModes[2]->code;
688 if ($paycode == 'LIQ') {
689 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
692 } elseif ($paycode == 'CB') {
693 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
694 $payIcon = 'credit-card';
696 } elseif ($paycode == 'CHQ') {
697 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
698 $payIcon = 'money-check';
702 print '<button type="button" class="calcbutton2
" onclick="Validate(\
''.
dol_escape_js($paycode).
'\')
">'.(!empty($payIcon) ? '<span class="fa fa-2x fa-
'.$payIcon.' iconwithlabel
"></span><br>'.$langs->trans("PaymentTypeShort
".$arrayOfValidPaymentModes[2]->code) : $langs->trans("PaymentTypeShort
".$arrayOfValidPaymentModes[2]->code)).'</button>';
704 $button = array_pop($action_buttons);
705 print '<button type="button" class="calcbutton2
" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
708print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '0
' : '0.01
').')
">'.($numpad == 0 ? '0' : '0.01').'</button>';
709print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '\
'000\'' :
'0.02').
')">'.($numpad == 0 ?
'000' :
'0.02').
'</button>';
710print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'\'.\
'' :
'0.05').
')">'.($numpad == 0 ?
'.' :
'0.05').
'</button>';
713while ($i < count($arrayOfValidPaymentModes)) {
714 $paycode = $arrayOfValidPaymentModes[$i]->code;
716 if ($paycode ==
'LIQ') {
717 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) ||
getDolGlobalString(
'TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
720 } elseif ($paycode ==
'CB') {
721 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) ||
getDolGlobalString(
'TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
722 $payIcon =
'credit-card';
724 } elseif ($paycode ==
'CHQ') {
725 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) ||
getDolGlobalString(
'TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
726 $payIcon =
'money-check';
730 print
'<button type="button" class="calcbutton2" onclick="Validate(\''.dol_escape_js($paycode).
'\')
">'.(!empty($payIcon) ? '<span class="fa fa-2x fa-
'.$payIcon.' iconwithlabel
"></span><br>'.$langs->trans("PaymentTypeShort
".$arrayOfValidPaymentModes[$i]->code) : $langs->trans("PaymentTypeShort
".$arrayOfValidPaymentModes[$i]->code)).'</button>';
734if (isModEnabled('stripe') && isset($keyforstripeterminalbank) && getDolGlobalString('STRIPE_CARD_PRESENT')) {
735 $keyforstripeterminalbank = "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL
".$_SESSION["takeposterminal
"];
736 print '<span id="StripeTerminal
"></span>';
737 if (getDolGlobalString((string) $keyforstripeterminalbank)) {
740 $langs->loadLangs(array("errors
", "admin
"));
741 //print '<button type="button" class="calcbutton2
disabled" title="'.$langs->trans("SetupNotComplete").'">TerminalOff</button>';
745$keyforsumupbank = "CASHDESK_ID_BANKACCOUNT_SUMUP
".$_SESSION["takeposterminal
"];
746if (getDolGlobalInt("TAKEPOS_ENABLE_SUMUP
")) {
747 if (getDolGlobalString($keyforsumupbank)) {
748 print '<button type="button" class="calcbutton2
" onclick="ValidateSumup();
">Sumup</button>';
750 $langs->loadLangs(array("errors
", "admin
"));
751 print '<button type="button" class="calcbutton2
disabled" title="'.$langs->trans("SetupNotComplete").'">Sumup</button>';
755$parameters = array('action_buttons' => $action_buttons);
756$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $invoice, $action); // Note that $action and $invoice may have been modified by hook
758 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
759} elseif ($reshook == 0) {
760 $action_buttons = array_merge($action_buttons, $hookmanager->resArray);
761} elseif ($reshook > 0) {
762 $action_buttons = $hookmanager->resArray;
765$class = ($i == 3) ? "calcbutton3
" : "calcbutton2
";
766foreach ($action_buttons as $button) {
767 $newclass = $class.($button["class"] ? " ".$button["class"] : "");
768 print '<button type="button" class="'.$newclass.'" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
771if (getDolGlobalString('TAKEPOS_DELAYED_PAYMENT')) {
772 print '<button type="button" class="calcbutton2
" onclick="Validate(\
'delayed\')">'.$langs->trans(
"Reported").
'</button>';
778$parameters = array();
779$hookmanager->executeHooks(
'completePayment', $parameters, $invoice);
780print $hookmanager->resPrint;
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
isALNERunningVersion($blockedlogtestalreadydone=0)
Return if the application is executed with the LNE requirements on.
Class to manage invoices.
Stripe class @TODO No reason to extend CommonObject.
Class toolbox to validate values.
pricejs(amount, mode='MT', currency_code='', force_locale='')
Function similar to PHP price()
price2numjs(amount)
Function similar to PHP price2num()
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
Abort invoice creation with a given error message.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
if(getDolGlobalString( 'TAKEPOS_SHOW_CUSTOMER')) print $langs trans('Date')." left Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right PaymentTypeShortLIQ right SELECT p pos_change as p datep as p p num_paiement as f pf amount as amount
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.