* Copyright (C) 2005 Brice Davoleau * Copyright (C) 2005-2006 Regis Houssin * Copyright (C) 2006 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/categories/categorie.php \ingroup category \brief Page de l'onglet categories de produits \version $Revision$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/societe.class.php"); require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php"); $langs->load("categories"); $langs->load("companies"); $socid = isset($_GET["socid"])?$_GET["socid"]:''; // Sécurité d'accès client et commerciaux $socid = restrictedArea($user, 'societe', $socid); $mesg = ''; /* * Actions */ //on veut supprimer une catégorie if ($_REQUEST["removecat"] && $user->rights->societe->creer) { $soc = new Societe($db); if ($_REQUEST["socid"]) $result = $soc->fetch($_REQUEST["socid"]); $cat = new Categorie($db,$_REQUEST["removecat"]); $result=$cat->del_type($soc,"societe"); } //on veut ajouter une catégorie if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0 && $user->rights->societe->creer) { $soc = new Societe($db); if ($_REQUEST["socid"]) $result = $soc->fetch($_REQUEST["socid"]); $cat = new Categorie($db,$_REQUEST["catMere"]); $result=$cat->add_type($soc,"societe"); if ($result >= 0) { $mesg='
'.$langs->trans("Added").'
'; } else { $mesg='
'.$langs->trans("Error").' '.$cat->error.'
'; } } /* * Creation de l'objet fournisseur correspondant à l'id */ if ($_GET["socid"] || $_GET["ref"]) { $soc = new Societe($db); if ($_GET["socid"]) $result = $soc->fetch($_GET["socid"]); llxHeader("","",$langs->trans("CardCompany".$soc->type)); } $html = new Form($db); /* * Fiche produit */ if ($_GET["socid"] || $_GET["ref"]) { /* * Affichage onglets */ $head = societe_prepare_head($soc); dolibarr_fiche_head($head, 'category', $soc->nom); print ''; print ''; print ''; if ($soc->client) { print ''; } print ""; print '"; print '"; if ($soc->pays) { print ''; } print ''; print ''; print '"; // Assujeti à TVA ou pas print ''; print ''; print ''; print '
'.$langs->trans("Name").''; print $soc->nom; print '
'.$langs->trans('Prefix').''.$soc->prefix_comm.'
'; print $langs->trans('CustomerCode').''; print $soc->code_client; if ($soc->check_codeclient() <> 0) print ' '.$langs->trans("WrongCustomerCode"); print '
".$langs->trans('Address')."".nl2br($soc->adresse)."
'.$langs->trans('Zip').''.$soc->cp."'.$langs->trans('Town').''.$soc->ville."
'.$langs->trans('Country').''.$soc->pays.'
'.$langs->trans('Phone').''.dolibarr_print_phone($soc->tel,$soc->pays_code).''.$langs->trans('Fax').''.dolibarr_print_phone($soc->fax,$soc->pays_code).'
'.$langs->trans("Web")."url\" target=\"_blank\">".$soc->url." 
'.$langs->trans('VATIsUsed').''; print yn($soc->tva_assuj); 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->societe->creer) { print '
'; print '
'; print ''; print ''; print ''; print '
'; print $langs->trans("ClassifyInCategory").' '; print $html->select_all_categories(2,$categorie->id_mere).'
'; print '
'; print '
'; } $c = new Categorie($db); if ($_GET["socid"]) { $cats = $c->containing($_REQUEST["socid"],"societe"); } if (sizeof($cats) > 0) { print_fiche_titre($langs->trans("CompanyIsInCategories")); 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->societe->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("CompanyHasNoCategory")."
"; } } $db->close(); llxFooter('$Date$ - $Revision$'); ?>