diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php new file mode 100644 index 00000000000..7b8569749d1 --- /dev/null +++ b/htdocs/categories/categorie.class.php @@ -0,0 +1,690 @@ + + * Copyright (C) 2005 Davoleau Brice + * + * + * 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$ + * + */ + +require_once DOL_DOCUMENT_ROOT."/product.class.php"; + +class Categorie +{ + var $db; + + var $id; + var $label; + var $description; + + /** + * Constructeur + * db : accès base de données + * id : id de la catégorie + */ + function Categorie ($db, $id=-1) + { + $this->db = $db; + $this->id = $id; + + if ($id != -1) $this->fetch ($this->id); + } + + /** + * Charge la catégorie + * id : id de la catégorie à charger + */ + function fetch ($id) + { + $sql = "SELECT rowid,label,description "; + $sql .= "FROM ".MAIN_DB_PREFIX."categorie WHERE rowid = ".$id; + + $res = $this->db->query ($sql); + + if ($res) + { + $res = $this->db->fetch_array (); + + $this->id = $res['rowid']; + $this->label = $res['label']; + $this->description = $res['description']; + + $this->db->free (); + } + else + { + dolibarr_print_error ($this->db); + return -1; + } + } + + /** + * Ajoute la catégorie dans la base de données + * retour : -1 : erreur SQL + * -2 : nouvel ID inconnu + * -3 : catégorie invalide + */ + function create () + { + if (!$this->check () || $this->already_exists ($this->label)) + { + return -3; + } + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label, description) "; + $sql .= "VALUES ('".$this->label."', '".$this->description."')"; + + $res = $this->db->query ($sql); + + if ($res) + { + $id = $this->db->last_insert_id (MAIN_DB_PREFIX."categorie"); + + if ($id > 0) + { + $this->id = $id; + return $id; + } + else + { + return -2; + } + } + else + { + dolibarr_print_error ($this->db); + return -1; + } + } + + /** + * Mise à jour de la catégorie + * retour : 1 : OK + * -1 : erreur SQL + * -2 : catégorie invalide + */ + function update () + { + if (!$this->check () || $this->id < 0) + { + return -2; + } + + $sql = "UPDATE ".MAIN_DB_PREFIX."categorie "; + $sql .= "SET label = '".trim ($this->label)."'"; + if (strlen (trim ($this->description)) > 0) + { + $sql .= ", description = '".trim ($this->description)."'"; + } + $sql .= " WHERE rowid = ".$this->id; + + if ($this->db->query ($sql)) + { + return 1; + } + else + { + dolibarr_print_error ($this->db); + return -1; + } + } + + /** + * Supprime la catégorie + * Les produits et sous-catégories deviennent orphelins + * si $all = false, et sont (seront :) supprimés sinon + * TODO : imp. $all + */ + function remove ($all = false) + { + if (!$this->check ()) + { + return -2; + } + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_product "; + $sql .= "WHERE fk_categorie = ".$this->id; + if (!$this->db->query ($sql)) + { + dolibarr_print_error ($this->db); + return -1; + } + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_association "; + $sql .= "WHERE fk_categorie_mere = ".$this->id; + $sql .= " OR fk_categorie_fille = ".$this->id; + if (!$this->db->query ($sql)) + { + dolibarr_print_error ($this->db); + return -1; + } + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie "; + $sql .= "WHERE rowid = ".$this->id; + if (!$this->db->query ($sql)) + { + dolibarr_print_error ($this->db); + return -1; + } + else + { + return 1; + } + + } + + /** + * Vérifie si la catégorie est correcte (prête à être + * enregistrée ou mise à jour + */ + function check () + { + if (strlen (trim ($this->label)) == 0) + { + return false; + } + + return true; + } + + /** + * Ajout d'une sous-catégorie + * $fille : objet catégorie + * retour : 1 : OK + * -2 : $fille est déjà une fille de $this + * -3 : catégorie ($this ou $fille) invalide + */ + function add_fille ($fille) + { + if (!$this->check () || !$fille->check ()) + { + return -3; + } + else if ($this->is_fille ($fille)) + { + return -2; + } + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_association (fk_categorie_mere, fk_categorie_fille) "; + $sql .= "VALUES (".$this->id.", ".$fille->id.")"; + + if ($this->db->query ($sql)) + { + return 1; + } + else + { + dolibarr_print_error ($this->db); + return -1; + } + } + + /** + * Suppression d'une sous-catégorie (seulement "désassociation") + * $fille : objet catégorie + * retour : 1 : OK + * -3 : catégorie ($this ou $fille) invalide + */ + function del_fille ($fille) + { + if (!$this->check () || !$fille->check ()) + { + return -3; + } + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_association "; + $sql .= "WHERE fk_categorie_mere = ".$this->id." and fk_categorie_fille = ".$fille->id; + + if ($this->db->query ($sql)) + { + return 1; + } + else + { + dolibarr_print_error ($this->db); + return -1; + } + } + + /** + * Ajout d'un produit à la catégorie + * retour : 1 : OK + * -1 : erreur SQL + * -2 : id non renseigné + */ + function add_product ($prod) + { + if ($this->id == -1) + { + return -2; + } + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_product (fk_categorie, fk_product) "; + $sql .= "VALUES (".$this->id.", ".$prod->id.")"; + + if ($this->db->query ($sql)) + { + return 1; + } + else + { + dolibarr_print_error ($this->db); + return -1; + } + } + + /** + * Suppresion d'un produit de la catégorie + * @param $prod est un objet de type produit + * retour : 1 : OK + * -1 : erreur SQL + */ + function del_product ($prod) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_product"; + $sql .= " WHERE fk_categorie = ".$this->id; + $sql .= " AND fk_product = ".$prod->id; + + if ($this->db->query ($sql)) + { + return 1; + } + else + { + dolibarr_print_error ($this->db); + return -1; + } + } + + /** + * Retourne les produits de la catégorie + */ + function get_products () + { + $sql = "SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product "; + $sql .= "WHERE fk_categorie = ".$this->id; + + $res = $this->db->query ($sql); + + if ($res) + { + $prods = array (); + while ($rec = $this->db->fetch_array ($res)) + { + $prod = new Product ($this->db, $rec['fk_product']); + $prod->fetch ($prod->id); + $prods[] = $prod; + } + return $prods; + } + else + { + dolibarr_print_error ($this->db); + return -1; + } + } + + /** + * Retourne les filles de la catégorie + */ + function get_filles () + { + $sql = "SELECT fk_categorie_fille FROM ".MAIN_DB_PREFIX."categorie_association "; + $sql .= "WHERE fk_categorie_mere = ".$this->id; + + $res = $this->db->query ($sql); + + if ($res) + { + $cats = array (); + while ($rec = $this->db->fetch_array ($res)) + { + $cat = new Categorie ($this->db, $rec['fk_categorie_fille']); + $cats[] = $cat; + } + return $cats; + } + else + { + dolibarr_print_error ($this->db); + return -1; + } + } + + /** + * La catégorie $fille est-elle une fille de cette catégorie ? + */ + function is_fille ($fille) + { + $sql = "SELECT count(fk_categorie_fille) FROM ".MAIN_DB_PREFIX."categorie_association "; + $sql .= "WHERE fk_categorie_mere = ".$this->id." AND fk_categorie_fille = ".$fille->id; + + $res = $this->db->query ($sql); + + $n = $this->db->fetch_array ($res); + + return ($n[0] > 0); + } + + /** + * Retourne toutes les catégories + */ + function get_all_categories () + { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; + + $res = $this->db->query ($sql); + + if ($res) + { + $cats = array (); + while ($record = $this->db->fetch_array ($res)) + { + $cat = new Categorie ($this->db, $record['rowid']); + $cats[$record['rowid']] = $cat; + } + return $cats; + } + else + { + dolibarr_print_error ($this->db); + return -1; + } + } + + /** + * Retourne toutes les catégories qui ont au moins 1 fille + */ + function get_all_meres () + { + $sql = "SELECT DISTINCT fk_categorie_mere FROM ".MAIN_DB_PREFIX."categorie_association"; + + $res = $this->db->query ($sql); + + if ($res) + { + $cats = array (); + while ($record = $this->db->fetch_array ($res)) + { + $cat = new Categorie ($this->db, $record['fk_categorie_mere']); + $cats[$record['fk_categorie_mere']] = $cat; + } + return $cats; + } + else + { + dolibarr_print_error ($this->db); + return -1; + } + } + + /** + * Retourne le nombre total de catégories + */ + function get_nb_categories () + { + $sql = "SELECT count(rowid) FROM ".MAIN_DB_PREFIX."categorie"; + $res = $this->db->query ($sql); + + if ($res) + { + $res = $this->db->fetch_array (); + return $res[0]; + } + else + { + dolibarr_print_error ($this->db); + return -1; + } + } + + /** + * Vérifie si une catégorie porte le label $label + */ + function already_exists ($label) + { + $sql = "SELECT count(rowid) FROM ".MAIN_DB_PREFIX."categorie "; + $sql .= "WHERE label = '".$label."'"; + + $res = $this->db->query ($sql); + $res = $this->db->fetch_array ($res); + + return ($res[0] > 0); + } + + /** + * Retourne les catégories de premier niveau + */ + function get_main_categories () + { + $allcats = $this->get_all_categories (); + + /* $sql = "SELECT rowid,label,description FROM ".MAIN_DB_PREFIX."categorie "; + $sql .= "WHERE ".MAIN_DB_PREFIX."categorie.rowid NOT IN ("; + $sql .= "SELECT fk_categorie_fille FROM ".MAIN_DB_PREFIX."categorie_association)"; + + $res = $this->db->query ($sql); + + if ($res) + { + $cats = array (); + while ($record = $this->db->fetch_array ($res)) + { + $cat = array ("rowid" => $record['rowid'], + "label" => $record['label'], + "description" => $record['description']); + $cats[$record['rowid']] = $cat; + } + return $cats; + } + else + { + return -1; + } + */ // pas de NOT IN avec MySQL ? + + + $maincats = array (); + $filles = array (); + + $sql = "SELECT fk_categorie_fille FROM ".MAIN_DB_PREFIX."categorie_association"; + $res = $this->db->query ($sql); + while ($res = $this->db->fetch_array ($res)) + { + $filles[] = $res['fk_categorie_fille']; + } + + foreach ($allcats as $cat) + { + if (!in_array ($cat->id, $filles)) + { + $maincats[] = $cat; + } + else + { + } + } + + return $maincats; + } + + /** + * Retourne les chemin de la catégorie, avec les noms des catégories + * séparés par $sep (" >> " par défaut) + */ + function print_all_ways ($sep = " >> ") + { + $ways = array (); + + foreach ($this->get_all_ways () as $way) + { + $w = array (); + foreach ($way as $cat) + { + $w[] = "".$cat->label.""; + } + $ways[] = implode ($sep, $w); + } + + return $ways; + } + + /** + * get_primary_way() affiche le chemin le plus court pour se rendre à un produit + */ + function get_primary_way($id) + { + $primary_way = Array("taille"=>-1,"chemin"=>Array()); + $meres = $this->containing($id); + foreach ($meres as $mere) + { + foreach ($mere->get_all_ways() as $way) + { + if(sizeof($way)<$primary_way["taille"] || $primary_way["taille"]<0) + { + $primary_way["taille"] = sizeOf($way); + $primary_way["chemin"] = $way; + } + } + } + return $primary_way["chemin"]; + + } + + /** + * print_primary_way() affiche le chemin le plus court pour se rendre à un produit + */ + function print_primary_way($id, $sep= " >> ") + { + $primary_way = Array(); + $way = $this->get_primary_way($id); + foreach ($way as $cat) + { + $primary_way[] = "".$cat->label.""; + } + + return implode($sep, $primary_way); + + } + /** + * Retourne un tableau contenant la liste des catégories mères + */ + function get_meres () + { + $meres = array (); + + $sql = "SELECT fk_categorie_mere FROM ".MAIN_DB_PREFIX."categorie_association "; + $sql .= "WHERE fk_categorie_fille = ".$this->id; + + $res = $this->db->query ($sql); + + while ($cat = $this->db->fetch_array ($res)) + { + $meres[] = new Categorie ($this->db, $cat['fk_categorie_mere']); + } + + return $meres; + } + + /** + * Retourne dans un tableau tous les chemins possibles pour arriver à la catégorie + * en partant des catégories principales, représentés par des tableaux de catégories + */ + function get_all_ways () + { + $ways = array (); + + foreach ($this->get_meres () as $mere) + { + foreach ($mere->get_all_ways () as $way) + { + $w = $way; + $w[] = $this; + + $ways[] = $w; + } + } + + if (sizeof ($ways) == 0) + $ways[0][0] = $this; + + return $ways; + } + + /** + * Retourne les catégories contenant le produit $id + */ + function containing ($id) + { + $cats = array (); + + $sql = "SELECT fk_categorie FROM ".MAIN_DB_PREFIX."categorie_product "; + $sql .= "WHERE fk_product = ".$id; + + $res = $this->db->query ($sql); + + if ($res) + { + while ($cat = $this->db->fetch_array ($res)) + { + $cats[] = new Categorie ($this->db, $cat['fk_categorie']); + } + + return $cats; + } + else + { + dolibarr_print_error ($this->db); + return -1; + } + } + + /** + * Retourne les catégories dont le nom correspond à $nom + * ajoute des wildcards sauf si $exact = true + */ + function rechercher_par_nom ($nom, $exact = false) + { + $cats = array (); + + if (!$exact) + { + $nom = '%'.str_replace ('*', '%', $nom).'%'; + } + + $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)) + { + $cats[] = new Categorie ($this->db, $id['rowid']); + } + + return $cats; + } + else + { + return 0; + } + } +} +?> diff --git a/htdocs/categories/create.php b/htdocs/categories/create.php new file mode 100644 index 00000000000..4f3160d234c --- /dev/null +++ b/htdocs/categories/create.php @@ -0,0 +1,187 @@ + + * + * 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$ + */ + +require "./pre.inc.php"; + +if (!$user->rights->categorie->creer) 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; +} + +llxHeader("","",$langs->trans("Categories")); + +print_titre($langs->trans("CreateCat")); + +print ''; + +print '
'; +?> +
+ + + + + + + + + + + + + + + get_all_categories ();//on récupère toutes les catégories et leurs attributs + + for ($i = 0; $i < $nbcats ; $i++) + { + echo ""; + } + ?> + + + + + + 1 && sizeof (array_unique ($cats_meres)) != sizeof ($cats_meres)) + { // alors il y a des valeurs en double + echo "

".$langs->trans ("ErrSameCatSelected")."

"; + $OK = false; + } + + // vérification des champs renseignés par l'utilisateur: si il y a un problème, on affiche un message d'erreur + foreach ($cats_meres as $nb => $cat_mere) + { + if ($cat_mere == -1) + { + echo "

".$langs->trans ("ErrForgotCat")." ".($nb+1)."

"; + $OK = false; + } + } + + // si les champs de description sont mal renseignés + if ($_POST["nom"] == '') + { + echo "

".$langs->trans ("ErrForgotField")." \"".$langs->trans ("Label")."\"

"; + $OK = false; + } + else if ($c->already_exists ($_POST["nom"])) + { + // on regarde si le champ nom n'est pas déjà dans la table catégorie (rappel: un nom est unique dans la table catégorie + // nb a déjà été renseigné, il contient le nombre de catégories + echo "

".$langs->trans ("ErrCatAlreadyExists")."

"; + $OK = false; + } + + if ($_POST["description"] == '') + { + echo "

".$langs->trans ("ErrForgotField")." \"".$langs->trans ("Description")."\"

"; + $OK = false; + } + + // vérification pour savoir si tous les champs sont corrects + if ($OK) + { + $nom = htmlspecialchars(stripslashes($_REQUEST['nom']) ,ENT_QUOTES); + $description = htmlspecialchars(stripslashes($_REQUEST['description']),ENT_QUOTES); + // creation de champs caches pour etre appele dans la classe de traitement + ?> +
trans ("Label"); ?> :' /> +
trans ("Description"); ?> :
trans ("In"); ?> trans ("categories"); ?> + + " name="ok" id="ok" /> +
".$langs->trans ("Categorie")." ".($i+1)."
+
+

trans ("ValidateFields"); ?> ? + + + + + $cat_mere) + { + echo ""; + } + ?> +

