[ 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/categorie/ -> index.php (source)

   1  <?php
   2  /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2003 Éric Seigne          <erics@rycks.com>
   4   * Copyright (C) 2004 Laurent Destailleur  <eldy@users.sourceforge.net>
   5   *
   6   * This program is free software; you can redistribute it and/or modify
   7   * it under the terms of the GNU General Public License as published by
   8   * the Free Software Foundation; either version 2 of the License, or
   9   * (at your option) any later version.
  10   *
  11   * This program is distributed in the hope that it will be useful,
  12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14   * GNU General Public License for more details.
  15   *
  16   * You should have received a copy of the GNU General Public License
  17   * along with this program; if not, write to the Free Software
  18   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19   *
  20   * $Id: index.php,v 1.14 2005/08/11 19:19:08 eldy Exp $
  21   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/product/categorie/index.php,v $
  22   */
  23  
  24  require ("./pre.inc.php");
  25  
  26  llxHeader();
  27  
  28  if ($id)
  29  {
  30      $title = title_url($id, $db);
  31  
  32      print_barre_liste($title, $page, "index.php");
  33  
  34      $sql = "SELECT products_id FROM ".OSC_DB_NAME.".products_to_categories WHERE categories_id = $id";
  35  
  36      if ( $db->query($sql) )
  37      {
  38          $numprod = $db->num_rows();
  39          $i = 0;
  40          $wc = "(";
  41          while ($i < $numprod)
  42          {
  43              $objp = $db->fetch_object( $i);
  44              $wc .= $objp->products_id;
  45              if ($i < $numprod -1)
  46              {
  47                  $wc .= ",";
  48              }
  49              $i++;
  50          }
  51          $wc .=")";
  52          $db->free();
  53      }
  54      else
  55      {
  56          dolibarr_print_error($db);
  57      }
  58      //  print $wc ;
  59  
  60      if ($numprod)
  61      {
  62  
  63          $sql = "SELECT l.rowid, l.title, l.oscid, l.ref, l.status FROM ".MAIN_DB_PREFIX."livre as l";
  64          $sql .= " WHERE l.oscid in $wc";
  65  
  66          if ( $db->query($sql) )
  67          {
  68              $num = $db->num_rows();
  69              $i = 0;
  70              print "<table class=\"noborder\" width=\"100%\">";
  71              print "<tr class=\"liste_titre\"><td>".$langs->trans("Ref")."</td>";
  72              print_liste_field_titre("Titre","index.php", "l.title");
  73              print '<td colspan="3">&nbsp;</td>';
  74              print "</tr>\n";
  75              $var=True;
  76              while ($i < $num)
  77              {
  78                  $objp = $db->fetch_object( $i);
  79                  $var=!$var;
  80                  print "<tr $bc[$var]>";
  81                  print '<td><a href="'.DOL_URL_ROOT.'/boutique/livre/fiche.php?id='.$objp->rowid.'">'.$objp->ref.'</a></TD>';
  82                  print '<td width="70%"><a href="'.DOL_URL_ROOT.'/boutique/livre/fiche.php?id='.$objp->rowid.'">'.$objp->title.'</a></TD>';
  83  
  84                  if ($objp->status == 1)
  85                  {
  86                      print '<td align="center">';
  87                      print '<img src="/theme/'.$conf->theme.'/img/icon_status_green.png" border="0"></a></td>';
  88                      print '<td align="center">';
  89                      print '<img src="/theme/'.$conf->theme.'/img/icon_status_red_light.png" border="0"></a></td>';
  90                  }
  91                  else
  92                  {
  93                      print '<td align="center">';
  94                      print '<img src="/theme/'.$conf->theme.'/img/icon_status_green_light.png" border="0"></a></td>';
  95                      print '<td align="center">';
  96                      print '<img src="/theme/'.$conf->theme.'/img/icon_status_red.png" border="0"></a></td>';
  97                  }
  98  
  99                  print '<td align="right">';
 100                  print '<a href="'.OSC_CATALOG_URL.'product_info.php?products_id='.$objp->oscid.'">Fiche en ligne</a></TD>';
 101                  print "</tr>\n";
 102                  $i++;
 103              }
 104              print "</TABLE>";
 105              $db->free();
 106          }
 107          else
 108          {
 109              dolibarr_print_error($db);
 110          }
 111      }
 112      else
 113      {
 114          print "Aucun produits dans cette catégorie";
 115      }
 116  }
 117  else
 118  {
 119  
 120      print_barre_liste("Liste des catégories", $page, "index.php");
 121  
 122      $sql = "SELECT c.categories_id, cd.categories_name ";
 123      $sql .= " FROM ".OSC_DB_NAME.".categories as c,".OSC_DB_NAME.".categories_description as cd";
 124      $sql .= " WHERE c.categories_id = cd.categories_id AND cd.language_id = ".OSC_LANGUAGE_ID;
 125      $sql .= " AND c.parent_id = 0";
 126      $sql .= " ORDER BY cd.categories_name ASC ";
 127  
 128      if ( $db->query($sql) )
 129      {
 130          $num = $db->num_rows();
 131          $i = 0;
 132          print "<table class=\"noborder\" width=\"100%\">";
 133          print "<tr class=\"liste_titre\">";
 134          print_liste_field_titre("Titre","index.php", "a.title");
 135          print "<td>&nbsp;</td>";
 136          print "</tr>\n";
 137  
 138          $var=True;
 139          while ($i < $num)
 140          {
 141              $objp = $db->fetch_object( $i);
 142              $var=!$var;
 143  
 144              printc($objp->categories_id,$db, 0);
 145  
 146              $i++;
 147          }
 148          print "</TABLE>";
 149          $db->free();
 150      }
 151      else
 152      {
 153          dolibarr_print_error($db);
 154      }
 155  }
 156  $db->close();
 157  
 158  llxFooter('$Date: 2005/08/11 19:19:08 $ - $Revision: 1.14 $');
 159  
 160  
 161  /*
 162   *
 163   *
 164   */
 165  function printc($id, $db, $level)
 166  {
 167  
 168      $cat = new Categorie($db);
 169      $cat->fetch($id);
 170  
 171      print "<tr $bc[$var]><td>";
 172  
 173      for ($i = 0 ; $i < $level ; $i++)
 174      {
 175          print "&nbsp;&nbsp;|--";
 176      }
 177  
 178      print '<a href="index.php?id='.$cat->id.'">'.$cat->name."</a></td>\n";
 179      print "</tr>\n";
 180  
 181      $childs = array();
 182      $childs = $cat->liste_childs_array();
 183      if (sizeof($childs))
 184      {
 185          foreach($childs as $key => $value)
 186          {
 187              printc($key,$db, $level+1);
 188          }
 189      }
 190  }
 191  
 192  function title_url($id, $db)
 193  {
 194  
 195      $cat = new Categorie($db);
 196      $cat->fetch($id);
 197  
 198      $title = $title . '<a href="index.php?id='.$cat->id.'">'.  $cat->name ."</a>";
 199  
 200  
 201      if (sizeof($cat->parent_id))
 202      {
 203          $title = title_url($cat->parent_id, $db) . " / ".$title;
 204      }
 205  
 206      return $title;
 207  }
 208  
 209  ?>


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