diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php index 713f3ba4677..1585fe481e3 100644 --- a/htdocs/categories/categorie.class.php +++ b/htdocs/categories/categorie.class.php @@ -468,19 +468,22 @@ class Categorie * \brief Reconstruit l'arborescence des catégories sous la forme d'un tableau * Renvoi un tableau de tableau('id','id_mere',...) trié selon * arbre et avec: - * id = id de la categorie - * id_mere = id de la categorie mere - * id_children = tableau des id enfant - * label = nom de la categorie - * fulllabel = nom avec chemin complet de la categorie - * fullpath = chemin complet compose des id - * \return array Tableau de array + * id = id de la categorie + * id_mere = id de la categorie mere + * id_children = tableau des id enfant + * label = nom de la categorie + * fulllabel = nom avec chemin complet de la categorie + * fullpath = chemin complet compose des id + * \param type Type de categories (0=produit, 1=fournisseur, 2=client) + * \return array Tableau de array */ function get_full_arbo($type) { // Charge tableau des meres $sql = "SELECT fk_categorie_mere as id_mere, fk_categorie_fille as id_fille"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie_association"; + + dolibarr_syslog("Categorie::get_full_arbo sql=".$sql); $res = $this->db->query ($sql); if ($res) { @@ -502,6 +505,8 @@ class Categorie $sql.= " ON c.rowid=ca.fk_categorie_mere"; $sql.= " WHERE c.type = ".$type; $sql.= " ORDER BY c.label, c.rowid"; + + dolibarr_syslog("Categorie::get_full_arbo sql=".$sql); $res = $this->db->query ($sql); if ($res) { @@ -866,7 +871,6 @@ class Categorie $sql.= " WHERE ct.fk_".$type." = ".$id." AND c.type = ".$typeid; $res = $this->db->query ($sql); - if ($res) { while ($cat = $this->db->fetch_array ($res)) diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index ccc413a927d..208300601e3 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -20,7 +20,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** @@ -110,7 +109,7 @@ if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0) $html = new Form($db); /* - * Fiche objet client/fournisseur + * Fiche categorie de client et/ou fournisseur */ if ($_GET["socid"]) { @@ -186,26 +185,21 @@ if ($_GET["socid"]) if ($mesg) print($mesg); - if ($soc->client) - { - formCategory($db,$soc,$type,2); - print '

'; - } + if ($soc->client) formCategory($db,$soc,$type,2); + + if ($soc->client && $soc->fournisseur) print '

'; + if ($soc->fournisseur) formCategory($db,$soc,$type,1); } else if ($_GET["id"] || $_GET["ref"]) { - /* - * Fiche produit - */ + /* + * Fiche categorie de produit + */ + require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); + require_once(DOL_DOCUMENT_ROOT."/product.class.php"); - require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); - require_once(DOL_DOCUMENT_ROOT."/product.class.php"); - - /* - * Creation de l'objet produit correspondant à l'id - */ - + // Produit $product = new Product($db); if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); if ($_GET["id"]) $result = $product->fetch($_GET["id"]); @@ -213,9 +207,9 @@ else if ($_GET["id"] || $_GET["ref"]) llxHeader("","",$langs->trans("CardProduct".$product->type)); - $head=product_prepare_head($product, $user); - $titre=$langs->trans("CardProduct".$product->type); - dolibarr_fiche_head($head, 'category', $titre); + $head=product_prepare_head($product, $user); + $titre=$langs->trans("CardProduct".$product->type); + dolibarr_fiche_head($head, 'category', $titre); print ''; @@ -230,8 +224,8 @@ else if ($_GET["id"] || $_GET["ref"]) print ''; print ''; - // Prix - print ''; - // Statut - print ''; + print ''; print '
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").''; + // Prix + print '
'.$langs->trans("SellingPrice").''; if ($product->price_base_type == 'TTC') { print price($product->price_ttc).' '.$langs->trans($product->price_base_type); @@ -242,10 +236,10 @@ else if ($_GET["id"] || $_GET["ref"]) } print '
'.$langs->trans("Status").''; + // Statut + print '
'.$langs->trans("Status").''; print $product->getLibStatut(2); - print '
'; @@ -254,23 +248,22 @@ else if ($_GET["id"] || $_GET["ref"]) if ($mesg) print($mesg); formCategory($db,$product,'product',0); - } - - /* - * Fonction Barre d'actions - * - */ + +/* +* Fonction Barre d'actions +*/ function formCategory($db,$object,$type,$typeid) { - global $user,$langs,$html; + 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') { $nameId = 'socid'; - if ($typeid == 2) $title = $langs->trans("CustomersCategoriesShort"); - if ($typeid == 1) $title = $langs->trans("SuppliersCategoriesShort"); } else { @@ -304,9 +297,11 @@ function formCategory($db,$object,$type,$typeid) if (sizeof($cats) > 0) { - print_fiche_titre($langs->trans("CompanyIsInCategories")); + if ($typeid == 0) $title=$langs->trans("ProductIsInCategories"); + if ($typeid == 1) $title=$langs->trans("CompanyIsInSuppliersCategories"); + if ($typeid == 2) $title=$langs->trans("CompanyIsInCustomersCategories"); print ''; - print ''; + print ''; $var = true; foreach ($cats as $cat) @@ -337,7 +332,7 @@ function formCategory($db,$object,$type,$typeid) print "\n"; } } - print "
'.$langs->trans("Categories").'
'.$title.':

\n"; + print "\n"; } else if($cats < 0) { diff --git a/htdocs/categories/fiche.php b/htdocs/categories/fiche.php index a0df9430c78..3cdacf1e212 100644 --- a/htdocs/categories/fiche.php +++ b/htdocs/categories/fiche.php @@ -51,13 +51,28 @@ if ($_REQUEST['origin']) +/* +* Actions +*/ -llxHeader("","",$langs->trans("Categories")); -$html = new Form($db); - -// Action ajout d'une catégorie if ($_POST["action"] == 'add' && $user->rights->categorie->creer) { + // Action ajout d'une catégorie + if ($_POST["cancel"]) + { + if ($idProdOrigin) + { + header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?id='.$idProdOrigin); + exit; + } + if ($idSupplierOrigin || $idCompanyOrigin) + { + header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idCompanyOrigin); + exit; + } + + } + $categorie = new Categorie($db); $categorie->label = $_POST["nom"]; @@ -87,6 +102,15 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer) } } +} + + + +llxHeader("","",$langs->trans("Categories")); +$html = new Form($db); + +if ($_POST["action"] == 'add' && $user->rights->categorie->creer) +{ /* * Action confirmation de création de la catégorie */ @@ -168,7 +192,9 @@ if ($user->rights->categorie->creer) print $html->selectyesno("visible", 1,1); print ''; print ''; - print ''; + print ''; + print '     '; + print ''; print ''; } diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 2831d412418..2a730487608 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -1682,9 +1682,8 @@ class Form } /** - * \brief Retourne la liste des catégories en fonction - * du nombre choisi. - * \param type Type de categories + * \brief Retourne la liste des catégories du type choisi + * \param type Type de categories (0=produit, 1=fournisseur, 2=client) * \param selected Id categorie preselectionnee * \param select_name Nom formulaire HTML */ diff --git a/htdocs/langs/fr_FR/categories.lang b/htdocs/langs/fr_FR/categories.lang index a60206a8802..19e4749f681 100644 --- a/htdocs/langs/fr_FR/categories.lang +++ b/htdocs/langs/fr_FR/categories.lang @@ -41,7 +41,8 @@ WasAddedSuccessfully=a CategorySuccessfullyCreated=La catégorie %s a été ajouté avec succès. ProductIsInCategories=Ce produit/service est dans les catégories suivantes SupplierIsInCategories=Ce fournisseur est dans les catégories suivantes -CompanyIsInCategories=Cette societé est dans les catégories suivantes +CompanyIsInCustomersCategories=Cette societé est dans les catégories clients suivantes +CompanyIsInSuppliersCategories=Cette societé est dans les catégories fournisseurs suivantes ProductHasNoCategory=Ce produit/service n'est dans aucune catégorie en particulier SupplierHasNoCategory=Ce fournisseur n'est dans aucune catégorie en particulier CompanyHasNoCategory=Cette societé n'est dans aucune catégorie en particulier