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');
316 $(
'.change1').html(
pricejs(received,
'MT'));
318 $(
'.change2').html(
pricejs(received,
'MT'));
320 $(
'.change1').removeClass(
'colorgreen');
321 $(
'.change1').addClass(
'colorred');
322 $(
'.change2').removeClass(
'colorred');
323 $(
'.change2').addClass(
'colorwhite');
328 var invoiceid = <?php echo ($invoiceid > 0 ? $invoiceid : 0); ?>;
329 var accountid = $(
"#selectaccountid").val();
330 var amountpayed = $(
"#change1").val();
331 var excess = $(
"#change2").val();
332 if (amountpayed > <?php echo $invoice->total_ttc; ?>) {
333 amountpayed = <?php echo $invoice->total_ttc; ?>;
335 console.log(
"We click on the payment mode to pay amount = "+amountpayed);
336 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() {
337 if (amountpayed > <?php echo $remaintopay; ?> || amountpayed == <?php echo $remaintopay; ?> || amountpayed==0 ) {
338 console.log(
"Close popup");
339 parent.$.colorbox.close();
342 console.log(
"Amount is not comple, so we do NOT close popup and reload it.");
350 function fetchPaymentIntentClientSecret(amount, invoiceid) {
351 const bodyContent = JSON.stringify({ amount : amount, invoiceid : invoiceid });
353 $urlpaymentintent = DOL_URL_ROOT.
'/stripe/ajax/ajax.php?action=createPaymentIntent&token='.
newToken().
'&servicestatus='.$servicestatus;
354 if (!empty($stripeacc)) $urlpaymentintent .=
'&stripeacc='.$stripeacc;
356 return fetch(
'<?php echo $urlpaymentintent; ?>', {
359 'Content-Type':
'application/json'
363 .then(
function(response) {
364 return response.json();
366 .then(
function(data) {
367 return data.client_secret;
372 function capturePaymentIntent(paymentIntentId) {
373 const bodyContent = JSON.stringify({
"id": paymentIntentId})
375 $urlpaymentintent = DOL_URL_ROOT.
'/stripe/ajax/ajax.php?action=capturePaymentIntent&token='.
newToken().
'&servicestatus='.urlencode($servicestatus);
376 if (!empty($stripeacc)) {
377 $urlpaymentintent .=
'&stripeacc='.urlencode($stripeacc);
380 return fetch(
'<?php echo $urlpaymentintent; ?>', {
383 'Content-Type':
'application/json'
387 .then(
function(response) {
388 return response.json();
390 .then(
function(data) {
391 return data.client_secret;
396 function ValidateStripeTerminal() {
397 console.log(
"Launch ValidateStripeTerminal");
398 var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
399 var accountid = $(
"#selectaccountid").val();
400 var amountpayed = $(
"#change1").val();
401 var excess = $(
"#change2").val();
402 if (amountpayed > <?php echo $invoice->getRemainToPay(); ?>) {
403 amountpayed = <?php echo $invoice->getRemainToPay(); ?>;
405 if (amountpayed == 0) {
406 amountpayed = <?php echo $invoice->getRemainToPay(); ?>;
409 console.log(
"Pay with terminal ", amountpayed);
411 fetchPaymentIntentClientSecret(amountpayed, invoiceid).then(
function(client_secret) {
412 <?php
if (empty($servicestatus) && !empty($conf->global->STRIPE_TERMINAL_SIMULATED)) { ?>
413 terminal.setSimulatorConfiguration({testCardNumber:
'<?php echo $conf->global->STRIPE_TERMINAL_SIMULATED; ?>'});
415 document.getElementById(
"card-present-alert").innerHTML =
'<div class="warning clearboth"><?php echo $langs->trans('PaymentSendToStripeTerminal
'); ?></div>';
416 terminal.collectPaymentMethod(client_secret).then(
function(result) {
419 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error clearboth">'+result.error.message+
'</div>';
421 document.getElementById(
"card-present-alert").innerHTML =
'<div class="warning clearboth"><?php echo $langs->trans('PaymentBeingProcessed
'); ?></div>';
422 console.log(
'terminal.collectPaymentMethod', result.paymentIntent);
423 terminal.processPayment(result.paymentIntent).then(function(result) {
425 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error clearboth">'+result.error.message+
'</div>';
426 console.log(result.error)
427 } else if (result.paymentIntent) {
428 paymentIntentId = result.paymentIntent.id;
429 console.log(
'terminal.processPayment', result.paymentIntent);
430 capturePaymentIntent(paymentIntentId).then(function(client_secret) {
433 document.getElementById(
"card-present-alert").innerHTML =
'<div class="error clearboth">'+result.error.message+
'</div>';
434 console.log(
"error when capturing paymentIntent", result.error);
436 document.getElementById(
"card-present-alert").innerHTML =
'<div class="warning clearboth"><?php echo $langs->trans('PaymentValidated
'); ?></div>';
437 console.log(
"Capture paymentIntent successfull "+paymentIntentId);
438 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() {
439 if (amountpayed > <?php echo $remaintopay; ?> || amountpayed == <?php echo $remaintopay; ?> || amountpayed==0 ) {
440 console.log(
"Close popup");
441 parent.$.colorbox.close();
444 console.log(
"Amount is not comple, so we do NOT close popup and reload it.");
458 function ValidateSumup() {
459 console.log(
"Launch ValidateSumup");
460 <?php $_SESSION[
'SMP_CURRENT_PAYMENT'] =
"NEW" ?>
461 var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
462 var amountpayed = $(
"#change1").val();
463 if (amountpayed > <?php echo $invoice->total_ttc; ?>) {
464 amountpayed = <?php echo $invoice->total_ttc; ?>;
468 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');
470 var loop = window.setInterval(
function () {
473 data: { token:
'<?php echo currentToken(); ?>' },
474 url:
'<?php echo DOL_URL_ROOT ?>/takepos/smpcb.php?status' }).done(
function (data) {
476 if (data ===
"SUCCESS") {
477 parent.$(
"#poslines").load(
"invoice.php?place=<?php echo $place; ?>&action=valid&token=<?php echo newToken(); ?>&pay=CB&amount=" + amountpayed +
"&invoiceid=" + invoiceid,
function () {
479 parent.$.colorbox.close();
483 }
else if (data ===
"FAILED") {
484 parent.$.colorbox.close();
492 if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
493 echo
"var line1='".$langs->trans(
'TotalTTC').
"'.substring(0,20);";
494 echo
"line1=line1.padEnd(20);";
495 echo
"var line2='".price($invoice->total_ttc, 1,
'', 1, -1, -1).
"'.substring(0,20);";
496 echo
"line2=line2.padEnd(20);";
499 data: { text: line1+line2 },
500 url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER').
"/display/index.php',
506 <div style=
"position:relative; padding-top: 20px; left:5%; height:140px; width:90%;">
507 <div
class=
"paymentbordline paymentbordlinetotal center">
508 <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>
510 <?php
if ($remaintopay != $invoice->total_ttc) { ?>
511 <div
class=
"paymentbordline paymentbordlineremain center">
512 <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>
515 <div
class=
"paymentbordline paymentbordlinereceived center">
516 <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>
518 <div
class=
"paymentbordline paymentbordlinechange center">
519 <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>
522 if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) {
523 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
524 print
'<div class="paymentbordline paddingtop paddingbottom center">';
527 print
'<span class="takepospay colorwhite">'.$langs->trans(
"BankAccount").
': </span>';
528 $form->select_comptes(0,
'accountid', 0, $filter, 1,
'');
534 <div style=
"position:absolute; left:5%; height:52%; width:90%;">
536 $action_buttons = array(
538 "function" =>
"reset()",
539 "span" =>
"style='font-size: 150%;'",
541 "class" =>
"poscolorblue"
544 "function" =>
"parent.$.colorbox.close();",
545 "span" =>
"id='printtext' style='font-weight: bold; font-size: 18pt;'",
547 "class" =>
"poscolordelete"
550 $numpad = $conf->global->TAKEPOS_NUMPAD;
551 if (
isModEnabled(
'stripe') && isset($keyforstripeterminalbank) && !empty($conf->global->STRIPE_CARD_PRESENT)) {
552 print
'<span id="card-present-alert">';
553 dol_htmloutput_mesg($langs->trans(
'ConnectingToStripeTerminal',
'Stripe'),
'',
'warning', 1);
556 print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'7' :
'10').
')">'.($numpad == 0 ?
'7' :
'10').
'</button>';
557 print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'8' :
'20').
')">'.($numpad == 0 ?
'8' :
'20').
'</button>';
558 print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'9' :
'50').
')">'.($numpad == 0 ?
'9' :
'50').
'</button>';
560 <?php
if (count($arrayOfValidPaymentModes) > 0) {
561 $paycode = $arrayOfValidPaymentModes[0]->code;
563 if ($paycode ==
'LIQ') {
564 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
567 } elseif ($paycode ==
'CB') {
568 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
569 $payIcon =
'credit-card';
571 } elseif ($paycode ==
'CHQ') {
572 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
573 $payIcon =
'money-check';
577 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>';
579 print '<button type="button" class="calcbutton2
">'.$langs->trans("NoPaimementModesDefined
").'</button>';
582 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '4
' : '1
').')
">'.($numpad == 0 ? '4' : '1').'</button>';
583 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '5
' : '2
').')
">'.($numpad == 0 ? '5' : '2').'</button>';
584 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '6
' : '5
').')
">'.($numpad == 0 ? '6' : '5').'</button>';
586 <?php if (count($arrayOfValidPaymentModes) > 1) {
587 $paycode = $arrayOfValidPaymentModes[1]->code;
589 if ($paycode == 'LIQ') {
590 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
593 } elseif ($paycode == 'CB') {
594 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
595 $payIcon = 'credit-card';
597 } elseif ($paycode == 'CHQ') {
598 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
599 $payIcon = 'money-check';
603 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>';
605 $button = array_pop($action_buttons);
606 print '<button type="button" class="calcbutton2
" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
609 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '1
' : '0.10
').')
">'.($numpad == 0 ? '1' : '0.10').'</button>';
610 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '2
' : '0.20
').')
">'.($numpad == 0 ? '2' : '0.20').'</button>';
611 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '3
' : '0.50
').')
">'.($numpad == 0 ? '3' : '0.50').'</button>';
613 <?php if (count($arrayOfValidPaymentModes) > 2) {
614 $paycode = $arrayOfValidPaymentModes[2]->code;
616 if ($paycode == 'LIQ') {
617 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
620 } elseif ($paycode == 'CB') {
621 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
622 $payIcon = 'credit-card';
624 } elseif ($paycode == 'CHQ') {
625 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
626 $payIcon = 'money-check';
630 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>';
632 $button = array_pop($action_buttons);
633 print '<button type="button" class="calcbutton2
" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
636 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '0
' : '0.01
').')
">'.($numpad == 0 ? '0' : '0.01').'</button>';
637 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '\
'000\'' :
'0.02').
')">'.($numpad == 0 ?
'000' :
'0.02').
'</button>';
638 print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'\'.\
'' :
'0.05').
')">'.($numpad == 0 ?
'.' :
'0.05').
'</button>';
641 while ($i < count($arrayOfValidPaymentModes)) {
642 $paycode = $arrayOfValidPaymentModes[$i]->code;
644 if ($paycode ==
'LIQ') {
645 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
648 } elseif ($paycode ==
'CB') {
649 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
650 $payIcon =
'credit-card';
652 } elseif ($paycode ==
'CHQ') {
653 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
654 $payIcon =
'money-check';
658 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>';
662 if (isModEnabled('stripe') && isset($keyforstripeterminalbank) && !empty($conf->global->STRIPE_CARD_PRESENT)) {
663 $keyforstripeterminalbank = "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL
".$_SESSION["takeposterminal
"];
664 print '<span id="StripeTerminal
"></span>';
665 if (!empty($conf->global->$keyforstripeterminalbank)) {
667 $langs->loadLangs(array("errors
", "admin
"));
668 //print '<button type="button" class="calcbutton2 disabled
" title="'.$langs->trans("SetupNotComplete").'">TerminalOff</button>';
672 $keyforsumupbank = "CASHDESK_ID_BANKACCOUNT_SUMUP
".$_SESSION["takeposterminal
"];
673 if (getDolGlobalInt('TAKEPOS_ENABLE_SUMUP')) {
674 if (!empty($conf->global->$keyforsumupbank)) {
675 print '<button type="button" class="calcbutton2
" onclick="ValidateSumup();
">Sumup</button>';
677 $langs->loadLangs(array("errors
", "admin
"));
678 print '<button type="button" class="calcbutton2 disabled
" title="'.$langs->trans("SetupNotComplete").'">Sumup</button>';
682 $parameters = array();
683 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $invoice, $action); // Note that $action and $object may have been modified by hook
684 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
686 $class = ($i == 3) ? "calcbutton3
" : "calcbutton2
";
687 foreach ($action_buttons as $button) {
688 $newclass = $class.($button["class"] ? " ".$button["class"] : "");
689 print '<button type="button" class="'.$newclass.'" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
692 if (getDolGlobalString('TAKEPOS_DELAYED_PAYMENT')) {
693 print '<button type="button" class="calcbutton2
" onclick="Validate(\
'delayed\')">'.$langs->trans(
"Reported").
'</button>';
700 $hookmanager->executeHooks(
'completePayment', $parameters, $invoice);
701 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') && $user->hasRight('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') && $user->hasRight('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)) $sql
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.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.