Nouveau fichier
This commit is contained in:
parent
e27e5012ae
commit
2932a4e5e4
295
htdocs/product/reassort.php
Normal file
295
htdocs/product/reassort.php
Normal file
@ -0,0 +1,295 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/product/liste.php
|
||||
\ingroup produit
|
||||
\brief Page liste des produits ou services
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/product.class.php');
|
||||
require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php");
|
||||
|
||||
$langs->load("products");
|
||||
|
||||
$user->getrights('produit');
|
||||
|
||||
if (!$user->rights->produit->lire)
|
||||
accessforbidden();
|
||||
|
||||
|
||||
$sref=isset($_GET["sref"])?$_GET["sref"]:$_POST["sref"];
|
||||
$snom=isset($_GET["snom"])?$_GET["snom"]:$_POST["snom"];
|
||||
$sall=isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"];
|
||||
$type=isset($_GET["type"])?$_GET["type"]:$_POST["type"];
|
||||
$sref=trim($sref);
|
||||
$snom=trim($snom);
|
||||
$sall=trim($sall);
|
||||
$type=trim($type);
|
||||
|
||||
$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
|
||||
$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
|
||||
if (! $sortfield) $sortfield="stock";
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
$page = $_GET["page"];
|
||||
$limit = $conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
|
||||
if (isset($_POST["button_removefilter_x"]))
|
||||
{
|
||||
$sref="";
|
||||
$snom="";
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['catid']))
|
||||
{
|
||||
$catid = $_REQUEST['catid'];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Affichage mode liste
|
||||
*
|
||||
*/
|
||||
|
||||
$title=$langs->trans("ProductsAndServices");
|
||||
|
||||
$sql = 'SELECT p.rowid, p.ref, p.label, p.price, p.fk_product_type, '.$db->pdate('p.tms').' as datem,';
|
||||
$sql.= ' p.duration, p.envente as statut,';
|
||||
$sql.= ' SUM(reel) as stock';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; // '.MAIN_DB_PREFIX.'product_det as d'; //en attendant le debugage
|
||||
$sql.= ',' .MAIN_DB_PREFIX.'product_stock as s';
|
||||
if ($catid || ($conf->categorie->enabled && !$user->rights->categorie->voir))
|
||||
{
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
|
||||
}
|
||||
|
||||
if ($_GET["fourn_id"] > 0)
|
||||
{
|
||||
$fourn_id = $_GET["fourn_id"];
|
||||
$sql .= ", ".MAIN_DB_PREFIX."product_fournisseur as pf";
|
||||
}
|
||||
$sql .= " WHERE p.rowid = s.fk_product";
|
||||
if ($sall)
|
||||
{
|
||||
$sql .= " AND (p.ref like '%".$sall."%' OR p.label like '%".$sall."%' OR p.description like '%".$sall."%' OR p.note like '%".$sall."%')";
|
||||
}
|
||||
if (strlen($_GET["type"]) || strlen($_POST["type"]))
|
||||
{
|
||||
$sql .= " AND p.fk_product_type = ".(strlen($_GET["type"])?$_GET["type"]:$_POST["type"]);
|
||||
}
|
||||
if ($sref)
|
||||
{
|
||||
$sql .= " AND p.ref like '%".$sref."%'";
|
||||
}
|
||||
if ($snom)
|
||||
{
|
||||
$sql .= " AND p.label like '%".$snom."%'";
|
||||
}
|
||||
if (isset($_GET["envente"]) && strlen($_GET["envente"]) > 0)
|
||||
{
|
||||
$sql .= " AND p.envente = ".$_GET["envente"];
|
||||
}
|
||||
if($catid)
|
||||
{
|
||||
$sql .= " AND cp.fk_categorie = ".$catid;
|
||||
}
|
||||
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
|
||||
{
|
||||
$sql.= ' AND IFNULL(c.visible,1)=1';
|
||||
}
|
||||
if ($fourn_id > 0)
|
||||
{
|
||||
$sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id;
|
||||
}
|
||||
$sql .= " GROUP BY p.rowid";
|
||||
$sql .= " ORDER BY $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;
|
||||
}
|
||||
|
||||
if (isset($_GET["envente"]) || isset($_POST["envente"]))
|
||||
{
|
||||
$envente = (isset($_GET["envente"])?$_GET["envente"]:$_POST["envente"]);
|
||||
}
|
||||
|
||||
if (isset($_GET["type"]) || isset($_POST["type"]))
|
||||
{
|
||||
$type=isset($_GET["type"])?$_GET["type"]:$_POST["type"];
|
||||
if ($type) { $texte = $langs->trans("Services"); }
|
||||
else { $texte = $langs->trans("Products"); }
|
||||
} else {
|
||||
$texte = $langs->trans("ProductsAndServices");
|
||||
}
|
||||
|
||||
|
||||
llxHeader("","",$texte);
|
||||
|
||||
if ($sref || $snom || $sall || $_POST["search"])
|
||||
{
|
||||
print_barre_liste($texte, $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&envente=".$_POST["envente"], $sortfield, $sortorder,'',$num);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_barre_liste($texte, $page, "reassort.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":""), $sortfield, $sortorder,'',$num);
|
||||
}
|
||||
|
||||
if (isset($catid))
|
||||
{
|
||||
print "<div id='ways'>";
|
||||
$c = new Categorie ($db, $catid);
|
||||
$ways = $c->print_all_ways(' > ','product/reassort.php');
|
||||
print " > ".$ways[0]."<br />\n";
|
||||
print "</div><br />";
|
||||
}
|
||||
|
||||
print '<table class="liste" width="100%">';
|
||||
|
||||
// Lignes des titres
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print_liste_field_titre($langs->trans("Ref"),"reassort.php", "p.ref","&envente=$envente".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Label"),"reassort.php", "p.label","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("DateModification"),"reassort.php", "p.tms","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="center"',$sortfield);
|
||||
if ($conf->service->enabled && $type != 0) print_liste_field_titre($langs->trans("Duration"),"reassort.php", "p.duration","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Stock"),"reassort.php", "stock","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Status"),"reassort.php", "p.envente","&envente=$envente&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="center"',$sortfield);
|
||||
print "</tr>\n";
|
||||
|
||||
// Lignes des champs de filtre
|
||||
print '<form action="reassort.php" method="post" name="formulaire">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="type" value="'.$type.'">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre">';
|
||||
print '<input class="flat" type="text" name="sref" value="'.$sref.'">';
|
||||
print '</td>';
|
||||
print '<td class="liste_titre" valign="right">';
|
||||
print '<input class="flat" type="text" name="snom" value="'.$snom.'">';
|
||||
print '</td>';
|
||||
if ($conf->service->enabled && $type != 0)
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
}
|
||||
print '<td class="liste_titre">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
print '<td class="liste_titre">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
print '<td class="liste_titre" align="right">';
|
||||
print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
|
||||
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" alt="'.$langs->trans("RemoveFilter").'">';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '</form>';
|
||||
|
||||
$product_static=new Product($db);
|
||||
|
||||
$var=True;
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
// Multilangs
|
||||
if ($conf->global->MAIN_MULTILANGS) // si l'option est active
|
||||
{
|
||||
$sql = "SELECT label FROM ".MAIN_DB_PREFIX."product_det";
|
||||
$sql.= " WHERE fk_product=".$objp->rowid." AND lang='". $langs->getDefaultLang() ."'";
|
||||
$sql.= " LIMIT 1";
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$objtp = $db->fetch_object($result);
|
||||
if ($objtp->label != '') $objp->label = $objtp->label;
|
||||
}
|
||||
}
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td nowrap="nowrap">';
|
||||
print "<a href=\"fiche.php?id=$objp->rowid\">";
|
||||
if ($objp->fk_product_type) print img_object($langs->trans("ShowService"),"service");
|
||||
else print img_object($langs->trans("ShowProduct"),"product");
|
||||
print '</a> ';
|
||||
print '<a href="fiche.php?id='.$objp->rowid.'">'.$objp->ref.'</a></td>';
|
||||
print '<td>'.$objp->label.'</td>';
|
||||
print '<td align="center">'.dolibarr_print_date($objp->datem).'</td>';
|
||||
if ($conf->service->enabled && $type != 0)
|
||||
{
|
||||
print '<td align="center">';
|
||||
if (eregi('([0-9]+)y',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear");
|
||||
elseif (eregi('([0-9]+)m',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth");
|
||||
elseif (eregi('([0-9]+)d',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay");
|
||||
else print $objp->duration;
|
||||
print '</td>';
|
||||
}
|
||||
print '<td align="right">'.$objp->stock.'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.$product_static->LibStatut($objp->statut,5).'</td>';
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($num > $conf->liste_limit)
|
||||
{
|
||||
if ($sref || $snom || $sall || $_POST["search"])
|
||||
{
|
||||
print_barre_liste($texte, $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&envente=".$_POST["envente"], $sortfield, $sortorder,'',$num);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_barre_liste($texte, $page, "reassort.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":""), $sortfield, $sortorder,'',$num);
|
||||
}
|
||||
}
|
||||
|
||||
$db->free($resql);
|
||||
|
||||
print "</table>";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user