* Copyright (C) 2005 Brice Davoleau * Copyright (C) 2005-2006 Regis Houssin * Copyright (C) 2006-2007 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * * 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/categorie.php \ingroup product \brief Page de l'onglet categories de produits \version $Revision$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php"); $langs->load("categories"); if (!$user->rights->produit->lire) accessforbidden(); $mesg = ''; /* * Actions */ //on veut supprimer une catégorie if ($_REQUEST["removecat"] && $user->rights->produit->creer) { $product = new Product($db); if ($_REQUEST["ref"]) $result = $product->fetch('',$_REQUEST["ref"]); if ($_REQUEST["id"]) $result = $product->fetch($_REQUEST["id"]); $cat = new Categorie($db,$_REQUEST["removecat"]); $result=$cat->del_type($product,"product"); } //on veut ajouter une catégorie if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0 && $user->rights->produit->creer) { $product = new Product($db); if ($_REQUEST["ref"]) $result = $product->fetch('',$_REQUEST["ref"]); if ($_REQUEST["id"]) $result = $product->fetch($_REQUEST["id"]); $cat = new Categorie($db,$_REQUEST["catMere"]); $result=$cat->add_type($product,"product"); if ($result >= 0) { $mesg='
'.$langs->trans("Added").'
'; } else { $mesg='
'.$langs->trans("Error").' '.$cat->error.'
'; } } /* * Creation de l'objet produit correspondant à l'id */ if ($_GET["id"] || $_GET["ref"]) { $product = new Product($db); if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); if ($_GET["id"]) $result = $product->fetch($_GET["id"]); llxHeader("","",$langs->trans("CardProduct".$product->type)); } $html = new Form($db); /* * Fiche produit */ if ($_GET["id"] || $_GET["ref"]) { $head=product_prepare_head($product, $user); $titre=$langs->trans("CardProduct".$product->type); dolibarr_fiche_head($head, 'category', $titre); print ''; print ""; // Reference print ''; print ''; // Libelle print ''; print ''; // Prix print ''; // Statut print ''; print '
'.$langs->trans("Ref").''; print $html->showrefnav($product,'ref'); print '
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").''; if ($product->price_base_type == 'TTC') { print price($product->price_ttc).' '.$langs->trans($product->price_base_type); } else { print price($product->price).' '.$langs->trans($product->price_base_type); } print '
'.$langs->trans("Status").''; print $product->getLibStatut(2); print '
'; print ''; if ($mesg) print($mesg); /* * Barre d'actions * */ print '
'; if ($user->rights->categorie->creer) { print ''.$langs->trans("NewCat").''; } print '
'; // Formulaire ajout dans une categorie if ($user->rights->produit->creer) { print '
'; print '
'; print ''; print ''; print ''; print '
'; print $langs->trans("ClassifyInCategory").' '; print $html->select_all_categories(0,$categorie->id_mere).'
'; print '
'; print '
'; } $c = new Categorie($db); if ($_GET["id"]) { $cats = $c->containing($_REQUEST["id"],"product"); } if ($_GET["ref"]) { $cats = $c->containing_ref($_REQUEST["ref"],"product"); } if (sizeof($cats) > 0) { print_fiche_titre($langs->trans("ProductIsInCategories")); print ''; print ''; $var = true; foreach ($cats as $cat) { $ways = $cat->print_all_ways (); foreach ($ways as $way) { $var = ! $var; print ""; // Categorie print ""; // Lien supprimer print '"; print "\n"; } } print "
'.$langs->trans("Categories").'
".$way."'; if ($user->rights->produit->creer) { print ""; print img_delete($langs->trans("DeleteFromCat")).' '; print $langs->trans("DeleteFromCat").""; } else { print ' '; } print "

\n"; } else if($cats < 0) { print $langs->trans("ErrorUnknown"); } else { print $langs->trans("ProductHasNoCategory")."
"; } } $db->close(); llxFooter('$Date$ - $Revision$'); ?>