30 if (!defined(
'NOTOKENRENEWAL')) {
31 define(
'NOTOKENRENEWAL',
'1');
33 if (!defined(
'NOREQUIREMENU')) {
34 define(
'NOREQUIREMENU',
'1');
36 if (!defined(
'NOREQUIREHTML')) {
37 define(
'NOREQUIREHTML',
'1');
41 require
'../main.inc.php';
42 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
47 $langs->loadLangs(array(
"main",
"bills",
"cashdesk",
"banks"));
49 $place = (
GETPOST(
'place',
'aZ09') ?
GETPOST(
'place',
'aZ09') :
'0');
51 $invoiceid =
GETPOST(
'invoiceid',
'int');
53 $hookmanager->initHooks(array(
'takepospay'));
55 if (empty($user->rights->takepos->run)) {
64 $arrayofcss = array(
'/takepos/css/pos.css.php');
72 $head=
'<link rel="stylesheet" href="css/pos.css.php">';
74 $head .=
'<link rel="stylesheet" href="css/colorful.css">';
77 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
84 $service =
'StripeTest';
86 if (!empty($conf->global->STRIPE_LIVE) && !
GETPOST(
'forcesandbox',
'alpha')) {
87 $service =
'StripeLive';
92 global $stripearrayofkeysbyenv;
93 $site_account = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
96 $stripeacc = $stripe->getStripeAccount($service);
97 $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus, $site_account);
98 $keyforstripeterminalbank =
"CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$_SESSION[
"takeposterminal"];
102 if ($usestripeterminals) {
104 <script src=
"https://js.stripe.com/terminal/v1/"></script>
106 var terminal = StripeTerminal.create({
107 onFetchConnectionToken: fetchConnectionToken,
108 onUnexpectedReaderDisconnect: unexpectedDisconnect,
111 function unexpectedDisconnect() {
114 console.log(
"Disconnected from reader")
117 function fetchConnectionToken() {
119 $urlconnexiontoken = DOL_URL_ROOT.
'/stripe/ajax/ajax.php?action=getConnexionToken&token='.
newToken().
'&servicestatus='.urlencode($servicestatus);
120 if (!empty($conf->global->STRIPE_LOCATION)) {
121 $urlconnexiontoken .=
'&location='.urlencode($conf->global->STRIPE_LOCATION);
123 if (!empty($stripeacc)) {
124 $urlconnexiontoken .=
'&stripeacc='.urlencode($stripeacc);
128 return fetch(
'<?php echo $urlconnexiontoken; ?>', { method:
"POST" })
129 .then(
function(response) {
130 return response.json();
132 .then(
function(data) {
142 if (
isModEnabled(
'stripe') && isset($keyforstripeterminalbank) && (empty($conf->global->STRIPE_LIVE) ||
GETPOST(
'forcesandbox',
'alpha'))) {
143 dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode',
'Stripe'),
'',
'warning', 1);
147 if ($invoiceid > 0) {
148 $invoice->fetch($invoiceid);
150 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture where ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
151 $resql = $db->query($sql);
152 $obj = $db->fetch_object(
$resql);
154 $invoiceid = $obj->rowid;
159 $invoice->fetch($invoiceid);
166 if ($invoice->type != $invoice::TYPE_CREDIT_NOTE) {
167 if (empty($conf->global->$keyforstripeterminalbank)) { ?>
168 const config = {simulated: <?php
if (empty($servicestatus) && !empty($conf->global->STRIPE_TERMINAL_SIMULATED)) { ?>
true <?php }
else { ?> false <?php } ?>
169 <?php
if (!empty($conf->global->STRIPE_LOCATION)) { ?>, location:
'<?php echo $conf->global->STRIPE_LOCATION; ?>'<?php } ?>}
170 terminal.discoverReaders(config).then(
function(discoverResult) {
171 if (discoverResult.error) {
172 console.log(
'Failed to discover: ', discoverResult.error);
173 }
else if (discoverResult.discoveredReaders.length === 0) {
174 console.log(
'No available readers.');
178 selectedReader = discoverResult.discoveredReaders[0];
181 terminal.connectReader(selectedReader).then(function(connectResult) {
182 if (connectResult.error) {
183 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error">'+connectResult.error.message+
'</div>';
184 console.log(
'Failed to connect: ', connectResult.error);
186 document.getElementById(
"card-present-alert").innerHTML =
'';
187 console.log(
'Connected to reader: ', connectResult.reader.label);
188 if (document.getElementById(
"StripeTerminal")) {
189 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>';
197 terminal.connectReader(<?php echo json_encode($stripe->getSelectedReader($conf->global->$keyforstripeterminalbank, $stripeacc, $servicestatus)); ?>).then(
function(connectResult) {
198 if (connectResult.error) {
199 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error clearboth">'+connectResult.error.message+
'</div>';
200 console.log(
'Failed to connect: ', connectResult.error);
202 document.getElementById(
"card-present-alert").innerHTML =
'';
203 console.log(
'Connected to reader: ', connectResult.reader.label);
204 if (document.getElementById(
"StripeTerminal")) {
205 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>';
215 $arrayOfValidPaymentModes = array();
216 $arrayOfValidBankAccount = array();
218 $sql =
"SELECT code, libelle as label FROM ".MAIN_DB_PREFIX.
"c_paiement";
219 $sql .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
220 $sql .=
" AND active = 1";
221 $sql .=
" ORDER BY libelle";
222 $resql = $db->query($sql);
225 while ($obj = $db->fetch_object(
$resql)) {
226 $paycode = $obj->code;
227 if ($paycode ==
'LIQ') {
230 if ($paycode ==
'CB') {
233 if ($paycode ==
'CHQ') {
237 $accountname =
"CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION[
"takeposterminal"];
238 if (!empty($conf->global->$accountname) && $conf->global->$accountname > 0) {
239 $arrayOfValidBankAccount[$conf->global->$accountname] = $conf->global->$accountname;
240 $arrayOfValidPaymentModes[] = $obj;
243 if ($paycode ==
'CASH' || $paycode ==
'CB') $arrayOfValidPaymentModes[] = $obj;
252 if ($invoice->id > 0) {
253 $remaintopay = $invoice->getRemainToPay();
255 $alreadypayed = (is_object($invoice) ? ($invoice->total_ttc - $remaintopay) : 0);
257 if ($conf->global->TAKEPOS_NUMPAD == 0) {
258 print
"var received='';";
260 print
"var received=0;";
264 var alreadypayed = <?php echo $alreadypayed ?>;
266 function addreceived(
price)
269 if (empty($conf->global->TAKEPOS_NUMPAD)) {
270 print
'received+=String(price);'.
"\n";
272 print
'received+=parseFloat(price);'.
"\n";
275 $(
'.change1').html(
pricejs(parseFloat(received),
'MT'));
276 $(
'.change1').val(parseFloat(received));
277 alreadypaydplusreceived=
price2numjs(alreadypayed + parseFloat(received));
280 if (alreadypaydplusreceived > <?php echo $invoice->total_ttc; ?>)
282 var change=parseFloat(alreadypayed + parseFloat(received) - <?php echo $invoice->total_ttc; ?>);
283 $(
'.change2').html(
pricejs(change,
'MT'));
284 $(
'.change2').val(change);
285 $(
'.change1').removeClass(
'colorred');
286 $(
'.change1').addClass(
'colorgreen');
287 $(
'.change2').removeClass(
'colorwhite');
288 $(
'.change2').addClass(
'colorred');
292 $(
'.change2').html(
pricejs(0,
'MT'));
293 $(
'.change2').val(0);
294 if (alreadypaydplusreceived == <?php echo $invoice->total_ttc; ?>)
296 $(
'.change1').removeClass(
'colorred');
297 $(
'.change1').addClass(
'colorgreen');
298 $(
'.change2').removeClass(
'colorred');
299 $(
'.change2').addClass(
'colorwhite');
303 $(
'.change1').removeClass(
'colorgreen');
304 $(
'.change1').addClass(
'colorred');
305 $(
'.change2').removeClass(
'colorred');
306 $(
'.change2').addClass(
'colorwhite');
314 $(
'.change1').html(
pricejs(received,
'MT'));
316 $(
'.change2').html(
pricejs(received,
'MT'));
318 $(
'.change1').removeClass(
'colorgreen');
319 $(
'.change1').addClass(
'colorred');
320 $(
'.change2').removeClass(
'colorred');
321 $(
'.change2').addClass(
'colorwhite');
326 var invoiceid = <?php echo ($invoiceid > 0 ? $invoiceid : 0); ?>;
327 var accountid = $(
"#selectaccountid").val();
328 var amountpayed = $(
"#change1").val();
329 var excess = $(
"#change2").val();
330 if (amountpayed > <?php echo $invoice->total_ttc; ?>) {
331 amountpayed = <?php echo $invoice->total_ttc; ?>;
333 console.log(
"We click on the payment mode to pay amount = "+amountpayed);
334 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() {
335 if (amountpayed > <?php echo $remaintopay; ?> || amountpayed == <?php echo $remaintopay; ?> || amountpayed==0 ) {
336 console.log(
"Close popup");
337 parent.$.colorbox.close();
340 console.log(
"Amount is not comple, so we do NOT close popup and reload it.");
346 function fetchPaymentIntentClientSecret(amount, invoiceid) {
347 const bodyContent = JSON.stringify({ amount : amount, invoiceid : invoiceid });
349 $urlpaymentintent = DOL_URL_ROOT.
'/stripe/ajax/ajax.php?action=createPaymentIntent&token='.
newToken().
'&servicestatus='.$servicestatus;
350 if (!empty($stripeacc)) $urlpaymentintent .=
'&stripeacc='.$stripeacc;
352 return fetch(
'<?php echo $urlpaymentintent; ?>', {
355 'Content-Type':
'application/json'
359 .then(
function(response) {
360 return response.json();
362 .then(
function(data) {
363 return data.client_secret;
368 function capturePaymentIntent(paymentIntentId) {
369 const bodyContent = JSON.stringify({
"id": paymentIntentId})
371 $urlpaymentintent = DOL_URL_ROOT.
'/stripe/ajax/ajax.php?action=capturePaymentIntent&token='.
newToken().
'&servicestatus='.urlencode($servicestatus);
372 if (!empty($stripeacc)) {
373 $urlpaymentintent .=
'&stripeacc='.urlencode($stripeacc);
376 return fetch(
'<?php echo $urlpaymentintent; ?>', {
379 'Content-Type':
'application/json'
383 .then(
function(response) {
384 return response.json();
386 .then(
function(data) {
387 return data.client_secret;
392 function ValidateStripeTerminal() {
393 console.log(
"Launch ValidateStripeTerminal");
394 var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
395 var accountid = $(
"#selectaccountid").val();
396 var amountpayed = $(
"#change1").val();
397 var excess = $(
"#change2").val();
398 if (amountpayed > <?php echo $invoice->getRemainToPay(); ?>) {
399 amountpayed = <?php echo $invoice->getRemainToPay(); ?>;
401 if (amountpayed == 0) {
402 amountpayed = <?php echo $invoice->getRemainToPay(); ?>;
405 console.log(
"Pay with terminal ", amountpayed);
407 fetchPaymentIntentClientSecret(amountpayed, invoiceid).then(
function(client_secret) {
408 <?php
if (empty($servicestatus) && !empty($conf->global->STRIPE_TERMINAL_SIMULATED)) { ?>
409 terminal.setSimulatorConfiguration({testCardNumber:
'<?php echo $conf->global->STRIPE_TERMINAL_SIMULATED; ?>'});
411 document.getElementById(
"card-present-alert").innerHTML =
'<div class="warning clearboth"><?php echo $langs->trans('PaymentSendToStripeTerminal
'); ?></div>';
412 terminal.collectPaymentMethod(client_secret).then(
function(result) {
415 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error clearboth">'+result.error.message+
'</div>';
417 document.getElementById(
"card-present-alert").innerHTML =
'<div class="warning clearboth"><?php echo $langs->trans('PaymentBeingProcessed
'); ?></div>';
418 console.log(
'terminal.collectPaymentMethod', result.paymentIntent);
419 terminal.processPayment(result.paymentIntent).then(function(result) {
421 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error clearboth">'+result.error.message+
'</div>';
422 console.log(result.error)
423 } else if (result.paymentIntent) {
424 paymentIntentId = result.paymentIntent.id;
425 console.log(
'terminal.processPayment', result.paymentIntent);
426 capturePaymentIntent(paymentIntentId).then(function(client_secret) {
429 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error clearboth">'+result.error.message+
'</div>';
430 console.log(
"error when capturing paymentIntent", result.error);
432 document.getElementById(
"card-present-alert").innerHTML =
'<div class="warning clearboth"><?php echo $langs->trans('PaymentValidated
'); ?></div>';
433 console.log(
"Capture paymentIntent successfull "+paymentIntentId);
434 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() {
435 if (amountpayed > <?php echo $remaintopay; ?> || amountpayed == <?php echo $remaintopay; ?> || amountpayed==0 ) {
436 console.log(
"Close popup");
437 parent.$.colorbox.close();
440 console.log(
"Amount is not comple, so we do NOT close popup and reload it.");
454 function ValidateSumup() {
455 console.log(
"Launch ValidateSumup");
456 <?php $_SESSION[
'SMP_CURRENT_PAYMENT'] =
"NEW" ?>
457 var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
458 var amountpayed = $(
"#change1").val();
459 if (amountpayed > <?php echo $invoice->total_ttc; ?>) {
460 amountpayed = <?php echo $invoice->total_ttc; ?>;
464 window.open(
'sumupmerchant://pay/1.0?affiliate-key=<?php echo $conf->global->TAKEPOS_SUMUP_AFFILIATE ?>&app-id=<?php echo $conf->global->TAKEPOS_SUMUP_APPID ?>&total=' + amountpayed +
'¤cy=EUR&title=' + invoiceid +
'&callback=<?php echo DOL_MAIN_URL_ROOT ?>/takepos/smpcb.php');
466 var loop = window.setInterval(
function () {
469 data: { token:
'<?php echo currentToken(); ?>' },
470 url:
'<?php echo DOL_URL_ROOT ?>/takepos/smpcb.php?status' }).done(
function (data) {
472 if (data ===
"SUCCESS") {
473 parent.$(
"#poslines").load(
"invoice.php?place=<?php echo $place; ?>&action=valid&token=<?php echo newToken(); ?>&pay=CB&amount=" + amountpayed +
"&invoiceid=" + invoiceid,
function () {
475 parent.$.colorbox.close();
479 }
else if (data ===
"FAILED") {
480 parent.$.colorbox.close();
488 if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
489 echo
"var line1='".$langs->trans(
'TotalTTC').
"'.substring(0,20);";
490 echo
"line1=line1.padEnd(20);";
491 echo
"var line2='".price($invoice->total_ttc, 1,
'', 1, -1, -1).
"'.substring(0,20);";
492 echo
"line2=line2.padEnd(20);";
495 data: { text: line1+line2 },
496 url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER').
"/display/index.php',
502 <div style=
"position:relative; padding-top: 20px; left:5%; height:140px; width:90%;">
503 <div
class=
"paymentbordline paymentbordlinetotal center">
504 <span
class=
"takepospay colorwhite"><?php echo $langs->trans(
'TotalTTC'); ?>: <span
id=
"totaldisplay" class=
"colorwhite"><?php echo
price($invoice->total_ttc, 1,
'', 1, -1, -1, $invoice->multicurrency_code); ?></span></span>
506 <?php
if ($remaintopay != $invoice->total_ttc) { ?>
507 <div
class=
"paymentbordline paymentbordlineremain center">
508 <span
class=
"takepospay colorwhite"><?php echo $langs->trans(
'RemainToPay'); ?>: <span
id=
"remaintopaydisplay" class=
"colorwhite"><?php echo
price($remaintopay, 1,
'', 1, -1, -1, $invoice->multicurrency_code); ?></span></span>
511 <div
class=
"paymentbordline paymentbordlinereceived center">
512 <span
class=
"takepospay colorwhite"><?php echo $langs->trans(
"Received"); ?>: <span
class=
"change1 colorred"><?php echo
price(0, 1,
'', 1, -1, -1, $invoice->multicurrency_code); ?></span><input
type=
"hidden" id=
"change1" class=
"change1" value=
"0"></span>
514 <div
class=
"paymentbordline paymentbordlinechange center">
515 <span
class=
"takepospay colorwhite"><?php echo $langs->trans(
"Change"); ?>: <span
class=
"change2 colorwhite"><?php echo
price(0, 1,
'', 1, -1, -1, $invoice->multicurrency_code); ?></span><input
type=
"hidden" id=
"change2" class=
"change2" value=
"0"></span>
518 if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) {
519 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
520 print
'<div class="paymentbordline paddingtop paddingbottom center">';
523 print
'<span class="takepospay colorwhite">'.$langs->trans(
"BankAccount").
': </span>';
524 $form->select_comptes(0,
'accountid', 0, $filter, 1,
'');
530 <div style=
"position:absolute; left:5%; height:52%; width:90%;">
532 $action_buttons = array(
534 "function" =>
"reset()",
535 "span" =>
"style='font-size: 150%;'",
537 "class" =>
"poscolorblue"
540 "function" =>
"parent.$.colorbox.close();",
541 "span" =>
"id='printtext' style='font-weight: bold; font-size: 18pt;'",
543 "class" =>
"poscolordelete"
546 $numpad = $conf->global->TAKEPOS_NUMPAD;
547 if (
isModEnabled(
'stripe') && isset($keyforstripeterminalbank) && !empty($conf->global->STRIPE_CARD_PRESENT)) {
548 print
'<span id="card-present-alert">';
549 dol_htmloutput_mesg($langs->trans(
'ConnectingToStripeTerminal',
'Stripe'),
'',
'warning', 1);
552 print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'7' :
'10').
');">'.($numpad == 0 ?
'7' :
'10').
'</button>';
553 print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'8' :
'20').
');">'.($numpad == 0 ?
'8' :
'20').
'</button>';
554 print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'9' :
'50').
');">'.($numpad == 0 ?
'9' :
'50').
'</button>';
556 <?php
if (count($arrayOfValidPaymentModes) > 0) {
557 $paycode = $arrayOfValidPaymentModes[0]->code;
559 if ($paycode ==
'LIQ') {
560 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
563 } elseif ($paycode ==
'CB') {
564 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
565 $payIcon =
'credit-card';
567 } elseif ($paycode ==
'CHQ') {
568 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
569 $payIcon =
'money-check';
573 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>';
575 print '<button type="button" class="calcbutton2
">'.$langs->trans("NoPaimementModesDefined
").'</button>';
578 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '4
' : '1
').');
">'.($numpad == 0 ? '4' : '1').'</button>';
579 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '5
' : '2
').');
">'.($numpad == 0 ? '5' : '2').'</button>';
580 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '6
' : '5
').');
">'.($numpad == 0 ? '6' : '5').'</button>';
582 <?php if (count($arrayOfValidPaymentModes) > 1) {
583 $paycode = $arrayOfValidPaymentModes[1]->code;
585 if ($paycode == 'LIQ') {
586 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
589 } elseif ($paycode == 'CB') {
590 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
591 $payIcon = 'credit-card';
593 } elseif ($paycode == 'CHQ') {
594 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
595 $payIcon = 'money-check';
599 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>';
601 $button = array_pop($action_buttons);
602 print '<button type="button" class="calcbutton2
" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
605 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '1
' : '0.10
').');
">'.($numpad == 0 ? '1' : '0.10').'</button>';
606 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '2
' : '0.20
').');
">'.($numpad == 0 ? '2' : '0.20').'</button>';
607 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '3
' : '0.50
').');
">'.($numpad == 0 ? '3' : '0.50').'</button>';
609 <?php if (count($arrayOfValidPaymentModes) > 2) {
610 $paycode = $arrayOfValidPaymentModes[2]->code;
612 if ($paycode == 'LIQ') {
613 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
616 } elseif ($paycode == 'CB') {
617 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
618 $payIcon = 'credit-card';
620 } elseif ($paycode == 'CHQ') {
621 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
622 $payIcon = 'money-check';
626 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>';
628 $button = array_pop($action_buttons);
629 print '<button type="button" class="calcbutton2
" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
632 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '0
' : '0.01
').');
">'.($numpad == 0 ? '0' : '0.01').'</button>';
633 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '\
'000\'' :
'0.02').
');">'.($numpad == 0 ?
'000' :
'0.02').
'</button>';
634 print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'\'.\
'' :
'0.05').
');">'.($numpad == 0 ?
'.' :
'0.05').
'</button>';
637 while ($i < count($arrayOfValidPaymentModes)) {
638 $paycode = $arrayOfValidPaymentModes[$i]->code;
640 if ($paycode ==
'LIQ') {
641 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
644 } elseif ($paycode ==
'CB') {
645 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
646 $payIcon =
'credit-card';
648 } elseif ($paycode ==
'CHQ') {
649 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
650 $payIcon =
'money-check';
654 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>';
658 if (isModEnabled('stripe') && isset($keyforstripeterminalbank) && !empty($conf->global->STRIPE_CARD_PRESENT)) {
659 $keyforstripeterminalbank = "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL
".$_SESSION["takeposterminal
"];
660 print '<span id="StripeTerminal
"></span>';
661 if (!empty($conf->global->$keyforstripeterminalbank)) {
663 $langs->loadLangs(array("errors
", "admin
"));
664 //print '<button type="button" class="calcbutton2 disabled
" title="'.$langs->trans("SetupNotComplete").'">TerminalOff</button>';
668 $keyforsumupbank = "CASHDESK_ID_BANKACCOUNT_SUMUP
".$_SESSION["takeposterminal
"];
669 if (getDolGlobalInt('TAKEPOS_ENABLE_SUMUP')) {
670 if (!empty($conf->global->$keyforsumupbank)) {
671 print '<button type="button" class="calcbutton2
" onclick="ValidateSumup();
">Sumup</button>';
673 $langs->loadLangs(array("errors
", "admin
"));
674 print '<button type="button" class="calcbutton2 disabled
" title="'.$langs->trans("SetupNotComplete").'">Sumup</button>';
678 $parameters = array();
679 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $invoice, $action); // Note that $action and $object may have been modified by hook
680 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
682 $class = ($i == 3) ? "calcbutton3
" : "calcbutton2
";
683 foreach ($action_buttons as $button) {
684 $newclass = $class.($button["class"] ? " ".$button["class"] : "");
685 print '<button type="button" class="'.$newclass.'" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
688 if ($conf->global->TAKEPOS_DELAYED_PAYMENT) {
689 print '<button type="button" class="calcbutton2
" onclick="Validate(\
'delayed\');">'.$langs->trans(
"Reported").
'</button>';
696 $hookmanager->executeHooks(
'completePayment', $parameters, $invoice);
697 print $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.
Class to manage invoices.
Class toolbox to validate values.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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 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.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
isModEnabled($module)
Is Dolibarr module enabled.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
pricejs(amount, mode='MT', currency_code='', force_locale='')
Function similar to PHP price()
price2numjs(amount)
Function similar to PHP price2num()
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
table tableforfield button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.