+
+
'; + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/categories/docreate.php b/htdocs/categories/docreate.php new file mode 100644 index 00000000000..6e49a7e9649 --- /dev/null +++ b/htdocs/categories/docreate.php @@ -0,0 +1,76 @@ + + * + * 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$ + */ + +require "./pre.inc.php"; + +$user->getrights('categorie'); + +$langs->load("categories"); + + +if (!isset ($_REQUEST["nom"]) || !isset ($_REQUEST["description"])) + accessforbidden(); + + +/** + * Affichage page accueil + */ + +llxHeader("","",$langs->trans("Categories")); + +print_titre($langs->trans("CatCreated")); + +print ''; + +print '
'; + +$cat = new Categorie ($db); + +$cat->label = $_REQUEST["nom"]; +$cat->description = $_REQUEST["description"]; + +$cats_meres = isset ($_REQUEST['cats_meres']) ? $_REQUEST['cats_meres'] : array (); + +$res = $cat->create (); +if ($res < 0) + { + print "

Impossible d'ajouter la catégorie ".$cat->label.".

"; + } +else + { + print "

La catégorie ".$cat->label." a été ajoutée avec succès.

"; + + foreach ($cats_meres as $id) + { + $mere = new Categorie ($db, $id); + $res = $mere->add_fille ($cat); + if ($res < 0) + { + print "

