diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php index 54aef117192..55563dd6d43 100644 --- a/htdocs/categories/categorie.class.php +++ b/htdocs/categories/categorie.class.php @@ -874,23 +874,29 @@ class Categorie } /** - * Retourne les catégories dont le nom correspond à $nom - * ajoute des wildcards sauf si $exact = true + * \brief Retourne les catégories dont l'id ou le nom correspond + * ajoute des wildcards au nom sauf si $exact = true */ - function rechercher_par_nom ($nom, $exact = false) + function rechercher($id, $nom, $exact = false) { $cats = array (); - if (!$exact) + // Generation requete recherche + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie "; + if ($nom) { - $nom = '%'.str_replace ('*', '%', $nom).'%'; + if (! $exact) + { + $nom = '%'.str_replace ('*', '%', $nom).'%'; + } + $sql.= "WHERE label LIKE '".$nom."'"; + } + if ($id) + { + $sql.="WHERE rowid = '".$id."'"; } - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie "; - $sql .= "WHERE label LIKE '".$nom."'"; - $res = $this->db->query ($sql); - if ($res) { while ($id = $this->db->fetch_array ($res)) @@ -902,7 +908,10 @@ class Categorie } else { - return 0; + $this->error=$this->db->error().' sql='.$sql; + //dolibarr_syslog($this->error); + dolibarr_print_error('',$this->error); + return -1; } } } diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 802f9e78334..34d15923011 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -31,26 +31,11 @@ $user->getrights(); if (!$user->rights->categorie->lire) accessforbidden(); - -/* - * Affichage fiche - */ - -llxHeader("","",$langs->trans("Categories")); - -print_titre($langs->trans("ModifCat")); - -print ''; - -print '
'; - -$categorie = new Categorie ($db, $_REQUEST['id']); -$html = new Form($db); - - // Action mise à jour d'une catégorie if ($_POST["action"] == 'update' && $user->rights->categorie->creer) { + $categorie = new Categorie ($db, $_REQUEST['id']); + $categorie->label = $_POST["nom"]; $categorie->description = $_POST["description"]; $categorie->visible = $_POST["visible"]; @@ -69,22 +54,43 @@ if ($_POST["action"] == 'update' && $user->rights->categorie->creer) { if ($categorie->update() > 0) { - $_GET["action"] = 'confirmed'; - $_POST["addcat"] = ''; + header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$categorie->id); + exit; } } } + + + +/* + * Affichage fiche + */ + +llxHeader("","",$langs->trans("Categories")); + +print_titre($langs->trans("ModifCat")); +print "
"; + if ($categorie->error) { print '
'; print $categorie->error; print '
'; } -print '
'; + +$categorie = new Categorie ($db, $_REQUEST['id']); +$html = new Form($db); + +print ''; + +print '
'; + +print "\n"; +print '
'; +print ''; +print ''; ?> - - @@ -101,7 +107,7 @@ print '
trans("Label"); ?> :
'; if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('description',$categorie->description,240,'dolibarr_notes'); + $doleditor=new DolEditor('description',$categorie->description,200,'dolibarr_notes'); $doleditor->Create(); } else diff --git a/htdocs/categories/fiche.php b/htdocs/categories/fiche.php index d49d3bb3042..5abb9c57f66 100644 --- a/htdocs/categories/fiche.php +++ b/htdocs/categories/fiche.php @@ -67,7 +67,7 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer) if (!$categorie->label || !$categorie->description) { $_GET["action"] = 'create'; - $categorie->error = $langs->trans(ErrForgotField); + $categorie->error = $langs->trans("ErrForgotField"); } if ($categorie->error =="") { @@ -84,11 +84,13 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer) if ($_GET["action"] == 'confirmed') { - print_titre($langs->trans("CatCreated")); - - print ''; - print '
'; - print $langs->trans("TheCategorie").' '.$categorie->label.' '.$langs->trans("WasAddedSuccessfully"); + print_titre($langs->trans("NewCategory")); + print '
'; + + print ''; + print '
'; + + print '
'.$langs->trans("CategorySuccessfullyCreated",$categorie->label).'
'; if ($_REQUEST['idprodorigin']) { @@ -134,7 +136,7 @@ if ($user->rights->categorie->creer) if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('description',$categorie->description,240,'dolibarr_notes'); + $doleditor=new DolEditor('description',$categorie->description,200,'dolibarr_notes'); $doleditor->Create(); } else diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 62e8505d907..28ac344f626 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -36,15 +36,16 @@ if (!$user->rights->categorie->lire) accessforbidden(); * Affichage page accueil */ -llxHeader("","",$langs->trans("ProductsCategoriesArea")); +$c = new Categorie($db); $html = new Form($db); + +llxHeader("","",$langs->trans("ProductsCategoriesArea")); print_fiche_titre($langs->trans("ProductsCategoriesArea")); print ''; print '
'; -$c = new Categorie ($db); /* * Zone recherche produit/service @@ -74,10 +75,10 @@ print ''; /* * Catégories trouvées */ - -if($_POST['catname']) +if($_POST['catname'] || $_REQUEST['id']) { - $cats = $c->rechercher_par_nom ($_POST['catname']); + $cats = $c->rechercher($_REQUEST['id'],$_POST['catname']); + print ''; print ''; @@ -107,91 +108,97 @@ $cate_arbo = $c->get_full_arbo(); * Catégories en javascript */ -/* + if ($conf->use_javascript) { print '
'.$langs->trans("FoundCats").'
'; - print ''; + print ''; print ''; print "
'.$langs->trans("AllCats").'
'.$langs->trans("CategoriesTree").'
'; - require_once(DOL_DOCUMENT_ROOT.'/includes/treemenu/TreeMenu.php'); - - $menu = new HTML_TreeMenu(); - $icon = 'folder.gif'; - $expandedIcon = 'folder-expanded.gif'; - - // Création noeud racine - $node=array(); - $currentnode=-1; - $node[$currentnode] = new HTML_TreeNode( - array('text' => $langs->trans("AllCats"), 'link' => '', 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => true) - //,array('onclick' => "alert('foo'); return false", 'onexpand' => "alert('Expanded')") - ); - $node1 = new HTML_TreeNode( - array('text' => $langs->trans("AllCats"), 'link' => '', 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => true) - //,array('onclick' => "alert('foo'); return false", 'onexpand' => "alert('Expanded')") - ); - - // Ajoute id_mere sur tableau cate_arbo - foreach ($cate_arbo as $key => $val) + if (sizeof($cate_arbo)) { - - print 'x '.$cate_arbo[$key]['id'].' '.$cate_arbo[$key]['level'].' '.$cate_arbo[$key]['id_mere'].'
'; - + + require_once(DOL_DOCUMENT_ROOT.'/includes/treemenu/TreeMenu.php'); + + $menu = new HTML_TreeMenu(); + $icon = 'folder.gif'; + $expandedIcon = 'folder-expanded.gif'; + + // Création noeud racine + $node=array(); + $rootnode='-1'; + $node[$rootnode] = new HTML_TreeNode( + array('text' => $langs->trans("AllCats"), 'link' => '', 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => true) + //,array('onclick' => "alert('foo'); return false", 'onexpand' => "alert('Expanded')") + ); + + // Ajoute id_mere sur tableau cate_arbo + $i=0; + foreach ($cate_arbo as $key => $val) + { + $i++; + $nodeparent=ereg_replace('_[0-9]+$','',$cate_arbo[$key]['fullpath']); + if (! $nodeparent) $nodeparent=$rootnode; + //print "Ajout noeud sur noeud ".$nodeparent.' pour categorie '.$cate_arbo[$key]['fulllabel']."
\n"; + $node[$cate_arbo[$key]['fullpath']]=$node[$nodeparent]->addItem(new HTML_TreeNode(array( + 'text' => $cate_arbo[$key]['label'], + //'link' => $_SERVER["PHP_SELF"].'?id='.$cate_arbo[$key]['id'], + 'link' => DOL_URL_ROOT.'/categories/viewcat.php?id='.$cate_arbo[$key]['id'], + 'icon' => $icon, 'expandedIcon' => $expandedIcon))); + //print 'Resultat: noeud '.$cate_arbo[$key]['fullpath']." créé
\n"; + } + + $menu->addItem($node[$rootnode]); + + // Affiche arbre + print ''; + + $treeMenu = new HTML_TreeMenu_DHTML($menu, array('images' => DOL_URL_ROOT.'/includes/treemenu/images', 'defaultClass' => 'treeMenuDefault', false)); + $treeMenu->printMenu(); + + //$listBox = new HTML_TreeMenu_Listbox($menu, array('linkTarget' => '_self')); + //$listBox->printMenu(); + + } + else + { + print $langs->trans("NoneCategory"); } - - $node1->addItem(new HTML_TreeNode(array('text' => "Second level, item y", 'link' => $_SERVER["PHP_SELF"], 'icon' => $icon, 'expandedIcon' => $expandedIcon))); - $node1_1 = $node1->addItem(new HTML_TreeNode(array('text' => "Second level", 'link' => $_SERVER["PHP_SELF"], 'icon' => $icon, 'expandedIcon' => $expandedIcon))); - $node1_1_1 = $node1_1->addItem(new HTML_TreeNode(array('text' => "Third level", 'link' => $_SERVER["PHP_SELF"], 'icon' => $icon, 'expandedIcon' => $expandedIcon))); - $node1_1_1_1 = $node1_1_1->addItem(new HTML_TreeNode(array('text' => "Fourth level", 'link' => $_SERVER["PHP_SELF"], 'icon' => $icon, 'expandedIcon' => $expandedIcon))); - $node1_1_1_1->addItem(new HTML_TreeNode(array('text' => "Fifth level", 'link' => $_SERVER["PHP_SELF"], 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'cssClass' => 'treeMenuBold'))); - $node1_1->addItem(new HTML_TreeNode(array('text' => "Third Level, item 2", 'link' => $_SERVER["PHP_SELF"], 'icon' => $icon, 'expandedIcon' => $expandedIcon))); - $node1->addItem(new HTML_TreeNode(array('text' => "Second level, item 3", 'link' => $_SERVER["PHP_SELF"], 'icon' => $icon, 'expandedIcon' => $expandedIcon))); - $menu->addItem($node1); - - // Affiche arbre - print ''; - - $treeMenu = new HTML_TreeMenu_DHTML($menu, array('images' => DOL_URL_ROOT.'/includes/treemenu/images', 'defaultClass' => 'treeMenuDefault', false)); - $treeMenu->printMenu(); - - //$listBox = new HTML_TreeMenu_Listbox($menu, array('linkTarget' => '_self')); - //$listBox->printMenu(); print '
"; print '
'; } -*/ - -/* -* Catégories principales en HTML pure -*/ -if (1 == 1) +else { + /* + * Catégories principales en HTML pure + */ print ''; - print ''; - - if (is_array($cate_arbo)) + print ''; + + if (sizeof($cate_arbo)) { - $var=true; - foreach($cate_arbo as $key => $value) + if (is_array($cate_arbo)) { - $var = ! $var; - print "\t\n"; - print ''; - print ''; - print "\t\n"; - print "\t\n"; + $var=true; + foreach($cate_arbo as $key => $value) + { + $var = ! $var; + print "\t\n"; + print ''; + print ''; + print "\t\n"; + } } + } - + print "
'.$langs->trans("AllCats").''.$langs->trans("Desc").'
'.$langs->trans("AllCats").''.$langs->trans("Description").'
'.$cate_arbo[$key]['fulllabel'].''.$c->get_desc($cate_arbo[$key]['id']).'
'.$cate_arbo[$key]['fulllabel'].''.$c->get_desc($cate_arbo[$key]['id']).'
"; } - $db->close(); llxFooter('$Date$ - $Revision$'); diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index bdc4a3cae6c..65216f5698b 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -17,6 +17,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/** + \file htdocs/categories/edit.php + \ingroup categories + \brief Page de visualisation de categorie produit + \version $Revision$ +*/ + require "./pre.inc.php"; $user->getrights('categorie'); @@ -28,35 +35,74 @@ if (! $user->rights->categorie->lire) if ($_REQUEST['id'] == "") { - dolibarr_print_error (); - exit (); + dolibarr_print_error('','Missing parameter id'); + exit(); } -$c = new Categorie ($db, $_REQUEST['id']); /* * Affichage fiche categorie */ - llxHeader ("","",$langs->trans("Categories")); -print_fiche_titre($langs->trans("Category")); +$c = new Categorie ($db, $_REQUEST['id']); -print ''; -print '
'; +$h = 0; +$head = array(); +$head[$h][0] = DOL_URL_ROOT.'/categories/viewcat.php?id='.$c->id; +$head[$h][1] = $langs->trans("Card"); +$head[$h][2] = 'card'; +$h++; + +dolibarr_fiche_head($head, 'card', $langs->trans("Category")); + + +print ''; + +print ''; + + +print ''; + +print '
'; $ways = $c->print_all_ways (); -print "
"; -print $langs->trans("Ref").': '; +print $langs->trans("Ref").'
'; foreach ($ways as $way) { print $way."
\n"; } +print '
'; +print $langs->trans("Description").''; +print nl2br($c->description); +print '
'; + +print ''; + + +/* + * Boutons actions + */ +print "
\n"; + +if ($user->rights->categorie->creer) +{ + print "".$langs->trans("Edit").""; +} + +if ($user->rights->categorie->supprimer) +{ + print "".$langs->trans("Delete").""; +} + print "
"; -$cats = $c->get_filles (); + + + +$cats = $c->get_filles (); if ($cats < 0) { dolibarr_print_error(); @@ -96,10 +142,8 @@ else print "
\n"; } -$i = 0; $prods = $c->get_products (); - if ($prods < 0) { dolibarr_print_error(); @@ -112,6 +156,7 @@ else if (sizeof ($prods) > 0) { + $i = 0; $var=true; foreach ($prods as $prod) { @@ -134,25 +179,6 @@ else print "
\n"; } -/* - * Boutons actions - */ -print "
\n"; - -if ($user->rights->categorie->creer) -{ - print "".$langs->trans("Edit").""; -} - -if ($user->rights->categorie->supprimer) -{ - print "".$langs->trans("Delete").""; -} - -print "
"; - - -print '
'; $db->close(); diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 615277f94ac..e14d36710a7 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -7,6 +7,7 @@ In=In AddIn=Add in modify=modify CategoriesArea=Categories area +ProductsCategoriesArea=Products/Services' categories Area MainCats=Main categories SubCats=Subcategories CatStatistics=Statistics @@ -14,6 +15,7 @@ CatList=List of cat AllCats=All categories ViewCat=View category NewCat=Add category +NewCategory=New product/services category ModifCat=Modify category CatCreated=Category added CreateCat=Create category @@ -33,10 +35,14 @@ AddProductToCat=Add this product to a category? ImpossibleAddCat=Impossible to add the category ImpossibleAssociateCategory=Impossible to associate the category to WasAddedSuccessfully=was added successfully. +CategorySuccessfullyCreated=La catégorie %s a été ajouté avec succès. ProductIsInCategories=Product/service owns to categories ProductHasNoCategory=This product/service is not in any categories ClassifyInCategory=Classify in category +NoneCategory=None +CategoryExistsAtSameLevel=This category already exists at same place ReturnInProduct=Back to product/service card ContentsVisibleByAll=The contents will be visible by all ContentsVisibleByAllShort=Contents visible by all -ContentsNotVisibleByAllShort=Contents not visible by all \ No newline at end of file +ContentsNotVisibleByAllShort=Contents not visible by all +CategoriesTree=Categories tree \ No newline at end of file diff --git a/htdocs/langs/fr_FR/categories.lang b/htdocs/langs/fr_FR/categories.lang index c0bd53257ff..00cd06da197 100644 --- a/htdocs/langs/fr_FR/categories.lang +++ b/htdocs/langs/fr_FR/categories.lang @@ -15,6 +15,7 @@ CatList=Liste des cat AllCats=Toutes les catégories ViewCat=Visualisation de la catégorie NewCat=Nouvelle catégorie +NewCategory=Nouvelle catégorie de produits/services ModifCat=Modifier une catégorie CatCreated=Catégorie ajoutée CreateCat=Ajouter une catégorie @@ -34,6 +35,7 @@ AddProductToCat=Ajouter ce produit ImpossibleAddCat=Impossible d'ajouter la catégorie ImpossibleAssociateCategory=Impossible d'associer la catégorie WasAddedSuccessfully=a été ajoutée avec succès. +CategorySuccessfullyCreated=La catégorie %s a été ajouté avec succès. ProductIsInCategories=Ce produit/service est dans les catégorie suivantes ProductHasNoCategory=Ce produit/service n'est dans aucune catégorie en particulier ClassifyInCategory=Classer dans la catégorie @@ -43,5 +45,4 @@ ReturnInProduct=Retour sur la fiche produit/service ContentsVisibleByAll=Le contenu sera visible par tous ContentsVisibleByAllShort=Contenu visible par tous ContentsNotVisibleByAllShort=Contenu non visible par tous -Desc=Description - +CategoriesTree=Arbre des catégories \ No newline at end of file