* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ /** * \file new_products.php * \ingroup importzugferd * \brief List of products starting with "New" that need review after import */ // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; // Load translation files $langs->loadLangs(array('products', 'stocks', 'importzugferd@importzugferd')); // Security check if (!$user->hasRight('produit', 'lire')) { accessforbidden(); } // Get parameters $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $optioncss = GETPOST('optioncss', 'alpha'); // Search Criteria $search_ref = GETPOST("search_ref", 'alpha'); $search_label = GETPOST("search_label", 'alpha'); $search_tosell = GETPOST("search_tosell"); $search_tobuy = GETPOST("search_tobuy"); // Load variable for pagination $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortfield) { $sortfield = "p.datec"; } if (!$sortorder) { $sortorder = "DESC"; } // Initialize objects $object = new Product($db); $form = new Form($db); $arrayfields = array( 'p.ref' => array('label' => 'Ref', 'checked' => 1, 'position' => 10), 'p.label' => array('label' => 'Label', 'checked' => 1, 'position' => 20), 'p.fk_product_type' => array('label' => 'Type', 'checked' => 1, 'position' => 30), 'p.price' => array('label' => 'SellingPrice', 'checked' => 1, 'position' => 40), 'p.price_ttc' => array('label' => 'SellingPriceTTC', 'checked' => 0, 'position' => 41), 'p.tosell' => array('label' => 'OnSell', 'checked' => 1, 'position' => 50), 'p.tobuy' => array('label' => 'OnBuy', 'checked' => 1, 'position' => 60), 'p.datec' => array('label' => 'DateCreation', 'checked' => 1, 'position' => 70), ); /* * Actions */ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $search_ref = ''; $search_label = ''; $search_tosell = ''; $search_tobuy = ''; $toselect = array(); $search_array_options = array(); } /* * View */ $title = $langs->trans('NewProductsToReview'); $help_url = ''; llxHeader('', $title, $help_url); // Build SQL query $sql = "SELECT p.rowid, p.ref, p.label, p.fk_product_type, p.entity,"; $sql .= " p.price, p.price_ttc, p.price_base_type, p.tva_tx,"; $sql .= " p.tosell, p.tobuy, p.datec, p.tms"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " WHERE p.entity IN (".getEntity('product').")"; $sql .= " AND p.ref LIKE 'New%'"; // Add search filters if ($search_ref) { $sql .= natural_search('p.ref', $search_ref); } if ($search_label) { $sql .= natural_search('p.label', $search_label); } if ($search_tosell != '' && $search_tosell >= 0) { $sql .= " AND p.tosell = ".((int) $search_tosell); } if ($search_tobuy != '' && $search_tobuy >= 0) { $sql .= " AND p.tobuy = ".((int) $search_tobuy); } // Count total $sqlcount = preg_replace('/^SELECT[^F]*FROM/', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); $sqlcount = preg_replace('/ORDER BY.*$/', '', $sqlcount); $resqlcount = $db->query($sqlcount); $nbtotalofrecords = 0; if ($resqlcount) { $objcount = $db->fetch_object($resqlcount); $nbtotalofrecords = $objcount->nbtotalofrecords; } // Add sorting $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if (!$resql) { dol_print_error($db); exit; } $num = $db->num_rows($resql); $param = ''; if ($search_ref) { $param .= '&search_ref='.urlencode($search_ref); } if ($search_label) { $param .= '&search_label='.urlencode($search_label); } if ($search_tosell != '') { $param .= '&search_tosell='.urlencode($search_tosell); } if ($search_tobuy != '') { $param .= '&search_tobuy='.urlencode($search_tobuy); } if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } // List header print '
'; // End of page llxFooter(); $db->close();