From ec0733d2026e52034a648d33fe343ec1cde59454 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Mar 2019 12:40:32 +0100 Subject: [PATCH 01/15] Use color on the amount of the payment page of TakePOS module FIX Use pricejs instead of toFixed to be compatible with all currencies WIP Prepare to be able to enter different payment modes on same invoice --- htdocs/core/js/lib_head.js.php | 19 +++++++ htdocs/takepos/css/pos.css | 10 +++- htdocs/takepos/invoice.php | 51 +++++++++++------- htdocs/takepos/pay.php | 95 ++++++++++++++++++++++++---------- htdocs/takepos/takepos.php | 6 +-- 5 files changed, 131 insertions(+), 50 deletions(-) diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 6a16357f6fa..c81a365bfbc 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1009,6 +1009,25 @@ function getParameterByName(name, valueifnotfound) function dolroundjs(number, decimals) { return +(Math.round(number + "e+" + decimals) + "e-" + decimals); } +/** + * Function similar to PHP price() + * + * @param {number|string} amount The amount to show + * @param {string} mode 'MT' or 'MU' + * @return {string} The amount with digits + */ +function pricejs(amount, mode) { + var main_max_dec_shown = global->MAIN_MAX_DECIMALS_SHOWN); ?>; + var main_rounding_unit = global->MAIN_MAX_DECIMALS_UNIT; ?>; + var main_rounding_tot = global->MAIN_MAX_DECIMALS_TOT; ?>; + + console.log(amount); + + if (mode == 'MU') return amount.toFixed(main_rounding_unit); + if (mode == 'MT') return amount.toFixed(main_rounding_tot); + return 'Bad value for parameter mode'; +} + /** * Function similar to PHP price2num() * diff --git a/htdocs/takepos/css/pos.css b/htdocs/takepos/css/pos.css index 086e4e5fcb0..4b90f712f1d 100644 --- a/htdocs/takepos/css/pos.css +++ b/htdocs/takepos/css/pos.css @@ -103,7 +103,6 @@ div.description{ width:100%; /* styling below */ background-color:black; - font-family: 'tahoma'; color:white; opacity:0.8; /* transparency */ filter:alpha(opacity=80); /* IE transparency */ @@ -209,6 +208,15 @@ div.catwatermark{ padding-left: 5px; } +.colorwhite { + color: white; +} +.colorred { + color: red; +} +.colorgreen { + color: green; +} p.description_content{ padding:10px; margin:0px; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 4d6299b3c0a..a0020ec1f41 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -36,10 +36,11 @@ $id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); $idproduct = GETPOST('idproduct', 'int'); $place = (GETPOSTISSET('place')?GETPOST('place', 'int'):0); // $place is id of POS -$number = GETPOST('number'); -$idline = GETPOST('idline'); +$number = GETPOST('number', 'alpha'); +$idline = GETPOST('idline', 'int'); $desc = GETPOST('desc', 'alpha'); -$pay = GETPOST('pay'); +$pay = GETPOST('pay', 'alpha'); +$amountofpayment = price2num(GETPOST('amount', 'alpha')); $placeid = 0; // $placeid is id of invoice @@ -48,28 +49,29 @@ $ret = $invoice->fetch('', '(PROV-POS-'.$place.')'); if ($ret > 0) $placeid = $invoice->id; $paycode = $pay; -if ($pay == 'cash') $paycode = 'LIQ'; -if ($pay == 'card') $paycode = 'CB'; -if ($pay == 'cheque') $paycode = 'CHQ'; - +if ($pay == 'cash') $paycode = 'LIQ'; // For backward compatibility +if ($pay == 'card') $paycode = 'CB'; // For backward compatibility +if ($pay == 'cheque') $paycode = 'CHQ'; // For backward compatibility + // Retrieve paiementid $sql = "SELECT id FROM ".MAIN_DB_PREFIX."c_paiement"; $sql.= " WHERE entity IN (".getEntity('c_paiement').")"; -$sql.= " AND code = '".$paycode."'"; +$sql.= " AND code = '".$db->escape($paycode)."'"; $resql = $db->query($sql); $codes = $db->fetch_array($resql); $paiementid=$codes[0]; + /* * Actions */ if ($action == 'valid' && $user->rights->facture->creer) { - if ($pay == "cash") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CASH; - elseif ($pay == "card") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CB; - elseif ($pay == "cheque") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; - else + if ($pay == "cash") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CASH; // For backward compatibility + elseif ($pay == "card") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CB; // For backward compatibility + elseif ($pay == "cheque") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; // For backward compatibility + else { $accountname="CASHDESK_ID_BANKACCOUNT_".$pay; $bankaccount=$conf->global->$accountname; @@ -79,22 +81,26 @@ if ($action == 'valid' && $user->rights->facture->creer) $invoice = new Facture($db); $invoice->fetch($placeid); - if (! empty($conf->stock->enabled) and $conf->global->CASHDESK_NO_DECREASE_STOCK!="1") $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE); + if (! empty($conf->stock->enabled) && $conf->global->CASHDESK_NO_DECREASE_STOCK != "1") $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE); else $invoice->validate($user); // Add the payment $payment=new Paiement($db); $payment->datepaye = $now; - $payment->bank_account = $bankaccount; - $payment->amounts[$invoice->id] = $invoice->total_ttc; + $payment->fk_account = $bankaccount; + $payment->amounts[$invoice->id] = $amountofpayment; $payment->paiementid=$paiementid; - $payment->num_paiement=$invoice->ref; + $payment->num_payment=$invoice->ref; $payment->create($user); $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); - $invoice->set_paid($user); + + if ($amountofpayment == $invoice->getRemainToPay()) + { + $invoice->set_paid($user); + } } if (($action=="addline" || $action=="freezone") && $placeid == 0) @@ -388,7 +394,16 @@ if ($invoice->socid != $conf->global->CASHDESK_ID_THIRDPARTY) } if ($action=="valid") { - print '