Impossible d'associer la catégorie à \"".$mere->label."\" ($res).

"; + } + } + } + + +print '
'; + +$db->close(); +?> diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php new file mode 100644 index 00000000000..8a1b885c1ec --- /dev/null +++ b/htdocs/categories/index.php @@ -0,0 +1,92 @@ + + * + * 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. + */ +require "./pre.inc.php"; + +if (!$user->rights->categorie->lire) accessforbidden(); + +/** + * Affichage page accueil + */ + +llxHeader("","",$langs->trans("Categories")); + +print_titre($langs->trans("CategoriesArea")); + +print ''; + +print '
'; + +$c = new Categorie ($db); + +/* + * Zone recherche produit/service + */ +print '
'; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print '
'.$langs->trans("Search").'
'; +print $langs->trans("Name").' :
'; +print $langs->trans("SubCatOf").' :
'; + +print '
'; + +/* + * Catégories principales + */ +$cats = $c->get_main_categories (); + +if ($cats != -1) +{ + print ''; + print ''; + + foreach ($cats as $cat) + { + $i = !$i; + print "\t\n"; + print "\t\t\n"; + print "\t\t\n"; + print "\t\n"; + } + print "
'.$langs->trans("MainCats").'
".$cat->label."".$cat->description."
"; +} +else +{ + dolibarr_print_error(); +} + +print '
'; + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php new file mode 100644 index 00000000000..b5c051cb1ca --- /dev/null +++ b/htdocs/categories/viewcat.php @@ -0,0 +1,108 @@ + + * + * 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. + */ + +require "./pre.inc.php"; + +llxHeader ("","",$langs->trans("Categories")); + +if ($_REQUEST['id'] == "") +{ + dolibarr_print_error (); + exit (); +} + +$c = new Categorie ($db, $_REQUEST['id']); + +print_titre ($langs->trans("Categorie")." ".$c->label); +?> + +
+print_all_ways (); +print "
"; +foreach ($ways as $way) +{ + print $way."
\n"; +} +print "
"; + +$cats = $c->get_filles (); + +if ($cats < 0) +{ + dolibarr_print_error(); +} +else if (sizeof ($cats) > 0) +{ + print "\n"; + print "\n"; + + foreach ($cats as $cat) + { + $i++; + print "\t\n"; + print "\t\t\n"; + print "\t\t\n"; + print "\t\n"; + } + print "
".$langs->trans("SubCats")."
".$cat->label."".$cat->description."
\n
\n"; +} +else +{ + print "

