From 5f835bed7ec7a7b9e46764f66b25213e3267f85c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 21 May 2012 15:45:44 +0200 Subject: [PATCH] Fix: broken features --- htdocs/categories/categorie.php | 6 ++--- htdocs/categories/class/categorie.class.php | 26 ++++++++++++++------- htdocs/categories/edit.php | 14 ++++++----- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index 2a6e437c765..4a7ceaf36c3 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -39,6 +39,7 @@ $type = GETPOST('type'); $mesg = GETPOST('mesg'); $removecat = GETPOST('removecat','int'); +$catMere=GETPOST('catMere','int'); $dbtablename = ''; @@ -121,7 +122,7 @@ if ($removecat > 0) } // Add object into a category -if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0) +if ($catMere > 0) { if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer)) { @@ -150,7 +151,7 @@ if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0) $elementtype = 'member'; } $cat = new Categorie($db); - $result=$cat->fetch($_REQUEST["catMere"]); + $result=$cat->fetch($catMere); $result=$cat->add_type($object,$elementtype); if ($result >= 0) @@ -162,7 +163,6 @@ if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0) if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') $mesg='
'.$langs->trans("ObjectAlreadyLinkedToCategory").'
'; else $mesg=$langs->trans("Error").' '.$cat->error; } - } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index ad11b066e8b..3a31f6b0e7f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -579,7 +579,8 @@ class Categorie $cats = array (); while ($rec = $this->db->fetch_array($res)) { - $cat = new Categorie($this->db, $rec['fk_categorie_fille']); + $cat = new self($this->db); + $cat->fetch($rec['fk_categorie_fille']); $cats[] = $cat; } return $cats; @@ -826,9 +827,10 @@ class Categorie if ($res) { $cats = array (); - while ($record = $this->db->fetch_array($res)) + while ($rec = $this->db->fetch_array($res)) { - $cat = new Categorie($this->db, $record['rowid']); + $cat = new self($this->db); + $cat->fetch($rec['rowid']); $cats[$record['rowid']] = $cat; } return $cats; @@ -1059,9 +1061,11 @@ class Categorie if ($res) { - while ($cat = $this->db->fetch_array($res)) + while ($rec = $this->db->fetch_array($res)) { - $meres[] = new Categorie($this->db, $cat['fk_categorie_mere']); + $cat = new self($this->db); + $cat->fetch($rec['fk_categorie_mere']); + $meres[] = $cat; } return $meres; } @@ -1125,9 +1129,11 @@ class Categorie $res = $this->db->query($sql); if ($res) { - while ($cat = $this->db->fetch_array($res)) + while ($rec = $this->db->fetch_array($res)) { - $cats[] = new Categorie($this->db, $cat['fk_categorie']); + $cat = new self($this->db); + $cat->fetch($rec['fk_categorie']); + $cats[] = $cat; } return $cats; @@ -1174,9 +1180,11 @@ class Categorie $res = $this->db->query($sql); if ($res) { - while ($id = $this->db->fetch_array($res)) + while ($rec = $this->db->fetch_array($res)) { - $cats[] = new Categorie($this->db, $id['rowid']); + $cat = new self($this->db); + $cat->fetch($rec['rowid']); + $cats[] = $cat; } return $cats; diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 015b964d452..76b38f29681 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -108,7 +108,9 @@ print_fiche_titre($langs->trans("ModifCat")); dol_htmloutput_errors($mesg); -$categorie = new Categorie($db, $id); +$object = new Categorie($db); +$object->fetch($id); + $form = new Form($db); print ''; @@ -119,7 +121,7 @@ print "\n"; print ''; print ''; print ''; -print ''; +print ''; print ''; print '
'; @@ -127,7 +129,7 @@ print '
'; // Ref print ''; -print ''; // Description @@ -135,13 +137,13 @@ print ''; print ''; print ''; // Parent category print ''; print '
'; print $langs->trans("Ref").''; +print ''; print '
'.$langs->trans("Description").''; require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); -$doleditor=new DolEditor('description',$categorie->description,'',200,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,ROWS_6,50); +$doleditor=new DolEditor('description',$object->description,'',200,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,ROWS_6,50); $doleditor->Create(); print '
'.$langs->trans("In").''; -print $form->select_all_categories($type,$categorie->id_mere,'catMere',64,$categorie->id); +print $form->select_all_categories($type,$object->id_mere,'catMere',64,$object->id); print '
'; @@ -154,7 +156,7 @@ print ''; print ''; -$db->close(); llxFooter(); +$db->close(); ?>