From 8d00838fa59065584ec88c0fccb7d2e0b558cc57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Salvador?= Date: Tue, 4 Jun 2013 18:25:15 +0200 Subject: [PATCH] moved page + added link in the left menu --- htdocs/product/replenish.php | 541 ------------------- htdocs/product/stock/replenish.php | 826 +++++++++++++++-------------- 2 files changed, 415 insertions(+), 952 deletions(-) delete mode 100644 htdocs/product/replenish.php diff --git a/htdocs/product/replenish.php b/htdocs/product/replenish.php deleted file mode 100644 index d09079f818b..00000000000 --- a/htdocs/product/replenish.php +++ /dev/null @@ -1,541 +0,0 @@ - - * - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/product/replenish.php - * \ingroup produit - * \brief Page to list stocks - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; -require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - -$langs->load("products"); -$langs->load("stocks"); -$langs->load("orders"); - -// Security check -if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'produit|service'); - - -$action=GETPOST('action','alpha'); -$sref=GETPOST("sref"); -$snom=GETPOST("snom"); -$sall=GETPOST("sall"); -$type=GETPOST("type","int"); -$sbarcode=GETPOST("sbarcode"); -$catid=GETPOST('catid','int'); -$tobuy = GETPOST("tobuy"); - -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -$page = GETPOST("page",'int'); -if (! $sortfield) $sortfield="stock_physique"; -if (! $sortorder) $sortorder="ASC"; -$limit = $conf->liste_limit; -$offset = $limit * $page ; - -// Load sale and categ filters -$search_sale = GETPOST("search_sale"); -$search_categ = GETPOST("search_categ"); - -// Get object canvas (By default, this is not defined, so standard usage of dolibarr) -//$object->getCanvas($id); -$canvas=GETPOST("canvas"); -$objcanvas=''; -if (! empty($canvas)) -{ - require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; - $objcanvas = new Canvas($db,$action); - $objcanvas->getCanvas('product','list',$canvas); -} - -if (! empty($_POST["button_removefilter_x"])) -{ - $sref=""; - $snom=""; - $sall=""; - $search_sale=""; - $search_categ=""; - $type=""; - $catid=''; -} - - - -/* - * Actions - */ - -if($action == 'order'){ - $linecount = GETPOST('linecount', 'int'); - $suppliers = array(); - for($i = 0; $i < $linecount; $i++) { - if(GETPOST($i, 'alpha') === 'on') { //one line - $supplierpriceid = GETPOST('fourn'.$i, 'int'); - //get all the parameters needed to create a line - $qty = GETPOST('tobuy'.$i, 'int'); - $desc = GETPOST('desc'.$i, 'alpha'); - $sql = 'Select fk_product, fk_soc, ref_fourn'; - $sql .= ', tva_tx, unitprice'; - $sql .= ' from '.MAIN_DB_PREFIX.'product_fournisseur_price'; - $sql .= ' where rowid = '.$supplierpriceid; - $resql = $db->query($sql); - if($resql && $db->num_rows($resql) > 0) { - //might need some value checks - $obj = $db->fetch_object($resql); - $line = new CommandeFournisseurLigne($db); - $line->qty = $qty; - $line->desc = $desc; - $line->fk_product = $obj->fk_product; - $line->tva_tx = $obj->tva_tx; - $line->subprice = $obj->unitprice; - $line->total_ht = $obj->unitprice * $qty; - $line->total_tva = $line->total_ht * $line->tva_tx / 100; - $line->total_ttc = $line->total_ht + $line->total_tva; - $line->ref_fourn = $obj->ref_fourn; - $suppliers[$obj->fk_soc]['lines'][] = $line; - } - } - } - //we now know how many orders we need and what lines they have - $i = 0; - $orders = array(); - $suppliersid = array_keys($suppliers); - foreach($suppliers as $supplier){ - $order = new CommandeFournisseur($db); - $order->socid = $suppliersid[$i]; - //little trick to know which orders have been generated this way - $order->source = 42; - foreach($supplier['lines'] as $line){ - $order->lines[] = $line; - } - $id = $order->create($user); - if($id < 0) { - //error stuff - } - $i++; - } -} - -/* - * View - */ - -$htmlother=new FormOther($db); - -$title=$langs->trans("Replenishment"); - -$sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,'; -$sql.= ' p.fk_product_type, p.tms as datem,'; -$sql.= ' p.duration, p.tobuy, p.seuil_stock_alerte,'; -$sql.= ' SUM(s.reel) as stock_physique'; -$sql .= ', p.desiredstock'; -$sql.= ' FROM ('.MAIN_DB_PREFIX.'product as p'; -// We'll need this table joined to the select in order to filter by categ -if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp"; -$sql .= ') LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf on p.rowid = pf.fk_product'; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product'; - -$sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; -if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ -if ($sall) -{ - $sql.= " AND (p.ref LIKE '%".$db->escape($sall)."%' OR p.label LIKE '%".$db->escape($sall)."%' OR p.description LIKE '%".$db->escape($sall)."%' OR p.note LIKE '%".$db->escape($sall)."%')"; -} -// if the type is not 1, we show all products (type = 0,2,3) -if (dol_strlen($type)) -{ - if ($type==1) - { - $sql.= " AND p.fk_product_type = '1'"; - } - else - { - $sql.= " AND p.fk_product_type <> '1'"; - } -} -if ($sref) $sql.= " AND p.ref LIKE '%".$sref."%'"; -if ($sbarcode) $sql.= " AND p.barcode LIKE '%".$sbarcode."%'"; -if ($snom) $sql.= " AND p.label LIKE '%".$db->escape($snom)."%'"; - -$sql.= " AND p.tobuy = 1"; - -if (! empty($canvas)) -{ - $sql.= " AND p.canvas = '".$db->escape($canvas)."'"; -} -if($catid) -{ - $sql.= " AND cp.fk_categorie = ".$catid; -} - - $sql.= " AND p.rowid = pf.fk_product"; - -// Insert categ filter -if ($search_categ) -{ - $sql .= " AND cp.fk_categorie = ".$db->escape($search_categ); -} -$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,"; -$sql.= " p.fk_product_type, p.tms,"; -$sql.= " p.duration, p.tobuy, p.seuil_stock_alerte"; -$sql .= ", p.desiredstock"; -$sql.= $db->order($sortfield,$sortorder); -$sql.= $db->plimit($limit + 1, $offset); -$resql = $db->query($sql); - -if ($resql) -{ - $num = $db->num_rows($resql); - - $i = 0; - - if ($num == 1 && ($sall or $snom or $sref)) - { - $objp = $db->fetch_object($resql); - header("Location: fiche.php?id=$objp->rowid"); - exit; - } - - $helpurl=''; - $helpurl='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; - $texte = $langs->trans('Replenishment'); - llxHeader("",$title,$helpurl,$texte); - - if ($sref || $snom || $sall || GETPOST('search')) - { - print_barre_liste($texte, $page, "replenish.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall, $sortfield, $sortorder,'',$num); - } - else - { - print_barre_liste($texte, $page, "replenish.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":""), $sortfield, $sortorder,'',$num); - } - - if (! empty($catid)) - { - print "
"; - $c = new Categorie($db); - $c->fetch($catid); - $ways = $c->print_all_ways(' > ','product/replenish.php'); - print " > ".$ways[0]."
\n"; - print "

"; - } - - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - - // Filter on categories - $moreforfilter=''; - if (! empty($conf->categorie->enabled)) - { - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$htmlother->select_categories(0,$search_categ,'search_categ'); - $moreforfilter.='           '; - } - if ($moreforfilter) - { - print ''; - print ''; - } - - $param=(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref"; - - // Lignes des titres - print ""; - print ""; - print_liste_field_titre($langs->trans("Ref"),"replenish.php", "p.ref",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"),"replenish.php", "p.label",$param,"","",$sortfield,$sortorder); - if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"),"replenish.php", "p.duration",$param,"",'align="center"',$sortfield,$sortorder); - //print_liste_field_titre($langs->trans("MininumStock"),"replenish.php", "p.seuil_stock_alerte",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DesiredStock"),"replenish.php", "p.desiredstock",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("PhysicalStock"),"replenish.php", "stock_physique",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("StockToBuy"),"replenish.php", "",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Supplier"),"replenish.php", "",$param,"",'align="right"',$sortfield,$sortorder); - print ''; - print "\n"; - - // Lignes des champs de filtre - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->service->enabled) && $type == 1) - { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $product_static=new Product($db); - - $var=True; - while ($i < min($num,$limit)) - { - $objp = $db->fetch_object($resql); - - // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active - { - $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$objp->rowid; - $sql.= " AND lang='". $langs->getDefaultLang() ."'"; - $sql.= " LIMIT 1"; - - $result = $db->query($sql); - if ($result) - { - $objtp = $db->fetch_object($result); - if (! empty($objtp->label)) $objp->label = $objtp->label; - } - } - - $var=!$var; - print ''; - print ''; - print ''; - print ''; - print ''; - - if (! empty($conf->service->enabled) && $type == 1) - { - print ''; - } - print ''; - print ''; - //depending on conf, use either physical stock or - //theoretical stock to compute the stock to buy value - ($conf->global->use_theoretical_stock? $stock = $objp->stock_théorique : $stock = $objp->stock_physique); - $stocktobuy = $objp->desiredstock - $stock; - print ''; - print ''; - $form = new Form($db); - print ''; - print ''; - print "\n"; - $i++; - } - print "
'; - print $moreforfilter; - print '
  
 '; - print ''; - print ''; - print ''; - print ''; - print ' '; - print '    '; - print ''; - print ''; - print '
