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"];
 
  100 <script src=
"https://js.stripe.com/terminal/v1/"></script>
 
  102 var terminal = StripeTerminal.create({
 
  103   onFetchConnectionToken: fetchConnectionToken,
 
  104   onUnexpectedReaderDisconnect: unexpectedDisconnect,
 
  106 function unexpectedDisconnect() {
 
  109   console.log(
"Disconnected from reader")
 
  111 function fetchConnectionToken() {
 
  113   $urlconnexiontoken = DOL_URL_ROOT.
'/stripe/ajax/ajax.php?action=getConnexionToken&token='.
newToken().
'&servicestatus='.urlencode($servicestatus);
 
  114   if (!empty($conf->global->STRIPE_LOCATION)) {
 
  115     $urlconnexiontoken .= 
'&location='.urlencode($conf->global->STRIPE_LOCATION);
 
  117   if (!empty($stripeacc)) {
 
  118     $urlconnexiontoken .= 
'&stripeacc='.urlencode($stripeacc);
 
  122   return fetch(
'<?php echo $urlconnexiontoken; ?>', { method: 
"POST" })
 
  123   .then(
function(response) {
 
  124     return response.json();
 
  126   .then(
function(data) {
 
  133 if (
isModEnabled(
'stripe') && isset($keyforstripeterminalbank) && (empty($conf->global->STRIPE_LIVE) || 
GETPOST(
'forcesandbox', 
'alpha'))) {
 
  134   dol_htmloutput_mesg($langs->trans(
'YouAreCurrentlyInSandboxMode', 
'Stripe'), 
'', 
'warning', 1);
 
  138 if ($invoiceid > 0) {
 
  139   $invoice->fetch($invoiceid);
 
  141   $sql = 
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture where ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
 
  142   $resql = $db->query($sql);
 
  143   $obj = $db->fetch_object(
$resql);
 
  145     $invoiceid = $obj->rowid;
 
  150     $invoice->fetch($invoiceid);
 
  157   if ($invoice->type != $invoice::TYPE_CREDIT_NOTE) {
 
  158     if (empty($conf->global->$keyforstripeterminalbank)) { ?>
 
  159     const config = {simulated: <?php 
if (empty($servicestatus) && !empty($conf->global->STRIPE_TERMINAL_SIMULATED)) { ?> 
true <?php } 
else { ?> false <?php } ?>
 
  160       <?php 
if (!empty($conf->global->STRIPE_LOCATION)) { ?>, location: 
'<?php echo $conf->global->STRIPE_LOCATION; ?>'<?php } ?>}
 
  161   terminal.discoverReaders(config).then(
function(discoverResult) {
 
  162   if (discoverResult.error) {
 
  163     console.log(
'Failed to discover: ', discoverResult.error);
 
  164   } 
else if (discoverResult.discoveredReaders.length === 0) {
 
  165     console.log(
'No available readers.');
 
  169     selectedReader = discoverResult.discoveredReaders[0];
 
  172     terminal.connectReader(selectedReader).then(function(connectResult) {
 
  173     if (connectResult.error) {
 
  174     document.getElementById(
"card-present-alert").innerHTML = 
'<div class="error">'+connectResult.error.message+
'</div>';
 
  175       console.log(
'Failed to connect: ', connectResult.error);
 
  177     document.getElementById(
"card-present-alert").innerHTML = 
'';
 
  178       console.log(
'Connected to reader: ', connectResult.reader.label);
 
  179       if (document.getElementById(
"StripeTerminal")) {
 
  180         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>';
 
  188   terminal.connectReader(<?php echo json_encode($stripe->getSelectedReader($conf->global->$keyforstripeterminalbank, $stripeacc, $servicestatus)); ?>).then(
function(connectResult) {
 
  189     if (connectResult.error) {
 
  190     document.getElementById(
"card-present-alert").innerHTML = 
'<div class="error clearboth">'+connectResult.error.message+
'</div>';
 
  191         console.log(
'Failed to connect: ', connectResult.error);
 
  193     document.getElementById(
"card-present-alert").innerHTML = 
'';
 
  194       console.log(
'Connected to reader: ', connectResult.reader.label);
 
  195       if (document.getElementById(
"StripeTerminal")) {
 
  196         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>';
 
  206 $arrayOfValidPaymentModes = array();
 
  207 $arrayOfValidBankAccount = array();
 
  209 $sql = 
"SELECT code, libelle as label FROM ".MAIN_DB_PREFIX.
"c_paiement";
 
  210 $sql .= 
" WHERE entity IN (".getEntity(
'c_paiement').
")";
 
  211 $sql .= 
" AND active = 1";
 
  212 $sql .= 
" ORDER BY libelle";
 
  213 $resql = $db->query($sql);
 
  216   while ($obj = $db->fetch_object(
$resql)) {
 
  217     $paycode = $obj->code;
 
  218     if ($paycode == 
'LIQ') {
 
  221     if ($paycode == 
'CB') {
 
  224     if ($paycode == 
'CHQ') {
 
  228     $accountname = 
"CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION[
"takeposterminal"];
 
  229     if (!empty($conf->global->$accountname) && $conf->global->$accountname > 0) {
 
  230       $arrayOfValidBankAccount[$conf->global->$accountname] = $conf->global->$accountname;
 
  231       $arrayOfValidPaymentModes[] = $obj;
 
  234       if ($paycode == 
'CASH' || $paycode == 
'CB') $arrayOfValidPaymentModes[] = $obj;
 
  243 if ($invoice->id > 0) {
 
  244   $remaintopay = $invoice->getRemainToPay();
 
  246 $alreadypayed = (is_object($invoice) ? ($invoice->total_ttc - $remaintopay) : 0);
 
  248 if ($conf->global->TAKEPOS_NUMPAD == 0) {
 
  249   print 
"var received='';";
 
  251   print 
"var received=0;";
 
  255   var alreadypayed = <?php echo $alreadypayed ?>;
 
  257   function addreceived(
price)
 
  260     if (empty($conf->global->TAKEPOS_NUMPAD)) {
 
  261       print 
'received+=String(price);'.
"\n";
 
  263       print 
'received+=parseFloat(price);'.
"\n";
 
  266     $(
'.change1').html(
pricejs(parseFloat(received), 
'MT'));
 
  267     $(
'.change1').val(parseFloat(received));
 
  268     alreadypaydplusreceived=
price2numjs(alreadypayed + parseFloat(received));
 
  271     if (alreadypaydplusreceived > <?php echo $invoice->total_ttc; ?>)
 
  273       var change=parseFloat(alreadypayed + parseFloat(received) - <?php echo $invoice->total_ttc; ?>);
 
  274       $(
'.change2').html(
pricejs(change, 
'MT'));
 
  275       $(
'.change2').val(change);
 
  276       $(
'.change1').removeClass(
'colorred');
 
  277       $(
'.change1').addClass(
'colorgreen');
 
  278       $(
'.change2').removeClass(
'colorwhite');
 
  279       $(
'.change2').addClass(
'colorred');
 
  283       $(
'.change2').html(
pricejs(0, 
'MT'));
 
  284       $(
'.change2').val(0);
 
  285       if (alreadypaydplusreceived == <?php echo $invoice->total_ttc; ?>)
 
  287         $(
'.change1').removeClass(
'colorred');
 
  288         $(
'.change1').addClass(
'colorgreen');
 
  289         $(
'.change2').removeClass(
'colorred');
 
  290         $(
'.change2').addClass(
'colorwhite');
 
  294         $(
'.change1').removeClass(
'colorgreen');
 
  295         $(
'.change1').addClass(
'colorred');
 
  296         $(
'.change2').removeClass(
'colorred');
 
  297         $(
'.change2').addClass(
'colorwhite');
 
  305     $(
'.change1').html(
pricejs(received, 
'MT'));
 
  307     $(
'.change2').html(
pricejs(received, 
'MT'));
 
  309     $(
'.change1').removeClass(
'colorgreen');
 
  310     $(
'.change1').addClass(
'colorred');
 
  311     $(
'.change2').removeClass(
'colorred');
 
  312     $(
'.change2').addClass(
'colorwhite');
 
  317     var invoiceid = <?php echo ($invoiceid > 0 ? $invoiceid : 0); ?>;
 
  318     var accountid = $(
"#selectaccountid").val();
 
  319     var amountpayed = $(
"#change1").val();
 
  320     var excess = $(
"#change2").val();
 
  321     if (amountpayed > <?php echo $invoice->total_ttc; ?>) {
 
  322       amountpayed = <?php echo $invoice->total_ttc; ?>;
 
  324     console.log(
"We click on the payment mode to pay amount = "+amountpayed);
 
  325     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() {
 
  326       if (amountpayed > <?php echo $remaintopay; ?> || amountpayed == <?php echo $remaintopay; ?> || amountpayed==0 ) {
 
  327         console.log(
"Close popup");
 
  328         parent.$.colorbox.close();
 
  331         console.log(
"Amount is not comple, so we do NOT close popup and reload it.");
 
  337   function fetchPaymentIntentClientSecret(amount, invoiceid) {
 
  338     const bodyContent = JSON.stringify({ amount : amount, invoiceid : invoiceid });
 
  340   $urlpaymentintent = DOL_URL_ROOT.
'/stripe/ajax/ajax.php?action=createPaymentIntent&token='.
newToken().
'&servicestatus='.$servicestatus;
 
  341   if (!empty($stripeacc)) $urlpaymentintent .= 
'&stripeacc='.$stripeacc;
 
  343   return fetch(
'<?php echo $urlpaymentintent; ?>', {
 
  346     'Content-Type': 
'application/json' 
  350   .then(
function(response) {
 
  351   return response.json();
 
  353   .then(
function(data) {
 
  354   return data.client_secret;
 
  359   function capturePaymentIntent(paymentIntentId) {
 
  360   const bodyContent = JSON.stringify({
"id": paymentIntentId})
 
  362   $urlpaymentintent = DOL_URL_ROOT.
'/stripe/ajax/ajax.php?action=capturePaymentIntent&token='.
newToken().
'&servicestatus='.urlencode($servicestatus);
 
  363   if (!empty($stripeacc)) {
 
  364     $urlpaymentintent .= 
'&stripeacc='.urlencode($stripeacc);
 
  367   return fetch(
'<?php echo $urlpaymentintent; ?>', {
 
  370     'Content-Type': 
'application/json' 
  374   .then(
function(response) {
 
  375   return response.json();
 
  377   .then(
function(data) {
 
  378   return data.client_secret;
 
  383   function ValidateStripeTerminal() {
 
  384     console.log(
"Launch ValidateStripeTerminal");
 
  385     var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
 
  386     var accountid = $(
"#selectaccountid").val();
 
  387     var amountpayed = $(
"#change1").val();
 
  388     var excess = $(
"#change2").val();
 
  389     if (amountpayed > <?php echo $invoice->getRemainToPay(); ?>) {
 
  390       amountpayed = <?php echo $invoice->getRemainToPay(); ?>;
 
  392     if (amountpayed == 0) {
 
  393       amountpayed = <?php echo $invoice->getRemainToPay(); ?>;
 
  396     console.log(
"Pay with terminal ", amountpayed);
 
  398     fetchPaymentIntentClientSecret(amountpayed, invoiceid).then(
function(client_secret) {
 
  399       <?php 
if (empty($servicestatus) && !empty($conf->global->STRIPE_TERMINAL_SIMULATED)) { ?>
 
  400     terminal.setSimulatorConfiguration({testCardNumber: 
'<?php echo $conf->global->STRIPE_TERMINAL_SIMULATED; ?>'});
 
  402     document.getElementById(
"card-present-alert").innerHTML = 
'<div class="warning clearboth"><?php echo $langs->trans('PaymentSendToStripeTerminal
'); ?></div>';
 
  403     terminal.collectPaymentMethod(client_secret).then(
function(result) {
 
  406     document.getElementById(
"card-present-alert").innerHTML = 
'<div class="error clearboth">'+result.error.message+
'</div>';
 
  408     document.getElementById(
"card-present-alert").innerHTML = 
'<div class="warning clearboth"><?php echo $langs->trans('PaymentBeingProcessed
'); ?></div>';
 
  409       console.log(
'terminal.collectPaymentMethod', result.paymentIntent);
 
  410       terminal.processPayment(result.paymentIntent).then(function(result) {
 
  412       document.getElementById(
"card-present-alert").innerHTML = 
'<div class="error clearboth">'+result.error.message+
'</div>';
 
  413       console.log(result.error)
 
  414     } else if (result.paymentIntent) {
 
  415         paymentIntentId = result.paymentIntent.id;
 
  416         console.log(
'terminal.processPayment', result.paymentIntent);
 
  417         capturePaymentIntent(paymentIntentId).then(function(client_secret) {
 
  420         document.getElementById(
"card-present-alert").innerHTML = 
'<div class="error clearboth">'+result.error.message+
'</div>';
 
  421         console.log(
"error when capturing paymentIntent", result.error);
 
  423         document.getElementById(
"card-present-alert").innerHTML = 
'<div class="warning clearboth"><?php echo $langs->trans('PaymentValidated
'); ?></div>';
 
  424         console.log(
"Capture paymentIntent successfull "+paymentIntentId);
 
  425           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() {
 
  426       if (amountpayed > <?php echo $remaintopay; ?> || amountpayed == <?php echo $remaintopay; ?> || amountpayed==0 ) {
 
  427         console.log(
"Close popup");
 
  428         parent.$.colorbox.close();
 
  431         console.log(
"Amount is not comple, so we do NOT close popup and reload it.");
 
  445   function ValidateSumup() {
 
  446     console.log(
"Launch ValidateSumup");
 
  447     <?php $_SESSION[
'SMP_CURRENT_PAYMENT'] = 
"NEW" ?>
 
  448     var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
 
  449     var amountpayed = $(
"#change1").val();
 
  450     if (amountpayed > <?php echo $invoice->total_ttc; ?>) {
 
  451       amountpayed = <?php echo $invoice->total_ttc; ?>;
 
  455     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');
 
  457     var loop = window.setInterval(
function () {
 
  460         data: { token: 
'<?php echo currentToken(); ?>' },
 
  461         url: 
'<?php echo DOL_URL_ROOT ?>/takepos/smpcb.php?status' }).done(
function (data) {
 
  463         if (data === 
"SUCCESS") {
 
  464           parent.$(
"#poslines").load(
"invoice.php?place=<?php echo $place; ?>&action=valid&token=<?php echo newToken(); ?>&pay=CB&amount=" + amountpayed + 
"&invoiceid=" + invoiceid, 
function () {
 
  466             parent.$.colorbox.close();
 
  470         } 
else if (data === 
"FAILED") {
 
  471           parent.$.colorbox.close();
 
  479 if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
 
  480   echo 
"var line1='".$langs->trans(
'TotalTTC').
"'.substring(0,20);";
 
  481   echo 
"line1=line1.padEnd(20);";
 
  482   echo 
"var line2='".price($invoice->total_ttc, 1, 
'', 1, -1, -1).
"'.substring(0,20);";
 
  483   echo 
"line2=line2.padEnd(20);";
 
  486     data: { text: line1+line2 }, 
  487     url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER').
"/display/index.php', 
  493 <div style=
"position:relative; padding-top: 20px; left:5%; height:140px; width:90%;">
 
  494   <div 
class=
"paymentbordline paymentbordlinetotal center">
 
  495     <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>
 
  497   <?php 
if ($remaintopay != $invoice->total_ttc) { ?>
 
  498     <div 
class=
"paymentbordline paymentbordlineremain center">
 
  499       <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>
 
  502   <div 
class=
"paymentbordline paymentbordlinereceived center">
 
  503     <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>
 
  505   <div 
class=
"paymentbordline paymentbordlinechange center">
 
  506     <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>
 
  509   if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) {
 
  510     require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
 
  511     print 
'<div class="paymentbordline paddingtop paddingbottom center">';
 
  514     print 
'<span class="takepospay colorwhite">'.$langs->trans(
"BankAccount").
': </span>';
 
  515     $form->select_comptes(0, 
'accountid', 0, $filter, 1, 
'');
 
  521 <div style=
"position:absolute; left:5%; height:52%; width:90%;">
 
  523 $action_buttons = array(
 
  525     "function" =>
"reset()",
 
  526     "span" => 
"style='font-size: 150%;'",
 
  528     "class" => 
"poscolorblue" 
  531     "function" => 
"parent.$.colorbox.close();",
 
  532     "span" => 
"id='printtext' style='font-weight: bold; font-size: 18pt;'",
 
  534     "class" => 
"poscolordelete" 
  537 $numpad = $conf->global->TAKEPOS_NUMPAD;
 
  538 if (
isModEnabled(
'stripe') && isset($keyforstripeterminalbank) && !empty($conf->global->STRIPE_CARD_PRESENT)) {
 
  539   print 
'<span id="card-present-alert">';
 
  540   dol_htmloutput_mesg($langs->trans(
'ConnectingToStripeTerminal', 
'Stripe'), 
'', 
'warning', 1);
 
  543 print 
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ? 
'7' : 
'10').
');">'.($numpad == 0 ? 
'7' : 
'10').
'</button>';
 
  544 print 
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ? 
'8' : 
'20').
');">'.($numpad == 0 ? 
'8' : 
'20').
'</button>';
 
  545 print 
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ? 
'9' : 
'50').
');">'.($numpad == 0 ? 
'9' : 
'50').
'</button>';
 
  547 <?php 
if (count($arrayOfValidPaymentModes) > 0) {
 
  548   $paycode = $arrayOfValidPaymentModes[0]->code;
 
  550   if ($paycode == 
'LIQ') {
 
  551     if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
 
  554   } elseif ($paycode == 
'CB') {
 
  555     if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
 
  556       $payIcon = 
'credit-card';
 
  558   } elseif ($paycode == 
'CHQ') {
 
  559     if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
 
  560       $payIcon = 
'money-check';
 
  564   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>'; 
  566   print '<button type="button" class="calcbutton2
">'.$langs->trans("NoPaimementModesDefined
").'</button>'; 
  569 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '4
' : '1
').');
">'.($numpad == 0 ? '4' : '1').'</button>'; 
  570 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '5
' : '2
').');
">'.($numpad == 0 ? '5' : '2').'</button>'; 
  571 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '6
' : '5
').');
">'.($numpad == 0 ? '6' : '5').'</button>'; 
  573 <?php if (count($arrayOfValidPaymentModes) > 1) { 
  574   $paycode = $arrayOfValidPaymentModes[1]->code; 
  576   if ($paycode == 'LIQ') { 
  577     if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) { 
  580   } elseif ($paycode == 'CB') { 
  581     if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) { 
  582       $payIcon = 'credit-card'; 
  584   } elseif ($paycode == 'CHQ') { 
  585     if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) { 
  586       $payIcon = 'money-check'; 
  590   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>'; 
  592   $button = array_pop($action_buttons); 
  593   print '<button type="button" class="calcbutton2
" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>'; 
  596 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '1
' : '0.10
').');
">'.($numpad == 0 ? '1' : '0.10').'</button>'; 
  597 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '2
' : '0.20
').');
">'.($numpad == 0 ? '2' : '0.20').'</button>'; 
  598 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '3
' : '0.50
').');
">'.($numpad == 0 ? '3' : '0.50').'</button>'; 
  600 <?php if (count($arrayOfValidPaymentModes) > 2) { 
  601   $paycode = $arrayOfValidPaymentModes[2]->code; 
  603   if ($paycode == 'LIQ') { 
  604     if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) { 
  607   } elseif ($paycode == 'CB') { 
  608     if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) { 
  609       $payIcon = 'credit-card'; 
  611   } elseif ($paycode == 'CHQ') { 
  612     if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) { 
  613       $payIcon = 'money-check'; 
  617   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>'; 
  619   $button = array_pop($action_buttons); 
  620   print '<button type="button" class="calcbutton2
" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>'; 
  623 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '0
' : '0.01
').');
">'.($numpad == 0 ? '0' : '0.01').'</button>'; 
  624 print '<button type="button" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '\
'000\'' : 
'0.02').
');">'.($numpad == 0 ? 
'000' : 
'0.02').
'</button>';
 
  625 print 
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ? 
'\'.\
'' : 
'0.05').
');">'.($numpad == 0 ? 
'.' : 
'0.05').
'</button>';
 
  628 while ($i < count($arrayOfValidPaymentModes)) {
 
  629   $paycode = $arrayOfValidPaymentModes[$i]->code;
 
  631   if ($paycode == 
'LIQ') {
 
  632     if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
 
  635   } elseif ($paycode == 
'CB') {
 
  636     if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
 
  637       $payIcon = 
'credit-card';
 
  639   } elseif ($paycode == 
'CHQ') {
 
  640     if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
 
  641       $payIcon = 
'money-check';
 
  645   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>'; 
  649 if (isModEnabled('stripe') && isset($keyforstripeterminalbank) && !empty($conf->global->STRIPE_CARD_PRESENT)) { 
  650   $keyforstripeterminalbank = "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL
".$_SESSION["takeposterminal
"]; 
  651   print '<span id="StripeTerminal
"></span>'; 
  652   if (!empty($conf->global->$keyforstripeterminalbank)) { 
  654     $langs->loadLangs(array("errors
", "admin
")); 
  655     //print '<button type="button" class="calcbutton2 disabled
" title="'.$langs->trans("SetupNotComplete").'">TerminalOff</button>'; 
  659 $keyforsumupbank = "CASHDESK_ID_BANKACCOUNT_SUMUP
".$_SESSION["takeposterminal
"]; 
  660 if (getDolGlobalInt('TAKEPOS_ENABLE_SUMUP')) { 
  661   if (!empty($conf->global->$keyforsumupbank)) { 
  662     print '<button type="button" class="calcbutton2
" onclick="ValidateSumup();
">Sumup</button>'; 
  664     $langs->loadLangs(array("errors
", "admin
")); 
  665     print '<button type="button" class="calcbutton2 disabled
" title="'.$langs->trans("SetupNotComplete").'">Sumup</button>'; 
  669 $parameters = array(); 
  670 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $invoice, $action); // Note that $action and $object may have been modified by hook 
  671 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 
  673 $class = ($i == 3) ? "calcbutton3
" : "calcbutton2
"; 
  674 foreach ($action_buttons as $button) { 
  675   $newclass = $class.($button["class"] ? " ".$button["class"] : ""); 
  676   print '<button type="button" class="'.$newclass.'" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>'; 
  679 if ($conf->global->TAKEPOS_DELAYED_PAYMENT) { 
  680   print '<button type="button" class="calcbutton2
" onclick="Validate(\
'delayed\');">'.$langs->trans(
"Reported").
'</button>';
 
  687 $hookmanager->executeHooks(
'completePayment', $parameters, $invoice);
 
  688 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.
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.