From b2252106c3c31c3a2c3983d2b7b0a0c1a648885d Mon Sep 17 00:00:00 2001 From: henrynopo Date: Fri, 20 Aug 2021 10:43:34 +0800 Subject: [PATCH 1/7] Added function - using list of location_incoterms Added function to call for list of location_incoterms from the existing order records or table of location_incoterms. Accordingly, an dditional ajex file namely "locationincoterms.php" and a database table namely c_location_incoterms are required. --- htdocs/core/class/html.form.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 07abdb4b465..b78dc7d17a2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1055,8 +1055,12 @@ class Form } } $out .= ''; - - $out .= ''; + + if ($conf->use_javascript_ajax && empty($disableautocomplete = 0)) { + $out .= ajax_multiautocompleter('location_incoterms', '', DOL_URL_ROOT.'/core/ajax/locationincoterms.php')."\n"; + $moreattrib .= ' autocomplete="off"'; + } + $out .= ''."\n"; if (!empty($page)) { $out .= ''; From 0933b6c39ff8d6baaf39badec5c9d5c0031e80bf Mon Sep 17 00:00:00 2001 From: henrynopo Date: Fri, 20 Aug 2021 20:04:53 +0800 Subject: [PATCH 2/7] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b78dc7d17a2..5d919f160f4 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1056,7 +1056,7 @@ class Form } $out .= ''; - if ($conf->use_javascript_ajax && empty($disableautocomplete = 0)) { + if ($conf->use_javascript_ajax && empty($disableautocomplete)) { $out .= ajax_multiautocompleter('location_incoterms', '', DOL_URL_ROOT.'/core/ajax/locationincoterms.php')."\n"; $moreattrib .= ' autocomplete="off"'; } From 236554948c018f4af92364fc23be24db2dde79d8 Mon Sep 17 00:00:00 2001 From: henrynopo Date: Wed, 25 Aug 2021 19:40:58 +0800 Subject: [PATCH 3/7] Add files via upload --- htdocs/core/ajax/locationincoterms.php | 110 +++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 htdocs/core/ajax/locationincoterms.php diff --git a/htdocs/core/ajax/locationincoterms.php b/htdocs/core/ajax/locationincoterms.php new file mode 100644 index 00000000000..04e4a27b2a8 --- /dev/null +++ b/htdocs/core/ajax/locationincoterms.php @@ -0,0 +1,110 @@ + + * Copyright (C) 2011-2014 Laurent Destailleur + * Copyright (C) 2021 Henry Guo + * + * 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/core/ajax/locationincoterms.php + * \ingroup core + * \brief File to return Ajax response on location_incoterms request + */ + +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); // Disables token renewal +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', '1'); +} + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + + +/* + * View + */ + +// Ajout directives pour resoudre bug IE +//header('Cache-Control: Public, must-revalidate'); +//header('Pragma: public'); + +//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. +top_httphead(); + +//print ''."\n"; + +dol_syslog('location_incoterms call with MAIN_USE_LOCATION_INCOTERMS_DICTIONNARY='.(empty($conf->global->MAIN_USE_LOCATION_INCOTERMS_DICTIONNARY) ? '' : $conf->global->MAIN_USE_LOCATION_INCOTERMS_DICTIONNARY)); +//var_dump($_GET); + +// Generation of list of zip-town +if (GETPOST('location_incoterms')) { + $return_arr = array(); + + // Define filter on text typed + $location_incoterms = GETPOST('location_incoterms'); + + if (!empty($conf->global->MAIN_USE_LOCATION_INCOTERMS_DICTIONNARY)) { // Use location_incoterms + $sql = "SELECT z.location as location_incoterms, z.label as label"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_location_incoterms as z"; + $sql .= " WHERE z.active = 1 AND UPPER(z.location) LIKE UPPER('%".$db->escape($location_incoterms)."%')"; + $sql .= " ORDER BY z.location"; + $sql .= $db->plimit(100); // Avoid pb with bad criteria + } else // Use table of commande + { + $sql = "SELECT DISTINCT s.location_incoterms FROM ".MAIN_DB_PREFIX.'commande as s'; + $sql .= " WHERE UPPER(s.location_incoterms) LIKE UPPER('%".$db->escape($location_incoterms)."%')"; + + //Todo: merge with data from table of supplier order + /* $sql .=" UNION"; + $sql .= " SELECT DISTINCT p.location_incoterms FROM ".MAIN_DB_PREFIX.'commande_fournisseur as p'; + $sql .= " WHERE UPPER(p.location_incoterms) LIKE UPPER('%".$db->escape($location_incoterms)."%')"; + */ + $sql .= " ORDER BY s.location_incoterms"; + $sql .= $db->plimit(100); // Avoid pb with bad criteria + } + + //print $sql; + $resql = $db->query($sql); + //var_dump($db); + if ($resql) { + while ($row = $db->fetch_array($resql)) { + $row_array['label'] = $row['location_incoterms'].($row['label']?' - '.$row['label'] : ''); + if ($location_incoterms) { + $row_array['value'] = $row['location_incoterms']; + } + // TODO Use a cache here to avoid to make select_state in each pass (this make a SQL and lot of logs) + + array_push($return_arr, $row_array); + } + } + + echo json_encode($return_arr); +} + +$db->close(); From 951286191336aeb131aecdb7721e50461376319f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 25 Aug 2021 11:43:32 +0000 Subject: [PATCH 4/7] Fixing style errors. --- htdocs/core/ajax/locationincoterms.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/ajax/locationincoterms.php b/htdocs/core/ajax/locationincoterms.php index 04e4a27b2a8..3a508a07057 100644 --- a/htdocs/core/ajax/locationincoterms.php +++ b/htdocs/core/ajax/locationincoterms.php @@ -65,7 +65,7 @@ dol_syslog('location_incoterms call with MAIN_USE_LOCATION_INCOTERMS_DICTIONNARY // Generation of list of zip-town if (GETPOST('location_incoterms')) { $return_arr = array(); - + // Define filter on text typed $location_incoterms = GETPOST('location_incoterms'); @@ -79,13 +79,13 @@ if (GETPOST('location_incoterms')) { { $sql = "SELECT DISTINCT s.location_incoterms FROM ".MAIN_DB_PREFIX.'commande as s'; $sql .= " WHERE UPPER(s.location_incoterms) LIKE UPPER('%".$db->escape($location_incoterms)."%')"; - - //Todo: merge with data from table of supplier order - /* $sql .=" UNION"; + + //Todo: merge with data from table of supplier order + /* $sql .=" UNION"; $sql .= " SELECT DISTINCT p.location_incoterms FROM ".MAIN_DB_PREFIX.'commande_fournisseur as p'; $sql .= " WHERE UPPER(p.location_incoterms) LIKE UPPER('%".$db->escape($location_incoterms)."%')"; - */ - $sql .= " ORDER BY s.location_incoterms"; + */ + $sql .= " ORDER BY s.location_incoterms"; $sql .= $db->plimit(100); // Avoid pb with bad criteria } @@ -94,7 +94,7 @@ if (GETPOST('location_incoterms')) { //var_dump($db); if ($resql) { while ($row = $db->fetch_array($resql)) { - $row_array['label'] = $row['location_incoterms'].($row['label']?' - '.$row['label'] : ''); + $row_array['label'] = $row['location_incoterms'].($row['label']?' - '.$row['label'] : ''); if ($location_incoterms) { $row_array['value'] = $row['location_incoterms']; } From ae384900421481016d836c6eb0ef21beb43343cc Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 2 Sep 2021 10:53:22 +0200 Subject: [PATCH 5/7] Fix #18443 : overwrite file works fine --- htdocs/ecm/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 3a8d33343c7..5d6ed32801f 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -120,7 +120,8 @@ if (GETPOST("sendit", 'alphanohtml') && !empty($conf->global->MAIN_UPLOAD_DOC)) if (!$error) { $generatethumbs = 0; - $res = dol_add_file_process($upload_dir, 0, 1, 'userfile', '', null, '', $generatethumbs); + $overwritefile = GETPOST('overwritefile','int')?GETPOST('overwritefile','int'):0; + $res = dol_add_file_process($upload_dir, $overwritefile, 1, 'userfile', '', null, '', $generatethumbs); if ($res > 0) { $result = $ecmdir->changeNbOfFiles('+'); } From e01ccabbd51f5aa4eb5aaba5bce7c8be203e62c4 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 2 Sep 2021 08:56:53 +0000 Subject: [PATCH 6/7] Fixing style errors. --- htdocs/ecm/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 5d6ed32801f..20d948b4b3b 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -120,7 +120,7 @@ if (GETPOST("sendit", 'alphanohtml') && !empty($conf->global->MAIN_UPLOAD_DOC)) if (!$error) { $generatethumbs = 0; - $overwritefile = GETPOST('overwritefile','int')?GETPOST('overwritefile','int'):0; + $overwritefile = GETPOST('overwritefile', 'int')?GETPOST('overwritefile', 'int'):0; $res = dol_add_file_process($upload_dir, $overwritefile, 1, 'userfile', '', null, '', $generatethumbs); if ($res > 0) { $result = $ecmdir->changeNbOfFiles('+'); From 18d61574d3c09b182c0f6594158a7511e7eec1da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 2 Sep 2021 12:40:05 +0200 Subject: [PATCH 7/7] fix tooltip info --- htdocs/expedition/shipment.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 8510e6f3609..e9f79e2ef12 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012-2015 Juanjo Menent - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2018 Philippe Grand * * This program is free software; you can redistribute it and/or modify @@ -624,6 +624,7 @@ if ($id > 0 || !empty($ref)) { $sql .= ' p.rowid as prodid, p.label as product_label, p.entity, p.ref, p.fk_product_type as product_type, p.description as product_desc,'; $sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units,'; $sql .= ' p.surface, p.surface_units, p.volume, p.volume_units'; + $sql .= ', p.tobatch, p.tosell, p.tobuy, p.barcode'; $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; $sql .= " WHERE cd.fk_commande = ".((int) $object->id); @@ -711,6 +712,10 @@ if ($id > 0 || !empty($ref)) { $product_static->id = $objp->fk_product; $product_static->ref = $objp->ref; $product_static->entity = $objp->entity; + $product_static->status = $objp->tosell; + $product_static->status_buy = $objp->tobuy; + $product_static->status_batch = $objp->tobatch; + $product_static->barcode = $objp->barcode; $product_static->weight = $objp->weight; $product_static->weight_units = $objp->weight_units;