* Copyright (C) 2003 Éric Seigne * * 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$ * */ require("./pre.inc.php"); llxHeader(); if ($id) { $title = title_url($id, $db); print_barre_liste($title, $page, $PHP_SELF); $sql = "SELECT products_id FROM ".DB_NAME_OSC.".products_to_categories WHERE categories_id = $id"; if ( $db->query($sql) ) { $numprod = $db->num_rows(); $i = 0; $wc = "("; while ($i < $numprod) { $objp = $db->fetch_object( $i); $wc .= $objp->products_id; if ($i < $numprod -1) { $wc .= ","; } $i++; } $wc .=")"; $db->free(); } else { print $db->error(); } // print $wc ; if ($numprod) { $sql = "SELECT l.rowid, l.title, l.oscid, l.ref, l.status FROM ".MAIN_DB_PREFIX."livre as l"; $sql .= " WHERE l.oscid in $wc"; if ( $db->query($sql) ) { $num = $db->num_rows(); $i = 0; print "

"; print ""; print ''; print "\n"; $var=True; while ($i < $num) { $objp = $db->fetch_object( $i); $var=!$var; print ""; print ''; print ''; if ($objp->status == 1) { print ''; print ''; } else { print ''; print ''; } print ''; print "\n"; $i++; } print "
Réf."; print_liste_field_titre("Titre",$PHP_SELF, "l.title"); print " 
'.$objp->ref.''.$objp->title.''; print ''; print ''; print ''; print ''; print 'Fiche en ligne
"; $db->free(); } else { print $db->error(); } } else { print "Aucun produits dans cette catégorie"; } } else { print_barre_liste("Liste des catégories", $page, $PHP_SELF); $sql = "SELECT c.categories_id, cd.categories_name "; $sql .= " FROM ".DB_NAME_OSC.".categories as c,".DB_NAME_OSC.".categories_description as cd"; $sql .= " WHERE c.categories_id = cd.categories_id AND cd.language_id = ".OSC_LANGUAGE_ID; $sql .= " AND c.parent_id = 0"; $sql .= " ORDER BY cd.categories_name ASC "; if ( $db->query($sql) ) { $num = $db->num_rows(); $i = 0; print "

"; print ""; print ""; print "\n"; $var=True; while ($i < $num) { $objp = $db->fetch_object( $i); $var=!$var; printc($objp->categories_id,$db, 0); $i++; } print "
"; print_liste_field_titre("Titre",$PHP_SELF, "a.title"); print "
"; $db->free(); } else { print $db->error(); } } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); /* * * */ Function printc($id, $db, $level) { $cat = new Categorie($db); $cat->fetch($id); print ""; for ($i = 0 ; $i < $level ; $i++) { print "  |--"; } print ''.$cat->name."\n"; print "\n"; $childs = array(); $childs = $cat->liste_childs_array(); if (sizeof($childs)) { foreach($childs as $key => $value) { printc($key,$db, $level+1); } } } Function title_url($id, $db) { $cat = new Categorie($db); $cat->fetch($id); $title = $title . ''. $cat->name .""; if (sizeof($cat->parent_id)) { $title = title_url($cat->parent_id, $db) . " / ".$title; } return $title; } ?>