Fix: Search in stock area

New: Add list of last stock movements
This commit is contained in:
Laurent Destailleur 2008-11-26 12:18:57 +00:00
parent 44a8179a5a
commit 0e1fc52054
3 changed files with 67 additions and 12 deletions

View File

@ -49,7 +49,7 @@ print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
print '<td colspan="3">'.$langs->trans("Search").'</td></tr>';
print "<tr $bc[0]><td>";
print $langs->trans("Ref").':</td><td><input class="flat" type="text" size="18" name="sf_ref"></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print $langs->trans("Ref").':</td><td><input class="flat" type="text" size="18" name="sref"></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print "<tr $bc[0]><td>".$langs->trans("Other").':</td><td><input type="text" name="sall" class="flat" size="18"></td>';
print "</table></form><br>";
@ -94,6 +94,63 @@ else
print '</td><td valign="top" width="70%" class="notopnoleft">';
// Last movements
$max=10;
$sql = "SELECT p.rowid, p.label as produit,";
$sql.= " s.label as stock, s.rowid as entrepot_id,";
$sql.= " m.value, ".$db->pdate("m.datem")." as datem";
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as s, ".MAIN_DB_PREFIX."stock_mouvement as m, ".MAIN_DB_PREFIX."product as p";
if ($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";
}
$sql .= " WHERE m.fk_product = p.rowid AND m.fk_entrepot = s.rowid";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " AND IFNULL(c.visible,1)=1";
}
$sql .= " ORDER BY datem DESC";
$sql .= $db->plimit($max,0);
dolibarr_syslog("Index:list stock movements sql=".$sql, LOG_DEBUG);
$resql = $db->query($sql) ;
if ($resql)
{
$num = $db->num_rows($resql);
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
print '<td>'.$langs->trans("LastMovements",min($num,$max)).'</td>';
print '<td>'.$langs->trans("Product").'</td>';
print '<td>'.$langs->trans("Warehouse").'</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/product/stock/mouvement.php">'.$langs->trans("FullList").'</a></td>';
print "</tr>\n";
$var=True;
$i=0;
while ($i < min($num,$max))
{
$objp = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>'.dolibarr_print_date($objp->datem,'dayhour').'</td>';
print "<td><a href=\"../fiche.php?id=$objp->rowid\">";
print img_object($langs->trans("ShowProduct"),"product").' '.$objp->produit;
print "</a></td>\n";
print '<td><a href="fiche.php?id='.$objp->entrepot_id.'">';
print img_object($langs->trans("ShowWarehouse"),"stock").' '.$objp->stock;
print "</a></td>\n";
print '<td align="right">';
if ($objp->value > 0) print '+';
print $objp->value.'</td>';
print "</tr>\n";
$i++;
}
$db->free($resql);
print "</table>";
}
print '</td></tr></table>';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -15,16 +15,13 @@
* 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/stock/liste.php
\ingroup stock
\brief Page liste des stocks
\version $Revision$
\version $Id$
*/
require("./pre.inc.php");
@ -49,16 +46,16 @@ $limit = $conf->liste_limit;
$offset = $limit * $page;
$sql = "SELECT e.rowid as ref, e.label, e.statut, e.lieu, e.address, e.cp, e.ville, e.fk_pays";
$sql = "SELECT e.rowid, e.label as ref, e.statut, e.lieu, e.address, e.cp, e.ville, e.fk_pays";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql .= " WHERE 1=1";
if ($sref)
{
$sql .= " AND e.ref like '%".$sref."%'";
$sql .= " AND e.label like '%".$sref."%'";
}
if ($sall)
{
$sql .= " AND (e.label like '%".$sall."%' OR e.description like '%".$sall."%' OR e.lieu like '%".$sall."%' OR e.address like '%".$sall."%' OR e.ville like '%".$sall."%')";
$sql .= " AND (e.description like '%".$sall."%' OR e.lieu like '%".$sall."%' OR e.address like '%".$sall."%' OR e.ville like '%".$sall."%')";
}
$sql .= " ORDER BY $sortfield $sortorder";
$sql .= $db->plimit($limit + 1 ,$offset);
@ -91,7 +88,7 @@ if ($result)
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="fiche.php?id='.$objp->ref.'">'.img_object($langs->trans("ShowWarehouse"),'stock').' '.$objp->label.'</a></td>';
print '<td><a href="fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowWarehouse"),'stock').' '.$objp->ref.'</a></td>';
print '<td>'.$objp->lieu.'</td>';
print '<td align="right">'.$entrepot->LibStatut($objp->statut,5).'</td>';
print "</tr>\n";

View File

@ -77,7 +77,7 @@ if ($resql)
$result = $entrepot->fetch($_GET["id"]);
if ($result < 0)
{
dolibarr_print_error($db);
dolibarr_print_error($db);
}
}
@ -142,7 +142,8 @@ if ($resql)
$param="&id=".$_GET["id"]."&sref=$sref&snom=$snom";
print_barre_liste($texte, $page, "mouvement.php", $param, $sortfield, $sortorder,'',$num,0,'');
if ($_GET["id"]) print_barre_liste($texte, $page, "mouvement.php", $param, $sortfield, $sortorder,'',$num,0,'');
else print_barre_liste($texte, $page, "mouvement.php", $param, $sortfield, $sortorder,'',$num);
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";