Merge pull request #16139 from aspangaro/14a14

NEW: Stock movement list - Add more complete date field
This commit is contained in:
Laurent Destailleur 2021-02-14 22:45:39 +01:00 committed by GitHub
commit 5fc36ab736
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,8 +66,8 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected
$result = restrictedArea($user, 'stock'); $result = restrictedArea($user, 'stock');
$idproduct = GETPOST('idproduct', 'int'); $idproduct = GETPOST('idproduct', 'int');
$year = GETPOST("year"); $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'), 'tzuserrel');
$month = GETPOST("month"); $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_ref = GETPOST('search_ref', 'alpha');
$search_movement = GETPOST("search_movement"); $search_movement = GETPOST("search_movement");
$search_product_ref = trim(GETPOST("search_product_ref")); $search_product_ref = trim(GETPOST("search_product_ref"));
@ -162,8 +162,8 @@ if (empty($reshook))
// Do we click on purge search criteria ? // 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 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 = ''; $search_date_start = '';
$month = ''; $search_date_end = '';
$search_ref = ''; $search_ref = '';
$search_movement = ""; $search_movement = "";
$search_type_mouvement = ""; $search_type_mouvement = "";
@ -482,7 +482,8 @@ $sql .= " AND m.fk_entrepot = e.rowid";
$sql .= " AND e.entity IN (".getEntity('stock').")"; $sql .= " AND e.entity IN (".getEntity('stock').")";
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0"; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0";
if ($id > 0) $sql .= " AND e.rowid ='".$id."'"; 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 ($idproduct > 0) $sql .= " AND p.rowid = ".((int) $idproduct);
if (!empty($search_ref)) $sql .= natural_search('m.rowid', $search_ref, 1); 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_movement)) $sql .= natural_search('m.label', $search_movement);
@ -711,6 +712,8 @@ if ($resql)
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($id > 0) $param .= '&id='.urlencode($id); 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_movement) $param .= '&search_movement='.urlencode($search_movement);
if ($search_inventorycode) $param .= '&search_inventorycode='.urlencode($search_inventorycode); if ($search_inventorycode) $param .= '&search_inventorycode='.urlencode($search_inventorycode);
if ($search_type_mouvement) $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); if ($search_type_mouvement) $param .= '&search_type_mouvement='.urlencode($search_type_mouvement);
@ -789,16 +792,17 @@ if ($resql)
print '<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; print '<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['m.datem']['checked'])) if (! empty($arrayfields['m.datem']['checked']))
{ {
// Date print '<td class="liste_titre center">';
print '<td class="liste_titre nowraponall">'; print '<div class="nowrap">';
print '<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans("Month")).'" name="month" value="'.$month.'">'; print $langs->trans('From') . ' ';
if (empty($conf->productbatch->enabled)) print '&nbsp;'; print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
//else print '<br>'; print '</div>';
$syear = $year ? $year : -1; print '<div class="nowrap">';
print '<input class="flat maxwidth50" type="text" maxlength="4" placeholder="'.dol_escape_htmltag($langs->trans("Year")).'" name="year" value="'.($syear > 0 ? $syear : '').'">'; print $langs->trans('to') . ' ';
//print $formother->selectyear($syear,'year',1, 20, 5); print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
print '</div>';
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['p.ref']['checked'])) if (!empty($arrayfields['p.ref']['checked']))