'.$invoice->ref." ".$langs->trans('BillShortStatusValidated').'

'; + print '

'; + if ($invoice->getRemainToPay() > 0) + { + print $invoice->getNomUrl(1)." ".$langs->trans('Generated'); + } + else + { + print $invoice->getNomUrl(1)." ".$langs->trans('BillShortStatusValidated'); + } + print '

'; if ($conf->global->TAKEPOSCONNECTOR) print '
'; else print '
'; if($conf->global->TAKEPOS_AUTO_PRINT_TICKETS) print ''; diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index a4c7f5680f6..81e2db34f3f 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -41,7 +41,7 @@ $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS-".$place. $resql = $db->query($sql); $row = $db->fetch_array($resql); $placeid=$row[0]; -if (! $placeid) $placeid=0; // Invoice not exist +if (! $placeid) $placeid=0; // Invoice does not exist yet else{ $invoice = new Facture($db); $invoice->fetch($placeid); @@ -51,7 +51,7 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); $langs->loadLangs(array("main", "bills", "cashdesk")); -$sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_paiement"; +$sql = "SELECT code, libelle as label FROM ".MAIN_DB_PREFIX."c_paiement"; $sql.= " WHERE entity IN (".getEntity('c_paiement').")"; $sql.= " AND active = 1"; $sql.= " ORDER BY libelle"; @@ -70,58 +70,97 @@ if ($resql) { } ?> - - - -
+
-
trans('TotalTTC');?>: total_ttc, 1, '', 1, - 1, - 1, $conf->currency) ?>
+
trans('TotalTTC');?>: total_ttc, 1, '', 1, -1, -1) ?>
-
trans("AlreadyPaid"); ?>:
+
trans("AlreadyPaid"); ?>:
-
trans("Change"); ?>:
+
trans("Change"); ?>:
-
+
global->TAKEPOS_NUMPAD; if ($paycode == 'CB') $paycode = 'card'; if ($paycode == 'CHQ') $paycode = 'cheque'; ?> - + @@ -159,7 +198,7 @@ $numpad=$conf->global->TAKEPOS_NUMPAD; if ($paycode == 'CB') $paycode = 'card'; if ($paycode == 'CHQ') $paycode = 'cheque'; ?> - + @@ -174,7 +213,7 @@ $button = array_pop($action_buttons); if ($paycode == 'CB') $paycode = 'card'; if ($paycode == 'CHQ') $paycode = 'cheque'; ?> - + - + global->$accountname) && $conf->global->$accountname > 0) array_push($paiementsModes, $obj); } @@ -484,7 +484,7 @@ $menus[$r++]=array('title'=>$langs->trans("FreeZone"), $menus[$r++]=array('title'=>$langs->trans("Customer"), 'action'=>'Customer();'); $menus[$r++]=array('title'=>$langs->trans("BackOffice"), - 'action'=>'window.open(\''.(DOL_URL_ROOT ? DOL_URL_ROOT : '/').'\', \'_self\');'); + 'action'=>'window.open(\''.(DOL_URL_ROOT ? DOL_URL_ROOT : '/').'\', \'_backoffice\');'); $menus[$r++]=array('title'=>$langs->trans("ValidateBill"), 'action'=>'CloseBill();'); $menus[$r++]=array('title'=>$langs->trans("Logout"), From 11e44114004b38119f57b33b869ec21beb16015d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Mar 2019 15:42:53 +0100 Subject: [PATCH 02/15] TakePOS Can enter payment in several times and with different modes --- htdocs/compta/facture/class/facture.class.php | 9 ++- htdocs/core/js/lib_head.js.php | 2 - htdocs/takepos/invoice.php | 59 +++++++++++---- htdocs/takepos/pay.php | 74 +++++++++++++------ htdocs/takepos/takepos.php | 12 +-- 5 files changed, 108 insertions(+), 48 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 15d985db6bf..2e299740290 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1199,9 +1199,10 @@ class Facture extends CommonInvoice * @param int $notooltip 1=Disable tooltip * @param int $addlinktonotes 1=Add link to notes * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param string $target Target of link ('', '_self', '_blank', '_parent', '_backoffice', ...) * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1, $target = '') { global $langs, $conf, $user, $form; @@ -1254,7 +1255,7 @@ class Facture extends CommonInvoice if ($moretitle) $label.=' - '.$moretitle; } - $linkclose=''; + $linkclose=($target?' target="'.$target.'"':''); if (empty($notooltip) && $user->rights->facture->lire) { if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) @@ -2720,7 +2721,7 @@ class Facture extends CommonInvoice // Check parameters if ($type < 0) return -1; - + if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); $this->error=$langs->trans('ErrorStartDateGreaterEnd'); @@ -2929,7 +2930,7 @@ class Facture extends CommonInvoice return -3; } } - + if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); $this->error=$langs->trans('ErrorStartDateGreaterEnd'); diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index c81a365bfbc..db86d5e8b58 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1021,8 +1021,6 @@ function pricejs(amount, mode) { var main_rounding_unit = global->MAIN_MAX_DECIMALS_UNIT; ?>; var main_rounding_tot = global->MAIN_MAX_DECIMALS_TOT; ?>; - console.log(amount); - if (mode == 'MU') return amount.toFixed(main_rounding_unit); if (mode == 'MT') return amount.toFixed(main_rounding_tot); return 'Bad value for parameter mode'; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index a0020ec1f41..e4dde53e9e7 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -42,11 +42,7 @@ $desc = GETPOST('desc', 'alpha'); $pay = GETPOST('pay', 'alpha'); $amountofpayment = price2num(GETPOST('amount', 'alpha')); -$placeid = 0; // $placeid is id of invoice - -$invoice = new Facture($db); -$ret = $invoice->fetch('', '(PROV-POS-'.$place.')'); -if ($ret > 0) $placeid = $invoice->id; +$invoiceid = GETPOST('invoiceid', 'int'); $paycode = $pay; if ($pay == 'cash') $paycode = 'LIQ'; // For backward compatibility @@ -62,6 +58,21 @@ $codes = $db->fetch_array($resql); $paiementid=$codes[0]; +$invoice = new Facture($db); +if ($invoiceid > 0) +{ + $ret = $invoice->fetch($invoiceid); +} +else +{ + $ret = $invoice->fetch('', '(PROV-POS-'.$place.')'); +} +if ($ret > 0) +{ + $placeid = $invoice->id; +} + + /* * Actions */ @@ -81,8 +92,14 @@ if ($action == 'valid' && $user->rights->facture->creer) $invoice = new Facture($db); $invoice->fetch($placeid); - if (! empty($conf->stock->enabled) && $conf->global->CASHDESK_NO_DECREASE_STOCK != "1") $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE); - else $invoice->validate($user); + if (! empty($conf->stock->enabled) && $conf->global->CASHDESK_NO_DECREASE_STOCK != "1") + { + $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE); + } + else + { + $invoice->validate($user); + } // Add the payment $payment=new Paiement($db); @@ -96,10 +113,9 @@ if ($action == 'valid' && $user->rights->facture->creer) $payment->create($user); $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); - - if ($amountofpayment == $invoice->getRemainToPay()) + if ($invoice->getRemainToPay() == 0) { - $invoice->set_paid($user); + $result = $invoice->set_paid($user); } } @@ -248,6 +264,11 @@ if ($action == "order" and $placeid != 0) { $invoice->fetch($placeid); } + +/* + * View + */ + ?> + use_javascript_ajax)) +{ + print "\n".''."\n"; + print ''."\n"; +} + print '
'; print ''; print ''; @@ -387,8 +390,22 @@ if ($placeid > 0) { if ($line->special_code == "3") { print ' order'; } - print '" id="' . $line->rowid . '">'; - print ''; print ''; diff --git a/htdocs/takepos/js/takepos.js b/htdocs/takepos/js/takepos.js deleted file mode 100644 index 062a3bb4e4a..00000000000 --- a/htdocs/takepos/js/takepos.js +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright (C) 2018 Charles-FR BENKE - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index e02f14d8384..9262e8aff43 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -31,7 +31,7 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $place = GETPOST('place', 'int'); @@ -61,9 +61,8 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); ?> - - + '."\n"; } + print '
'; print '
' . $line->product_label . $line->desc; + print '" id="' . $line->id . '">'; + print ''; + print $line->product_label; + if ($line->product_label && $line->desc) print '
'; + if ($line->product_label != $line->desc) + { + $firstline = dolGetFirstLineOfText($line->desc); + if ($firstline != $line->desc) + { + print $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); + } + else + { + print $line->desc; + } + } if (!empty($line->array_options['options_order_notes'])) echo "
(".$line->array_options['options_order_notes'].")"; print '
' . $line->qty . '
'; print ''; -print ''; +print ''; print ''; print ''; print ''; print "\n"; -if ($placeid > 0) { - foreach($invoice->lines as $line) +if ($placeid > 0) +{ + $tmplines = array_reverse($invoice->lines); + foreach($tmplines as $line) { - print 'special_code == "3") { - print ' order'; + $htmlforlines.= ' order'; } - print '" id="' . $line->id . '">'; - print ''; - print ''; - print ''; - print ''; - print ''; + if (!empty($line->array_options['options_order_notes'])) $htmlforlines.= "
(".$line->array_options['options_order_notes'].")"; + $htmlforlines.= ''; + $htmlforlines.= ''; + $htmlforlines.= ''; + $htmlforlines.= ''; + $htmlforlines.= ''."\n"; + + print $htmlforlines; } } print '
' . $langs->trans('Description') . ''; +print ''; +if ($conf->global->TAKEPOS_BAR_RESTAURANT) +{ + $sql="SELECT floor, label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place); + $resql = $db->query($sql); + $obj = $db->fetch_object($resql); + if ($obj) + { + $label = $obj->label; + $floor = $obj->floor; + } + print $langs->trans('Place')." ".$label." - "; + print $langs->trans('Floor')." ".$floor." - "; +} +print $langs->trans('TotalTTC'); +print ' : '.price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).''; +print '' . $langs->trans('ReductionShort') . '' . $langs->trans('Qty') . '' . $langs->trans('TotalHTShort') . '
'; - print $line->product_label; - if ($line->product_label && $line->desc) print '
'; + $htmlforlines.= '" id="' . $line->id . '">'; + $htmlforlines.= '
'; + $htmlforlines.= $line->product_label; + if ($line->product_label && $line->desc) $htmlforlines.= '
'; if ($line->product_label != $line->desc) { $firstline = dolGetFirstLineOfText($line->desc); if ($firstline != $line->desc) { - print $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); + $htmlforlines.= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); } else { - print $line->desc; + $htmlforlines.= $line->desc; } } - if (!empty($line->array_options['options_order_notes'])) echo "
(".$line->array_options['options_order_notes'].")"; - print '
' . vatrate($line->remise_percent, true) . '' . $line->qty . '' . price($line->total_ttc) . '
' . vatrate($line->remise_percent, true) . '' . $line->qty . '' . price($line->total_ttc) . '
'; -print '

