--- /tmp/dsg/dolibarr/htdocs/fourn/product/github_19.0.3_list.php +++ /tmp/dsg/dolibarr/htdocs/fourn/product/client_list.php @@ -24,3 +24,3 @@ - * \file htdocs/fourn/product/list.php - * \ingroup product - * \brief Page to list supplier products and services + * \file htdocs/fourn/product/list.php + * \ingroup produit + * \brief Page to list supplier products and services @@ -29,2 +28,0 @@ - -// Load Dolibarr environment @@ -32,11 +30,9 @@ -require_once DOL_DOCUMENT_ROOT .'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT .'/fourn/class/fournisseur.class.php'; - - -// Load translation files required by the page -$langs->loadLangs(array('products', 'suppliers')); - - -// Get Parameters -$sref = GETPOST('sref', 'alphanohtml'); +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + +$langs->loadLangs(array("products", "suppliers")); + +if (!$user->rights->produit->lire && !$user->rights->service->lire) accessforbidden(); + +$sref = GETPOST('sref'); @@ -44,2 +40,2 @@ -$snom = GETPOST('snom', 'alphanohtml'); -$type = GETPOST('type', 'alphanohtml'); +$snom = GETPOST('snom'); +$type = GETPOST('type'); @@ -49,3 +45,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -53,3 +49 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -59,6 +53,2 @@ -if (!$sortfield) { - $sortfield = "p.ref"; // Set here default search field -} -if (!$sortorder) { - $sortorder = "ASC"; -} +if (!$sortfield) $sortfield = "p.ref"; // Set here default search field +if (!$sortorder) $sortorder = "ASC"; @@ -67,3 +57 @@ -if ($user->socid) { - $fourn_id = $user->socid; -} +if ($user->socid) $fourn_id = $user->socid; @@ -77,6 +65 @@ -if (!$user->hasRight("produit", "lire") && !$user->hasRight("service", "lire")) { - accessforbidden(); -} - -// Permissions -$permissiontoadd = ($user->hasRight('product', 'read') || $user->hasRight('service', 'read')); + @@ -86 +69,3 @@ - * Actions + * ACTIONS + * + * Put here all code to do according to value of "action" parameter @@ -89,7 +74,2 @@ -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; -} +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } @@ -100,22 +80,21 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - $sref = ''; - $sRefSupplier = ''; - $snom = ''; - $search_field1 = ''; - $search_field2 = ''; - $search_date_creation = ''; - $search_date_update = ''; - $toselect = array(); - $search_array_options = array(); - } -} - +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $sref = ''; + $sRefSupplier = ''; + $snom = ''; + $search_field1 = ''; + $search_field2 = ''; + $search_date_creation = ''; + $search_date_update = ''; + $toselect = ''; + $search_array_options = array(); + } +} @@ -131,3 +110,4 @@ -$title = $langs->trans('Supplier')." - ".$langs->trans('ProductsAndServices'); - -if ($fourn_id) { +$title = $langs->trans("ProductsAndServices"); + +if ($fourn_id) +{ @@ -141,3 +121,3 @@ - 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), - 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), - 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), + 'generate_doc'=>$langs->trans("ReGeneratePDF"), + 'builddoc'=>$langs->trans("PDFMerge"), + 'presend'=>$langs->trans("SendByMail"), @@ -145,6 +125,2 @@ -if ($user->hasRight('mymodule', 'supprimer')) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); -} -if (in_array($massaction, array('presend', 'predelete'))) { - $arrayofmassactions = array(); -} +if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); @@ -154 +130 @@ -$sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type, p.entity, p.tosell, p.tobuy, p.barcode, p.fk_barcode_type,"; +$sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type, p.entity,"; @@ -160,3 +136 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -164,3 +137,0 @@ - -$sqlfields = $sql; // $sql fields to remove for count total - @@ -168,5 +139,3 @@ -if ($catid) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; -} -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON p.rowid = ppf.fk_product AND p.entity = ppf.entity"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ppf.fk_soc = s.rowid AND s.entity IN (".getEntity('societe').")"; +if ($catid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON p.rowid = ppf.fk_product"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ppf.fk_soc = s.rowid"; @@ -174 +143,2 @@ -if ($sRefSupplier) { +if ($sRefSupplier) +{ @@ -177 +147,2 @@ -if (GETPOST('type')) { +if (GETPOST('type')) +{ @@ -180 +151,2 @@ -if ($sref) { +if ($sref) +{ @@ -183 +155,2 @@ -if ($snom) { +if ($snom) +{ @@ -186,5 +159,7 @@ -if ($catid) { - $sql .= " AND cp.fk_categorie = ".((int) $catid); -} -if ($fourn_id > 0) { - $sql .= " AND ppf.fk_soc = ".((int) $fourn_id); +if ($catid) +{ + $sql .= " AND cp.fk_categorie = ".$catid; +} +if ($fourn_id > 0) +{ + $sql .= " AND ppf.fk_soc = ".$fourn_id; @@ -196,3 +171 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -201 +174,3 @@ -// Count total nb of records +$sql .= $db->order($sortfield, $sortorder); + +// Count total nb of records without orderby and limit @@ -203,24 +178,12 @@ -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); - $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); - $resql = $db->query($sqlforcount); - if ($resql) { - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - } else { - dol_print_error($db); - } - - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 - $page = 0; - $offset = 0; - } - $db->free($resql); -} - -// Complete request and execute it with limit -$sql .= $db->order($sortfield, $sortorder); -if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); -} +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } +} + +$sql .= $db->plimit($limit + 1, $offset); @@ -230 +193,2 @@ -if ($resql) { +if ($resql) +{ @@ -235 +199,2 @@ - if ($num == 1 && (GETPOST("mode") == 'search')) { + if ($num == 1 && (GETPOST("mode") == 'search')) + { @@ -241,5 +206,2 @@ - if (!empty($supplier->id)) { - $texte = $langs->trans("ListOfSupplierProductForSupplier", $supplier->name); - } else { - $texte = $langs->trans("List"); - } + if (!empty($supplier->id)) $texte = $langs->trans("ListOfSupplierProductForSupplier", $supplier->name); + else $texte = $langs->trans("List"); @@ -249,11 +211,8 @@ - $param = "&sref=".$sref."&snom=".$snom."&fourn_id=".$fourn_id.(isset($type) ? "&type=".$type : "").(empty($sRefSupplier) ? "" : "&srefsupplier=".$sRefSupplier); - if ($optioncss != '') { - $param .= '&optioncss='.$optioncss; - } - - $newcardbutton = ''; - $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/list.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); - - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'generic', 0, $newcardbutton); - - if (!empty($catid)) { + + $param = "&tobuy=".$tobuy."&sref=".$sref."&snom=".$snom."&fourn_id=".$fourn_id.(isset($type) ? "&type=".$type : "").(empty($sRefSupplier) ? "" : "&srefsupplier=".$sRefSupplier); + if ($optioncss != '') $param .= '&optioncss='.$optioncss; + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords); + + + if (!empty($catid)) + { @@ -268,3 +227 @@ - if ($optioncss != '') { - print ''; - } + if ($optioncss != '') print ''; @@ -272,3 +229 @@ - if ($fourn_id > 0) { - print ''; - } + if ($fourn_id > 0) print ''; @@ -277 +232 @@ - print ''; + print ''; @@ -286 +240,0 @@ - print '