diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index f571af9873eefc8722e6978ad41e316da26ac055..c064c74b0acb8370a8efef5ca9569b64f585e5c8 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -243,7 +243,7 @@ $sql.=$db->order($sortfield,$sortorder); //$sql.= $db->plimit($conf->liste_limit+1, $offset); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 3edda4f8587a6ac829933ebcbb9830a758a65b5d..47dcce5031b75abeffd687988610dda3e7e1fc6b 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -172,7 +172,7 @@ if (strlen(trim($search_pcgsubtype))) { $sql .= $db->order($sortfield, $sortorder); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 4127f5e4ee2aacdc59aaca7c82f62bedae8bf3fe..c5a1bffc694c79781c9f1c1269f97e7143976395 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -90,7 +90,7 @@ $sql .= " WHERE f.entity = " . $conf->entity; $sql.=$db->order($sortfield,$sortorder); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 1cb37e92baa29c5dca25e08f5310634078ce6e40..69d0fdc7f94aee354ee8eeaf5bb3364bc4215dd1 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -248,7 +248,7 @@ if (strlen(trim($search_desc))) { } $sql .= $db->order($sortfield, $sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index f0a103ae912892293b3566fc2bb6b442566800c8..557f786b4b8d86b50fb2ba92e8c06b0e3404b254 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -143,7 +143,7 @@ else { // List - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); if ($nbtotalofrecords < 0) { diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index df2ee00e86913666b4665db10430f97bbfee5cc9..f60b15844558e05e77c0b24460dcfc82eaee2e0f 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -293,7 +293,7 @@ llxHeader('', $title_page); // List -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); if ($nbtotalofrecords < 0) { diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 63b0955722fc413900427c2993d6c8fe78dad87a..6308c2d3edc52ecd160af94215196d22339cbe27 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -162,7 +162,7 @@ llxHeader('', $title_page); // List -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter); if ($nbtotalofrecords < 0) { diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index d8df8eb5007e4b2e7a82120367999b63e63aaf95..b607d055a7a573b780a662dee9fe532a250a085e 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -158,7 +158,7 @@ if (! empty($search_code_journal)) { * Mode List */ -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0); if ($nbtotalofrecords < 0) { diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index b133e505d5cb14a4c2d476e5a515d337298adf95..7882c3b9320d58e618a717496ea1d0d3cf0888a6 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -200,7 +200,7 @@ $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't sha $sql .= $db->order($sortfield, $sortorder); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 83a01abadc36825a94966a78927e47ae92ff606c..7f214ffdf3c22b9131130a8b164092c3de2e12f7 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -215,7 +215,7 @@ $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't sha $sql .= $db->order($sortfield, $sortorder); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 5ac3f5b7a011f06b4ed4a1f16ed377b7280643c5..8c47627f2f78357bff1708d6b49acc4fb6b6932d 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -178,7 +178,7 @@ $sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don' $sql .= $db->order($sortfield, $sortorder); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 0d058ffc4022460310cf079ce47e71695bba0a8d..396095eee5a9b1f9e00ba59f70cd1f2469ef534b 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -208,7 +208,7 @@ $sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don' $sql .= $db->order($sortfield, $sortorder); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 41d62a60f2225cc2ed550a5945be21b034d3b141..d4428dbcb1ab91a8be0bbd1423d7858f89b819b7 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -182,7 +182,7 @@ $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't $sql .= $db->order($sortfield, $sortorder); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 2bbc150428b51eeb81eedde694b6e913bac84af9..2f19ff0bc75fef7595f00f26c4a12137245b8212 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -217,7 +217,7 @@ $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't $sql .= $db->order($sortfield, $sortorder); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 33925e8d13098c21cc260f90d833145498146496..77519b0e570191cee8d15072829f70b5caaffe4f 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -250,7 +250,7 @@ $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); // Count total nb of records with no order and no limits -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 5ab73082a96511dd55213cafec6759cbab84e083..078eb1e0e6f065e31e08114aeefff9d8ddbc027e 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -110,7 +110,7 @@ if ($search_account > 0) $sql.= " AND b.fk_account = ".$search_account; if ($search_amount) $sql.= natural_search('c.subscription', $search_amount, 1); $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 155656e92eb680d13b00cff9a09f5fe5d440e426..3bbccd2693a617fb3b14c04353799d7761b568a7 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -414,7 +414,7 @@ if ($rowid > 0) $sql.=" AND datefin < '".$db->idate($now)."'"; } // Count total nb of records - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index e6743546b2f3000282e48300a1def82f402d94f4..471c6b2fdde2b450df7c931777b593e854b91db4 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -209,7 +209,7 @@ class Categories extends DolibarrApi $sql.= ' AND s.rowid = sub.fk_categorie'; $sql.= ' AND sub.'.$subcol_name.' = '.$item; - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/categories/class/api_deprecated_category.class.php b/htdocs/categories/class/api_deprecated_category.class.php index 7bff4d1608270c4aa84ac3d8082f19b04dd2695a..2cb25b70779400f0c99eb2c5c44f8f1fe3e49472 100644 --- a/htdocs/categories/class/api_deprecated_category.class.php +++ b/htdocs/categories/class/api_deprecated_category.class.php @@ -124,7 +124,7 @@ class CategoryApi extends DolibarrApi $sql.= ' WHERE s.entity IN ('.getEntity('category', 1).')'; $sql.= ' AND s.type='.array_search($type,CategoryApi::$TYPES); - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -205,7 +205,7 @@ class CategoryApi extends DolibarrApi $sql.= ' AND s.rowid = sub.fk_categorie'; $sql.= ' AND sub.'.$subcol_name.' = '.$item; - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index e0ccf854b894e70c2383464a0bcb52d028a1d4e7..1584e28bad996b911b4a7f65e6542f7913dc1b72 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -245,7 +245,7 @@ if ($datestart > 0) $sql.= " AND a.datep BETWEEN '".$db->idate($datestart)."' AN if ($dateend > 0) $sql.= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend+3600*24-1)."'"; $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 95c2874150abc9376b908cd5968ed576b439823b..fdc94005cdb717bfbd587c5922e080c39329f5c1 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -85,7 +85,7 @@ $sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')'; $sql.= " GROUP BY year, month, df"; $sql.= " ORDER BY year DESC, month DESC, df DESC"; -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index e22b8538a6681dfc55e0eacfce4ab6fbf3ad72ca..ab7ee3c7c8a05364b66503483f3d2256d59fcd0d 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -412,7 +412,7 @@ if ($object->fetch($id) >= 0) $sql .= $db->order($sortfield,$sortorder); // Count total nb of records - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index bd52652d9c5d1a0245886f64f6241e1ae88298a5..cdcedf9bbcc72023f1908b769606779349919103 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -333,7 +333,7 @@ $sql.= $db->order($sortfield,$sortorder); $sql.=', p.ref DESC'; // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/commande/class/api_deprecated_commande.class.php b/htdocs/commande/class/api_deprecated_commande.class.php index 16e37cc62351246374b1ff04a9e8a87eb980b231..b0b22764ec76da397ebdd418afd8b218b3bbe332 100644 --- a/htdocs/commande/class/api_deprecated_commande.class.php +++ b/htdocs/commande/class/api_deprecated_commande.class.php @@ -138,7 +138,7 @@ class CommandeApi extends DolibarrApi $sql .= " AND sc.fk_user = ".$search_sale; } - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 2fd7b4822ef653d3275aaf30f09e2f135daaceac..0262187b342147e66e1c56e75ef8e74e72a44088 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -560,7 +560,7 @@ $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index 49113ed7d5889ee8d26f515547a41fb44d2e2bde..189fbaa188f32039f114100c2ae90800886129a9 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -501,7 +501,7 @@ $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; $nbtotalofpages = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 51cb5c636fd8311b405e8a22c115a9045cd8e53b..b3c9a90302812910bb4f5701ab3c3ac31179adad 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -175,7 +175,7 @@ $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/compta/facture/class/api_deprecated_invoice.class.php b/htdocs/compta/facture/class/api_deprecated_invoice.class.php index 0b2949ca9bb0ebba6365f0dcee0549f00503380c..a2706b3150fc55063668df44826a885cbf1eb3bb 100644 --- a/htdocs/compta/facture/class/api_deprecated_invoice.class.php +++ b/htdocs/compta/facture/class/api_deprecated_invoice.class.php @@ -137,7 +137,7 @@ class InvoiceApi extends DolibarrApi $sql .= " AND sc.fk_user = ".$search_sale; } - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 51295cd0cf14b847cc24b991df91e24ee2e08979..fccb1d001063a1b86ae299abb9e0dc82660b184d 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1555,7 +1555,7 @@ else $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,12,false))."'"; } - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index ea012cb3672e01fc23991a7575ad41907767e9a1..0e2ac88fe8339a5caab3c576d265d095a59185c6 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -401,7 +401,7 @@ $listfield=explode(',',$sortfield); foreach ($listfield as $key => $value) $sql.= $listfield[$key].' '.$sortorder.','; $sql.= ' f.rowid DESC '; -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index df507490aec8ee51affd57287420f0b3c9bdc0b2..8fd4eee5339247624ee8b55547e83074384d33d7 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -112,7 +112,7 @@ else if ($year > 0) } $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 9495b56e90bbb3dffe5abe64624d4fb6c2448a88..f55d591775097c2c3fe0768e49b758d39775125f 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -186,7 +186,7 @@ else } $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 04b73ccbb6d4ed8c5ab927f51737f732bb819bc6..33e5110153be39d9b1bfc24576c0896e0b403d82 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -365,7 +365,7 @@ else } // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index e0f465b5389f2cc5f9dc6da3177f0e6701a673a2..efb2c13ea9eaee67fe7797d0bb1710a839d1aa8d 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -288,7 +288,7 @@ if ($result) $totalnboflines = $db->num_rows($result); } -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/core/class/html.formpropal.class.php b/htdocs/core/class/html.formpropal.class.php index 2cfeaadd3686e07dc9c51242ad6b668a2d7fddb5..14e1a4662752099b027f913935650cc8eb1f329c 100644 --- a/htdocs/core/class/html.formpropal.class.php +++ b/htdocs/core/class/html.formpropal.class.php @@ -101,7 +101,7 @@ class FormPropal } print '<select class="flat" name="'.$htmlname.'">'; - if ($showempty) print '<option value=""> </option>'; + if ($showempty) print '<option value="-1"> </option>'; foreach($listofstatus as $key => $obj) { @@ -113,7 +113,7 @@ class FormPropal continue; } } - if ($selected == $obj['id']) + if ($selected != '' && $selected == $obj['id']) { print '<option value="'.$obj['id'].'" selected>'; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 33be611442e2ae379567d624f7f4c4ec786b695d..1e0e423976303457c159a2b08aceb58a130dd5aa 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3174,7 +3174,7 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', * @param int $hideselectlimit Force to hide select limit * @return void */ -function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0, $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=-1, $hideselectlimit=0) +function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=-1, $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=-1, $hideselectlimit=0) { global $conf,$langs; @@ -3204,7 +3204,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so print '<td class="nobordernopadding valignmiddle">'; if ($picto && $titre) print img_picto('', $picto, 'class="hideonsmartphone valignmiddle" id="pictotitle"', $pictoisfullpath); print '<div class="titre inline-block">'.$titre; - if (!empty($titre) && $savtotalnboflines > 0) print ' ('.$totalnboflines.')'; + if (!empty($titre) && $savtotalnboflines >= 0) print ' ('.$totalnboflines.')'; print '</div></td>'; // Center diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 49d916d2d9d0e4085101b6c04cd982462c314e36..c400f9d167b43bbbd7c96922ca3cd57b8971c998 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -225,7 +225,7 @@ $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/don/list.php b/htdocs/don/list.php index a6a60dc79c30fbdb308a31c876d724fca1e03247..9ca8a79bb159caeda204d097a543f546dac15017 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -113,7 +113,7 @@ if (trim($search_name) != '') if ($search_amount) $sql.= natural_search(array('d.amount'), price2num(trim($search_amount)), 1); $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index d7624e146b1f7c24f0e423f30fd38120bb0aad52..34c989587afa48997441227050f9968288c1601e 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -238,7 +238,7 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 6f71bd77ce6d2f2fc97472d08061c703793da2e5..7ecbf665545e29e7990f7bd67bab6a6ba0046513 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -275,7 +275,7 @@ $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index cbfe245eba42cead1537919870539ad7cb5b5ca3..706ca4e143f3ba1388e6caa1dbe086c7eb3c9a14 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -121,7 +121,7 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search $fieldstosearchall = array( 'cf.ref'=>'Ref', 'cf.ref_supplier'=>'RefSupplierOrder', - //'pd.description'=>'Description', + 'pd.description'=>'Description', 's.nom'=>"ThirdParty", 'cf.note_public'=>'NotePublic', ); @@ -371,7 +371,7 @@ $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 2ebdb7fe7bb44f7beedbf16379b3c5c549a7ae27..b424ff4e7a0bf10fd7d7fbf1b50837cea51108a8 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -127,7 +127,7 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search $fieldstosearchall = array( 'f.ref'=>'Ref', 'f.ref_supplier'=>'RefSupplier', - //'fd.description'=>'Description', + 'pd.description'=>'Description', 's.nom'=>"ThirdParty", 'f.note_public'=>'NotePublic', ); @@ -246,7 +246,7 @@ $formcompany=new FormCompany($db); llxHeader('',$langs->trans("SuppliersInvoices"),'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores'); $sql = "SELECT"; -if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; +if ($search_all || $search_product_category > 0) $sql = 'SELECT DISTINCT'; $sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.date_lim_reglement as datelimite,"; $sql.= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label,"; $sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; @@ -266,7 +266,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; $sql.= ', '.MAIN_DB_PREFIX.'facture_fourn as f'; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn_extrafields as ef on (f.rowid = ef.fk_object)"; -if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn'; +if ($search_all || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn'; if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet"; // We'll need this table joined to the select in order to filter by sale @@ -372,7 +372,7 @@ $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 16aca2068b7b84053fec8c9875d99f15b13aead0..5c370a419246cf35d5004dff52d67877580c4560 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -627,6 +627,14 @@ if (empty($action)) $sql.= " GROUP BY p.rowid, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, c.code, c.libelle, ba.rowid, ba.label"; if (!$user->rights->societe->client->voir) $sql .= ", sc.fk_soc, sc.fk_user"; $sql.= $db->order($sortfield,$sortorder); + + $nbtotalofrecords = -1; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + } + $sql.= $db->plimit($limit+1, $offset); $resql = $db->query($sql); @@ -643,7 +651,7 @@ if (empty($action)) $paramlist.=($search_payment_num?"&search_payment_num=".urlencode($search_payment_num):""); if ($optioncss != '') $paramlist.='&optioncss='.urlencode($optioncss); - print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER["PHP_SELF"],$paramlist,$sortfield,$sortorder,'',$num, 0, 'title_accountancy.png'); + print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER["PHP_SELF"],$paramlist,$sortfield,$sortorder,'',$num, $nbtotalofrecords, 'title_accountancy.png'); print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index 95ff1620691b26a26f4c3356d54c5dc55b44cb5b..971849092909ee6e926ab4511f3b1b39d5ec0235 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -120,7 +120,7 @@ if ($fourn_id > 0) $sql .= " AND ppf.fk_soc = ".$fourn_id; } // Count total nb of records without orderby and limit -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index 0d79913f10ef732bb8518a7cfad0a594eab1f531..a03abce63500a25b7f02bae84c1140eaa979129f 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -86,7 +86,7 @@ if ($filtre) { $sql.= " GROUP BY l.rowid, l.label, l.capital, l.datestart, l.dateend"; $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index 24451e39d77b90a4af2df2266a2d6462032daf10..eb3292cd332f4fa64bcc0462e027f026f91b5278 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -157,7 +157,7 @@ if (! empty($enddate)) $sql .= " AND d.buy_price_ht IS NOT NULL"; $sql .= $db->order($sortfield, $sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { dol_syslog(__FILE__, LOG_DEBUG); diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index 584685ead51c6e1ed7a1d00bfe408722a661d4e0..42791f0af8d8ebc21a11d65c6bd4adbb125f8f95 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -124,7 +124,7 @@ $sql.= " u.login, u.firstname, u.lastname"; $sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p"; $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/product/class/api_deprecated_product.class.php b/htdocs/product/class/api_deprecated_product.class.php index 66f34fbd9c341418bf59cd386183eb3a7e7105ce..cdda0c45fbb7cafe07c4e778ab2740182885d6f2 100644 --- a/htdocs/product/class/api_deprecated_product.class.php +++ b/htdocs/product/class/api_deprecated_product.class.php @@ -126,7 +126,7 @@ class ProductApi extends DolibarrApi // Show product on buy if ($to_buy) $sql.= " AND p.to_buy = ".$db->escape($to_buy); - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -212,7 +212,7 @@ class ProductApi extends DolibarrApi // Show product on buy if ($to_buy) $sql.= " AND p.to_buy = ".$db->escape($to_buy); - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 9b101907bdaba138a469944fad0c1d78c490f5fb..24df0f6571556b1f1557ae7e1f6e383f137da98d 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -304,7 +304,7 @@ else $sql.=$hookmanager->resPrint; //if (GETPOST("toolowstock")) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte"; // Not used yet $sql.= $db->order($sortfield,$sortorder); - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/product/price.php b/htdocs/product/price.php index f74a637d2706583da55829c8facceb2edd1f1f6b..8f1e7484cedbc15151621cf47f15dc50efe48822 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1661,7 +1661,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $filter = array('t.fk_product' => $object->id,'t.fk_soc' => GETPOST('socid', 'int')); // Count total nb of records - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); } @@ -1741,7 +1741,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) // List of all prices by customers // Count total nb of records - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $prodcustprice->fetch_all($sortorder, $sortfield, 0, 0, $filter); } diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 21444984d65b72fe3ccdde934ae27665a1bea946..e2cb108f87dd0f3806142e7d72918a07f7af4e0d 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -456,7 +456,7 @@ $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // No $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index dfcda620a8ce65b54d119e5c0ce2a36aaad53481..848bc519946f532b9d3818c7d8fbaa56f9ac79e2 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -259,7 +259,7 @@ $sql.=$db->order($sortfield,$sortorder); //$sql.= $db->plimit($conf->liste_limit+1, $offset); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index c6a44f32c9b172c588068b221c216959738ccd5c..b98126a6bd0cb5037e17dd06cb5235e526cf2112 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -315,7 +315,7 @@ $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // No $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 5526aa91efb85bf4febb434eb2de3ab6bcf2beb0..86d79676d584664c1593ad419cbbbf3fad30a7f1 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -308,7 +308,7 @@ $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // No $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/societe/class/api_deprecated_contact.class.php b/htdocs/societe/class/api_deprecated_contact.class.php index 65f361de23a5c9712701780483ab9fe443fa9f7c..d3d085e7135ddfecaf6920d7a147cb3c41ca1403 100644 --- a/htdocs/societe/class/api_deprecated_contact.class.php +++ b/htdocs/societe/class/api_deprecated_contact.class.php @@ -143,7 +143,7 @@ class ContactApi extends DolibarrApi $sql .= " AND sc.fk_user = " . $search_sale; } - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/societe/class/api_deprecated_thirdparty.class.php b/htdocs/societe/class/api_deprecated_thirdparty.class.php index 61c9c1cc01399c04c26d4963e6a3a1ae3a82801c..3e937557941418482fbb7ca3e4b0ff6015101e98 100644 --- a/htdocs/societe/class/api_deprecated_thirdparty.class.php +++ b/htdocs/societe/class/api_deprecated_thirdparty.class.php @@ -189,7 +189,7 @@ class ThirdpartyApi extends DolibarrApi $sql .= " AND sc.fk_user = ".$search_sale; } - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 032df5b45d8f8f8bf6fc0ccdd4a0df764a68e0aa..cbc4a9670a1131d1723723b44b899ee85aa542c7 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -438,7 +438,7 @@ $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); // Count total nb of records -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 9236fc35f6f0bf39af524bb166647c8f9dbbf922..db2592f225cbfaf55111a7bc7a63ecf586e142af 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -379,7 +379,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { ); // Count total nb of records - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); } @@ -469,7 +469,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { // Count total nb of records - $nbtotalofrecords = 0; + $nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index d2649a42a43c875396e1ae7360076b88afadf445..a8e3809877528e807288f87371317457beab9071 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -55,7 +55,7 @@ $search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','al $search_societe=GETPOST('search_societe','alpha'); $search_montant_ht=GETPOST('search_montant_ht','alpha'); $search_author=GETPOST('search_author','alpha'); -$viewstatut=$db->escape(GETPOST('viewstatut')); +$search_status=GETPOST('viewstatut','alpha')?GETPOST('viewstatut','alpha'):GETPOST('search_status','int'); $object_statut=$db->escape(GETPOST('supplier_proposal_statut')); $sall=GETPOST("sall"); @@ -89,11 +89,22 @@ if ($page == -1) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='p.date_livraison'; +if (! $sortfield) $sortfield='sp.date_livraison'; if (! $sortorder) $sortorder='DESC'; -if($object_statut != '') -$viewstatut=$object_statut; +if ($object_statut != '') $search_status=$object_statut; + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$contextpage='supplierproposallist'; + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('supplierproposallist')); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('supplier_proposal'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -137,7 +148,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPO $monthvalid=''; $year=''; $month=''; - $viewstatut=''; + $search_status=''; $object_statut=''; } @@ -196,13 +207,30 @@ $companystatic=new Societe($db); $now=dol_now(); -$sql = 'SELECT s.rowid as socid, s.nom as name, s.town, s.client, s.code_client,'; -$sql.= ' p.rowid, p.note_private, p.total_ht, p.ref, p.fk_statut, p.fk_user_author, p.date_valid, p.date_livraison as dp,'; -if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; -$sql.= ' u.login'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'supplier_proposal as p'; -if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'supplier_proposaldet as pd ON p.rowid=pd.fk_supplier_proposal'; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; +$sql = 'SELECT'; +if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; +$sql.= ' s.rowid as socid, s.nom as name, s.town, s.client, s.code_client,'; +$sql.= " typent.code as typent_code,"; +$sql.= " state.code_departement as state_code, state.nom as state_name,"; +$sql.= ' sp.rowid, sp.note_private, sp.total_ht, sp.ref, sp.fk_statut, sp.fk_user_author, sp.date_valid, sp.date_livraison as dp,'; +$sql.= " p.rowid as project_id, p.ref as project_ref,"; +$sql.= " u.firstname, u.lastname, u.photo, u.login"; +// Add fields from extrafields +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +$sql.= ', '.MAIN_DB_PREFIX.'supplier_proposal as sp'; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."supplier_proposal_extrafields as ef on (sp.rowid = ef.fk_object)"; +if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'supplier_proposaldet as pd ON sp.rowid=pd.fk_supplier_proposal'; +if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sp.fk_user_author = u.rowid'; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = sp.fk_projet"; // We'll need this table joined to the select in order to filter by sale if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) @@ -210,55 +238,54 @@ if ($search_user > 0) $sql.=", ".MAIN_DB_PREFIX."element_contact as c"; $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; } -$sql.= ' WHERE p.fk_soc = s.rowid'; -$sql.= ' AND p.entity = '.$conf->entity; +$sql.= ' WHERE sp.fk_soc = s.rowid'; +$sql.= ' AND sp.entity IN ('.getEntity('supplier_proposal', 1).')'; if (! $user->rights->societe->client->voir && ! $socid) //restriction { $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; } -if ($search_ref) $sql .= natural_search('p.ref', $search_ref); +if ($search_ref) $sql .= natural_search('sp.ref', $search_ref); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); -if ($search_author) $sql.= " AND u.login LIKE '%".$db->escape(trim($search_author))."%'"; -if ($search_montant_ht) $sql.= " AND p.total_ht='".$db->escape(price2num(trim($search_montant_ht)))."'"; +if ($search_author) $sql .= natural_search('u.login', $search_author); +if ($search_montant_ht) $sql.= " AND sp.total_ht='".$db->escape(price2num(trim($search_montant_ht)))."'"; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); if ($socid) $sql.= ' AND s.rowid = '.$socid; -if ($viewstatut <> '') $sql.= ' AND p.fk_statut IN ('.$viewstatut.')'; +if ($search_status <> '') $sql.= ' AND sp.fk_statut IN ('.$search_status.')'; if ($month > 0) { if ($year > 0 && empty($day)) - $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + $sql.= " AND sp.date_livraison BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; else if ($year > 0 && ! empty($day)) - $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; + $sql.= " AND sp.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; else - $sql.= " AND date_format(p.date_livraison, '%m') = '".$month."'"; + $sql.= " AND date_format(sp.date_livraison, '%m') = '".$month."'"; } else if ($year > 0) { - $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + $sql.= " AND sp.date_livraison BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; } if ($monthvalid > 0) { if ($yearvalid > 0 && empty($dayvalid)) - $sql.= " AND p.date_valid BETWEEN '".$db->idate(dol_get_first_day($yearvalid,$monthvalid,false))."' AND '".$db->idate(dol_get_last_day($yearvalid,$monthvalid,false))."'"; + $sql.= " AND sp.date_valid BETWEEN '".$db->idate(dol_get_first_day($yearvalid,$monthvalid,false))."' AND '".$db->idate(dol_get_last_day($yearvalid,$monthvalid,false))."'"; else if ($yearvalid > 0 && ! empty($dayvalid)) - $sql.= " AND p.date_valid BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $monthvalid, $dayvalid, $yearvalid))."' AND '".$db->idate(dol_mktime(23, 59, 59, $monthvalid, $dayvalid, $yearvalid))."'"; + $sql.= " AND sp.date_valid BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $monthvalid, $dayvalid, $yearvalid))."' AND '".$db->idate(dol_mktime(23, 59, 59, $monthvalid, $dayvalid, $yearvalid))."'"; else - $sql.= " AND date_format(p.date_valid, '%m') = '".$monthvalid."'"; + $sql.= " AND date_format(sp.date_valid, '%m') = '".$monthvalid."'"; } else if ($yearvalid > 0) { - $sql.= " AND p.date_valid BETWEEN '".$db->idate(dol_get_first_day($yearvalid,1,false))."' AND '".$db->idate(dol_get_last_day($yearvalid,12,false))."'"; + $sql.= " AND sp.date_valid BETWEEN '".$db->idate(dol_get_first_day($yearvalid,1,false))."' AND '".$db->idate(dol_get_last_day($yearvalid,12,false))."'"; } if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; if ($search_user > 0) { - $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='supplier_proposal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$search_user; + $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='supplier_proposal' AND tc.source='internal' AND c.element_id = sp.rowid AND c.fk_socpeople = ".$search_user; } +$sql.= ' ORDER BY '.$sortfield.' '.$sortorder.', sp.ref DESC'; -$sql.= ' ORDER BY '.$sortfield.' '.$sortorder.', p.ref DESC'; - -$nbtotalofrecords = 0; +$nbtotalofrecords = -1; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); @@ -279,7 +306,7 @@ if ($result) $soc->fetch($socid); } - $param='&socid='.$socid.'&viewstatut='.$viewstatut; + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($sall) $param.='&sall='.$sall; @@ -291,7 +318,9 @@ if ($result) if ($search_sale > 0) $param.='&search_sale='.$search_sale; if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht; if ($search_author) $param.='&search_author='.$search_author; - + if ($socid > 0) $param.='&socid='.$socid; + if ($search_status != '') $param.='&search_status='.$search_status; + // Lignes des champs de filtre print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; @@ -344,13 +373,13 @@ if ($result) print '<div class="div-table-responsive">'; print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'; print '<tr class="liste_titre">'; - print_liste_field_titre($langs->trans('Ref'),$_SERVER["PHP_SELF"],'p.ref','',$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Ref'),$_SERVER["PHP_SELF"],'sp.ref','',$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Supplier'),$_SERVER["PHP_SELF"],'s.nom','',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Date'),$_SERVER["PHP_SELF"],'p.date_valid','',$param, 'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('SupplierProposalDate'),$_SERVER["PHP_SELF"],'p.date_livraison','',$param, 'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('AmountHT'),$_SERVER["PHP_SELF"],'p.total_ht','',$param, 'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Date'),$_SERVER["PHP_SELF"],'sp.date_valid','',$param, 'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('SupplierProposalDate'),$_SERVER["PHP_SELF"],'sp.date_livraison','',$param, 'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('AmountHT'),$_SERVER["PHP_SELF"],'sp.total_ht','',$param, 'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Author'),$_SERVER["PHP_SELF"],'u.login','',$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Status'),$_SERVER["PHP_SELF"],'p.fk_statut','',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Status'),$_SERVER["PHP_SELF"],'sp.fk_statut','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "</tr>\n"; @@ -389,7 +418,7 @@ if ($result) print '<input class="flat" size="10" type="text" name="search_author" value="'.$search_author.'">'; print '</td>'; print '<td class="liste_titre" align="right">'; - $formpropal->selectProposalStatus($viewstatut,1,0,1,'supplier'); + $formpropal->selectProposalStatus($search_status,1,0,1,'supplier','search_status'); print '</td>'; // Check boxes print '<td class="liste_titre" align="right">';