|
@@ -96,6 +96,7 @@ if (!$sortorder) {
|
|
|
$sortorder = "ASC";
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// Initialize array of search criterias
|
|
|
$search = array();
|
|
|
foreach ($object->fields as $key => $val) {
|
|
@@ -107,6 +108,12 @@ foreach ($object->fields as $key => $val) {
|
|
|
$search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
|
|
|
}
|
|
|
}
|
|
|
+$key = 'sellby';
|
|
|
+$search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
|
|
|
+$search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
|
|
|
+$key = 'eatby';
|
|
|
+$search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
|
|
|
+$search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
|
|
|
|
|
|
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
|
|
|
$canvas = GETPOST("canvas");
|
|
@@ -155,6 +162,10 @@ if (empty($reshook)) {
|
|
|
$search[$key.'_dtend'] = '';
|
|
|
}
|
|
|
}
|
|
|
+ $search['sellby_dtstart'] = '';
|
|
|
+ $search['eatby_dtstart'] = '';
|
|
|
+ $search['sellby_dtend'] = '';
|
|
|
+ $search['eatby_dtend'] = '';
|
|
|
$sref = "";
|
|
|
$snom = "";
|
|
|
$sall = "";
|
|
@@ -268,6 +279,37 @@ if ($search_warehouse) {
|
|
|
if ($search_batch) {
|
|
|
$sql .= natural_search("pb.batch", $search_batch);
|
|
|
}
|
|
|
+
|
|
|
+foreach ($search as $key => $val) {
|
|
|
+ if (array_key_exists($key, $object->fields)) {
|
|
|
+ if ($key == 'status' && $search[$key] == -1) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
|
|
|
+ if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
|
|
|
+ if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
|
|
|
+ $search[$key] = '';
|
|
|
+ }
|
|
|
+ $mode_search = 2;
|
|
|
+ }
|
|
|
+ if ($search[$key] != '') {
|
|
|
+ $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
|
|
|
+ $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
|
|
|
+ if ($columnName == 'eatby' || $columnName == 'sellby') {
|
|
|
+ if (preg_match('/_dtstart$/', $key)) {
|
|
|
+ $sql .= " AND pl.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'";
|
|
|
+ }
|
|
|
+ if (preg_match('/_dtend$/', $key)) {
|
|
|
+ $sql .= " AND pl.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
$sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,";
|
|
|
$sql .= " p.fk_product_type, p.tms,";
|
|
|
$sql .= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tosell, p.tobuy, p.tobatch,";
|
|
@@ -293,10 +335,13 @@ if (!empty($sql_having)) {
|
|
|
$sql .= $sql_having;
|
|
|
}
|
|
|
|
|
|
+//print $sql;
|
|
|
+
|
|
|
+// Count total nb of records
|
|
|
$nbtotalofrecords = '';
|
|
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
|
|
- $result = $db->query($sql);
|
|
|
- $nbtotalofrecords = $db->num_rows($result);
|
|
|
+ $resql = $db->query($sql);
|
|
|
+ $nbtotalofrecords = $db->num_rows($resql);
|
|
|
|
|
|
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
|
|
|
$page = 0;
|
|
@@ -339,9 +384,29 @@ if (isset($type)) {
|
|
|
$texte .= ' ('.$langs->trans("StocksByLotSerial").')';
|
|
|
|
|
|
$param = '';
|
|
|
+if (!empty($mode)) {
|
|
|
+ $param .= '&mode='.urlencode($mode);
|
|
|
+}
|
|
|
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
|
|
+ $param .= '&contextpage='.urlencode($contextpage);
|
|
|
+}
|
|
|
if ($limit > 0 && $limit != $conf->liste_limit) {
|
|
|
$param .= '&limit='.urlencode($limit);
|
|
|
}
|
|
|
+foreach ($search as $key => $val) {
|
|
|
+ if (is_array($search[$key]) && count($search[$key])) {
|
|
|
+ foreach ($search[$key] as $skey) {
|
|
|
+ if ($skey != '') {
|
|
|
+ $param .= '&search_'.$key.'[]='.urlencode($skey);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } elseif ($search[$key] != '') {
|
|
|
+ $param .= '&search_'.$key.'='.urlencode($search[$key]);
|
|
|
+ }
|
|
|
+}
|
|
|
+if ($optioncss != '') {
|
|
|
+ $param .= '&optioncss='.urlencode($optioncss);
|
|
|
+}
|
|
|
if ($sall) {
|
|
|
$param .= "&sall=".urlencode($sall);
|
|
|
}
|
|
@@ -389,11 +454,18 @@ if ($sellby) $param.="&sellby=".$sellby;*/
|
|
|
|
|
|
llxHeader("", $title, $helpurl, $texte);
|
|
|
|
|
|
-print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">';
|
|
|
+print '<form id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" method="POST" name="formulaire">'."\n";
|
|
|
+if ($optioncss != '') {
|
|
|
+ print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
|
|
+}
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
|
+print '<input type="hidden" name="action" value="list">';
|
|
|
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
|
|
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
|
|
print '<input type="hidden" name="type" value="'.$type.'">';
|
|
|
+print '<input type="hidden" name="page" value="'.$page.'">';
|
|
|
+print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
|
|
+print '<input type="hidden" name="mode" value="'.$mode.'">';
|
|
|
|
|
|
print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'product', 0, '', '', $limit, 0, 0, 1);
|
|
|
|
|
@@ -428,7 +500,7 @@ if (!empty($moreforfilter)) {
|
|
|
|
|
|
|
|
|
print '<div class="div-table-responsive">';
|
|
|
-print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
|
|
|
+print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
|
|
|
|
|
|
// Fields title search
|
|
|
// --------------------------------------------------------------------
|
|
@@ -447,10 +519,26 @@ if (!empty($conf->service->enabled) && $type == 1) {
|
|
|
print '<td class="liste_titre"><input class="flat" type="text" name="search_warehouse" size="6" value="'.$search_warehouse.'"></td>';
|
|
|
print '<td class="liste_titre center"><input class="flat" type="text" name="search_batch" size="6" value="'.$search_batch.'"></td>';
|
|
|
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
|
|
|
- print '<td class="liste_titre"> </td>';
|
|
|
+ print '<td class="liste_titre center">';
|
|
|
+ $key = 'sellby';
|
|
|
+ print '<div class="nowrap">';
|
|
|
+ print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
|
|
|
+ print '</div>';
|
|
|
+ print '<div class="nowrap">';
|
|
|
+ print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
|
|
|
+ print '</div>';
|
|
|
+ print '</td>';
|
|
|
}
|
|
|
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
|
|
|
- print '<td class="liste_titre"> </td>';
|
|
|
+ print '<td class="liste_titre center">';
|
|
|
+ $key = 'eatby';
|
|
|
+ print '<div class="nowrap">';
|
|
|
+ print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
|
|
|
+ print '</div>';
|
|
|
+ print '<div class="nowrap">';
|
|
|
+ print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
|
|
|
+ print '</div>';
|
|
|
+ print '</td>';
|
|
|
}
|
|
|
// Physical stock
|
|
|
print '<td class="liste_titre right">';
|
|
@@ -459,14 +547,21 @@ print '</td>';
|
|
|
print '<td class="liste_titre"> </td>';
|
|
|
print '<td class="liste_titre"> </td>';
|
|
|
print '<td class="liste_titre"> </td>';
|
|
|
-print '<td class="liste_titre maxwidthsearch">';
|
|
|
-$searchpicto = $form->showFilterAndCheckAddButtons(0);
|
|
|
-print $searchpicto;
|
|
|
-print '</td>';
|
|
|
-print '</tr>';
|
|
|
+// Action column
|
|
|
+if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
|
|
|
+ print '<td class="liste_titre maxwidthsearch">';
|
|
|
+ $searchpicto = $form->showFilterButtons();
|
|
|
+ print $searchpicto;
|
|
|
+ print '</td>';
|
|
|
+}
|
|
|
+print '</tr>'."\n";
|
|
|
+
|
|
|
+$totalarray = array();
|
|
|
+$totalarray['nbfield'] = 0;
|
|
|
|
|
|
-//Line for column titles
|
|
|
-print "<tr class=\"liste_titre\">";
|
|
|
+// Fields title label
|
|
|
+// --------------------------------------------------------------------
|
|
|
+print '<tr class="liste_titre">';
|
|
|
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", '', $param, "", $sortfield, $sortorder);
|
|
|
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", '', $param, "", $sortfield, $sortorder);
|
|
|
if (!empty($conf->service->enabled) && $type == 1) {
|