'.$langs->trans('TotalTTC'); - -if ($conf->global->TAKEPOS_BAR_RESTAURANT) print " ".$langs->trans('Place')." ".$place; - -print ': '.price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).' 

'; - if ($invoice->socid != $conf->global->CASHDESK_ID_THIRDPARTY) { $soc = new Societe($db); diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 6dd80bed342..fed57dcf068 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -34,7 +34,9 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -$place = GETPOST('place', 'int'); +$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant +$posnb = (GETPOST('posnb', 'int') > 0 ? GETPOST('posnb', 'int') : 0); // $posnb is id of POS + $invoiceid = GETPOST('invoiceid', 'int'); @@ -51,15 +53,18 @@ else { $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS-".$place.")'"; $resql = $db->query($sql); - $row = $db->fetch_array($resql); - $placeid=$row[0]; - if (! $placeid) + $obj = $db->fetch_object($resql); + if ($obj) { - $placeid=0; // Invoice does not exist yet + $invoiceid = $obj->rowid; + } + if (! $invoiceid) + { + $invoiceid=0; // Invoice does not exist yet } else { - $invoice->fetch($placeid); + $invoice->fetch($invoiceid); } } diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index fb23120623a..7e560a0d40f 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -24,19 +24,27 @@ include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $langs->loadLangs(array("main", "cashdesk")); +$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant +$posnb = (GETPOST('posnb', 'int') > 0 ? GETPOST('posnb', 'int') : 0); // $posnb is id of POS + +$facid=GETPOST('facid', 'int'); + + /* * View */ top_httphead('text/html'); -$facid=GETPOST('facid', 'int'); -$place=GETPOST('place', 'int'); -if ($place>0){ +if ($place > 0) +{ $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS-".$place.")'"; $resql = $db->query($sql); - $row = $db->fetch_array($resql); - $facid=$row[0]; + $obj = $db->fetch_object($resql); + if ($obj) + { + $facid=$obj->rowid; + } } $object=new Facture($db); $object->fetch($facid); diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index fb0b0073510..bb57baaf04d 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -32,8 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$place = GETPOST('place', 'int'); -if ($place=="") $place="0"; +$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant +$posnb = (GETPOST('posnb', 'int') > 0 ? GETPOST('posnb', 'int') : 0); // $posnb is id of POS + $action = GETPOST('action', 'alpha'); $langs->loadLangs(array("bills","orders","commercial","cashdesk","receiptprinter")); @@ -259,7 +260,7 @@ function ClickProduct(position) { if (idproduct=="") return; // Call page invoice.php to generate the section with product lines $("#poslines").load("invoice.php?action=addline&place="+place+"&idproduct="+idproduct, function() { - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); } } From 9105e205ff1e8a23bab342804da417cf87e7077c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Mar 2019 20:20:39 +0100 Subject: [PATCH 13/15] No more need to set scroolTop, lines are sorted with last added first --- htdocs/takepos/customers.php | 2 +- htdocs/takepos/invoice.php | 68 ++++++++++++++++++++---------------- htdocs/takepos/pay.php | 2 +- htdocs/takepos/takepos.php | 18 +++++----- 4 files changed, 49 insertions(+), 41 deletions(-) diff --git a/htdocs/takepos/customers.php b/htdocs/takepos/customers.php index 46e06365a93..05fdf5537c9 100644 --- a/htdocs/takepos/customers.php +++ b/htdocs/takepos/customers.php @@ -61,7 +61,7 @@ if ($action=="change") { ?> diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 4b6aebbe80c..3c39b7e1e4e 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -407,39 +407,47 @@ print "\n"; if ($placeid > 0) { - $tmplines = array_reverse($invoice->lines); - foreach($tmplines as $line) + if (is_array($invoice->lines) && count($invoice->lines)) { - $htmlforlines = ''; - - $htmlforlines.= 'id . '">'; - $htmlforlines.= ''; - $htmlforlines.= $line->product_label; - if ($line->product_label && $line->desc) $htmlforlines.= '
'; - if ($line->product_label != $line->desc) + $tmplines = array_reverse($invoice->lines); + foreach($tmplines as $line) { - $firstline = dolGetFirstLineOfText($line->desc); - if ($firstline != $line->desc) - { - $htmlforlines.= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); - } - else - { - $htmlforlines.= $line->desc; - } - } - if (!empty($line->array_options['options_order_notes'])) $htmlforlines.= "
(".$line->array_options['options_order_notes'].")"; - $htmlforlines.= ''; - $htmlforlines.= '' . vatrate($line->remise_percent, true) . ''; - $htmlforlines.= '' . $line->qty . ''; - $htmlforlines.= '' . price($line->total_ttc) . ''; - $htmlforlines.= ''."\n"; + $htmlforlines = ''; + + $htmlforlines.= 'id . '">'; + $htmlforlines.= ''; + $htmlforlines.= $line->product_label; + if ($line->product_label && $line->desc) $htmlforlines.= '
'; + if ($line->product_label != $line->desc) + { + $firstline = dolGetFirstLineOfText($line->desc); + if ($firstline != $line->desc) + { + $htmlforlines.= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); + } + else + { + $htmlforlines.= $line->desc; + } + } + if (!empty($line->array_options['options_order_notes'])) $htmlforlines.= "
(".$line->array_options['options_order_notes'].")"; + $htmlforlines.= ''; + $htmlforlines.= '' . vatrate($line->remise_percent, true) . ''; + $htmlforlines.= '' . $line->qty . ''; + $htmlforlines.= '' . price($line->total_ttc) . ''; + $htmlforlines.= ''."\n"; + + print $htmlforlines; + } + } + else + { + print ''.$langs->trans("Empty").''; - print $htmlforlines; } } diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index fed57dcf068..3f9641b37d5 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -170,7 +170,7 @@ else print "var received=0;"; } console.log("We click on the payment mode to pay amount = "+amountpayed); parent.$("#poslines").load("invoice.php?place=&action=valid&pay="+payment+"&amount="+amountpayed+"&invoiceid="+invoiceid, function() { - parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight); + //parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight); parent.$.colorbox.close(); }); } diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index bb57baaf04d..9fa2154eaf1 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -66,9 +66,9 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); get_full_arbo('product', 0, (($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0)?$conf->global->TAKEPOS_ROOT_CATEGORY_ID:0)); -//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0; // Search root category to know its level +//$conf->global->TAKEPOS_ROOT_CATEGORY_ID=0; $levelofrootcategory=0; if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) { @@ -267,7 +267,7 @@ function ClickProduct(position) { function deleteline() { $("#poslines").load("invoice.php?action=deleteline&place="+place+"&idline="+selectedline, function() { - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); } @@ -295,13 +295,13 @@ function TakeposOrderNotes() { function Refresh() { $("#poslines").load("invoice.php?place="+place, function() { - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); } function Search() { $("#poslines").load("invoice.php?action=search&place="+place, function() { - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); } @@ -334,7 +334,7 @@ function Edit(number){ if (editaction=='qty' && editnumber!=""){ $("#poslines").load("invoice.php?action=updateqty&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { editnumber=""; - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); $("#qty").html("trans("Qty"); ?>"); }); return; @@ -347,7 +347,7 @@ function Edit(number){ if (editaction=='p' && editnumber!=""){ $("#poslines").load("invoice.php?action=updateprice&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { editnumber=""; - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); $("#price").html("trans("Price"); ?>"); }); return; @@ -360,7 +360,7 @@ function Edit(number){ if (editaction=='r' && editnumber!=""){ $("#poslines").load("invoice.php?action=updatereduction&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { editnumber=""; - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); $("#reduction").html("trans("ReductionShort"); ?>"); }); return; @@ -395,13 +395,13 @@ function Edit(number){ function TakeposPrintingOrder(){ $("#poslines").load("invoice.php?action=order&place="+place, function() { - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); } function TakeposPrintingTemp(){ $("#poslines").load("invoice.php?action=temp&place="+place, function() { - $('#poslines').scrollTop($('#poslines')[0].scrollHeight); + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); } From eb1d57226f45de3f1934845d220880b633cb477d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Mar 2019 20:28:02 +0100 Subject: [PATCH 14/15] Fix status paid after entering a payment --- htdocs/takepos/invoice.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 3c39b7e1e4e..0a748ee32d8 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -116,9 +116,16 @@ if ($action == 'valid' && $user->rights->facture->creer) $payment->create($user); $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); - if ($invoice->getRemainToPay() == 0) + $remaintopay = $invoice->getRemainToPay(); + if ($remaintopay == 0) { + dol_syslog("Invoice is paid, so we set it to pay"); $result = $invoice->set_paid($user); + if ($result > 0) $invoice->paye = 1; + } + else + { + dol_syslog("Invoice is not paid, remain to pay = ".$remaintopay); } } From c6543614850007b0c6590df3c312afbb4b112f10 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Mar 2019 20:46:07 +0100 Subject: [PATCH 15/15] Show link to invoice at the TOP --- htdocs/takepos/invoice.php | 44 ++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 0a748ee32d8..ed3f133b2d4 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -274,6 +274,28 @@ if ($action == "order" and $placeid != 0) { $invoice->fetch($placeid); } +$sectionwithinvoicelink=''; +if ($action=="valid") +{ + $sectionwithinvoicelink.=''."\n"; + $sectionwithinvoicelink.=''; + $sectionwithinvoicelink.=''; + $sectionwithinvoicelink.=$invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - "; + if ($invoice->getRemainToPay() > 0) + { + $sectionwithinvoicelink.=$langs->trans('Generated'); + } + else + { + if ($invoice->paye) $sectionwithinvoicelink.=$langs->trans("Payed"); + else $sectionwithinvoicelink.=$langs->trans('BillShortStatusValidated'); + } + $sectionwithinvoicelink.=''; + if ($conf->global->TAKEPOSCONNECTOR) $sectionwithinvoicelink.=' '; + else $sectionwithinvoicelink.=' '; + if ($conf->global->TAKEPOS_AUTO_PRINT_TICKETS) $sectionwithinvoicelink.=''; +} + /* * View @@ -406,6 +428,7 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) } print $langs->trans('TotalTTC'); print ' : '.price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).''; +print '
'.$sectionwithinvoicelink; print ''; print '' . $langs->trans('ReductionShort') . ''; print '' . $langs->trans('Qty') . ''; @@ -470,27 +493,6 @@ if ($invoice->socid != $conf->global->CASHDESK_ID_THIRDPARTY) print '

'; } -if ($action=="valid") -{ - print ''."\n"; - print ''; - print '

'; - print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - "; - if ($invoice->getRemainToPay() > 0) - { - print $langs->trans('Generated'); - } - else - { - if ($invoice->paye) print $langs->trans("Payed"); - else print $langs->trans('BillShortStatusValidated'); - } - print '

'; - if ($conf->global->TAKEPOSCONNECTOR) print '
'; - else print '
'; - if ($conf->global->TAKEPOS_AUTO_PRINT_TICKETS) print ''; -} - if ($action == "search") { print '