28 if (!defined(
'NOCSRFCHECK')) define(
'NOCSRFCHECK',
'1');
29 if (!defined(
'NOTOKENRENEWAL')) define(
'NOTOKENRENEWAL',
'1');
30 if (!defined(
'NOREQUIREMENU')) define(
'NOREQUIREMENU',
'1');
31 if (!defined(
'NOREQUIREHTML')) define(
'NOREQUIREHTML',
'1');
32 if (!defined(
'NOREQUIREAJAX')) define(
'NOREQUIREAJAX',
'1');
34 require
'../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
37 $langs->loadLangs(array(
"main",
"bills",
"cashdesk",
"banks"));
39 $place = (
GETPOST(
'place',
'aZ09') ?
GETPOST(
'place',
'aZ09') :
'0');
41 $invoiceid =
GETPOST(
'invoiceid',
'int');
43 if (empty($user->rights->takepos->run)) {
55 $invoice->fetch($invoiceid);
57 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture where ref='(PROV-POS".$_SESSION[
"takeposterminal"].
"-".$place.
")'";
59 $obj = $db->fetch_object(
$resql);
62 $invoiceid = $obj->rowid;
68 $invoice->fetch($invoiceid);
72 $arrayofcss = array(
'/takepos/css/pos.css.php');
80 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
83 $arrayOfValidPaymentModes = array();
84 $arrayOfValidBankAccount = array();
86 $sql =
"SELECT code, libelle as label FROM ".MAIN_DB_PREFIX.
"c_paiement";
87 $sql .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
88 $sql .=
" AND active = 1";
89 $sql .=
" ORDER BY libelle";
93 while ($obj = $db->fetch_object(
$resql)) {
94 $paycode = $obj->code;
95 if ($paycode ==
'LIQ') $paycode =
'CASH';
96 if ($paycode ==
'CB') $paycode =
'CB';
97 if ($paycode ==
'CHQ') $paycode =
'CHEQUE';
99 $accountname =
"CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION[
"takeposterminal"];
100 if (!empty($conf->global->$accountname) && $conf->global->$accountname > 0) {
101 $arrayOfValidBankAccount[$conf->global->$accountname] = $conf->global->$accountname;
102 $arrayOfValidPaymentModes[] = $obj;
107 <link rel=
"stylesheet" href=
"css/pos.css.php">
109 if ($conf->global->TAKEPOS_COLOR_THEME == 1)
print '<link rel="stylesheet" href="css/colorful.css">';
117 if ($invoice->id > 0)
119 $remaintopay = $invoice->getRemainToPay();
121 $alreadypayed = (is_object($invoice) ? ($invoice->total_ttc - $remaintopay) : 0);
123 if ($conf->global->TAKEPOS_NUMPAD == 0)
print "var received='';";
124 else print "var received=0;";
127 var alreadypayed = <?php echo $alreadypayed ?>;
129 function addreceived(
price)
132 if (empty($conf->global->TAKEPOS_NUMPAD))
print 'received+=String(price);'.
"\n";
133 else print 'received+=parseFloat(price);'.
"\n";
135 $(
'.change1').html(
pricejs(parseFloat(received),
'MT'));
136 $(
'.change1').val(parseFloat(received));
137 alreadypaydplusreceived=
price2numjs(alreadypayed + parseFloat(received));
140 if (alreadypaydplusreceived > <?php echo $invoice->total_ttc; ?>)
142 var change=parseFloat(alreadypayed + parseFloat(received) - <?php echo $invoice->total_ttc; ?>);
143 $(
'.change2').html(
pricejs(change,
'MT'));
144 $(
'.change2').val(change);
145 $(
'.change1').removeClass(
'colorred');
146 $(
'.change1').addClass(
'colorgreen');
147 $(
'.change2').removeClass(
'colorwhite');
148 $(
'.change2').addClass(
'colorred');
152 $(
'.change2').html(
pricejs(0,
'MT'));
153 $(
'.change2').val(0);
154 if (alreadypaydplusreceived == <?php echo $invoice->total_ttc; ?>)
156 $(
'.change1').removeClass(
'colorred');
157 $(
'.change1').addClass(
'colorgreen');
158 $(
'.change2').removeClass(
'colorred');
159 $(
'.change2').addClass(
'colorwhite');
163 $(
'.change1').removeClass(
'colorgreen');
164 $(
'.change1').addClass(
'colorred');
165 $(
'.change2').removeClass(
'colorred');
166 $(
'.change2').addClass(
'colorwhite');
174 $(
'.change1').html(
pricejs(received,
'MT'));
176 $(
'.change2').html(
pricejs(received,
'MT'));
178 $(
'.change1').removeClass(
'colorgreen');
179 $(
'.change1').addClass(
'colorred');
180 $(
'.change2').removeClass(
'colorred');
181 $(
'.change2').addClass(
'colorwhite');
184 function Validate(payment)
186 var invoiceid = <?php echo ($invoiceid > 0 ? $invoiceid : 0); ?>;
187 var accountid = $(
"#selectaccountid").val();
188 var amountpayed = $(
"#change1").val();
189 var excess = $(
"#change2").val();
190 if (amountpayed > <?php echo $invoice->total_ttc; ?>) {
191 amountpayed = <?php echo $invoice->total_ttc; ?>;
193 console.log(
"We click on the payment mode to pay amount = "+amountpayed);
194 parent.$(
"#poslines").load(
"invoice.php?place=<?php echo $place; ?>&action=valid&pay="+payment+
"&amount="+amountpayed+
"&excess="+excess+
"&invoiceid="+invoiceid+
"&accountid="+accountid,
function() {
195 if (amountpayed > <?php echo $remaintopay; ?> || amountpayed == <?php echo $remaintopay; ?> || amountpayed==0 ) {
196 console.log(
"Close popup");
197 parent.$.colorbox.close();
200 console.log(
"Amount is not comple, so we do NOT close popup and reload it.");
206 function ValidateSumup() {
207 console.log(
"Launch ValidateSumup");
208 <?php $_SESSION[
'SMP_CURRENT_PAYMENT'] =
"NEW" ?>
209 var invoiceid = <?php echo($invoiceid > 0 ? $invoiceid : 0); ?>;
210 var amountpayed = $(
"#change1").val();
211 if (amountpayed > <?php echo $invoice->total_ttc; ?>) {
212 amountpayed = <?php echo $invoice->total_ttc; ?>;
216 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');
218 var loop = window.setInterval(
function () {
219 $.ajax(
'<?php echo DOL_URL_ROOT ?>/takepos/smpcb.php?status').done(
function (data) {
221 if (data ===
"SUCCESS") {
222 parent.$(
"#poslines").load(
"invoice.php?place=<?php echo $place; ?>&action=valid&pay=CB&amount=" + amountpayed +
"&invoiceid=" + invoiceid,
function () {
224 parent.$.colorbox.close();
228 }
else if (data ===
"FAILED") {
229 parent.$.colorbox.close();
237 <div style=
"position:relative; padding-top: 20px; left:5%; height:150px; width:90%;">
239 <div
class=
"paymentbordline paymentbordlinetotal">
240 <center><span
class=
"takepospay"><font color=
"white"><?php echo $langs->trans(
'TotalTTC'); ?>: </font><span
id=
"totaldisplay" class=
"colorwhite"><?php echo
price($invoice->total_ttc, 1,
'', 1, -1, -1, $invoice->multicurrency_code); ?></span></span></center>
242 <?php
if ($remaintopay != $invoice->total_ttc) { ?>
243 <div
class=
"paymentbordline paymentbordlineremain">
244 <center><span
class=
"takepospay"><font color=
"white"><?php echo $langs->trans(
'RemainToPay'); ?>: </font><span
id=
"remaintopaydisplay" class=
"colorwhite"><?php echo
price($remaintopay, 1,
'', 1, -1, -1, $invoice->multicurrency_code); ?></span></span></center>
247 <div
class=
"paymentbordline paymentbordlinereceived">
248 <center><span
class=
"takepospay"><font color=
"white"><?php echo $langs->trans(
"Received"); ?>: </font><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></center>
250 <div
class=
"paymentbordline paymentbordlinechange">
251 <center><span
class=
"takepospay"><font color=
"white"><?php echo $langs->trans(
"Change"); ?>: </font><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></center>
254 if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) {
255 print '<div class="paymentbordline paddingtop paddingbottom">
258 $form =
new Form($db);
259 print '<span class="takepospay"><font color="white">'.$langs->trans(
"BankAccount").
': </font></span>';
260 $form->select_comptes(0,
'accountid', 0, $filter, 1,
'');
270 <div style=
"position:absolute; left:5%; height:52%; width:90%;">
272 $action_buttons = array(
274 "function" =>
"reset()",
275 "span" =>
"style='font-size: 150%;'",
277 "class" =>
"poscolorblue"
280 "function" =>
"parent.$.colorbox.close();",
281 "span" =>
"id='printtext' style='font-weight: bold; font-size: 18pt;'",
283 "class" =>
"poscolordelete"
286 $numpad = $conf->global->TAKEPOS_NUMPAD;
288 print '<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'7' :
'10').
');">'.($numpad == 0 ?
'7' :
'10').
'</button>';
289 print '<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'8' :
'20').
');">'.($numpad == 0 ?
'8' :
'20').
'</button>';
290 print '<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'9' :
'50').
');">'.($numpad == 0 ?
'9' :
'50').
'</button>';
292 <?php
if (count($arrayOfValidPaymentModes) > 0) {
293 $paycode = $arrayOfValidPaymentModes[0]->code;
295 if ($paycode ==
'LIQ') {
297 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon =
'coins';
298 } elseif ($paycode ==
'CB') {
300 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon =
'credit-card';
301 } elseif ($paycode ==
'CHQ') {
303 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon =
'money-check';
306 print '<button type="button" class="calcbutton2" onclick="Validate(\''.$langs->trans($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>';
308 print '<button type="button
" class="calcbutton2
">'.$langs->trans("NoPaimementModesDefined
").'</button>';
311 print '<button type="button
" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '4
' : '1
').');
">'.($numpad == 0 ? '4' : '1').'</button>';
312 print '<button type="button
" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '5
' : '2
').');
">'.($numpad == 0 ? '5' : '2').'</button>';
313 print '<button type="button
" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '6
' : '5
').');
">'.($numpad == 0 ? '6' : '5').'</button>';
315 <?php if (count($arrayOfValidPaymentModes) > 1) {
316 $paycode = $arrayOfValidPaymentModes[1]->code;
318 if ($paycode == 'LIQ') {
320 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'coins';
321 } elseif ($paycode == 'CB') {
323 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'credit-card';
324 } elseif ($paycode == 'CHQ') {
326 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'money-check';
329 print '<button type="button
" class="calcbutton2
" onclick="Validate(\
''.$langs->trans($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>';
331 $button = array_pop($action_buttons);
332 print '<button type="button
" class="calcbutton2
" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
335 print '<button type="button
" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '1
' : '0.10
').');
">'.($numpad == 0 ? '1' : '0.10').'</button>';
336 print '<button type="button
" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '2
' : '0.20
').');
">'.($numpad == 0 ? '2' : '0.20').'</button>';
337 print '<button type="button
" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '3
' : '0.50
').');
">'.($numpad == 0 ? '3' : '0.50').'</button>';
339 <?php if (count($arrayOfValidPaymentModes) > 2) {
340 $paycode = $arrayOfValidPaymentModes[2]->code;
342 if ($paycode == 'LIQ') {
344 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'coins';
345 } elseif ($paycode == 'CB') {
347 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'credit-card';
348 } elseif ($paycode == 'CHQ') {
350 if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'money-check';
353 print '<button type="button
" class="calcbutton2
" onclick="Validate(\
''.$langs->trans($paycode).
'\');
">'.(!empty($payIcon) ? '<span class="fa fa-2x fa-
'.$payIcon.' iconwithlabel
"></span>'.(!empty($conf->global->TAKEPOS_NUMPAD_FORCE_PAYMENT_ICONS_LABELS) ? '<br> '. $langs->trans("PaymentTypeShort
".$arrayOfValidPaymentModes[2]->code) : '') : $langs->trans("PaymentTypeShort
".$arrayOfValidPaymentModes[2]->code)).'</button>';
355 $button = array_pop($action_buttons);
356 print '<button type="button
" class="calcbutton2
" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
359 print '<button type="button
" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '0
' : '0.01
').');
">'.($numpad == 0 ? '0' : '0.01').'</button>';
360 print '<button type="button
" class="calcbutton
" onclick="addreceived(
'.($numpad == 0 ? '\
'000\'' :
'0.02').
');">'.($numpad == 0 ?
'000' :
'0.02').
'</button>';
361 print '<button type="button" class="calcbutton" onclick="addreceived('.($numpad == 0 ?
'\'.\
'' :
'0.05').
');">'.($numpad == 0 ?
'.' :
'0.05').
'</button>';
364 while ($i < count($arrayOfValidPaymentModes)) {
365 print '<button type="button" class="calcbutton2" onclick="Validate(\''.$langs->trans($arrayOfValidPaymentModes[$i]->
code).
'\');
">'.$langs->trans("PaymentTypeShort
".$arrayOfValidPaymentModes[$i]->code).'</button>';
369 $keyforsumupbank = "CASHDESK_ID_BANKACCOUNT_SUMUP
".$_SESSION["takeposterminal
"];
370 if ($conf->global->TAKEPOS_ENABLE_SUMUP) {
371 if (!empty($conf->global->$keyforsumupbank)) {
372 print '<button type="button
" class="calcbutton2
" onclick="ValidateSumup();
">Sumup</button>';
374 $langs->loadLangs(array("errors
", "admin
"));
375 print '<button type="button
" class="calcbutton2 disabled
" title="'.$langs->trans("SetupNotComplete").'">Sumup</button>';
379 $class = ($i == 3) ? "calcbutton3
" : "calcbutton2
";
380 foreach ($action_buttons as $button) {
381 $newclass = $class.($button["class"] ? " ".$button["class"] : "");
382 print '<button type="button
" class="'.$newclass.'" onclick="'.$button["function"].'"><span '.$button["span
"].'>'.$button["text
"].'</span></button>';
385 if ($conf->global->TAKEPOS_DELAYED_PAYMENT) {
386 print '<button type="button
" class="calcbutton2
" onclick="Validate(\
'delayed\');">'.$langs->trans(
"Reported").
'</button>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
pricejs(amount, mode)
Function similar to PHP price()
if(!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'] country if(!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'] typent code
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
top_htmlhead($head, $title= '', $disablejs=0, $disablehead=0, $arrayofjs= '', $arrayofcss= '', $disablejmobile=0, $disablenofollow=0)
Ouput html header of a page.
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...
price2numjs(amount)
Function similar to PHP price2num()
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Class to manage invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type