From 335b0aebb519e7f6cacefb61998ead4f54aea4ba Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 2 Feb 2021 10:17:22 +0100 Subject: [PATCH 1/3] NEW: Stock movement list - Add more complete date field --- htdocs/product/stock/movement_list.php | 46 ++++++++++++++------------ 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 6ab8a99ac76..9da798f3209 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -66,8 +66,8 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $result = restrictedArea($user, 'stock'); $idproduct = GETPOST('idproduct', 'int'); -$year = GETPOST("year"); -$month = GETPOST("month"); +$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); +$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); $search_ref = GETPOST('search_ref', 'alpha'); $search_movement = GETPOST("search_movement"); $search_product_ref = trim(GETPOST("search_product_ref")); @@ -162,8 +162,8 @@ if (empty($reshook)) // Do we click on purge search criteria ? if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $year = ''; - $month = ''; + $search_date_start = ''; + $search_date_end = ''; $search_ref = ''; $search_movement = ""; $search_type_mouvement = ""; @@ -482,17 +482,18 @@ $sql .= " AND m.fk_entrepot = e.rowid"; $sql .= " AND e.entity IN (".getEntity('stock').")"; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0"; if ($id > 0) $sql .= " AND e.rowid ='".$id."'"; -$sql .= dolSqlDateFilter('m.datem', 0, $month, $year); +if (!empty($search_date_start)) $sql .= " AND m.datem >= '" . $db->idate($search_date_start) . "'"; +if (!empty($search_date_end)) $sql .= " AND m.datem <= '" . $db->idate($search_date_end) . "'"; if ($idproduct > 0) $sql .= " AND p.rowid = ".((int) $idproduct); if (!empty($search_ref)) $sql .= natural_search('m.rowid', $search_ref, 1); -if (!empty($search_movement)) $sql .= natural_search('m.label', $search_movement); -if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode); -if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); -if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); +if (!empty($search_movement)) $sql .= natural_search('m.label', $search_movement); +if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode); +if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); +if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); -if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); -if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); -if (!empty($product_id)) $sql .= natural_search('p.rowid', $product_id); +if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); +if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); +if (!empty($product_id)) $sql .= natural_search('p.rowid', $product_id); if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); // Add where from extra fields @@ -711,6 +712,8 @@ if ($resql) if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($id > 0) $param .= '&id='.urlencode($id); + if ($search_date_start) $param .= '&search_date_start='.urlencode($search_date_start); + if ($search_date_end) $param .= '&search_date_end='.urlencode($search_date_end); if ($search_movement) $param .= '&search_movement='.urlencode($search_movement); if ($search_inventorycode) $param .= '&search_inventorycode='.urlencode($search_inventorycode); if ($search_type_mouvement) $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); @@ -789,16 +792,17 @@ if ($resql) print ''; print ''; } - if (!empty($arrayfields['m.datem']['checked'])) + if (! empty($arrayfields['m.datem']['checked'])) { - // Date - print ''; - print ''; - if (empty($conf->productbatch->enabled)) print ' '; - //else print '
'; - $syear = $year ? $year : -1; - print ''; - //print $formother->selectyear($syear,'year',1, 20, 5); + print ''; + print '
'; + print $langs->trans('From') . ' '; + print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1); + print '
'; + print '
'; + print $langs->trans('to') . ' '; + print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1); + print '
'; print ''; } if (!empty($arrayfields['p.ref']['checked'])) From dc91dbabd1e3a1bd650577e2cb1ee511d9288ae5 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 14 Feb 2021 07:26:53 +0100 Subject: [PATCH 2/3] Fix tzuserrel --- htdocs/product/stock/movement_list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 9da798f3209..37fe102fd73 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -66,8 +66,8 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $result = restrictedArea($user, 'stock'); $idproduct = GETPOST('idproduct', 'int'); -$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); -$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); +$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'), 'tzuserrel'); +$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'), 'tzuserrel'); $search_ref = GETPOST('search_ref', 'alpha'); $search_movement = GETPOST("search_movement"); $search_product_ref = trim(GETPOST("search_product_ref")); @@ -797,11 +797,11 @@ if ($resql) print ''; print '
'; print $langs->trans('From') . ' '; - print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1); + print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '' , 'tzuserrel'); print '
'; print '
'; print $langs->trans('to') . ' '; - print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1); + print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '' , 'tzuserrel'); print '
'; print ''; } From fb7e103d6522c944901b40847c19af974561acc6 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 14 Feb 2021 06:29:06 +0000 Subject: [PATCH 3/3] Fixing style errors. --- htdocs/product/stock/movement_list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 37fe102fd73..3486eae6c9d 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -797,11 +797,11 @@ if ($resql) print ''; print '
'; print $langs->trans('From') . ' '; - print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '' , 'tzuserrel'); + print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel'); print '
'; print '
'; print $langs->trans('to') . ' '; - print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '' , 'tzuserrel'); + print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel'); print '
'; print ''; }