* Copyright (C) 2006 Laurent Destailleur * Copyright (C) 2006 Regis Houssin * * 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/fiche.php \ingroup categorie \brief Page creation nouvelle categorie */ require "./pre.inc.php"; require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php"); if (!$user->rights->categorie->lire) accessforbidden(); if (isset ($_REQUEST['choix'])) { $nbcats = $_REQUEST['choix']; } else { // par défault, une nouvelle catégorie sera dans une seule catégorie mère $nbcats = 1; } if ($_REQUEST['origin']) { $idprodorigin = $_REQUEST['origin']; } llxHeader("","",$langs->trans("Categories")); $html = new Form($db); // Action ajout d'une catégorie if ($_POST["action"] == 'add' && $user->rights->categorie->creer) { $categorie = new Categorie($db); $categorie->label = $_POST["nom"]; $categorie->description = $_POST["description"]; $categorie->visible = $_POST["visible"]; if($_POST['catMere'] != "-1") $categorie->id_mere = $_POST['catMere']; if (! $categorie->label) { $categorie->error = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")); $_GET["action"] = 'create'; } else if (! $categorie->description) { $categorie->error = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Description")); $_GET["action"] = 'create'; } if ($categorie->error =="") { if ($categorie->create() > 0) { $_GET["action"] = 'confirmed'; $_POST["addcat"] = ''; } } /* * Action confirmation de création de la catégorie */ if ($_GET["action"] == 'confirmed') { print_titre($langs->trans("NewCategory")); print '
'; print ''; print '
'; print '
'.$langs->trans("CategorySuccessfullyCreated",$categorie->label).'
'; if ($_REQUEST['idprodorigin']) { $idprodorigin = $_REQUEST['idprodorigin']; print ''.$langs->trans("ReturnInProduct").''; } print '
'; } } if ($user->rights->categorie->creer) { /* * Fiche en mode création */ if ($_GET["action"] == 'create' || $_POST["addcat"] == 'addcat') { if($categorie->error != "") { print '
'; print $categorie->error; print '
'; } print '
'; print ''; print ''; if ($idprodorigin) { print ''; } print_fiche_titre($langs->trans("CreateCat")); print ''; print ''; print ''; print ''; print ''; print ''; print ''; } } print '
'.$langs->trans("Ref").''; print'
'.$langs->trans("Description").''; if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); $doleditor=new DolEditor('description',$categorie->description,200,'dolibarr_notes'); $doleditor->Create(); } else { print ''; } print '
'.$langs->trans ("AddIn").''; print $html->select_all_categories(); print '
'.$langs->trans ("ContentsVisibleByAll").''; print $html->selectyesnonum("visible", 1); print '
'; print ''; print '
'; $db->close(); llxFooter('$Date$ - $Revision$'); ?>