* * 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 '
'; print ''; print ''; print ''; print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'product', 0, '', '', $limit, 0, 0, 1); // Info box print '
'; print $langs->trans('NewProductsToReviewDesc', 'New'); print '

'; print '
'; print ''; // Header row with search fields print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // Column headers 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); print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'p.fk_product_type', '', $param, '', $sortfield, $sortorder); print_liste_field_titre('SellingPrice', $_SERVER["PHP_SELF"], 'p.price', '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre('OnSell', $_SERVER["PHP_SELF"], 'p.tosell', '', $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre('OnBuy', $_SERVER["PHP_SELF"], 'p.tobuy', '', $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], 'p.datec', '', $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre('', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); print ''; // Data rows $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); if (!$obj) { break; } $product_static = new Product($db); $product_static->id = $obj->rowid; $product_static->ref = $obj->ref; $product_static->label = $obj->label; $product_static->type = $obj->fk_product_type; $product_static->entity = $obj->entity; $product_static->status = $obj->tosell; $product_static->status_buy = $obj->tobuy; print ''; // Ref print ''; // Label print ''; // Type print ''; // Price print ''; // On sell print ''; // On buy print ''; // Date creation print ''; // Action column print ''; print ''; $i++; } if ($num == 0) { print ''; } print '
'.$form->selectyesno('search_tosell', $search_tosell, 1, false, 1, 1).''.$form->selectyesno('search_tobuy', $search_tobuy, 1, false, 1, 1).''; print ''; print ''; print '
'; print $product_static->getNomUrl(1); print ''.dol_escape_htmltag($obj->label).''; if ($obj->fk_product_type == 0) { print $langs->trans('Product'); } else { print $langs->trans('Service'); } print ''; if ($obj->price_base_type == 'TTC') { print ''.price($obj->price_ttc).''; } else { print ''.price($obj->price).''; } print ''; print $product_static->LibStatut($obj->tosell, 5, 0); print ''; print $product_static->LibStatut($obj->tobuy, 5, 1); print ''; print dol_print_date($db->jdate($obj->datec), 'dayhour'); print ''; print ''; print img_picto($langs->trans('Edit'), 'edit'); print ''; print '
'.$langs->trans("NoRecordFound").'
'; print '
'; print '
'; // End of page llxFooter(); $db->close();