From cc21257e3ef5f52f31a448e1b3ddd65117da7686 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Thu, 7 Oct 2021 09:51:55 +0200 Subject: [PATCH 1/2] NEW print without details --- htdocs/langs/en_US/cashdesk.lang | 3 + htdocs/langs/fr_FR/cashdesk.lang | 3 + htdocs/takepos/admin/receipt.php | 15 +++++ htdocs/takepos/invoice.php | 10 ++- htdocs/takepos/printbox.php | 102 +++++++++++++++++++++++++++++++ htdocs/takepos/receipt.php | 64 +++++++++++-------- 6 files changed, 171 insertions(+), 26 deletions(-) create mode 100644 htdocs/takepos/printbox.php diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 52dc71d140c..22d5afed2fc 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -130,3 +130,6 @@ ShowPriceHT = Display the column with the price excluding tax (on screen) ShowPriceHTOnReceipt = Display the column with the price excluding tax (on the receipt) CustomerDisplay=Customer display SplitSale=Split sale +PrintWithoutDetailsButton=Add "Print without details" button +PrintWithoutDetailsLabelDefault=Line label by default on printing without details +PrintWithoutDetails=Print without details diff --git a/htdocs/langs/fr_FR/cashdesk.lang b/htdocs/langs/fr_FR/cashdesk.lang index 1a2381584ed..45679973a66 100644 --- a/htdocs/langs/fr_FR/cashdesk.lang +++ b/htdocs/langs/fr_FR/cashdesk.lang @@ -129,3 +129,6 @@ WeighingScale=échelle de poids ShowPriceHT = Afficher la colonne du prix HT (à l'écran) ShowPriceHTOnReceipt = Afficher la colonne avec le prix hors taxes (sur le ticket de caisse) CustomerDisplay=Customer display +PrintWithoutDetailsButton=Ajouter un bouton "Imprimer sans détail" +PrintWithoutDetailsLabelDefault=Libellé de la ligne par défaut sur l'impression sans détail +PrintWithoutDetails=Imprimer sans détail diff --git a/htdocs/takepos/admin/receipt.php b/htdocs/takepos/admin/receipt.php index 1fe95ff57d8..7da8436fab8 100644 --- a/htdocs/takepos/admin/receipt.php +++ b/htdocs/takepos/admin/receipt.php @@ -51,6 +51,7 @@ if (GETPOST('action', 'alpha') == 'set') { $res = dolibarr_set_const($db, "TAKEPOS_AUTO_PRINT_TICKETS", GETPOST('TAKEPOS_AUTO_PRINT_TICKETS', 'int'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_PRINT_SERVER", GETPOST('TAKEPOS_PRINT_SERVER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_PRINT_PAYMENT_METHOD", GETPOST('TAKEPOS_PRINT_PAYMENT_METHOD', 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT', GETPOST('TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT', 'alphanohtml'), 'chaine', 0, '', $conf->entity); dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); @@ -262,6 +263,20 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector" && filter_var($con print "\n"; } +// Print without details +print ''; +print $langs->trans('PrintWithoutDetailsButton'); +print ''; +print ajax_constantonoff('TAKEPOS_PRINT_WITHOUT_DETAILS', array(), $conf->entity, 0, 0, 1, 0); +print "\n"; +if (!empty($conf->global->TAKEPOS_PRINT_WITHOUT_DETAILS)) { + print ''; + print $langs->trans('PrintWithoutDetailsLabelDefault'); + print ''; + print ''; + print "\n"; +} + print ''; print ''; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 8b2e5ca78b7..8a6bdcfd2bd 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -158,7 +158,7 @@ if ($ret > 0) { $placeid = $invoice->id; } -$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'. isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; +$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : ''); $soc = new Societe($db); if ($invoice->socid > 0) { @@ -877,6 +877,9 @@ if ($action == "valid" || $action == "history" || $action == 'creditnote') { $sectionwithinvoicelink .= ' '; } else { $sectionwithinvoicelink .= ' '; + if (getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) { + $sectionwithinvoicelink .= ' '; + } if (getDolGlobalString('TAKEPOS_GIFT_RECEIPT')) { $sectionwithinvoicelink .= ' '; } @@ -1017,6 +1020,11 @@ function SendTicket(id) $.colorbox({href:"send.php?facid="+id, width:"70%", height:"30%", transition:"none", iframe:"true", title:'trans("SendTicket")); ?>'}); } +function PrintBox(id, action) { + console.log("Open box before printing"); + $.colorbox({href:"printbox.php?facid="+id+"&action="+action, width:"80%", height:"200px", transition:"none", iframe:"true", title:"trans("PrintWithoutDetails"); ?>"}); +} + function Print(id, gift){ console.log("Call Print() to generate the receipt."); $.colorbox({href:"receipt.php?facid="+id+"&gift="+gift, width:"40%", height:"90%", transition:"none", iframe:"true", title:'trans("PrintTicket")); ?>'}); diff --git a/htdocs/takepos/printbox.php b/htdocs/takepos/printbox.php new file mode 100644 index 00000000000..cc5f5b305d1 --- /dev/null +++ b/htdocs/takepos/printbox.php @@ -0,0 +1,102 @@ + + * Copyright (C) 2020 Laurent Destailleur + * + * 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/printbox.php + * \ingroup takepos + * \brief Popup to enter details before printing + */ + +//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.'/core/lib/functions.lib.php'; + +global $langs, $db; + +$langs->loadLangs(array("bills", "cashdesk")); + +$facid = GETPOST('facid', 'int'); + +$action = GETPOST('action', 'aZ09'); + +if (empty($user->rights->takepos->run)) { + accessforbidden(); +} + + +/* + * View + */ + +$arrayofcss = array('/takepos/css/pos.css.php'); +$arrayofjs = array('/takepos/js/jquery.colorbox-min.js'); + +$head = ''; +top_htmlhead($head, '', 0, 0, $arrayofjs, $arrayofcss); +?> + + + +
+
+trans('Label') . '">'; + print ''; + } +?> + +
+ + + diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index 627a6c99565..df0b55bc64e 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -54,6 +54,7 @@ $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is $facid = GETPOST('facid', 'int'); +$action = GETPOST('action', 'aZ09'); $gift = GETPOST('gift', 'int'); if (empty($user->rights->takepos->run)) { @@ -169,33 +170,46 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER) { lines as $line) { - ?> - - - product_label)) { - echo $line->product_label; - } else { - echo $line->description; - } ?> - - qty; ?> - total_ttc / $line->qty, 'MT'), 1); - } ?> - global->TAKEPOS_SHOW_HT_RECEIPT)) { ?> - total_ht, 1); - } ?> + if ($action == 'without_details') { + $qty = GETPOST('qty', 'int') > 0 ? GETPOST('qty', 'int') : 1; + print ''; + print '' . GETPOST('label', 'alphanohtml') . ''; + print '' . $qty . ''; + print '' . price(price2num($object->total_ttc / $qty, 'MU'), 1) . ''; + if (!empty($conf->global->TAKEPOS_SHOW_HT_RECEIPT)) { + print '' . price($object->total_ht, 1) . ''; + } + print '' . price($object->total_ttc, 1) . ''; + print ''; + } else { + foreach ($object->lines as $line) { + ?> + + + product_label)) { + echo $line->product_label; + } else { + echo $line->description; + } ?> + + qty; ?> + total_ttc / $line->qty, 'MT'), 1); + } ?> + global->TAKEPOS_SHOW_HT_RECEIPT)) { ?> + total_ht, 1); + } ?> + + total_ttc, 1); + } ?> + - total_ttc, 1); - } ?> - - From da52ee55a4e9adaaa2e51806ceaecc168d3c57b2 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Thu, 7 Oct 2021 10:13:30 +0200 Subject: [PATCH 2/2] FIX sickler-ci errors --- htdocs/takepos/printbox.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/takepos/printbox.php b/htdocs/takepos/printbox.php index cc5f5b305d1..5d612fd19f2 100644 --- a/htdocs/takepos/printbox.php +++ b/htdocs/takepos/printbox.php @@ -87,13 +87,13 @@ top_htmlhead($head, '', 0, 0, $arrayofjs, $arrayofcss);
trans('Label') . '">'; - print ''; - } + print ''; + print ''; +} ?>