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.
'/core/class/discount.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
58$langs->loadLangs(array(
"main",
"bills",
"cashdesk",
"banks"));
60$action =
GETPOST(
'action',
'aZ09');
62$place = (
GETPOST(
'place',
'aZ09') ?
GETPOST(
'place',
'aZ09') :
'0');
66$hookmanager->initHooks(array(
'takepospay'));
68if (!$user->hasRight(
'takepos',
'run')) {
77$arrayofcss = array(
'/takepos/css/pos.css.php');
85$head =
'<link rel="stylesheet" href="css/pos.css.php">';
87 $head .=
'<link rel="stylesheet" href="css/colorful.css">';
90top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
96$usestripeterminals = 0;
97$keyforstripeterminalbank =
'';
103 $service =
'StripeTest';
106 $service =
'StripeLive';
111 global $stripearrayofkeysbyenv;
112 $site_account = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
114 $stripe =
new Stripe($db);
115 $stripeacc = $stripe->getStripeAccount($service);
117 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
118 $invoicetmp =
new Facture($db);
119 $invoicetmp->fetch($invoiceid);
120 $stripecu = $stripe->getStripeCustomerAccount($invoicetmp->socid, $servicestatus, $site_account);
121 $keyforstripeterminalbank =
"CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".(empty($_SESSION[
'takeposterminal']) ?
'' : $_SESSION[
'takeposterminal']);
125 if ($usestripeterminals) {
127<script src=
"https://js.stripe.com/terminal/v1/"></script>
129var terminal = StripeTerminal.create({
130 onFetchConnectionToken: fetchConnectionToken,
131 onUnexpectedReaderDisconnect: unexpectedDisconnect,
134function unexpectedDisconnect() {
137 console.log(
"Disconnected from reader")
140function fetchConnectionToken() {
142 $urlconnexiontoken = DOL_URL_ROOT.
'/stripe/ajax/ajax.php?action=getConnexionToken&token='.
currentToken().
'&servicestatus='.urlencode((
string) ($servicestatus));
146 if (!empty($stripeacc)) {
147 $urlconnexiontoken .=
'&stripeacc='.urlencode($stripeacc);
150 return fetch(
'<?php echo $urlconnexiontoken; ?>', { method:
"POST" })
151 .then(
function(response) {
152 return response.json();
154 .then(
function(data) {
165 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'), [],
'warning', 1);
170 $invoice->fetch($invoiceid);
172 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture";
173 $sql .=
" WHERE entity IN (".getEntity(
'invoice').
")";
174 $sql .=
" AND ref = '(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
175 $resql = $db->query($sql);
176 $obj = $db->fetch_object($resql);
178 $invoiceid = $obj->rowid;
183 $invoice->fetch($invoiceid);
190if ($usestripeterminals && $invoice->type != $invoice::TYPE_CREDIT_NOTE) {
191 if (!
getDolGlobalString((
string) $keyforstripeterminalbank) || $stripeacc ===
null) { ?>
193 simulated: <?php
if (empty($servicestatus) &&
getDolGlobalString(
'STRIPE_TERMINAL_SIMULATED')) { ?>
true <?php }
else { ?> false <?php } ?>
196 terminal.discoverReaders(config).then(
function(discoverResult) {
197 if (discoverResult.error) {
198 console.log(
'Failed to discover: ', discoverResult.error);
199 }
else if (discoverResult.discoveredReaders.length === 0) {
200 console.log(
'No available readers.');
204 selectedReader = discoverResult.discoveredReaders[0];
207 terminal.connectReader(selectedReader).then(function(connectResult) {
208 if (connectResult.error) {
209 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error">'+connectResult.error.message+
'</div>';
210 console.log(
'Failed to connect: ', connectResult.error);
212 document.getElementById(
"card-present-alert").innerHTML =
'';
213 console.log(
'Connected to reader: ', connectResult.reader.label);
214 if (document.getElementById(
"StripeTerminal")) {
215 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>';
222 terminal.connectReader(<?php echo json_encode($stripe->getSelectedReader(
getDolGlobalString((
string) $keyforstripeterminalbank), $stripeacc, $servicestatus)); ?>).then(
function(connectResult) {
223 if (connectResult.error) {
224 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error clearboth">'+connectResult.error.message+
'</div>';
225 console.log(
'Failed to connect: ', connectResult.error);
227 document.getElementById(
"card-present-alert").innerHTML =
'';
228 console.log(
'Connected to reader: ', connectResult.reader.label);
229 if (document.getElementById(
"StripeTerminal")) {
230 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>';
241$arrayOfValidPaymentModes = array();
242$arrayOfValidBankAccount = array();
244$sql =
"SELECT code, libelle as label FROM ".MAIN_DB_PREFIX.
"c_paiement";
245$sql .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
246$sql .=
" AND active = 1";
250 $sql .=
" AND code IN ('LIQ', 'CB', 'CHQ')";
252$sql .=
" ORDER BY libelle";
253$resql = $db->query($sql);
256 while ($obj = $db->fetch_object($resql)) {
257 $paycode = $obj->code;
258 if ($paycode ==
'LIQ') {
261 if ($paycode ==
'CB') {
264 if ($paycode ==
'CHQ') {
268 $accountname =
"CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION[
"takeposterminal"];
271 $arrayOfValidPaymentModes[] = $obj;
274 if ($paycode ==
'CASH' || $paycode ==
'CB') {
275 $arrayOfValidPaymentModes[] = $obj;
286if ($invoice->id > 0) {
287 $remaintopay = $invoice->getRemainToPay();
289$alreadypayed = (is_object($invoice) ? ($invoice->total_ttc - $remaintopay) : 0);
291$parameters = array();
292$reshook = $hookmanager->executeHooks(
'takeposPayActions', $parameters, $invoice, $action);
296 print
"var received='';";
298 print
"var received=0;";
302 var alreadypayed = <?php echo $alreadypayed ?>;
303 var invoicetype = <?php echo $invoice->type ?>;
305 function addreceived(
price)
309 print
'received+=String(price);'.
"\n";
311 print
'received+=parseFloat(price);'.
"\n";
314 $(
'.change1').html(pricejs(parseFloat(received),
'MT'));
315 $(
'.change1').val(parseFloat(received));
316 console.log(
"invoicetype="+invoicetype);
317 console.log(
"alreadyreceived="+alreadypayed);
318 console.log(
"received="+received);
319 if (invoicetype == 2) {
320 alreadypaydplusreceived = price2numjs(alreadypayed - parseFloat(received));
322 alreadypaydplusreceived = price2numjs(alreadypayed + parseFloat(received));
324 console.log(
"already+received = "+alreadypaydplusreceived);
326 if (Math.abs(alreadypaydplusreceived) > Math.abs(<?php echo ((
float) $invoice->total_ttc); ?>)) {
327 if (invoicetype == 2) {
328 var change = parseFloat(alreadypayed + parseFloat(received) + <?php echo (
float) $invoice->total_ttc; ?>);
330 var change = parseFloat(alreadypayed + parseFloat(received) - <?php echo (
float) $invoice->total_ttc; ?>);
332 $(
'.change2').html(pricejs(change,
'MT'));
333 $(
'.change2').val(change);
334 $(
'.change1').removeClass(
'colorred');
335 $(
'.change1').addClass(
'colorgreen');
336 $(
'.change2').removeClass(
'colorwhite');
337 $(
'.change2').addClass(
'colorred');
339 $(
'.change2').html(pricejs(0,
'MT'));
340 $(
'.change2').val(0);
341 if (alreadypaydplusreceived == <?php echo (
float) $invoice->total_ttc; ?>) {
342 $(
'.change1').removeClass(
'colorred');
343 $(
'.change1').addClass(
'colorgreen');
344 $(
'.change2').removeClass(
'colorred');
345 $(
'.change2').addClass(
'colorwhite');
347 $(
'.change1').removeClass(
'colorgreen');
348 $(
'.change1').addClass(
'colorred');
349 $(
'.change2').removeClass(
'colorred');
350 $(
'.change2').addClass(
'colorwhite');
360 $(
'.change1').html(pricejs(received,
'MT'));
361 $(
'.change1').val(price2numjs(received));
362 $(
'.change2').html(pricejs(received,
'MT'));
363 $(
'.change2').val(price2numjs(received));
364 $(
'.change1').removeClass(
'colorgreen');
365 $(
'.change1').addClass(
'colorred');
366 $(
'.change2').removeClass(
'colorred');
367 $(
'.change2').addClass(
'colorwhite');
372 console.log(
"Launch Validate");
374 var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
375 var accountid = $(
"#selectaccountid").val();
376 var amountpayed = $(
"#change1").val();
377 var excess = $(
"#change2").val();
378 if (amountpayed > <?php echo (
float) $invoice->total_ttc; ?>) {
379 amountpayed = <?php echo (
float) $invoice->total_ttc; ?>;
381 console.log(
"We click on the payment mode to pay amount = "+amountpayed);
382 parent.$(
"#poslines").load(
"invoice.php?place=<?php echo $place; ?>&action=valid&token=<?php echo currentToken(); ?>&pay="+payment+
"&amount="+amountpayed+
"&excess="+excess+
"&invoiceid="+invoiceid+
"&accountid="+accountid,
function() {
383 if (amountpayed > <?php echo (
float) $remaintopay; ?> || amountpayed == <?php echo (
float) $remaintopay; ?> || amountpayed == 0 ) {
384 console.log(
"Close popup");
385 parent.$(
'#invoiceid').val(
"");
386 parent.$.colorbox.close();
388 console.log(
"Amount is not complete, so we do NOT close popup and reload it.");
397 function OpenCreditApply() {
399 href:
"creditnote_apply.php?invoiceid=<?php echo $invoiceid; ?>&place=" + <?php echo
"'".dol_escape_js($place).
"'"; ?> +
"&token=<?php echo currentToken(); ?>",
404 title: <?php echo
"'".dol_escape_js($langs->trans(
'TakeposApplyAvailableCredit')).
"'"; ?>
408 function fetchPaymentIntentClientSecret(
amount, invoiceid) {
409 const bodyContent = JSON.stringify({
amount :
amount, invoiceid : invoiceid });
411 $urlpaymentintent = DOL_URL_ROOT.
'/stripe/ajax/ajax.php?action=createPaymentIntent&token='.
currentToken().
'&servicestatus='.urlencode((
string) $servicestatus);
412 if (!empty($stripeacc)) {
413 $urlpaymentintent .=
'&stripeacc='.$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 capturePaymentIntent(paymentIntentId) {
433 const bodyContent = JSON.stringify({
"id": paymentIntentId})
435 $urlpaymentintent = DOL_URL_ROOT.
'/stripe/ajax/ajax.php?action=capturePaymentIntent&token='.
currentToken().
'&servicestatus='.urlencode((
string) ($servicestatus));
436 if (!empty($stripeacc)) {
437 $urlpaymentintent .=
'&stripeacc='.urlencode($stripeacc);
440 return fetch(
'<?php echo $urlpaymentintent; ?>', {
443 'Content-Type':
'application/json'
447 .then(
function(response) {
448 return response.json();
450 .then(
function(data) {
451 return data.client_secret;
456 function ValidateStripeTerminal() {
457 console.log(
"Launch ValidateStripeTerminal");
458 var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
459 var accountid = $(
"#selectaccountid").val();
460 var amountpayed = $(
"#change1").val();
461 var excess = $(
"#change2").val();
462 if (amountpayed > <?php echo (
float) $invoice->getRemainToPay(); ?>) {
463 amountpayed = <?php echo (
float) $invoice->getRemainToPay(); ?>;
465 if (amountpayed == 0) {
466 amountpayed = <?php echo (
float) $invoice->getRemainToPay(); ?>;
469 console.log(
"Pay with terminal ", amountpayed);
471 fetchPaymentIntentClientSecret(amountpayed, invoiceid).then(
function(client_secret) {
472 <?php
if (empty($servicestatus) &&
getDolGlobalString(
'STRIPE_TERMINAL_SIMULATED')) { ?>
473 terminal.setSimulatorConfiguration({testCardNumber: <?php echo
"'".dol_escape_js(
getDolGlobalString(
'STRIPE_TERMINAL_SIMULATED')).
"'" ; ?>});
475 document.getElementById(
"card-present-alert").innerHTML =
'<div class="warning clearboth"><?php echo $langs->trans('PaymentSendToStripeTerminal
'); ?></div>';
476 terminal.collectPaymentMethod(client_secret).then(
function(result) {
479 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error clearboth">'+result.error.message+
'</div>';
481 document.getElementById(
"card-present-alert").innerHTML =
'<div class="warning clearboth"><?php echo $langs->trans('PaymentBeingProcessed
'); ?></div>';
482 console.log(
'terminal.collectPaymentMethod', result.paymentIntent);
483 terminal.processPayment(result.paymentIntent).then(function(result) {
485 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error clearboth">'+result.error.message+
'</div>';
486 console.log(result.error)
487 } else if (result.paymentIntent) {
488 paymentIntentId = result.paymentIntent.id;
489 console.log(
'terminal.processPayment', result.paymentIntent);
490 capturePaymentIntent(paymentIntentId).then(function(client_secret) {
493 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error clearboth">'+result.error.message+
'</div>';
494 console.log(
"error when capturing paymentIntent", result.error);
496 document.getElementById(
"card-present-alert").innerHTML =
'<div class="warning clearboth"><?php echo $langs->trans('PaymentValidated
'); ?></div>';
497 console.log(
"Capture paymentIntent successful "+paymentIntentId);
498 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() {
499 if (amountpayed > <?php echo (float) $remaintopay; ?> || amountpayed == <?php echo (float) $remaintopay; ?> || amountpayed == 0 ) {
500 console.log(
"Close popup");
501 parent.$.colorbox.close();
504 console.log(
"Amount is not comple, so we do NOT close popup and reload it.");
518 function ValidateSumup() {
519 console.log(
"Launch ValidateSumup");
520 <?php $_SESSION[
'SMP_CURRENT_PAYMENT'] =
"NEW" ?>
521 var invoiceid = <?php echo ($invoiceid > 0 ? $invoiceid : 0); ?>;
522 var amountpayed = $(
"#change1").val();
523 if (amountpayed > <?php echo (
float) $invoice->total_ttc; ?>) {
524 amountpayed = <?php echo (
float) $invoice->total_ttc; ?>;
526 if (amountpayed == 0) {
527 amountpayed = <?php echo (
float) $invoice->total_ttc; ?>;
529 var currencycode =
"<?php echo $invoice->multicurrency_code; ?>";
532 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');
534 var loop = window.setInterval(
function () {
537 data: { token:
'<?php echo currentToken(); ?>' },
538 url:
'<?php echo DOL_URL_ROOT ?>/takepos/smpcb.php?status' }).done(
function (data) {
540 if (data ===
"SUCCESS") {
541 parent.$(
"#poslines").load(
"invoice.php?place=<?php echo urlencode($place); ?>&action=valid&token=<?php echo newToken(); ?>&pay=CB&amount=" + amountpayed +
"&invoiceid=" + invoiceid,
function () {
543 parent.$.colorbox.close();
547 }
else if (data ===
"FAILED") {
548 parent.$.colorbox.close();
557 echo
"var line1='".$langs->trans(
'TotalTTC').
"'.substring(0,20);";
558 echo
"line1=line1.padEnd(20);";
559 echo
"var line2='".price($invoice->total_ttc, 1,
'', 1, -1, -1).
"'.substring(0,20);";
560 echo
"line2=line2.padEnd(20);";
562 echo
'webSocketCustomerDisplay.onOpen(function() {';
563 echo
' webSocketCustomerDisplay.send(line1);';
564 echo
' webSocketCustomerDisplay.send(line2);';
569 data: { text: line1+line2 },
570 url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER').
"/display/index.php',
578$sessioncurrency = $_SESSION[
"takeposcustomercurrency"] ??
'';
579print
'<!-- conf->currency = '.$conf->currency.
' - sessioncurrency = '.$sessioncurrency.
' -->'.
"\n";
580$multicurrency =
null;
581if (
isModEnabled(
'multicurrency') && $sessioncurrency !=
"" &&
$conf->currency != $sessioncurrency) {
583 include_once DOL_DOCUMENT_ROOT .
'/multicurrency/class/multicurrency.class.php';
585 $multicurrency->fetch(0, $sessioncurrency);
589<div style=
"position:relative; padding-top: 20px; left:5%; height:140px; width:90%;">
590 <div
class=
"paymentbordline paymentbordlinetotal center">
591 <span
class=
"takepospay colorwhite"><?php echo $langs->trans(
'TotalTTC'); ?>: <span
id=
"totaldisplay" class=
"colorwhite"><?php
592 echo
price($invoice->total_ttc, 1,
'', 1, -1, -1,
$conf->currency);
593 if ($multicurrency !==
null) {
594 print
' <span id="linecolht-span-total opacitymedium" style="font-size:0.9em; font-style:italic;">(' .
price($invoice->total_ht * $multicurrency->rate->rate) .
' ' . $sessioncurrency .
')</span>';
598 <?php
if ($remaintopay != $invoice->total_ttc) { ?>
599 <div
class=
"paymentbordline paymentbordlineremain center">
600 <span
class=
"takepospay colorwhite"><?php echo $langs->trans(
'RemainToPay'); ?>: <span
id=
"remaintopaydisplay" class=
"colorwhite"><?php
601 echo
price($remaintopay, 1,
'', 1, -1, -1,
$conf->currency);
602 if ($multicurrency !==
null) {
603 print
' <span id="linecolht-span-total opacitymedium" style="font-size:0.9em; font-style:italic;">(' .
price($remaintopay * $multicurrency->rate->rate) .
' ' . $sessioncurrency .
')</span>';
608 <div
class=
"paymentbordline paymentbordlinereceived center">
609 <span
class=
"takepospay colorwhite"><?php echo $invoice->type == $invoice::TYPE_CREDIT_NOTE ? $langs->trans(
"Refunded") : $langs->trans(
"Received"); ?>: <span
class=
"change1 colorred"><?php
610 echo
price(0, 1,
'', 1, -1, -1,
$conf->currency);
611 if ($multicurrency !==
null) {
612 print
' <span id="linecolht-span-total opacitymedium" style="font-size:0.9em; font-style:italic;">(' .
price(0 * $multicurrency->rate->rate) .
' ' . $sessioncurrency .
')</span>';
614 ?></span><input
type=
"hidden" id=
"change1" class=
"change1" value=
"0"></span>
616 <div
class=
"paymentbordline paymentbordlinechange center">
617 <span
class=
"takepospay colorwhite"><?php echo $langs->trans(
"Change"); ?>: <span
class=
"change2 colorwhite"><?php
618 echo
price(0, 1,
'', 1, -1, -1,
$conf->currency);
619 if ($multicurrency !==
null) {
620 print
' <span id="linecolht-span-total opacitymedium" style="font-size:0.9em; font-style:italic;">(' .
price(0 * $multicurrency->rate->rate) .
' ' . $sessioncurrency .
')</span>';
622 ?></span><input
type=
"hidden" id=
"change2" class=
"change2" value=
"0"></span>
626 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
627 print
'<div class="paymentbordline paddingtop paddingbottom center">';
629 $form =
new Form($db);
630 print
'<span class="takepospay colorwhite">'.$langs->trans(
"BankAccount").
': </span>';
631 $form->select_comptes(0,
'accountid', 0, $filter, 1,
'');
637<div style=
"position:absolute; left:5%; height:52%; width:90%;">
639$action_buttons = array(
641"function" =>
"reset()",
642"span" =>
"style='font-size: 150%;'",
644"class" =>
"poscolorblue"
647"function" =>
"parent.$.colorbox.close();",
648"span" =>
"id='printtext' style='font-weight: bold; font-size: 18pt;'",
650"class" =>
"poscolordelete"
655 print
'<span id="card-present-alert">';
656 dol_htmloutput_mesg($langs->trans(
'ConnectingToStripeTerminal',
'Stripe'), [],
'warning', 1);
659print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'7' :
'10').
')">'.($numpad == 0 ?
'7' :
'10').
'</button>';
660print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'8' :
'20').
')">'.($numpad == 0 ?
'8' :
'20').
'</button>';
661print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'9' :
'50').
')">'.($numpad == 0 ?
'9' :
'50').
'</button>';
663<?php
if (count($arrayOfValidPaymentModes) > 0) {
664 $paycode = $arrayOfValidPaymentModes[0]->code;
666 if ($paycode ==
'LIQ') {
667 if (!isset(
$conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) ||
getDolGlobalString(
'TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
670 } elseif ($paycode ==
'CB') {
671 if (!isset(
$conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) ||
getDolGlobalString(
'TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
672 $payIcon =
'credit-card';
674 } elseif ($paycode ==
'CHQ') {
675 if (!isset(
$conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) ||
getDolGlobalString(
'TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
676 $payIcon =
'money-check';
680 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>';
682 print '<button type="button" class="calcbutton2
">'.$langs->trans("NoPaimementModesDefined
").'</button>';
685print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '4
' : '1
').')
">'.($numpad == 0 ? '4' : '1').'</button>';
686print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '5
' : '2
').')
">'.($numpad == 0 ? '5' : '2').'</button>';
687print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '6
' : '5
').')
">'.($numpad == 0 ? '6' : '5').'</button>';
689<?php if (count($arrayOfValidPaymentModes) > 1) {
690 $paycode = $arrayOfValidPaymentModes[1]->code;
692 if ($paycode == 'LIQ') {
693 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
696 } elseif ($paycode == 'CB') {
697 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
698 $payIcon = 'credit-card';
700 } elseif ($paycode == 'CHQ') {
701 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
702 $payIcon = 'money-check';
706 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>';
708 $button = array_pop($action_buttons);
709 print '<button type="button" class="calcbutton2
" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
712print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '1
' : '0.10
').')
">'.($numpad == 0 ? '1' : '0.10').'</button>';
713print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '2
' : '0.20
').')
">'.($numpad == 0 ? '2' : '0.20').'</button>';
714print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '3
' : '0.50
').')
">'.($numpad == 0 ? '3' : '0.50').'</button>';
716<?php if (count($arrayOfValidPaymentModes) > 2) {
717 $paycode = $arrayOfValidPaymentModes[2]->code;
719 if ($paycode == 'LIQ') {
720 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
723 } elseif ($paycode == 'CB') {
724 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
725 $payIcon = 'credit-card';
727 } elseif ($paycode == 'CHQ') {
728 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
729 $payIcon = 'money-check';
733 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>';
735 $button = array_pop($action_buttons);
736 print '<button type="button" class="calcbutton2
" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
739print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '0
' : '0.01
').')
">'.($numpad == 0 ? '0' : '0.01').'</button>';
740print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '\
'000\'' :
'0.02').
')">'.($numpad == 0 ?
'000' :
'0.02').
'</button>';
741print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'\'.\
'' :
'0.05').
')">'.($numpad == 0 ?
'.' :
'0.05').
'</button>';
744while ($i < count($arrayOfValidPaymentModes)) {
745 $paycode = $arrayOfValidPaymentModes[$i]->code;
747 if ($paycode ==
'LIQ') {
748 if (!isset(
$conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) ||
getDolGlobalString(
'TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
751 } elseif ($paycode ==
'CB') {
752 if (!isset(
$conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) ||
getDolGlobalString(
'TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
753 $payIcon =
'credit-card';
755 } elseif ($paycode ==
'CHQ') {
756 if (!isset(
$conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) ||
getDolGlobalString(
'TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) {
757 $payIcon =
'money-check';
761 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>';
765// Show "Available credit
" button when the customer has credits and this is not a credit note
766if ($invoice->socid > 0 && $invoice->type != Facture::TYPE_CREDIT_NOTE) {
767 $invoice->fetch_thirdparty();
768 if (is_object($invoice->thirdparty)) {
769 $discountCheck = new DiscountAbsolute($db);
770 $availableCredit = $discountCheck->getAvailableDiscounts($invoice->thirdparty, null, '', 0, 0, 0);
771 if ($availableCredit > 0) {
772 print '<button type="button" class="calcbutton2
" onclick="OpenCreditApply()
">';
773 print '<span class="fa fa-2x fa-wallet iconwithlabel
"></span><br>';
774 print $langs->trans('TakeposAvailableCredit').'<br>';
775 print '<span style="font-size:0.85em;
">'.price($availableCredit, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
781if (isModEnabled('stripe') && getDolGlobalString('STRIPE_CARD_PRESENT')) {
782 $keyforstripeterminalbank = "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL
".$_SESSION["takeposterminal
"];
783 print '<span id="StripeTerminal
"></span>';
784 if (getDolGlobalString((string) $keyforstripeterminalbank)) {
787 $langs->loadLangs(array("errors
", "admin
"));
788 //print '<button type="button" class="calcbutton2
disabled" title="'.$langs->trans("SetupNotComplete").'">TerminalOff</button>';
792$keyforsumupbank = "CASHDESK_ID_BANKACCOUNT_SUMUP
".$_SESSION["takeposterminal
"];
793if (getDolGlobalInt("TAKEPOS_ENABLE_SUMUP
")) {
794 if (getDolGlobalString($keyforsumupbank)) {
795 print '<button type="button" class="calcbutton2
" onclick="ValidateSumup();
">Sumup</button>';
797 $langs->loadLangs(array("errors
", "admin
"));
798 print '<button type="button" class="calcbutton2
disabled" title="'.$langs->trans("SetupNotComplete").'">Sumup</button>';
802$parameters = array('action_buttons' => $action_buttons);
803$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $invoice, $action); // Note that $action and $invoice may have been modified by hook
805 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
806} elseif ($reshook == 0) {
807 $action_buttons = array_merge($action_buttons, $hookmanager->resArray);
808} elseif ($reshook > 0) {
809 $action_buttons = $hookmanager->resArray;
812$class = ($i == 3) ? "calcbutton3
" : "calcbutton2
";
813foreach ($action_buttons as $button) {
814 $newclass = $class.($button["class"] ? " ".$button["class"] : "");
815 print '<button type="button" class="'.$newclass.'" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
818if (getDolGlobalString('TAKEPOS_DELAYED_PAYMENT')) {
819 print '<button type="button" class="calcbutton2
" onclick="Validate(\
'delayed\')">'.$langs->trans(
"Reported").
'</button>';
825$parameters = array();
826$hookmanager->executeHooks(
'completePayment', $parameters, $invoice);
827print $hookmanager->resPrint;
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='', $placeholder='')
Convert a html select field into an ajax combobox.
isALNERunningVersion($blockedlogusagealreadychecked=0, $blockedlogmoduleonalreadychecked=0)
Return if the application is executed with the LNE requirements on.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage invoices.
Stripe class @TODO No reason to extend CommonObject.
Class toolbox to validate values.
currentToken()
Return the value of token currently saved into session with name 'token'.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
Build the customer statement lines (invoices and payments) with running balance.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
print $langs trans('Date')." left Ref 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 Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as p p num_paiement as f pf amount as amount
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button