".$langs->trans("NoSubCat")."

"; +} + +$i = 0; + +$prods = $c->get_products (); + +if ($prods < 0) +{ + dolibarr_print_error(); +} +else if (sizeof ($prods) > 0) +{ + print "\n"; + print "\n"; + + foreach ($prods as $prod) + { + $i++; + print "\t\n"; + print "\t\t\n"; + print "\t\t\n"; + print "\t\n"; + } + print "
".$langs->trans("Products")."
".$prod->libelle."".$prod->description."
\n"; +} +else +{ + print "

".$langs->trans ("NoProd")."

"; +} + +print "
\n"; +print "Éditer"; +print "Supprimer"; +print "
"; +print '
'; + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/mysql/tables/llx_categorie_product.key.sql b/mysql/tables/llx_categorie_product.key.sql new file mode 100644 index 00000000000..7ebb82c83e7 --- /dev/null +++ b/mysql/tables/llx_categorie_product.key.sql @@ -0,0 +1,27 @@ +-- ============================================================================ +-- Copyright (C) 2005 Brice Davoleau +-- Copyright (C) 2005 Matthieu Valleton +-- +-- 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. +-- +-- ============================================================================ + +ALTER TABLE llx_categorie_product ADD INDEX (fk_categorie); +ALTER TABLE llx_categorie_product ADD INDEX (fk_product); + +ALTER TABLE llx_categorie_product ADD FOREIGN KEY (fk_categorie) + REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_product ADD FOREIGN KEY (fk_product) + REFERENCES llx_product (rowid); diff --git a/mysql/tables/llx_categorie_product.sql b/mysql/tables/llx_categorie_product.sql new file mode 100644 index 00000000000..6a84e56848a --- /dev/null +++ b/mysql/tables/llx_categorie_product.sql @@ -0,0 +1,25 @@ +-- ============================================================================ +-- Copyright (C) 2005 Brice Davoleau +-- Copyright (C) 2005 Matthieu Valleton +-- +-- 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. +-- +-- ============================================================================ + +create table llx_categorie_product +( + fk_categorie integer NOT NULL, + fk_product integer NOT NULL +)type=innodb;