diff --git a/htdocs/product/list.php b/htdocs/product/list.php index f0efe20225c..ea739341972 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -16,7 +16,7 @@ * Copyright (C) 2020-2023 Alexandre Spangaro * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Benjamin Falière - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2026 Frédéric France * * 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 @@ -121,6 +121,25 @@ $search_accountancy_code_buy_export = GETPOST("search_accountancy_code_buy_expor $search_import_key = GETPOST("search_import_key", 'alpha'); $search_finished = GETPOST("search_finished"); $search_units = GETPOST('search_units', 'int'); + +$search_date_creation_startmonth = GETPOSTINT('search_date_creation_startmonth'); +$search_date_creation_startyear = GETPOSTINT('search_date_creation_startyear'); +$search_date_creation_startday = GETPOSTINT('search_date_creation_startday'); +$search_date_creation_start = dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear); // Use tzserver +$search_date_creation_endmonth = GETPOSTINT('search_date_creation_endmonth'); +$search_date_creation_endyear = GETPOSTINT('search_date_creation_endyear'); +$search_date_creation_endday = GETPOSTINT('search_date_creation_endday'); +$search_date_creation_end = dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear); // Use tzserver + +$search_date_modif_startmonth = GETPOSTINT('search_date_modif_startmonth'); +$search_date_modif_startyear = GETPOSTINT('search_date_modif_startyear'); +$search_date_modif_startday = GETPOSTINT('search_date_modif_startday'); +$search_date_modif_start = dol_mktime(0, 0, 0, $search_date_modif_startmonth, $search_date_modif_startday, $search_date_modif_startyear); // Use tzserver +$search_date_modif_endmonth = GETPOSTINT('search_date_modif_endmonth'); +$search_date_modif_endyear = GETPOSTINT('search_date_modif_endyear'); +$search_date_modif_endday = GETPOSTINT('search_date_modif_endday'); +$search_date_modif_end = dol_mktime(23, 59, 59, $search_date_modif_endmonth, $search_date_modif_endday, $search_date_modif_endyear); // Use tzserver + $type = GETPOST("type", 'alpha'); // Show/hide child product variants @@ -397,6 +416,23 @@ if (empty($reshook)) { $search_finished = ''; //$search_type=''; // There is 2 types of list: a list of product and a list of services. No list with both. So when we clear search criteria, we must keep the filter on type. + $search_date_creation_startmonth = ""; + $search_date_creation_startyear = ""; + $search_date_creation_startday = ""; + $search_date_creation_start = ""; + $search_date_creation_endmonth = ""; + $search_date_creation_endyear = ""; + $search_date_creation_endday = ""; + $search_date_creation_end = ""; + $search_date_modif_startmonth = ""; + $search_date_modif_startyear = ""; + $search_date_modif_startday = ""; + $search_date_modif_start = ""; + $search_date_modif_endmonth = ""; + $search_date_modif_endyear = ""; + $search_date_modif_endday = ""; + $search_date_modif_end = ""; + $show_childproducts = ''; $search_import_key = ''; $search_stockable_product = ''; @@ -609,6 +645,18 @@ if ($search_vatrate) { if (dol_strlen($canvas) > 0) { $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; } +if ($search_date_creation_start) { + $sql .= " AND p.datec >= '".$db->idate($search_date_creation_start)."'"; +} +if ($search_date_creation_end) { + $sql .= " AND p.datec <= '".$db->idate($search_date_creation_end)."'"; +} +if ($search_date_modif_start) { + $sql .= " AND p.tms >= '".$db->idate($search_date_modif_start)."'"; +} +if ($search_date_modif_end) { + $sql .= " AND p.tms <= '".$db->idate($search_date_modif_end)."'"; +} // Search for tag/category ($searchCategoryProductList is an array of ID) if (!empty($searchCategoryProductList)) { @@ -884,6 +932,54 @@ if ($search_finished) { if ($search_stockable_product != '') { $param .= "&search_stockable_product=".urlencode($search_stockable_product); } +if ($search_date_creation_startmonth) { + $param .= '&search_date_creation_startmonth='.urlencode((string) ($search_date_creation_startmonth)); +} +if ($search_date_creation_startyear) { + $param .= '&search_date_creation_startyear='.urlencode((string) ($search_date_creation_startyear)); +} +if ($search_date_creation_startday) { + $param .= '&search_date_creation_startday='.urlencode((string) ($search_date_creation_startday)); +} +if ($search_date_creation_start) { + $param .= '&search_date_creation_start='.urlencode((string) $search_date_creation_start); +} +if ($search_date_creation_endmonth) { + $param .= '&search_date_creation_endmonth='.urlencode((string) ($search_date_creation_endmonth)); +} +if ($search_date_creation_endyear) { + $param .= '&search_date_creation_endyear='.urlencode((string) ($search_date_creation_endyear)); +} +if ($search_date_creation_endday) { + $param .= '&search_date_creation_endday='.urlencode((string) ($search_date_creation_endday)); +} +if ($search_date_creation_end) { + $param .= '&search_date_creation_end='.urlencode((string) $search_date_creation_end); +} +if ($search_date_modif_startmonth) { + $param .= '&search_date_modif_startmonth='.urlencode((string) ($search_date_modif_startmonth)); +} +if ($search_date_modif_startyear) { + $param .= '&search_date_modif_startyear='.urlencode((string) ($search_date_modif_startyear)); +} +if ($search_date_modif_startday) { + $param .= '&search_date_modif_startday='.urlencode((string) ($search_date_modif_startday)); +} +if ($search_date_modif_start) { + $param .= '&search_date_modif_start='.urlencode((string) $search_date_modif_start); +} +if ($search_date_modif_endmonth) { + $param .= '&search_date_modif_endmonth='.urlencode((string) ($search_date_modif_endmonth)); +} +if ($search_date_modif_endyear) { + $param .= '&search_date_modif_endyear='.urlencode((string) ($search_date_modif_endyear)); +} +if ($search_date_modif_endday) { + $param .= '&search_date_modif_endday='.urlencode((string) ($search_date_modif_endday)); +} +if ($search_date_modif_end) { + $param .= '&search_date_modif_end=' . urlencode((string) $search_date_modif_end); +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -1308,12 +1404,24 @@ $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $obje print $hookmanager->resPrint; // Date creation if (!empty($arrayfields['p.datec']['checked'])) { - print ''; + print ''; + print '
'; + print $form->selectDate($search_date_creation_start ? $search_date_creation_start : -1, 'search_date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_creation_end ? $search_date_creation_end : -1, 'search_date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; print ''; } // Date modification if (!empty($arrayfields['p.tms']['checked'])) { - print ''; + print ''; + print '
'; + print $form->selectDate($search_date_modif_start ? $search_date_modif_start : -1, 'search_date_modif_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_modif_end ? $search_date_modif_end : -1, 'search_date_modif_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; print ''; } if (!empty($arrayfields['p.import_key']['checked'])) {