From 898007f0b454760a52e312cd1ba95c0f548a235b Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 11 Mar 2020 12:30:07 +0100 Subject: [PATCH] NEW add global reduction in cash desk --- htdocs/takepos/invoice.php | 6 + htdocs/takepos/reduction.php | 219 +++++++++++++++++++++++++++++++++++ htdocs/takepos/takepos.php | 7 ++ 3 files changed, 232 insertions(+) create mode 100644 htdocs/takepos/reduction.php diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 4660032cc15..e6811319199 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -453,6 +453,12 @@ if ($action == "updatereduction") else $result = $invoice->updateline($line->id, $line->desc, $line->multicurrency_subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } } + $invoice->fetch($placeid); +} elseif ($action == 'update_reduction_global') { + foreach ($invoice->lines as $line) { + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + } + $invoice->fetch($placeid); } diff --git a/htdocs/takepos/reduction.php b/htdocs/takepos/reduction.php new file mode 100644 index 00000000000..a8f77f1ffd7 --- /dev/null +++ b/htdocs/takepos/reduction.php @@ -0,0 +1,219 @@ + + * + * 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 . + */ + +/** + * \file htdocs/takepos/reduction.php + * \ingroup takepos + * \brief Page with the content of the popup to enter reductions + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +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') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant + +$invoiceid = GETPOST('invoiceid', 'int'); + + +/* + * View + */ + +$invoice = new Facture($db); +if ($invoiceid > 0) +{ + $invoice->fetch($invoiceid); +} +else +{ + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $resql = $db->query($sql); + $obj = $db->fetch_object($resql); + if ($obj) + { + $invoiceid = $obj->rowid; + } + if (!$invoiceid) + { + $invoiceid = 0; // Invoice does not exist yet + } + else + { + $invoice->fetch($invoiceid); + } +} + +$arrayofcss = array('/takepos/css/pos.css.php'); +$arrayofjs = array(); + +top_htmlhead($head, '', 0, 0, $arrayofjs, $arrayofcss); + +$langs->loadLangs(array('main', 'bills', 'cashdesk')); +?> + + + + + + +
+
+trans('Reduction') . '">'; +?> +
+
+ +
+7'; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +?> +
+ + + diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 8d4f8f929c8..da1a7f1cd1f 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -398,6 +398,12 @@ function History() $.colorbox({href:"../compta/facture/list.php?contextpage=poslist", width:"90%", height:"80%", transition:"none", iframe:"true", title:"trans("History"); ?>"}); } +function Reduction() { + invoiceid = $("#invoiceid").val(); + console.log("Open popup to enter reduction on invoiceid="+invoiceid); + $.colorbox({href:"reduction.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""}); +} + function CloseBill() { invoiceid = $("#invoiceid").val(); console.log("Open popup to enter payment on invoiceid="+invoiceid); @@ -766,6 +772,7 @@ if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { } $menus[$r++] = array('title'=>'
'.$langs->trans("History").'
', 'action'=>'History();'); $menus[$r++] = array('title'=>'
'.$langs->trans("FreeZone").'
', 'action'=>'FreeZone();'); +$menus[$r++] = array('title'=>'
'.$langs->trans("Reduction").'
', 'action'=>'Reduction();'); $menus[$r++] = array('title'=>'
'.$langs->trans("Payment").'
', 'action'=>'CloseBill();'); if ($conf->global->TAKEPOS_DIRECT_PAYMENT) {