début restructuration du code
This commit is contained in:
parent
f575fc20ed
commit
dbfa477d25
@ -32,13 +32,14 @@ class Categorie
|
|||||||
var $id;
|
var $id;
|
||||||
var $label;
|
var $label;
|
||||||
var $description;
|
var $description;
|
||||||
|
var $statut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur
|
* Constructeur
|
||||||
* db : accès base de données
|
* db : accès base de données
|
||||||
* id : id de la catégorie
|
* id : id de la catégorie
|
||||||
*/
|
*/
|
||||||
function Categorie ($db, $id=-1)
|
function Categorie($db, $id=-1)
|
||||||
{
|
{
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
@ -50,28 +51,29 @@ class Categorie
|
|||||||
* Charge la catégorie
|
* Charge la catégorie
|
||||||
* id : id de la catégorie à charger
|
* id : id de la catégorie à charger
|
||||||
*/
|
*/
|
||||||
function fetch ($id)
|
function fetch($id)
|
||||||
{
|
{
|
||||||
$sql = "SELECT rowid,label,description ";
|
$sql = "SELECT rowid, label, description, fk_statut";
|
||||||
$sql .= "FROM ".MAIN_DB_PREFIX."categorie WHERE rowid = ".$id;
|
$sql.= " FROM ".MAIN_DB_PREFIX."categorie WHERE rowid = ".$id;
|
||||||
|
|
||||||
$resql = $this->db->query ($sql);
|
$resql = $this->db->query ($sql);
|
||||||
|
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$res = $this->db->fetch_array($resql);
|
$res = $this->db->fetch_array($resql);
|
||||||
|
|
||||||
$this->id = $res['rowid'];
|
$this->id = $res['rowid'];
|
||||||
$this->label = $res['label'];
|
$this->label = $res['label'];
|
||||||
$this->description = stripslashes($res['description']);
|
$this->description = stripslashes($res['description']);
|
||||||
|
$this->statut = $res['fk_statut'];
|
||||||
|
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error ($this->db);
|
dolibarr_print_error ($this->db);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,12 +82,12 @@ class Categorie
|
|||||||
* -2 : nouvel ID inconnu
|
* -2 : nouvel ID inconnu
|
||||||
* -3 : catégorie invalide
|
* -3 : catégorie invalide
|
||||||
*/
|
*/
|
||||||
function create ()
|
function create()
|
||||||
{
|
{
|
||||||
if (!$this->check () || $this->already_exists ($this->label))
|
if (!$this->check () || $this->already_exists ($this->label))
|
||||||
{
|
{
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label, description) ";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label, description) ";
|
||||||
$sql .= "VALUES ('".$this->label."', '".$this->description."')";
|
$sql .= "VALUES ('".$this->label."', '".$this->description."')";
|
||||||
@ -93,24 +95,24 @@ class Categorie
|
|||||||
$res = $this->db->query ($sql);
|
$res = $this->db->query ($sql);
|
||||||
|
|
||||||
if ($res)
|
if ($res)
|
||||||
{
|
{
|
||||||
$id = $this->db->last_insert_id (MAIN_DB_PREFIX."categorie");
|
$id = $this->db->last_insert_id (MAIN_DB_PREFIX."categorie");
|
||||||
|
|
||||||
if ($id > 0)
|
if ($id > 0)
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error ($this->db);
|
dolibarr_print_error ($this->db);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,30 +121,31 @@ class Categorie
|
|||||||
* -1 : erreur SQL
|
* -1 : erreur SQL
|
||||||
* -2 : catégorie invalide
|
* -2 : catégorie invalide
|
||||||
*/
|
*/
|
||||||
function update ()
|
function update()
|
||||||
{
|
{
|
||||||
if (!$this->check () || $this->id < 0)
|
if (!$this->check() || $this->id < 0)
|
||||||
{
|
{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."categorie ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."categorie";
|
||||||
$sql .= "SET label = '".trim ($this->label)."'";
|
$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))
|
if (strlen (trim($this->description)) > 0)
|
||||||
{
|
{
|
||||||
return 1;
|
$sql .= ", description = '".trim($this->description)."'";
|
||||||
}
|
}
|
||||||
|
$sql .= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
|
if ($this->db->query($sql))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error ($this->db);
|
dolibarr_print_error($this->db);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -153,39 +156,42 @@ class Categorie
|
|||||||
*/
|
*/
|
||||||
function remove ($all = false)
|
function remove ($all = false)
|
||||||
{
|
{
|
||||||
if (!$this->check ())
|
if (!$this->check())
|
||||||
{
|
{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_product ";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_product ";
|
||||||
$sql .= "WHERE fk_categorie = ".$this->id;
|
$sql .= "WHERE fk_categorie = ".$this->id;
|
||||||
if (!$this->db->query ($sql))
|
|
||||||
{
|
if (!$this->db->query($sql))
|
||||||
dolibarr_print_error ($this->db);
|
{
|
||||||
return -1;
|
dolibarr_print_error($this->db);
|
||||||
}
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_association ";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_association ";
|
||||||
$sql .= "WHERE fk_categorie_mere = ".$this->id;
|
$sql .= "WHERE fk_categorie_mere = ".$this->id;
|
||||||
$sql .= " OR fk_categorie_fille = ".$this->id;
|
$sql .= " OR fk_categorie_fille = ".$this->id;
|
||||||
if (!$this->db->query ($sql))
|
|
||||||
{
|
if (!$this->db->query($sql))
|
||||||
dolibarr_print_error ($this->db);
|
{
|
||||||
return -1;
|
dolibarr_print_error($this->db);
|
||||||
}
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie ";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie ";
|
||||||
$sql .= "WHERE rowid = ".$this->id;
|
$sql .= "WHERE rowid = ".$this->id;
|
||||||
if (!$this->db->query ($sql))
|
|
||||||
{
|
if (!$this->db->query($sql))
|
||||||
dolibarr_print_error ($this->db);
|
{
|
||||||
return -1;
|
dolibarr_print_error($this->db);
|
||||||
}
|
return -1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,12 +199,12 @@ class Categorie
|
|||||||
* Vérifie si la catégorie est correcte (prête à être
|
* Vérifie si la catégorie est correcte (prête à être
|
||||||
* enregistrée ou mise à jour
|
* enregistrée ou mise à jour
|
||||||
*/
|
*/
|
||||||
function check ()
|
function check()
|
||||||
{
|
{
|
||||||
if (strlen (trim ($this->label)) == 0)
|
if (strlen(trim($this->label)) == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -210,29 +216,29 @@ class Categorie
|
|||||||
* -2 : $fille est déjà une fille de $this
|
* -2 : $fille est déjà une fille de $this
|
||||||
* -3 : catégorie ($this ou $fille) invalide
|
* -3 : catégorie ($this ou $fille) invalide
|
||||||
*/
|
*/
|
||||||
function add_fille ($fille)
|
function add_fille($fille)
|
||||||
{
|
{
|
||||||
if (!$this->check () || !$fille->check ())
|
if (!$this->check() || !$fille->check())
|
||||||
{
|
{
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
else if ($this->is_fille ($fille))
|
else if ($this->is_fille($fille))
|
||||||
{
|
{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_association (fk_categorie_mere, fk_categorie_fille) ";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_association (fk_categorie_mere, fk_categorie_fille)";
|
||||||
$sql .= "VALUES (".$this->id.", ".$fille->id.")";
|
$sql.= " VALUES (".$this->id.", ".$fille->id.")";
|
||||||
|
|
||||||
if ($this->db->query ($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error ($this->db);
|
dolibarr_print_error($this->db);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -241,25 +247,25 @@ class Categorie
|
|||||||
* retour : 1 : OK
|
* retour : 1 : OK
|
||||||
* -3 : catégorie ($this ou $fille) invalide
|
* -3 : catégorie ($this ou $fille) invalide
|
||||||
*/
|
*/
|
||||||
function del_fille ($fille)
|
function del_fille($fille)
|
||||||
{
|
{
|
||||||
if (!$this->check () || !$fille->check ())
|
if (!$this->check() || !$fille->check())
|
||||||
{
|
{
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_association ";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_association";
|
||||||
$sql .= "WHERE fk_categorie_mere = ".$this->id." and fk_categorie_fille = ".$fille->id;
|
$sql .= " WHERE fk_categorie_mere = ".$this->id." and fk_categorie_fille = ".$fille->id;
|
||||||
|
|
||||||
if ($this->db->query ($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error ($this->db);
|
dolibarr_print_error($this->db);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -268,25 +274,25 @@ class Categorie
|
|||||||
* -1 : erreur SQL
|
* -1 : erreur SQL
|
||||||
* -2 : id non renseigné
|
* -2 : id non renseigné
|
||||||
*/
|
*/
|
||||||
function add_product ($prod)
|
function add_product($prod)
|
||||||
{
|
{
|
||||||
if ($this->id == -1)
|
if ($this->id == -1)
|
||||||
{
|
{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_product (fk_categorie, fk_product) ";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_product (fk_categorie, fk_product)";
|
||||||
$sql .= "VALUES (".$this->id.", ".$prod->id.")";
|
$sql .= " VALUES (".$this->id.", ".$prod->id.")";
|
||||||
|
|
||||||
if ($this->db->query ($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error ($this->db);
|
dolibarr_print_error($this->db);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -295,49 +301,49 @@ class Categorie
|
|||||||
* retour : 1 : OK
|
* retour : 1 : OK
|
||||||
* -1 : erreur SQL
|
* -1 : erreur SQL
|
||||||
*/
|
*/
|
||||||
function del_product ($prod)
|
function del_product($prod)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_product";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_product";
|
||||||
$sql .= " WHERE fk_categorie = ".$this->id;
|
$sql .= " WHERE fk_categorie = ".$this->id;
|
||||||
$sql .= " AND fk_product = ".$prod->id;
|
$sql .= " AND fk_product = ".$prod->id;
|
||||||
|
|
||||||
if ($this->db->query ($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error ($this->db);
|
dolibarr_print_error($this->db);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne les produits de la catégorie
|
* Retourne les produits de la catégorie
|
||||||
*/
|
*/
|
||||||
function get_products ()
|
function get_products()
|
||||||
{
|
{
|
||||||
$sql = "SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product ";
|
$sql = "SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product ";
|
||||||
$sql .= "WHERE fk_categorie = ".$this->id;
|
$sql .= "WHERE fk_categorie = ".$this->id;
|
||||||
|
|
||||||
$res = $this->db->query ($sql);
|
$res = $this->db->query($sql);
|
||||||
|
|
||||||
if ($res)
|
if ($res)
|
||||||
{
|
{
|
||||||
$prods = array ();
|
$prods = array();
|
||||||
while ($rec = $this->db->fetch_array ($res))
|
while ($rec = $this->db->fetch_array ($res))
|
||||||
{
|
{
|
||||||
$prod = new Product ($this->db, $rec['fk_product']);
|
$prod = new Product ($this->db, $rec['fk_product']);
|
||||||
$prod->fetch ($prod->id);
|
$prod->fetch ($prod->id);
|
||||||
$prods[] = $prod;
|
$prods[] = $prod;
|
||||||
}
|
}
|
||||||
return $prods;
|
return $prods;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error ($this->db);
|
dolibarr_print_error ($this->db);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -477,52 +483,26 @@ class Categorie
|
|||||||
function get_main_categories ()
|
function get_main_categories ()
|
||||||
{
|
{
|
||||||
$allcats = $this->get_all_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 ();
|
$maincats = array ();
|
||||||
$filles = array ();
|
$filles = array ();
|
||||||
|
|
||||||
$sql = "SELECT fk_categorie_fille FROM ".MAIN_DB_PREFIX."categorie_association";
|
$sql = "SELECT fk_categorie_fille FROM ".MAIN_DB_PREFIX."categorie_association";
|
||||||
$res = $this->db->query ($sql);
|
$res = $this->db->query ($sql);
|
||||||
while ($res = $this->db->fetch_array ($res))
|
while ($res = $this->db->fetch_array ($res))
|
||||||
{
|
{
|
||||||
$filles[] = $res['fk_categorie_fille'];
|
$filles[] = $res['fk_categorie_fille'];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($allcats as $cat)
|
foreach ($allcats as $cat)
|
||||||
{
|
{
|
||||||
if (!in_array ($cat->id, $filles))
|
if (!in_array ($cat->id, $filles))
|
||||||
{
|
{
|
||||||
$maincats[] = $cat;
|
$maincats[] = $cat;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $maincats;
|
return $maincats;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,9 +72,9 @@ print '<tr><td valign="top" width="30%" class="notopnoleft">';
|
|||||||
<td><?php print $langs->trans ("In"); ?> <select name="choix">
|
<td><?php print $langs->trans ("In"); ?> <select name="choix">
|
||||||
<?php
|
<?php
|
||||||
// création d'un objet de type catégorie pour faire des requêtes sur la table
|
// création d'un objet de type catégorie pour faire des requêtes sur la table
|
||||||
$c = new Categorie ($db);
|
$categorie = new Categorie ($db);
|
||||||
|
|
||||||
$nb = $c->get_nb_categories ();
|
$nb = $categorie->get_nb_categories();
|
||||||
|
|
||||||
for ($i = 0 ; $i <= $nb ; $i++)
|
for ($i = 0 ; $i <= $nb ; $i++)
|
||||||
{
|
{
|
||||||
@ -94,7 +94,7 @@ print '<tr><td valign="top" width="30%" class="notopnoleft">';
|
|||||||
<input type="submit" value="<?php print $langs->trans ("modify"); ?>" name="ok" id="ok" />
|
<input type="submit" value="<?php print $langs->trans ("modify"); ?>" name="ok" id="ok" />
|
||||||
</td>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
$cats = $c->get_all_categories ();//on récupère toutes les catégories et leurs attributs
|
$all_categories = $categorie->get_all_categories();//on récupère toutes les catégories et leurs attributs
|
||||||
|
|
||||||
for ($i = 0; $i < $nbcats ; $i++)
|
for ($i = 0; $i < $nbcats ; $i++)
|
||||||
{
|
{
|
||||||
@ -102,7 +102,7 @@ print '<tr><td valign="top" width="30%" class="notopnoleft">';
|
|||||||
|
|
||||||
echo "<option value='-1' id='choix'>".$langs->trans ("Choose")."</option>\n";
|
echo "<option value='-1' id='choix'>".$langs->trans ("Choose")."</option>\n";
|
||||||
|
|
||||||
foreach ($cats as $id => $cat)
|
foreach ($all_categories as $id => $cat)
|
||||||
{ //ajout des categories dans la liste
|
{ //ajout des categories dans la liste
|
||||||
echo "<option value='$id' id='$id'";
|
echo "<option value='$id' id='$id'";
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ $user->getrights('categorie');
|
|||||||
$langs->load("categories");
|
$langs->load("categories");
|
||||||
|
|
||||||
|
|
||||||
if (!isset ($_REQUEST["nom"]) || !isset ($_REQUEST["description"]))
|
if (!isset($_REQUEST["nom"]) || !isset($_REQUEST["description"]))
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
@ -42,31 +42,33 @@ print '<table border="0" width="100%">';
|
|||||||
|
|
||||||
print '<tr><td valign="top" width="30%">';
|
print '<tr><td valign="top" width="30%">';
|
||||||
|
|
||||||
$cat = new Categorie ($db);
|
$categorie = new Categorie($db);
|
||||||
|
|
||||||
$cat->label = $_REQUEST["nom"];
|
$categorie->label = $_REQUEST["nom"];
|
||||||
$cat->description = $_REQUEST["description"];
|
$categorie->description = $_REQUEST["description"];
|
||||||
|
|
||||||
$cats_meres = isset ($_REQUEST['cats_meres']) ? $_REQUEST['cats_meres'] : array ();
|
$cats_meres = isset($_REQUEST['cats_meres']) ? $_REQUEST['cats_meres'] : array ();
|
||||||
|
|
||||||
$res = $cat->create ();
|
$res = $categorie->create();
|
||||||
if ($res < 0)
|
|
||||||
|
if ($res < 0)
|
||||||
{
|
{
|
||||||
print "<p>Impossible d'ajouter la catégorie ".$cat->label.".</p>";
|
print "<p>Impossible d'ajouter la catégorie ".$categorie->label.".</p>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print "<p>La catégorie ".$cat->label." a été ajoutée avec succès.</p>";
|
print "<p>La catégorie ".$categorie->label." a été ajoutée avec succès.</p>";
|
||||||
|
|
||||||
foreach ($cats_meres as $id)
|
foreach ($cats_meres as $id)
|
||||||
{
|
{
|
||||||
$mere = new Categorie ($db, $id);
|
$mere = new Categorie($db, $id);
|
||||||
$res = $mere->add_fille ($cat);
|
$res = $mere->add_fille($categorie);
|
||||||
if ($res < 0)
|
|
||||||
{
|
if ($res < 0)
|
||||||
print "<p>Impossible d'associer la catégorie à \"".$mere->label."\" ($res).</p>";
|
{
|
||||||
}
|
print "<p>Impossible d'associer la catégorie à \"".$mere->label."\" ($res).</p>";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user