diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index dd8ba5902ce..95639a25997 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -404,7 +404,7 @@ if ($object->fetch($id) >= 0) { } print '
'; - if ($nbofrecipient >= 0) { + if ($nbofrecipient === '' || $nbofrecipient >= 0) { print $nbofrecipient; } else { print $langs->trans("Error").' '.img_error($obj->error); diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index 8c5491918dd..688db8b8e7f 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -200,8 +200,8 @@ class mailing_advthirdparties extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql Not use here - * @return int Nb of recipients + * @param string $sql Not use here + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { @@ -212,8 +212,7 @@ class mailing_advthirdparties extends MailingTargets $sql .= " WHERE s.email != ''"; $sql .= " AND s.entity IN (".getEntity('societe').")"; - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients + // La requete doit retourner un champ "nb" pour etre comprise par parent::getNbOfRecipients return parent::getNbOfRecipients($sql); } diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 04bc4131f69..e3e349d2a17 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -94,8 +94,8 @@ class mailing_contacts1 extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql Requete sql de comptage - * @return int + * @param string $sql Requete sql de comptage + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { diff --git a/htdocs/core/modules/mailings/example.modules.php b/htdocs/core/modules/mailings/example.modules.php index bd553e1fd5d..739ab773196 100644 --- a/htdocs/core/modules/mailings/example.modules.php +++ b/htdocs/core/modules/mailings/example.modules.php @@ -111,8 +111,8 @@ class mailing_example extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql Requete sql de comptage - * @return int|string Number of recipient or '?' + * @param string $sql Requete sql de comptage + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index b5b4f249107..992539cc303 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -93,8 +93,8 @@ class mailing_fraise extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql Requete sql de comptage - * @return int Nb of recipients + * @param string $sql Requete sql de comptage + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { @@ -102,8 +102,7 @@ class mailing_fraise extends MailingTargets $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql .= " WHERE (a.email IS NOT NULL AND a.email != '') AND a.entity IN (".getEntity('member').")"; - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients + // La requete doit retourner un champ "nb" pour etre comprise par parent::getNbOfRecipients return parent::getNbOfRecipients($sql); } diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index dae8d1a12bf..2064613d1e9 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -99,8 +99,8 @@ class MailingTargets // This can't be abstract as it is used for some method /** * Retourne nombre de destinataires * - * @param string $sql Sql request to count - * @return int Nb of recipient, or <0 if error + * @param string $sql Sql request to count + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql) { diff --git a/htdocs/core/modules/mailings/partnership.modules.php b/htdocs/core/modules/mailings/partnership.modules.php index bb8e00a179f..7813d93f54d 100644 --- a/htdocs/core/modules/mailings/partnership.modules.php +++ b/htdocs/core/modules/mailings/partnership.modules.php @@ -166,8 +166,8 @@ class mailing_partnership extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql Requete sql de comptage - * @return int Nb of recipients + * @param string $sql Requete sql de comptage + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { @@ -187,8 +187,7 @@ class mailing_partnership extends MailingTargets //print $sql; - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients + // La requete doit retourner un champ "nb" pour etre comprise par parent::getNbOfRecipients return parent::getNbOfRecipients($sql); } diff --git a/htdocs/core/modules/mailings/pomme.modules.php b/htdocs/core/modules/mailings/pomme.modules.php index 56d62449bcf..7fdcdeb0c60 100644 --- a/htdocs/core/modules/mailings/pomme.modules.php +++ b/htdocs/core/modules/mailings/pomme.modules.php @@ -89,8 +89,8 @@ class mailing_pomme extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql SQL request to use to count - * @return int Number of recipients + * @param string $sql SQL request to use to count + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { @@ -101,8 +101,7 @@ class mailing_pomme extends MailingTargets $sql .= " WHERE u.email != ''"; // u.email IS NOT NULL est implicite dans ce test $sql .= " AND u.entity IN (0,".$conf->entity.")"; - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients + // La requete doit retourner un champ "nb" pour etre comprise par parent::getNbOfRecipients return parent::getNbOfRecipients($sql); } diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index afd8a05db02..073d45439eb 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -211,8 +211,8 @@ class mailing_thirdparties extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql Requete sql de comptage - * @return int Nb of recipients + * @param string $sql Requete sql de comptage + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { @@ -223,8 +223,7 @@ class mailing_thirdparties extends MailingTargets $sql .= " WHERE s.email <> ''"; $sql .= " AND s.entity IN (".getEntity('societe').")"; - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients + // La requete doit retourner un champ "nb" pour etre comprise par parent::getNbOfRecipients return parent::getNbOfRecipients($sql); } diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index 9b417ecd95f..b5dec9cbbe0 100644 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -184,8 +184,8 @@ class mailing_thirdparties_services_expired extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql SQL request to use to count - * @return int Number of recipients + * @param string $sql SQL request to use to count + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { diff --git a/htdocs/core/modules/mailings/xinputfile.modules.php b/htdocs/core/modules/mailings/xinputfile.modules.php index 3ece88d4c1d..77044ddb29e 100644 --- a/htdocs/core/modules/mailings/xinputfile.modules.php +++ b/htdocs/core/modules/mailings/xinputfile.modules.php @@ -77,8 +77,8 @@ class mailing_xinputfile extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql Sql request to count - * @return string '' means NA + * @param string $sql Sql request to count + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { diff --git a/htdocs/core/modules/mailings/xinputuser.modules.php b/htdocs/core/modules/mailings/xinputuser.modules.php index b2874b43ca0..117a5722c3c 100644 --- a/htdocs/core/modules/mailings/xinputuser.modules.php +++ b/htdocs/core/modules/mailings/xinputuser.modules.php @@ -77,8 +77,8 @@ class mailing_xinputuser extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql Sql request to count - * @return string '' means NA + * @param string $sql Sql request to count + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 031ef60ff6e..690d3f3f261 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -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 '
'; +print ''."\n"; +if ($optioncss != '') { + print ''; +} print ''; +print ''; print ''; print ''; print ''; +print ''; +print ''; +print ''; 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 '
'; -print ''; +print '
'; // Fields title search // -------------------------------------------------------------------- @@ -447,10 +519,26 @@ if (!empty($conf->service->enabled) && $type == 1) { print ''; print ''; if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - print ''; + print ''; } if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - print ''; + print ''; } // Physical stock print ''; print ''; print ''; print ''; -print ''; -print ''; +// Action column +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} +print ''."\n"; -//Line for column titles -print ""; +$totalarray = array(); +$totalarray['nbfield'] = 0; + +// Fields title label +// -------------------------------------------------------------------- +print ''; 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) { diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 13695752ad0..2743c4a5ea7 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -55,9 +55,10 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; -} // If $page is not defined, or '' or -1 +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -342,6 +343,7 @@ if (!$resql) { $num = $db->num_rows($resql); +$i = 0; // Direct jump if only one record found if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { @@ -439,6 +441,7 @@ if ($search_all) { print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } +// Filter on categories $moreforfilter = ''; /*$moreforfilter.='
'; $moreforfilter.= $langs->trans('MyFilter') . ': '; @@ -455,6 +458,9 @@ if (empty($reshook)) { if (!empty($moreforfilter)) { print '
'; print $moreforfilter; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; print '
'; } @@ -462,13 +468,13 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'; print '
 '; + $key = 'sellby'; + print '
'; + print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
 '; + $key = 'eatby'; + print '
'; + print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; @@ -459,14 +547,21 @@ print '   '; -$searchpicto = $form->showFilterAndCheckAddButtons(0); -print $searchpicto; -print '
'; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'."\n"; // Fields title search // -------------------------------------------------------------------- -print ''; +print ''; // Action column if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { print '
';