* Copyright (C) 2005 Brice Davoleau * Copyright (C) 2005-2007 Regis Houssin * Copyright (C) 2006-2008 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. */ /** \file htdocs/categories/categorie.php \ingroup category \brief Page de l'onglet categories \version $Id$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php"); $langs->load("categories"); $mesg=isset($_GET["mesg"])?'
'.$_GET["mesg"].'
':''; if ($_REQUEST["socid"]) { if ($_REQUEST["typeid"] == 1) { $type = 'fournisseur'; $socid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:''; } if ($_REQUEST["typeid"] == 2) { $type = 'societe'; $socid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:''; } $objectid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:''; } else if ($_REQUEST["id"] || $_REQUEST["ref"]) { $type = 'produit'; } // Security check if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, $type, $objectid); /* * Actions */ //Suppression d'un objet d'une categorie if ($_REQUEST["removecat"]) { if ($_REQUEST["socid"] && $user->rights->societe->creer) { $object = new Societe($db); $result = $object->fetch($_REQUEST["socid"]); } else if (($_REQUEST["id"] || $_REQUEST["ref"]) && $user->rights->produit->creer) { $object = new Product($db); if ($_REQUEST["ref"]) $result = $object->fetch('',$_REQUEST["ref"]); if ($_REQUEST["id"]) $result = $object->fetch($_REQUEST["id"]); $type = 'product'; } $cat = new Categorie($db,$_REQUEST["removecat"]); $result=$cat->del_type($object,$type); } //Ajoute d'un objet dans une categorie if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0) { if ($_REQUEST["socid"] && $user->rights->societe->creer) { $object = new Societe($db); $result = $object->fetch($_REQUEST["socid"]); } else if (($_REQUEST["id"] || $_REQUEST["ref"]) && $user->rights->produit->creer) { $object = new Product($db); if ($_REQUEST["ref"]) $result = $object->fetch('',$_REQUEST["ref"]); if ($_REQUEST["id"]) $result = $object->fetch($_REQUEST["id"]); $type = 'product'; } $cat = new Categorie($db); $result=$cat->fetch($_REQUEST["catMere"]); $result=$cat->add_type($object,$type); if ($result >= 0) { $mesg='
'.$langs->trans("WasAddedSuccessfully",$cat->label).'
'; } else { if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') $mesg='
'.$langs->trans("ObjectAlreadyLinkedToCategory").'
'; else $mesg='
'.$langs->trans("Error").' '.$cat->error.'
'; } } /* * View */ $html = new Form($db); /* * Fiche categorie de client et/ou fournisseur */ if ($_GET["socid"]) { require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/societe.class.php"); $langs->load("companies"); /* * Creation de l'objet client/fournisseur correspondant au socid */ $soc = new Societe($db); $result = $soc->fetch($_GET["socid"]); llxHeader("","",$langs->trans("Category")); /* * Affichage onglets */ $head = societe_prepare_head($soc); dolibarr_fiche_head($head, 'category', $langs->trans("ThirdParty")); print ''; print ''; print ''; if ($soc->client) { print ''; } if ($soc->fournisseur) { 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 '
'; print $langs->trans('SupplierCode').''; print $soc->code_fournisseur; if ($soc->check_codefournisseur() <> 0) print ' '.$langs->trans("WrongSupplierCode"); 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); if ($soc->client) formCategory($db,$soc,'societe',2); if ($soc->client && $soc->fournisseur) print '

'; if ($soc->fournisseur) formCategory($db,$soc,'fournisseur',1); } else if ($_GET["id"] || $_GET["ref"]) { /* * Fiche categorie de produit */ require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php"); // Produit $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)); $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','',1,'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); formCategory($db,$product,'product',0); } /* * Fonction Barre d'actions */ function formCategory($db,$object,$type,$typeid) { global $user,$langs,$html,$bc; if ($typeid == 0) $title = $langs->trans("ProductsCategoriesShort"); if ($typeid == 1) $title = $langs->trans("SuppliersCategoriesShort"); if ($typeid == 2) $title = $langs->trans("CustomersCategoriesShort"); if ($type == 'societe' || $type == 'fournisseur') { $nameId = 'socid'; } else if ($type == 'product') { $nameId = 'id'; } // Formulaire ajout dans une categorie print '
'; print_fiche_titre($title); print '
'; print ''; print ''; print ''; if ($user->rights->categorie->creer) { print ''; } print ''; print '
'; print $langs->trans("ClassifyInCategory").' '; print $html->select_all_categories($typeid).' '; print ''.$langs->trans("NewCat").''; print '
'; print '
'; print '
'; $c = new Categorie($db); $cats = $c->containing($object->id,$type,$typeid); if (sizeof($cats) > 0) { if ($typeid == 0) $title=$langs->trans("ProductIsInCategories"); if ($typeid == 1) $title=$langs->trans("CompanyIsInSuppliersCategories"); if ($typeid == 2) $title=$langs->trans("CompanyIsInCustomersCategories"); 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 "
'.$title.':
".$way."'; $permission=0; if ($type == 'fournisseur') $permission=$user->rights->societe->creer; if ($type == 'societe') $permission=$user->rights->societe->creer; if ($type == 'product') $permission=$user->rights->produit->creer; if ($permission) { print ""; print img_delete($langs->trans("DeleteFromCat")).' '; print $langs->trans("DeleteFromCat").""; } else { print ' '; } print "
\n"; } else if($cats < 0) { print $langs->trans("ErrorUnknown"); } else { if ($typeid == 0) $title=$langs->trans("ProductHasNoCategory"); if ($typeid == 1) $title=$langs->trans("CompanyHasNoCategory"); if ($typeid == 2) $title=$langs->trans("CompanyHasNoCategory"); print $title; print "
"; } } $db->close(); llxFooter('$Date$ - $Revision$'); ?>