[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/product/ -> liste.php (source)

   1  <?php
   2  /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18   *
  19   * $Id: liste.php,v 1.36 2005/11/27 21:42:01 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/product/liste.php,v $
  21   */
  22  
  23  /**
  24          \file       htdocs/product/liste.php
  25          \ingroup    produit
  26          \brief      Page liste des produits ou services
  27          \version    $Revision: 1.36 $
  28  */
  29  
  30  require ("./pre.inc.php");
  31  require_once(DOL_DOCUMENT_ROOT.'/product.class.php');
  32  
  33  $langs->load("products");
  34  
  35  $user->getrights('produit');
  36  
  37  if (!$user->rights->produit->lire)
  38    accessforbidden();
  39  
  40  
  41  $sref=isset($_GET["sref"])?$_GET["sref"]:$_POST["sref"];
  42  $snom=isset($_GET["snom"])?$_GET["snom"]:$_POST["snom"];
  43  $sall=isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"];
  44  $type=isset($_GET["type"])?$_GET["type"]:$_POST["type"];
  45  $sref=trim($sref);
  46  $snom=trim($snom);
  47  $sall=trim($sall);
  48  $type=trim($type);
  49  
  50  $sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
  51  $sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
  52  if (! $sortfield) $sortfield="p.ref";
  53  if (! $sortorder) $sortorder="DESC";
  54  $page = $_GET["page"];
  55  $limit = $conf->liste_limit;
  56  $offset = $limit * $page ;
  57  
  58  if (isset($_POST["button_removefilter_x"]))
  59  {
  60      $sref="";
  61      $snom="";
  62  }
  63  
  64  
  65  /*
  66   * Affichage mode liste
  67   *
  68   */
  69  
  70  $title=$langs->trans("ProductsAndServices");
  71  
  72  $sql = 'SELECT p.rowid, p.ref, p.label, p.price, p.fk_product_type, '.$db->pdate('p.tms').' as datem,';
  73  $sql.= ' p.duration, p.envente as statut';
  74  $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p';
  75  if ($_GET["fourn_id"] > 0)
  76  {
  77      $fourn_id = $_GET["fourn_id"];
  78      $sql .= ", ".MAIN_DB_PREFIX."product_fournisseur as pf";
  79  }
  80  $sql .= " WHERE 1=1";
  81  if ($sall)
  82  {
  83      $sql .= " AND (p.ref like '%".$sall."%' OR p.label like '%".$sall."%' OR p.description like '%".$sall."%' OR p.note like '%".$sall."%')";
  84  }
  85  if (strlen($_GET["type"]) || strlen($_POST["type"]))
  86  {
  87      $sql .= " AND p.fk_product_type = ".(strlen($_GET["type"])?$_GET["type"]:$_POST["type"]);
  88  }
  89  if ($sref)
  90  {
  91      $sql .= " AND p.ref like '%".$sref."%'";
  92  }
  93  if ($snom)
  94  {
  95      $sql .= " AND p.label like '%".$snom."%'";
  96  }
  97  if (isset($_GET["envente"]) && strlen($_GET["envente"]) > 0)
  98  {
  99      $sql .= " AND p.envente = ".$_GET["envente"];
 100  }
 101  if ($fourn_id > 0)
 102  {
 103      $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id;
 104  }
 105  $sql .= " ORDER BY $sortfield $sortorder ";
 106  $sql .= $db->plimit($limit + 1 ,$offset);
 107  $resql = $db->query($sql) ;
 108  
 109  if ($resql)
 110  {
 111      $num = $db->num_rows($resql);
 112  
 113      $i = 0;
 114  
 115      if ($num == 1 && (isset($_POST["sall"]) or $snom or $sref))
 116      {
 117          $objp = $db->fetch_object($resql);
 118          Header("Location: fiche.php?id=$objp->rowid");
 119      }
 120  
 121      if (isset($_GET["envente"]) || isset($_POST["envente"]))
 122      {
 123          $envente = (isset($_GET["envente"])?$_GET["envente"]:$_POST["envente"]);
 124      }
 125      else
 126      {
 127          $envente=1;
 128      }
 129  
 130      if (isset($_GET["type"]) || isset($_POST["type"]))
 131      {
 132          $type=isset($_GET["type"])?$_GET["type"]:$_POST["type"];
 133          if ($type) { $texte = $langs->trans("Services"); }
 134          else { $texte = $langs->trans("Products"); }
 135      } else {
 136          $texte = $langs->trans("ProductsAndServices");
 137      }
 138  
 139  
 140      llxHeader("","",$texte);
 141  
 142      if ($sref || $snom || $_POST["sall"] || $_POST["search"])
 143      {
 144          print_barre_liste($texte, $page, "liste.php", "&sref=".$sref."&snom=".$snom."&amp;envente=".$_POST["envente"], $sortfield, $sortorder,'',$num);
 145      }
 146      else
 147      {
 148          print_barre_liste($texte, $page, "liste.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&amp;type=$type":""), $sortfield, $sortorder,'',$num);
 149      }
 150  
 151      print '<table class="liste" width="100%">';
 152  
 153      // Lignes des titres
 154      print "<tr class=\"liste_titre\">";
 155      print_liste_field_titre($langs->trans("Ref"),"liste.php", "p.ref","&amp;envente=$envente".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","","",$sortfield);
 156      print_liste_field_titre($langs->trans("Label"),"liste.php", "p.label","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","","",$sortfield);
 157      print_liste_field_titre($langs->trans("DateModification"),"liste.php", "p.tms","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","",'align="center"',$sortfield);
 158      if ($conf->service->enabled && $type != 0) print_liste_field_titre($langs->trans("Duration"),"liste.php", "p.duration","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","",'align="center"',$sortfield);
 159      print_liste_field_titre($langs->trans("SellingPrice"),"liste.php", "p.price","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","",'align="right"',$sortfield);
 160      print_liste_field_titre($langs->trans("Status"),"liste.php", "p.envente","&envente=$envente&".(isset($type)?"&amp;type=$type":"")."&fourn_id=$fourn_id&amp;snom=$snom&amp;sref=$sref","",'align="center"',$sortfield);
 161      print "</tr>\n";
 162  
 163      // Lignes des champs de filtre
 164      print '<form action="liste.php" method="post" name="formulaire">';
 165      print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
 166      print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
 167      print '<input type="hidden" name="type" value="'.$type.'">';
 168      print '<tr class="liste_titre">';
 169      print '<td class="liste_titre">';
 170      print '<input class="flat" type="text" name="sref" value="'.$sref.'">';
 171      print '</td>';
 172      print '<td class="liste_titre" valign="right">';
 173      print '<input class="flat" type="text" name="snom" value="'.$snom.'">';
 174      print '</td>';
 175      if ($conf->service->enabled && $type != 0) 
 176      {
 177          print '<td class="liste_titre">';
 178          print '&nbsp;';
 179          print '</td>';
 180      }
 181      print '<td class="liste_titre">';
 182      print '&nbsp;';
 183      print '</td>';
 184      print '<td class="liste_titre">';
 185      print '&nbsp;';
 186      print '</td>';
 187      print '<td class="liste_titre" align="right">';
 188      print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
 189      print '<input type="image" class="liste_titre" name="button_removefilter" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" alt="'.$langs->trans("RemoveFilter").'">';
 190      print '</td>';
 191      print '</tr>';
 192      print '</form>';
 193  
 194      $product_static=new Product($db);
 195      
 196      $var=True;
 197      while ($i < min($num,$limit))
 198      {
 199          $objp = $db->fetch_object($resql);
 200          $var=!$var;
 201          print "<tr $bc[$var]><td>";
 202          print "<a href=\"fiche.php?id=$objp->rowid\">";
 203          if ($objp->fk_product_type) print img_object($langs->trans("ShowService"),"service");
 204          else print img_object($langs->trans("ShowProduct"),"product");
 205          print '</a> ';
 206          print '<a href="fiche.php?id='.$objp->rowid.'">'.$objp->ref.'</a></td>';
 207          print '<td>'.$objp->label.'</td>';
 208          print '<td align="center">'.dolibarr_print_date($objp->datem).'</td>';
 209          if ($conf->service->enabled && $type != 0) 
 210          {
 211              print '<td align="center">'.$objp->duration.'</td>';
 212          }
 213          print '<td align="right">'.price($objp->price).'</td>';
 214          print '<td align="center">'.$product_static->LibStatut($objp->statut).'</td>';
 215          print "</tr>\n";
 216          $i++;
 217      }
 218      $db->free($resql);
 219  
 220      print "</table>";
 221  
 222  }
 223  else
 224  {
 225      dolibarr_print_error($db);
 226  }
 227  
 228  
 229  $db->close();
 230  
 231  llxFooter('$Date: 2005/11/27 21:42:01 $ - $Revision: 1.36 $');
 232  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics