Fix: broken features

This commit is contained in:
Regis Houssin 2012-05-21 15:45:44 +02:00
parent fe48342aaf
commit 5f835bed7e
3 changed files with 28 additions and 18 deletions

View File

@ -39,6 +39,7 @@ $type = GETPOST('type');
$mesg = GETPOST('mesg'); $mesg = GETPOST('mesg');
$removecat = GETPOST('removecat','int'); $removecat = GETPOST('removecat','int');
$catMere=GETPOST('catMere','int');
$dbtablename = ''; $dbtablename = '';
@ -121,7 +122,7 @@ if ($removecat > 0)
} }
// Add object into a category // 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)) if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
{ {
@ -150,7 +151,7 @@ if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0)
$elementtype = 'member'; $elementtype = 'member';
} }
$cat = new Categorie($db); $cat = new Categorie($db);
$result=$cat->fetch($_REQUEST["catMere"]); $result=$cat->fetch($catMere);
$result=$cat->add_type($object,$elementtype); $result=$cat->add_type($object,$elementtype);
if ($result >= 0) if ($result >= 0)
@ -162,7 +163,6 @@ if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0)
if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') $mesg='<div class="error">'.$langs->trans("ObjectAlreadyLinkedToCategory").'</div>'; if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') $mesg='<div class="error">'.$langs->trans("ObjectAlreadyLinkedToCategory").'</div>';
else $mesg=$langs->trans("Error").' '.$cat->error; else $mesg=$langs->trans("Error").' '.$cat->error;
} }
} }

View File

@ -579,7 +579,8 @@ class Categorie
$cats = array (); $cats = array ();
while ($rec = $this->db->fetch_array($res)) 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; $cats[] = $cat;
} }
return $cats; return $cats;
@ -826,9 +827,10 @@ class Categorie
if ($res) if ($res)
{ {
$cats = array (); $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; $cats[$record['rowid']] = $cat;
} }
return $cats; return $cats;
@ -1059,9 +1061,11 @@ class Categorie
if ($res) 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; return $meres;
} }
@ -1125,9 +1129,11 @@ class Categorie
$res = $this->db->query($sql); $res = $this->db->query($sql);
if ($res) 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; return $cats;
@ -1174,9 +1180,11 @@ class Categorie
$res = $this->db->query($sql); $res = $this->db->query($sql);
if ($res) 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; return $cats;

View File

@ -108,7 +108,9 @@ print_fiche_titre($langs->trans("ModifCat"));
dol_htmloutput_errors($mesg); dol_htmloutput_errors($mesg);
$categorie = new Categorie($db, $id); $object = new Categorie($db);
$object->fetch($id);
$form = new Form($db); $form = new Form($db);
print '<table class="notopnoleft" border="0" width="100%">'; print '<table class="notopnoleft" border="0" width="100%">';
@ -119,7 +121,7 @@ print "\n";
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'">'; print '<form method="post" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$categorie->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="type" value="'.$type.'">'; print '<input type="hidden" name="type" value="'.$type.'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -127,7 +129,7 @@ print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td class="fieldrequired">'; print '<tr><td class="fieldrequired">';
print $langs->trans("Ref").'</td>'; print $langs->trans("Ref").'</td>';
print '<td><input type="text" size="25" id="nom" name ="nom" value="'.$categorie->label.'" />'; print '<td><input type="text" size="25" id="nom" name ="nom" value="'.$object->label.'" />';
print '</tr>'; print '</tr>';
// Description // Description
@ -135,13 +137,13 @@ print '<tr>';
print '<td width="25%">'.$langs->trans("Description").'</td>'; print '<td width="25%">'.$langs->trans("Description").'</td>';
print '<td>'; print '<td>';
require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); 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(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';
// Parent category // Parent category
print '<tr><td>'.$langs->trans("In").'</td><td>'; print '<tr><td>'.$langs->trans("In").'</td><td>';
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 '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
@ -154,7 +156,7 @@ print '</form>';
print '</td></tr></table>'; print '</td></tr></table>';
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>