'; - $product_static->ref=$objp->ref; - $product_static->id=$objp->rowid; - $product_static->type=$objp->fk_product_type; - print $product_static->getNomUrl(1,'',16); - //if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow")); - print ''.$objp->label.''; - if (preg_match('/([0-9]+)y/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); - elseif (preg_match('/([0-9]+)m/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth"); - elseif (preg_match('/([0-9]+)d/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay"); - else print $objp->duration; - print ''.$objp->desiredstock.''; - if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; - print $objp->stock_physique; - print ''.$stocktobuy.''.$form->select_product_fourn_price($product_static->id, "fourn".$i).' 
"; - print ''; - print ''; - print '
'; - print '
'; - - if ($num > $conf->liste_limit) - { - if ($sref || $snom || $sall || GETPOST('search')) - { - print_barre_liste('', $page, "replenish.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall, $sortfield, $sortorder,'',$num, 0, ''); - } - else - { - print_barre_liste('', $page, "replenish.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":""), $sortfield, $sortorder,'',$num, 0, ''); - } - } - - $db->free($resql); - -} -else -{ - dol_print_error($db); -} - -$commandestatic=new CommandeFournisseur($db); -$sref=GETPOST('search_ref'); -$snom=GETPOST('search_nom'); -$suser=GETPOST('search_user'); -$sttc=GETPOST('search_ttc'); -$sall=GETPOST('search_all'); - -$page = GETPOST('page','int'); -/*$sortorder = GETPOST('sortorder','alpha'); -$sortfield = GETPOST('sortfield','alpha');*/ -$sortorder="DESC"; -$sortfield="cf.date_creation"; -$offset = $conf->liste_limit * $page ; -$sql = "SELECT s.rowid as socid, s.nom, cf.date_creation as dc,"; -$sql.= " cf.rowid,cf.ref, cf.fk_statut, cf.total_ttc, cf.fk_user_author,"; -$sql.= " u.login"; -$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,"; -$sql.= " ".MAIN_DB_PREFIX."commande_fournisseur as cf"; -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= ")"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON cf.fk_user_author = u.rowid"; -$sql.= " WHERE cf.fk_soc = s.rowid "; -$sql.= " AND cf.entity = ".$conf->entity; -$sql.= " AND cf.source = 42"; -$sql.= " AND cf.fk_statut < 5"; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($sref) -{ - $sql.= " AND cf.ref LIKE '%".$db->escape($sref)."%'"; -} -if ($snom) -{ - $sql.= " AND s.nom LIKE '%".$db->escape($snom)."%'"; -} -if ($suser) -{ - $sql.= " AND u.login LIKE '%".$db->escape($suser)."%'"; -} -if ($sttc) -{ - $sql .= " AND total_ttc = ".price2num($sttc); -} -if ($sall) -{ - $sql.= " AND (cf.ref LIKE '%".$db->escape($sall)."%' OR cf.note LIKE '%".$db->escape($sall)."%')"; -} -if ($socid) $sql.= " AND s.rowid = ".$socid; - -if (GETPOST('statut')) -{ - $sql .= " AND fk_statut =".GETPOST('statut'); -} - -$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); -$resql = $db->query($sql); -if ($resql) -{ - - $num = $db->num_rows($resql); - $i = 0; - - - print_barre_liste($langs->trans('ReplenishmentOrders'), $page, "replenish.php", "", $sortfield, $sortorder, '', $num); - print '
'; - print ''; - print ''; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"","","",'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"","","",'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Author"),$_SERVER["PHP_SELF"],"","","",'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"","","",'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("OrderCreation"),$_SERVER["PHP_SELF"],"","","",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"","","",'align="right"',$sortfield,$sortorder); - print "\n"; - - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $var=true; - - $userstatic = new User($db); - - while ($i < min($num,$conf->liste_limit)) - { - $obj = $db->fetch_object($resql); - $var=!$var; - - print ""; - - // Ref - print ''."\n"; - - // Company - print ''."\n"; - - // Author - $userstatic->id=$obj->fk_user_author; - $userstatic->login=$obj->login; - print ""; - - // Amount - print '"; - - // Date - print "'; - - // Statut - print ''; - - print "\n"; - $i++; - } - print "
'; - print ''; - print '
'.img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref.''.img_object($langs->trans("ShowCompany"),"company").' '; - print $obj->nom.'"; - if ($userstatic->id) print $userstatic->getLoginUrl(1); - else print " "; - print "'.price($obj->total_ttc).""; - if ($obj->dc) - { - print dol_print_date($db->jdate($obj->dc),"day"); - } - else - { - print "-"; - } - print ''.$commandestatic->LibStatut($obj->fk_statut, 5).'
\n"; - print "
\n"; - - $db->free($resql); -} - -llxFooter(); -$db->close(); -?> diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 105fe45c739..70679319158 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -17,15 +17,16 @@ */ /** - * \file htdocs/product/stock/replenish.php + * \file htdocs/product/replenish.php * \ingroup produit - * \brief Page to list stocks to replenish + * \brief Page to list stocks */ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; $langs->load("products"); @@ -33,346 +34,267 @@ $langs->load("stocks"); $langs->load("orders"); // Security check -if ($user->societe_id) { - $socid = $user->societe_id; -} +if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service'); -//checks if a product has been ordered -function ordered($product_id) -{ - global $db; - $sql = 'SELECT DISTINCT cfd.fk_product, SUM(cfd.qty) from '; - $sql .= MAIN_DB_PREFIX . 'commande_fournisseurdet as cfd '; - $sql .= 'LEFT JOIN ' . MAIN_DB_PREFIX . 'commande_fournisseur as cf'; - $sql .= ' ON cfd.fk_commande = cf.rowid WHERE cf.source = 42 '; - $sql .= 'AND cf.fk_statut < 5 AND cfd.fk_product = ' . $product_id; - $sql .= ' GROUP BY cfd.fk_product'; - $resql = $db->query($sql); - if ($resql) { - $exists = $db->num_rows($resql); - if ($exists) { - $obj = $db->fetch_array($resql); +$action=GETPOST('action','alpha'); +$sref=GETPOST("sref"); +$snom=GETPOST("snom"); +$sall=GETPOST("sall"); +$type=GETPOST("type","int"); +$sbarcode=GETPOST("sbarcode"); +$catid=GETPOST('catid','int'); +$tobuy = GETPOST("tobuy"); - return $obj['SUM(cfd.qty)'] . ' ' . img_picto('','tick'); - } else { - return img_picto('', 'stcomm-1'); - } - } else { - $error = $db->lasterror(); - dol_print_error($db); - dol_syslog('replenish.php: ' . $error, LOG_ERROR); - - return $langs->trans('error'); - } -} - -$action = GETPOST('action','alpha'); -$sref = GETPOST('sref'); -$snom = GETPOST('snom'); -$sall = GETPOST('sall'); -$type = GETPOST('type','int'); -$tobuy = GETPOST('tobuy'); - -$sortfield = GETPOST('sortfield','alpha'); -$sortorder = GETPOST('sortorder','alpha'); -$page = GETPOST('page','int'); - -if (!$sortfield) { - $sortfield = 'p.ref'; -} - -if (!$sortorder) { - $sortorder = 'ASC'; -} +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if (! $sortfield) $sortfield="stock_physique"; +if (! $sortorder) $sortorder="ASC"; $limit = $conf->liste_limit; $offset = $limit * $page ; +// Load sale and categ filters +$search_sale = GETPOST("search_sale"); +$search_categ = GETPOST("search_categ"); + +// Get object canvas (By default, this is not defined, so standard usage of dolibarr) +//$object->getCanvas($id); +$canvas=GETPOST("canvas"); +$objcanvas=''; +if (! empty($canvas)) +{ + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db,$action); + $objcanvas->getCanvas('product','list',$canvas); +} + +if (! empty($_POST["button_removefilter_x"])) +{ + $sref=""; + $snom=""; + $sall=""; + $search_sale=""; + $search_categ=""; + $type=""; + $catid=''; +} + + + /* * Actions */ - -//orders creation -if ($action == 'order') { + +if($action == 'order'){ $linecount = GETPOST('linecount', 'int'); - unset($_POST['linecount']); - if ($linecount > 0) { - $suppliers = array(); - for ($i = 0; $i < $linecount; $i++) { - if(GETPOST($i, 'alpha') === 'on' - && GETPOST('fourn' . $i, 'int') > 0) { //one line - $supplierpriceid = GETPOST('fourn'.$i, 'int'); - //get all the parameters needed to create a line - $qty = GETPOST('tobuy'.$i, 'int'); - $desc = GETPOST('desc'.$i, 'alpha'); - $sql = 'SELECT fk_product, fk_soc, ref_fourn'; - $sql .= ', tva_tx, unitprice FROM '; - $sql .= MAIN_DB_PREFIX . 'product_fournisseur_price'; - $sql .= ' WHERE rowid = ' . $supplierpriceid; - $resql = $db->query($sql); - if ($resql && $db->num_rows($resql) > 0) { - //might need some value checks - $obj = $db->fetch_object($resql); - $line = new CommandeFournisseurLigne($db); - $line->qty = $qty; - $line->desc = $desc; - $line->fk_product = $obj->fk_product; - $line->tva_tx = $obj->tva_tx; - $line->subprice = $obj->unitprice; - $line->total_ht = $obj->unitprice * $qty; - $tva = $line->tva_tx / 100; - $line->total_tva = $line->total_ht * $tva; - $line->total_ttc = $line->total_ht + $line->total_tva; - $line->ref_fourn = $obj->ref_fourn; - $suppliers[$obj->fk_soc]['lines'][] = $line; - } else { - $error=$db->lasterror(); - dol_print_error($db); - dol_syslog('replenish.php: '.$error, LOG_ERROR); - } - $db->free($resql); - unset($_POST['fourn' . $i]); + $suppliers = array(); + for($i = 0; $i < $linecount; $i++) { + if(GETPOST($i, 'alpha') === 'on') { //one line + $supplierpriceid = GETPOST('fourn'.$i, 'int'); + //get all the parameters needed to create a line + $qty = GETPOST('tobuy'.$i, 'int'); + $desc = GETPOST('desc'.$i, 'alpha'); + $sql = 'Select fk_product, fk_soc, ref_fourn'; + $sql .= ', tva_tx, unitprice'; + $sql .= ' from '.MAIN_DB_PREFIX.'product_fournisseur_price'; + $sql .= ' where rowid = '.$supplierpriceid; + $resql = $db->query($sql); + if($resql && $db->num_rows($resql) > 0) { + //might need some value checks + $obj = $db->fetch_object($resql); + $line = new CommandeFournisseurLigne($db); + $line->qty = $qty; + $line->desc = $desc; + $line->fk_product = $obj->fk_product; + $line->tva_tx = $obj->tva_tx; + $line->subprice = $obj->unitprice; + $line->total_ht = $obj->unitprice * $qty; + $line->total_tva = $line->total_ht * $line->tva_tx / 100; + $line->total_ttc = $line->total_ht + $line->total_tva; + $line->ref_fourn = $obj->ref_fourn; + $suppliers[$obj->fk_soc]['lines'][] = $line; } - unset($_POST[$i]); } - //we now know how many orders we need and what lines they have - $i = 0; - $orders = array(); - $suppliersid = array_keys($suppliers); - foreach ($suppliers as $supplier) { - $order = new CommandeFournisseur($db); - $order->socid = $suppliersid[$i]; - //trick to know which orders have been generated this way - $order->source = 42; - foreach ($supplier['lines'] as $line) { - $order->lines[] = $line; - } - $id = $order->create($user); - if ($id < 0) { - $fail++; - setEventMessage($langs->trans('OrderFail'), 'errors'); - } - $i++; + } + //we now know how many orders we need and what lines they have + $i = 0; + $orders = array(); + $suppliersid = array_keys($suppliers); + foreach($suppliers as $supplier){ + $order = new CommandeFournisseur($db); + $order->socid = $suppliersid[$i]; + //little trick to know which orders have been generated this way + $order->source = 42; + foreach($supplier['lines'] as $line){ + $order->lines[] = $line; } - if (!$fail && $id) { - setEventMessage($langs->trans('OrderCreated'), 'mesgs'); - header('Location: replenishorders.php'); - exit; + $id = $order->create($user); + if($id < 0) { + //error stuff } + $i++; } } /* * View */ -$title = $langs->trans('Replenishment'); -$sql = 'SELECT p.rowid, p.ref, p.label, p.price'; -$sql .= ', p.price_ttc, p.price_base_type,p.fk_product_type'; -$sql .= ', p.tms as datem, p.duration, p.tobuy, p.seuil_stock_alerte,'; -$sql .= ' SUM(s.reel) as stock_physique'; +$htmlother=new FormOther($db); + +$title=$langs->trans("Replenishment"); + +$sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,'; +$sql.= ' p.fk_product_type, p.tms as datem,'; +$sql.= ' p.duration, p.tobuy, p.seuil_stock_alerte,'; +$sql.= ' SUM(s.reel) as stock_physique'; $sql .= ', p.desiredstock'; -$sql .= ' FROM ' . MAIN_DB_PREFIX . 'product as p'; -$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_fournisseur_price as pf'; -$sql .= ' ON p.rowid = pf.fk_product'; -$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_stock as s'; -$sql .= ' ON p.rowid = s.fk_product'; -$sql.= ' WHERE p.entity IN (' . getEntity("product", 1) . ')'; +$sql.= ' FROM ('.MAIN_DB_PREFIX.'product as p'; +// We'll need this table joined to the select in order to filter by categ +if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp"; +$sql .= ') LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf on p.rowid = pf.fk_product'; +$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product'; -if ($sall) { - $sql .= ' AND (p.ref LIKE "%'.$db->escape($sall).'%" '; - $sql .= 'OR p.label LIKE "%'.$db->escape($sall).'%" '; - $sql .= 'OR p.description LIKE "%'.$db->escape($sall).'%" '; - $sql .= 'OR p.note LIKE "%'.$db->escape($sall).'%")'; +$sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; +if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ +if ($sall) +{ + $sql.= " AND (p.ref LIKE '%".$db->escape($sall)."%' OR p.label LIKE '%".$db->escape($sall)."%' OR p.description LIKE '%".$db->escape($sall)."%' OR p.note LIKE '%".$db->escape($sall)."%')"; } // if the type is not 1, we show all products (type = 0,2,3) -if (dol_strlen($type)) { - if ($type == 1) { - $sql .= ' AND p.fk_product_type = 1'; - } else { - $sql .= ' AND p.fk_product_type != 1'; +if (dol_strlen($type)) +{ + if ($type==1) + { + $sql.= " AND p.fk_product_type = '1'"; + } + else + { + $sql.= " AND p.fk_product_type <> '1'"; } } -if ($sref) { - $sql .= ' AND p.ref LIKE "%' . $sref . '%"'; +if ($sref) $sql.= " AND p.ref LIKE '%".$sref."%'"; +if ($sbarcode) $sql.= " AND p.barcode LIKE '%".$sbarcode."%'"; +if ($snom) $sql.= " AND p.label LIKE '%".$db->escape($snom)."%'"; + +$sql.= " AND p.tobuy = 1"; + +if (! empty($canvas)) +{ + $sql.= " AND p.canvas = '".$db->escape($canvas)."'"; } -if ($snom) { - $sql .= ' AND p.label LIKE "%' . $db->escape($snom) . '%"'; +if($catid) +{ + $sql.= " AND cp.fk_categorie = ".$catid; } -$sql .= ' AND p.tobuy = 1'; + $sql.= " AND p.rowid = pf.fk_product"; -if (!empty($canvas)) { - $sql .= ' AND p.canvas = "' . $db->escape($canvas) . '"'; +// Insert categ filter +if ($search_categ) +{ + $sql .= " AND cp.fk_categorie = ".$db->escape($search_categ); } - - $sql .= ' AND p.rowid = pf.fk_product'; - -$sql .= ' GROUP BY p.rowid, p.ref, p.label, p.price'; -$sql .= ', p.price_ttc, p.price_base_type,p.fk_product_type, p.tms'; -$sql .= ', p.duration, p.tobuy, p.seuil_stock_alerte'; -$sql .= ', p.desiredstock'; -$sql .= ' HAVING p.desiredstock > SUM(s.reel) or SUM(s.reel) is NULL'; -$sql .= $db->order($sortfield,$sortorder); -$sql .= $db->plimit($limit + 1, $offset); +$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,"; +$sql.= " p.fk_product_type, p.tms,"; +$sql.= " p.duration, p.tobuy, p.seuil_stock_alerte"; +$sql .= ", p.desiredstock"; +$sql.= $db->order($sortfield,$sortorder); +$sql.= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); -if ($resql) { +if ($resql) +{ $num = $db->num_rows($resql); + $i = 0; - if ($num == 1 && ($sall or $snom or $sref)) { + + if ($num == 1 && ($sall or $snom or $sref)) + { $objp = $db->fetch_object($resql); - header('Location: ../fiche.php?id=' . $objp->rowid); + header("Location: fiche.php?id=$objp->rowid"); exit; } - $helpurl = 'EN:Module_Stocks_En|FR:Module_Stock|'; - $helpurl .= 'ES:Módulo_Stocks'; - llxHeader('', $title, $helpurl, $title); - $head = array(); - $head[0][0] = DOL_URL_ROOT.'/product/stock/replenish.php'; - $head[0][1] = $title; - $head[0][2] = 'replenish'; - $head[1][0] = DOL_URL_ROOT.'/product/stock/replenishorders.php'; - $head[1][1] = $langs->trans("ReplenishmentOrders"); - $head[1][2] = 'replenishorders'; - dol_fiche_head($head, 'replenish', $title, 0, 'stock'); - if ($sref || $snom || $sall || GETPOST('search')) { - $filters = '&sref=' . $sref . '&snom=' . $snom; - $filters .= '&sall=' . $sall; - print_barre_liste($texte, - $page, - 'replenish.php', - $filters, - $sortfield, - $sortorder, - '', - $num - ); - } else { - $filters = '&sref=' . $sref . '&snom=' . $snom; - $filters .= '&fourn_id=' . $fourn_id; - $filters .= (isset($type)?'&type=' . $type:''); - print_barre_liste($texte, - $page, - 'replenish.php', - $filters, - $sortfield, - $sortorder, - '', - $num); + $helpurl=''; + $helpurl='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; + $texte = $langs->trans('Replenishment'); + llxHeader("",$title,$helpurl,$texte); + + if ($sref || $snom || $sall || GETPOST('search')) + { + print_barre_liste($texte, $page, "replenish.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall, $sortfield, $sortorder,'',$num); + } + else + { + print_barre_liste($texte, $page, "replenish.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":""), $sortfield, $sortorder,'',$num); + } + + if (! empty($catid)) + { + print "
"; + $c = new Categorie($db); + $c->fetch($catid); + $ways = $c->print_all_ways(' > ','product/replenish.php'); + print " > ".$ways[0]."
\n"; + print "

"; } print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; print ''; - $param = (isset($type)? '&type=' . $type : ''); - $param .= '&fourn_id=' . $fourn_id . '&snom='. $snom; - $param .= '&sref=' . $sref; + // Filter on categories + $moreforfilter=''; + if (! empty($conf->categorie->enabled)) + { + $moreforfilter.=$langs->trans('Categories'). ': '; + $moreforfilter.=$htmlother->select_categories(0,$search_categ,'search_categ'); + $moreforfilter.='           '; + } + if ($moreforfilter) + { + print ''; + print ''; + } + + $param=(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref"; // Lignes des titres - print ''; + print ""; + print ""; + print_liste_field_titre($langs->trans("Ref"),"replenish.php", "p.ref",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"),"replenish.php", "p.label",$param,"","",$sortfield,$sortorder); + if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"),"replenish.php", "p.duration",$param,"",'align="center"',$sortfield,$sortorder); + //print_liste_field_titre($langs->trans("MininumStock"),"replenish.php", "p.seuil_stock_alerte",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DesiredStock"),"replenish.php", "p.desiredstock",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PhysicalStock"),"replenish.php", "stock_physique",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("StockToBuy"),"replenish.php", "",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Supplier"),"replenish.php", "",$param,"",'align="right"',$sortfield,$sortorder); print ''; - print_liste_field_titre($langs->trans('Ref'), - 'replenish.php', - 'p.ref', - $param, - '', - '', - $sortfield, - $sortorder - ); - print_liste_field_titre($langs->trans('Label'), - 'replenish.php', - 'p.label', - $param, - '', - '', - $sortfield, - $sortorder - ); - if (!empty($conf->service->enabled) && $type == 1) { - print_liste_field_titre($langs->trans('Duration'), - 'replenish.php', - 'p.duration', - $param, - '', - 'align="center"', - $sortfield, - $sortorder - ); - } - print_liste_field_titre($langs->trans('DesiredStock'), - 'replenish.php', - 'p.desiredstock', - $param, - '', - 'align="right"', - $sortfield, - $sortorder - ); - if ($conf->global->USE_VIRTUAL_STOCK) { - $stocklabel = $langs->trans('VirtualStock'); - } else { - $stocklabel = $langs->trans('PhysicalStock'); - } - print_liste_field_titre($stocklabel, - 'replenish.php', - 'stock_physique', - $param, - '', - 'align="right"', - $sortfield, - $sortorder - ); - print_liste_field_titre($langs->trans('StockToBuy'), - 'replenish.php', - '', - $param, - '', - 'align="right"', - $sortfield, - $sortorder - ); - print_liste_field_titre($langs->trans('Ordered'), - 'replenish.php', - '', - $param, - '', - 'align="right"', - $sortfield, - $sortorder - ); - print_liste_field_titre($langs->trans('Supplier'), - 'replenish.php', - '', - $param, - '', - 'align="right"', - $sortfield, - $sortorder - ); - print ''; - print ''; + print "\n"; // Lignes des champs de filtre print ''; print ''; print ''; print ''; - if (!empty($conf->service->enabled) && $type == 1) { + if (! empty($conf->service->enabled) && $type == 1) + { print ''; @@ -381,157 +303,239 @@ if ($resql) { print ''; print ''; print ''; - print ''; print ''; print ''; - $prod = new Product($db); + $product_static=new Product($db); - $var = True; - while ($i < min($num, $limit)) { + $var=True; + while ($i < min($num,$limit)) + { $objp = $db->fetch_object($resql); - if ($conf->global->STOCK_SUPPORTS_SERVICES - || $objp->fk_product_type == 0) { - // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) { - $sql = 'SELECT label'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'product_lang'; - $sql .= ' WHERE fk_product = ' . $objp->rowid; - $sql .= ' AND lang = "' . $langs->getDefaultLang() . '"'; - $sql .= ' LIMIT 1'; - $result = $db->query($sql); - if ($result) { - $objtp = $db->fetch_object($result); - if (!empty($objtp->label)) { - $objp->label = $objtp->label; - } - } - } + // Multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + { + $sql = "SELECT label"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql.= " WHERE fk_product=".$objp->rowid; + $sql.= " AND lang='". $langs->getDefaultLang() ."'"; + $sql.= " LIMIT 1"; - $var =! $var; - print ''; - print ''; - print ''; - print ''; - print ''; - - if (!empty($conf->service->enabled) && $type == 1) { - print ''; + $result = $db->query($sql); + if ($result) + { + $objtp = $db->fetch_object($result); + if (! empty($objtp->label)) $objp->label = $objtp->label; } - print ''; - print ''; - //depending on conf, use either physical stock or - //virtual stock to compute the stock to buy value - $stocktobuy = $objp->desiredstock - $stock; - print ''; - print ''; - print ''; - $form = new Form($db); - print ''; - print ''; - print ""; } + + $var=!$var; + print ''; + print ''; + print ''; + print ''; + print ''; + + if (! empty($conf->service->enabled) && $type == 1) + { + print ''; + } + print ''; + print ''; + //depending on conf, use either physical stock or + //theoretical stock to compute the stock to buy value + ($conf->global->use_theoretical_stock? $stock = $objp->stock_théorique : $stock = $objp->stock_physique); + $stocktobuy = $objp->desiredstock - $stock; + print ''; + print ''; + $form = new Form($db); + print ''; + print ''; + print "\n"; $i++; } print "
'; + print $moreforfilter; + print '
   
 '; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ' '; print '    '; - print ''; + print ''; + print ''; print '
'; - $prod->ref = $objp->ref; - $prod->id = $objp->rowid; - $prod->type = $objp->fk_product_type; - print $prod->getNomUrl(1, '', 16); - print '' . $objp->label . ''; - if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) { - print $regs[1] . ' ' . $langs->trans('DurationYear'); - } elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) { - print $regs[1] . ' ' . $langs->trans('DurationMonth'); - } elseif (preg_match('/([0-9]+)d/i', $objp->duration, $regs)) { - print $regs[1] . ' ' . $langs->trans('DurationDay'); - } else { - print $objp->duration; - } - print '' . $objp->desiredstock . ''; - if (!$objp->stock_physique) { - $objp->stock_physique = 0; - } - if ($conf->global->USE_VIRTUAL_STOCK) { - //compute virtual stock - $prod->fetch($prod->id); - $result=$prod->load_stats_commande(0, '1,2'); - if ($result < 0) { - dol_print_error($db, $prod->error); - } - $stock_commande_client = $prod->stats_commande['qty']; - $result=$prod->load_stats_commande_fournisseur(0, '3'); - if ($result < 0) { - dol_print_error($db,$prod->error); - } - $stock_commande_fournisseur = $prod->stats_commande_fournisseur['qty']; - $stock = $objp->stock_physique - $stock_commande_client + $stock_commande_fournisseur; - } else { - $stock = $objp->stock_physique; - } - if ($objp->seuil_stock_alerte - && ($stock < $objp->seuil_stock_alerte)) { - $warn = $langs->trans('StockTooLow'); - print img_warning($warn) . ' '; - } - print $stock; - print ''.$stocktobuy.''; - print ordered($prod->id); - print ''; - print $form->select_product_fourn_price($prod->id, - 'fourn' . $i, - 1 - ); - print ' 
'; + $product_static->ref=$objp->ref; + $product_static->id=$objp->rowid; + $product_static->type=$objp->fk_product_type; + print $product_static->getNomUrl(1,'',16); + //if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow")); + print ''.$objp->label.''; + if (preg_match('/([0-9]+)y/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); + elseif (preg_match('/([0-9]+)m/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth"); + elseif (preg_match('/([0-9]+)d/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay"); + else print $objp->duration; + print ''.$objp->desiredstock.''; + if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; + print $objp->stock_physique; + print ''.$stocktobuy.''.$form->select_product_fourn_price($product_static->id, "fourn".$i).' 
"; - print ''; print ''; - print '
'; - $value = $langs->trans("CreateOrders"); - print ''; - print '
'; + print ''; + print ''; print '
'; - if ($num > $conf->liste_limit) { - if ($sref || $snom || $sall || GETPOST('search')) { - $filters = '&sref=' . $sref . '&snom=' . $snom; - $filters .= '&sall=' . $sall; - print_barre_liste('', - $page, - 'replenish.php', - $filters, - $sortfield, - $sortorder, - '', - $num, - 0, - '' - ); - } else { - $filters = '&sref=' . $sref . '&snom=' . $snom; - $filters .= '&fourn_id=' . $fourn_id; - $filters .= (isset($type)? '&type=' . $type : ''); - print_barre_liste('', - $page, - 'replenish.php', - $filters, - $sortfield, - $sortorder, - '', - $num, - 0, - '' - ); + if ($num > $conf->liste_limit) + { + if ($sref || $snom || $sall || GETPOST('search')) + { + print_barre_liste('', $page, "replenish.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall, $sortfield, $sortorder,'',$num, 0, ''); + } + else + { + print_barre_liste('', $page, "replenish.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":""), $sortfield, $sortorder,'',$num, 0, ''); } } $db->free($resql); -} else { +} +else +{ dol_print_error($db); } +$commandestatic=new CommandeFournisseur($db); +$sref=GETPOST('search_ref'); +$snom=GETPOST('search_nom'); +$suser=GETPOST('search_user'); +$sttc=GETPOST('search_ttc'); +$sall=GETPOST('search_all'); + +$page = GETPOST('page','int'); +/*$sortorder = GETPOST('sortorder','alpha'); +$sortfield = GETPOST('sortfield','alpha');*/ +$sortorder="DESC"; +$sortfield="cf.date_creation"; +$offset = $conf->liste_limit * $page ; +$sql = "SELECT s.rowid as socid, s.nom, cf.date_creation as dc,"; +$sql.= " cf.rowid,cf.ref, cf.fk_statut, cf.total_ttc, cf.fk_user_author,"; +$sql.= " u.login"; +$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,"; +$sql.= " ".MAIN_DB_PREFIX."commande_fournisseur as cf"; +if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql.= ")"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON cf.fk_user_author = u.rowid"; +$sql.= " WHERE cf.fk_soc = s.rowid "; +$sql.= " AND cf.entity = ".$conf->entity; +$sql.= " AND cf.source = 42"; +$sql.= " AND cf.fk_statut < 5"; +if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +if ($sref) +{ + $sql.= " AND cf.ref LIKE '%".$db->escape($sref)."%'"; +} +if ($snom) +{ + $sql.= " AND s.nom LIKE '%".$db->escape($snom)."%'"; +} +if ($suser) +{ + $sql.= " AND u.login LIKE '%".$db->escape($suser)."%'"; +} +if ($sttc) +{ + $sql .= " AND total_ttc = ".price2num($sttc); +} +if ($sall) +{ + $sql.= " AND (cf.ref LIKE '%".$db->escape($sall)."%' OR cf.note LIKE '%".$db->escape($sall)."%')"; +} +if ($socid) $sql.= " AND s.rowid = ".$socid; + +if (GETPOST('statut')) +{ + $sql .= " AND fk_statut =".GETPOST('statut'); +} + +$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); +$resql = $db->query($sql); +if ($resql) +{ + + $num = $db->num_rows($resql); + $i = 0; + + + print_barre_liste($langs->trans('ReplenishmentOrders'), $page, "replenish.php", "", $sortfield, $sortorder, '', $num); + print '
'; + print ''; + print ''; + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"","","",'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"","","",'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Author"),$_SERVER["PHP_SELF"],"","","",'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"","","",'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("OrderCreation"),$_SERVER["PHP_SELF"],"","","",'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"","","",'align="right"',$sortfield,$sortorder); + print "\n"; + + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $var=true; + + $userstatic = new User($db); + + while ($i < min($num,$conf->liste_limit)) + { + $obj = $db->fetch_object($resql); + $var=!$var; + + print ""; + + // Ref + print ''."\n"; + + // Company + print ''."\n"; + + // Author + $userstatic->id=$obj->fk_user_author; + $userstatic->login=$obj->login; + print ""; + + // Amount + print '"; + + // Date + print "'; + + // Statut + print ''; + + print "\n"; + $i++; + } + print "
'; + print ''; + print '
'.img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref.''.img_object($langs->trans("ShowCompany"),"company").' '; + print $obj->nom.'"; + if ($userstatic->id) print $userstatic->getLoginUrl(1); + else print " "; + print "'.price($obj->total_ttc).""; + if ($obj->dc) + { + print dol_print_date($db->jdate($obj->dc),"day"); + } + else + { + print "-"; + } + print ''.$commandestatic->LibStatut($obj->fk_statut, 5).'
\n"; + print "
\n"; + + $db->free($resql); +} + llxFooter(); $db->close(); +?>