28 if (!defined(
'NOCSRFCHECK')) {
29 define(
'NOCSRFCHECK',
'1');
31 if (!defined(
'NOTOKENRENEWAL')) {
32 define(
'NOTOKENRENEWAL',
'1');
34 if (!defined(
'NOREQUIREMENU')) {
35 define(
'NOREQUIREMENU',
'1');
37 if (!defined(
'NOREQUIREHTML')) {
38 define(
'NOREQUIREHTML',
'1');
41 require
'../main.inc.php';
42 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
44 $langs->loadLangs(array(
"main",
"bills",
"cashdesk",
"banks"));
46 $place = (
GETPOST(
'place',
'aZ09') ?
GETPOST(
'place',
'aZ09') :
'0');
48 $invoiceid =
GETPOST(
'invoiceid',
'int');
50 if (empty($user->rights->takepos->run)) {
61 $invoice->fetch($invoiceid);
63 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture where ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
65 $obj = $db->fetch_object(
$resql);
67 $invoiceid = $obj->rowid;
72 $invoice->fetch($invoiceid);
76 $arrayofcss = array(
'/takepos/css/pos.css.php');
84 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
87 $arrayOfValidPaymentModes = array();
88 $arrayOfValidBankAccount = array();
90 $sql =
"SELECT code, libelle as label FROM ".MAIN_DB_PREFIX.
"c_paiement";
91 $sql .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
92 $sql .=
" AND active = 1";
93 $sql .=
" ORDER BY libelle";
97 while ($obj = $db->fetch_object(
$resql)) {
98 $paycode = $obj->code;
99 if ($paycode ==
'LIQ') {
102 if ($paycode ==
'CB') {
105 if ($paycode ==
'CHQ') {
109 $accountname =
"CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION[
"takeposterminal"];
110 if (!empty($conf->global->$accountname) && $conf->global->$accountname > 0) {
111 $arrayOfValidBankAccount[$conf->global->$accountname] = $conf->global->$accountname;
112 $arrayOfValidPaymentModes[] = $obj;
115 if ($paycode ==
'CASH' || $paycode ==
'CB') $arrayOfValidPaymentModes[] = $obj;
120 <link rel=
"stylesheet" href=
"css/pos.css.php">
122 if ($conf->global->TAKEPOS_COLOR_THEME == 1) {
123 print
'<link rel="stylesheet" href="css/colorful.css">';
132 if ($invoice->id > 0) {
133 $remaintopay = $invoice->getRemainToPay();
135 $alreadypayed = (is_object($invoice) ? ($invoice->total_ttc - $remaintopay) : 0);
137 if ($conf->global->TAKEPOS_NUMPAD == 0) {
138 print
"var received='';";
140 print
"var received=0;";
144 var alreadypayed = <?php echo $alreadypayed ?>;
146 function addreceived(
price)
149 if (empty($conf->global->TAKEPOS_NUMPAD)) {
150 print
'received+=String(price);'.
"\n";
152 print
'received+=parseFloat(price);'.
"\n";
155 $(
'.change1').html(
pricejs(parseFloat(received),
'MT'));
156 $(
'.change1').val(parseFloat(received));
157 alreadypaydplusreceived=
price2numjs(alreadypayed + parseFloat(received));
160 if (alreadypaydplusreceived > <?php echo $invoice->total_ttc; ?>)
162 var change=parseFloat(alreadypayed + parseFloat(received) - <?php echo $invoice->total_ttc; ?>);
163 $(
'.change2').html(
pricejs(change,
'MT'));
164 $(
'.change2').val(change);
165 $(
'.change1').removeClass(
'colorred');
166 $(
'.change1').addClass(
'colorgreen');
167 $(
'.change2').removeClass(
'colorwhite');
168 $(
'.change2').addClass(
'colorred');
172 $(
'.change2').html(
pricejs(0,
'MT'));
173 $(
'.change2').val(0);
174 if (alreadypaydplusreceived == <?php echo $invoice->total_ttc; ?>)
176 $(
'.change1').removeClass(
'colorred');
177 $(
'.change1').addClass(
'colorgreen');
178 $(
'.change2').removeClass(
'colorred');
179 $(
'.change2').addClass(
'colorwhite');
183 $(
'.change1').removeClass(
'colorgreen');
184 $(
'.change1').addClass(
'colorred');
185 $(
'.change2').removeClass(
'colorred');
186 $(
'.change2').addClass(
'colorwhite');
194 $(
'.change1').html(
pricejs(received,
'MT'));
196 $(
'.change2').html(
pricejs(received,
'MT'));
198 $(
'.change1').removeClass(
'colorgreen');
199 $(
'.change1').addClass(
'colorred');
200 $(
'.change2').removeClass(
'colorred');
201 $(
'.change2').addClass(
'colorwhite');
206 var invoiceid = <?php echo ($invoiceid > 0 ? $invoiceid : 0); ?>;
207 var accountid = $(
"#selectaccountid").val();
208 var amountpayed = $(
"#change1").val();
209 var excess = $(
"#change2").val();
210 if (amountpayed > <?php echo $invoice->total_ttc; ?>) {
211 amountpayed = <?php echo $invoice->total_ttc; ?>;
213 console.log(
"We click on the payment mode to pay amount = "+amountpayed);
214 parent.$(
"#poslines").load(
"invoice.php?place=<?php echo $place; ?>&action=valid&pay="+payment+
"&amount="+amountpayed+
"&excess="+excess+
"&invoiceid="+invoiceid+
"&accountid="+accountid,
function() {
215 if (amountpayed > <?php echo $remaintopay; ?> || amountpayed == <?php echo $remaintopay; ?> || amountpayed==0 ) {
216 console.log(
"Close popup");
217 parent.$.colorbox.close();
220 console.log(
"Amount is not comple, so we do NOT close popup and reload it.");
226 function ValidateSumup() {
227 console.log(
"Launch ValidateSumup");
228 <?php $_SESSION[
'SMP_CURRENT_PAYMENT'] =
"NEW" ?>
229 var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
230 var amountpayed = $(
"#change1").val();
231 if (amountpayed > <?php echo $invoice->total_ttc; ?>) {
232 amountpayed = <?php echo $invoice->total_ttc; ?>;
236 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');
238 var loop = window.setInterval(
function () {
241 data: { token:
'<?php echo currentToken(); ?>' },
242 url:
'<?php echo DOL_URL_ROOT ?>/takepos/smpcb.php?status' }).done(
function (data) {
244 if (data ===
"SUCCESS") {
245 parent.$(
"#poslines").load(
"invoice.php?place=<?php echo $place; ?>&action=valid&pay=CB&amount=" + amountpayed +
"&invoiceid=" + invoiceid,
function () {
247 parent.$.colorbox.close();
251 }
else if (data ===
"FAILED") {
252 parent.$.colorbox.close();
260 if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
261 echo
"var line1='".$langs->trans(
'TotalTTC').
"'.substring(0,20);";
262 echo
"line1=line1.padEnd(20);";
263 echo
"var line2='".price($invoice->total_ttc, 1,
'', 1, -1, -1).
"'.substring(0,20);";
264 echo
"line2=line2.padEnd(20);";
267 data: { text: line1+line2 },
268 url: '".getDolGlobalString(
'TAKEPOS_PRINT_SERVER').
"/display/index.php',
274 <div style=
"position:relative; padding-top: 20px; left:5%; height:150px; width:90%;">
275 <div
class=
"paymentbordline paymentbordlinetotal center">
276 <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>
278 <?php
if ($remaintopay != $invoice->total_ttc) { ?>
279 <div
class=
"paymentbordline paymentbordlineremain center">
280 <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>
283 <div
class=
"paymentbordline paymentbordlinereceived center">
284 <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>
286 <div
class=
"paymentbordline paymentbordlinechange center">
287 <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>
290 if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) {
291 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
292 print
'<div class="paymentbordline paddingtop paddingbottom center">';
295 print
'<span class="takepospay colorwhite">'.$langs->trans(
"BankAccount").
': </span>';
296 $form->select_comptes(0,
'accountid', 0, $filter, 1,
'');
303 <div style=
"position:absolute; left:5%; height:52%; width:90%;">
305 $action_buttons = array(
307 "function" =>
"reset()",
308 "span" =>
"style='font-size: 150%;'",
310 "class" =>
"poscolorblue"
313 "function" =>
"parent.$.colorbox.close();",
314 "span" =>
"id='printtext' style='font-weight: bold; font-size: 18pt;'",
316 "class" =>
"poscolordelete"
319 $numpad = $conf->global->TAKEPOS_NUMPAD;
321 print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'7' :
'10').
');">'.($numpad == 0 ?
'7' :
'10').
'</button>';
322 print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'8' :
'20').
');">'.($numpad == 0 ?
'8' :
'20').
'</button>';
323 print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'9' :
'50').
');">'.($numpad == 0 ?
'9' :
'50').
'</button>';
325 <?php
if (count($arrayOfValidPaymentModes) > 0) {
326 $paycode = $arrayOfValidPaymentModes[0]->code;
328 if ($paycode ==
'LIQ') {
329 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
332 } elseif ($paycode ==
'CB') {
333 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
334 $payIcon =
'credit-card';
336 } elseif ($paycode ==
'CHQ') {
337 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
338 $payIcon =
'money-check';
342 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>';
344 print '<button type="button
" class="calcbutton2
">'.$langs->trans("NoPaimementModesDefined
").'</button>';
347 print '<button type="button
" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '4
' : '1
').');
">'.($numpad == 0 ? '4' : '1').'</button>';
348 print '<button type="button
" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '5
' : '2
').');
">'.($numpad == 0 ? '5' : '2').'</button>';
349 print '<button type="button
" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '6
' : '5
').');
">'.($numpad == 0 ? '6' : '5').'</button>';
351 <?php if (count($arrayOfValidPaymentModes) > 1) {
352 $paycode = $arrayOfValidPaymentModes[1]->code;
354 if ($paycode == 'LIQ') {
355 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
358 } elseif ($paycode == 'CB') {
359 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
360 $payIcon = 'credit-card';
362 } elseif ($paycode == 'CHQ') {
363 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
364 $payIcon = 'money-check';
368 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>';
370 $button = array_pop($action_buttons);
371 print '<button type="button
" class="calcbutton2
" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
374 print '<button type="button
" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '1
' : '0.10
').');
">'.($numpad == 0 ? '1' : '0.10').'</button>';
375 print '<button type="button
" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '2
' : '0.20
').');
">'.($numpad == 0 ? '2' : '0.20').'</button>';
376 print '<button type="button
" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '3
' : '0.50
').');
">'.($numpad == 0 ? '3' : '0.50').'</button>';
378 <?php if (count($arrayOfValidPaymentModes) > 2) {
379 $paycode = $arrayOfValidPaymentModes[2]->code;
381 if ($paycode == 'LIQ') {
382 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
385 } elseif ($paycode == 'CB') {
386 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
387 $payIcon = 'credit-card';
389 } elseif ($paycode == 'CHQ') {
390 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
391 $payIcon = 'money-check';
395 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>';
397 $button = array_pop($action_buttons);
398 print '<button type="button
" class="calcbutton2
" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
401 print '<button type="button
" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '0
' : '0.01
').');
">'.($numpad == 0 ? '0' : '0.01').'</button>';
402 print '<button type="button
" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '\
'000\'' :
'0.02').
');">'.($numpad == 0 ?
'000' :
'0.02').
'</button>';
403 print
'<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'\'.\
'' :
'0.05').
');">'.($numpad == 0 ?
'.' :
'0.05').
'</button>';
406 while ($i < count($arrayOfValidPaymentModes)) {
407 $paycode = $arrayOfValidPaymentModes[$i]->code;
409 if ($paycode ==
'LIQ') {
410 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
413 } elseif ($paycode ==
'CB') {
414 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
415 $payIcon =
'credit-card';
417 } elseif ($paycode ==
'CHQ') {
418 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) {
419 $payIcon =
'money-check';
423 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>';
427 $keyforsumupbank = "CASHDESK_ID_BANKACCOUNT_SUMUP
".$_SESSION["takeposterminal
"];
428 if (getDolGlobalInt('TAKEPOS_ENABLE_SUMUP')) {
429 if (!empty($conf->global->$keyforsumupbank)) {
430 print '<button type="button
" class="calcbutton2
" onclick="ValidateSumup();
">Sumup</button>';
432 $langs->loadLangs(array("errors
", "admin
"));
433 print '<button type="button
" class="calcbutton2 disabled
" title="'.$langs->trans("SetupNotComplete").'">Sumup</button>';
437 $class = ($i == 3) ? "calcbutton3
" : "calcbutton2
";
438 foreach ($action_buttons as $button) {
439 $newclass = $class.($button["class"] ? " ".$button["class"] : "");
440 print '<button type="button
" class="'.$newclass.'" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
443 if ($conf->global->TAKEPOS_DELAYED_PAYMENT) {
444 print '<button type="button
" class="calcbutton2
" onclick="Validate(\
'delayed\');">'.$langs->trans(
"Reported").
'</button>';