Fix: Debug divers sur gestion des catgories

This commit is contained in:
Laurent Destailleur 2006-07-30 00:37:31 +00:00
parent f0a09048ef
commit c0e8e07d84
5 changed files with 111 additions and 78 deletions

View File

@ -85,7 +85,7 @@ print '<tr><td valign="top" width="30%">';
?> ?>
<form method="post" action="<?php print $_SERVER['REQUEST_URI']; ?>"> <form method="post" action="<?php print $_SERVER['REQUEST_URI']; ?>">
<input type="hidden" name="action" value="update"> <input type="hidden" name="action" value="update">
<table class="border"> <table class="border" width="100%">
<tr> <tr>
<td><?php print $langs->trans("Label"); ?>&nbsp;:</td> <td><?php print $langs->trans("Label"); ?>&nbsp;:</td>
@ -93,15 +93,27 @@ print '<tr><td valign="top" width="30%">';
print $categorie->label; print $categorie->label;
?>" /> ?>" />
</tr> </tr>
<tr> <?php
<td><?php print $langs->trans("Description"); ?>&nbsp;:</td> print '<tr>';
print '<td width="25%">'.$langs->trans("Description").':</td>';
<td><textarea name='description' cols='40' rows='6' id='description'><?php print '<td>';
print $categorie->description;
?></textarea></td> if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
{
</tr> require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('description',$categorie->description,240,'dolibarr_notes');
$doleditor->Create();
}
else
{
print '<textarea name="description" rows="'.ROWS_6.'" cols="50">';
print $categorie->description;
print '</textarea>';
}
print '</td>';
print '</tr>';
?>
<tr><td><?php print $langs->trans ("AddIn"); ?></td><td> <tr><td><?php print $langs->trans ("AddIn"); ?></td><td>
<?php print $html->select_all_categories($categorie->id_mere);?> <?php print $html->select_all_categories($categorie->id_mere);?>
@ -124,4 +136,6 @@ print '<tr><td valign="top" width="30%">';
print '</td></tr></table>'; print '</td></tr></table>';
$db->close(); $db->close();
llxFooter('$Date$ - $Revision$');
?> ?>

View File

@ -46,11 +46,12 @@ if ($_REQUEST['origin'])
$idprodorigin = $_REQUEST['origin']; $idprodorigin = $_REQUEST['origin'];
} }
llxHeader("","",$langs->trans("Categories")); llxHeader("","",$langs->trans("Categories"));
$html = new Form($db); $html = new Form($db);
// Action ajout d'une catégorie // Action ajout d'une catégorie
if ($_POST["action"] == 'add' && $user->rights->categorie->creer) if ($_POST["action"] == 'add' && $user->rights->categorie->creer)
{ {
@ -60,8 +61,8 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer)
$categorie->description = $_POST["description"]; $categorie->description = $_POST["description"];
$categorie->visible = $_POST["visible"]; $categorie->visible = $_POST["visible"];
if($_POST['catMere'] != "-1") if($_POST['catMere'] != "-1")
$categorie->id_mere = $_POST['catMere']; $categorie->id_mere = $_POST['catMere'];
if (!$categorie->label || !$categorie->description) if (!$categorie->label || !$categorie->description)
{ {
@ -74,37 +75,37 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer)
{ {
$_GET["action"] = 'confirmed'; $_GET["action"] = 'confirmed';
$_POST["addcat"] = ''; $_POST["addcat"] = '';
} }
} }
/* /*
* Action confirmation de création de la catégorie * Action confirmation de création de la catégorie
*/ */
if ($_GET["action"] == 'confirmed') if ($_GET["action"] == 'confirmed')
{ {
print_titre($langs->trans("CatCreated")); print_titre($langs->trans("CatCreated"));
print '<table border="0" width="100%">'; print '<table border="0" width="100%">';
print '<tr><td valign="top" width="30%">'; print '<tr><td valign="top" width="30%">';
print '<p>'.$langs->trans("TheCategorie").' '.$categorie->label.' '.$langs->trans("WasAddedSuccessfully").'</p>'; print $langs->trans("TheCategorie").' '.$categorie->label.' '.$langs->trans("WasAddedSuccessfully");
if ($_REQUEST['idprodorigin']) if ($_REQUEST['idprodorigin'])
{ {
$idprodorigin = $_REQUEST['idprodorigin']; $idprodorigin = $_REQUEST['idprodorigin'];
print '<p><a class="butAction" href="'.DOL_URL_ROOT.'/product/categorie.php?id='.$idprodorigin.'">'.$langs->trans("ReturnInProduct").'</a></p>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/categorie.php?id='.$idprodorigin.'">'.$langs->trans("ReturnInProduct").'</a>';
} }
print '</td></tr></table>'; print '</td></tr></table>';
} }
} }
if ($user->rights->produit->creer) if ($user->rights->categorie->creer)
{ {
/* /*
* Fiche en mode création * Fiche en mode création
*/ */
if ($_GET["action"] == 'create' || $_POST["addcat"] == 'addcat') if ($_GET["action"] == 'create' || $_POST["addcat"] == 'addcat')
{ {
if($categorie->error != "") if($categorie->error != "")
@ -126,11 +127,24 @@ if ($user->rights->produit->creer)
print '<table class="border" width="100%" class="notopnoleftnoright">'; print '<table class="border" width="100%" class="notopnoleftnoright">';
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("Label").'</td><td><input name="nom" size"25" value="'.$categorie->label.'">'; print '<td width="25%">'.$langs->trans("Label").'</td><td><input name="nom" size="25" value="'.$categorie->label.'">';
print'</td></tr>'; print'</td></tr>';
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'; print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
print '<textarea name="description" rows="6" cols="50">';
print $categorie->description.'</textarea></td></tr>'; if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('description',$categorie->description,240,'dolibarr_notes');
$doleditor->Create();
}
else
{
print '<textarea name="description" rows="'.ROWS_6.'" cols="50">';
print $categorie->description;
print '</textarea>';
}
print '</td></tr>';
print '<tr><td>'.$langs->trans ("AddIn").'</td><td>'; print '<tr><td>'.$langs->trans ("AddIn").'</td><td>';
print $html->select_all_categories(); print $html->select_all_categories();
print '</td></tr>'; print '</td></tr>';

View File

@ -75,50 +75,54 @@ print '</td><td valign="top" width="70%">';
* Catégories trouvées * Catégories trouvées
*/ */
if($_POST['catname']) { if($_POST['catname'])
$cats = $c->rechercher_par_nom ($_POST['catname']); {
print '<table class="noborder" width="100%">'; $cats = $c->rechercher_par_nom ($_POST['catname']);
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("FoundCats").'</td></tr>'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("FoundCats").'</td></tr>';
foreach ($cats as $cat)
{ $var=true;
$i = !$i; foreach ($cats as $cat)
print "\t<tr ".$bc[$i].">\n"; {
print "\t\t<td><a href='viewcat.php?id=".$cat->id."'>".$cat->label."</a></td>\n"; $var = ! $var;
print "\t\t<td>".$cat->description."</td>\n"; print "\t<tr ".$bc[$var].">\n";
print "\t</tr>\n"; print "\t\t<td><a href='viewcat.php?id=".$cat->id."'>".$cat->label."</a></td>\n";
} print "\t\t<td>".$cat->description."</td>\n";
print "</table>"; print "\t</tr>\n";
}
print "</table>";
} }
/* /*
* Catégories principales * Catégories principales
*/ */
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("AllCats").'</td><td>'.$langs->trans("Desc").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("AllCats").'</td><td>'.$langs->trans("Desc").'</td></tr>';
$c->get_categories_arbo(); $c->get_categories_arbo();
$cate_arbo = $c->get_arbo_each_cate(); $cate_arbo = $c->get_arbo_each_cate();
foreach($cate_arbo as $key => $value) if (is_array($cate_arbo))
{ {
$i = !$i; $var=true;
print "\t<tr ".$bc[$i].">\n"; foreach($cate_arbo as $key => $value)
print '<td><a href="viewcat.php?id='.$value[1].'">'.$value[0].'</a></td>'; {
print "\t</td>\n"; $var = ! $var;
print '<td>'.$c->get_desc($value[1]).'</td>'; print "\t<tr ".$bc[$var].">\n";
print "\t</td>\n"; print '<td><a href="viewcat.php?id='.$value[1].'">'.$value[0].'</a></td>';
print "\t</tr>\n"; print "\t</td>\n";
} print '<td>'.$c->get_desc($value[1]).'</td>';
print "\t</td>\n";
print "\t</tr>\n";
print "</table>"; }
}
print "</table>";
print '</td></tr></table>'; print '</td></tr></table>';
$db->close(); $db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>"); llxFooter('$Date$ - $Revision$');
?> ?>

View File

@ -1200,7 +1200,7 @@ class Form
$cat->get_categories_arbo(); $cat->get_categories_arbo();
$cate_arbo = $cat->get_arbo_each_cate(); $cate_arbo = $cat->get_arbo_each_cate();
$output = '<select name="'.$select_name.'">'; //creation des categories meres $output = '<select name="'.$select_name.'">'; //creation des categories meres
$output.= '<option value="-1" id="choix">&nbsp;</option>\n'; $output.= '<option value="-1" id="choix">&nbsp;</option>';
if ($cate_arbo) if ($cate_arbo)
{ {
@ -1215,6 +1215,7 @@ class Form
} }
$output.= '</select>'; $output.= '</select>';
$output.= "\n";
return $output; return $output;
} }

View File

@ -243,14 +243,14 @@ if ($_GET["id"] || $_GET["ref"])
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Categories").'</td></tr>'; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Categories").'</td></tr>';
$var = true;
foreach ($cats as $cat) foreach ($cats as $cat)
{ {
$ways = $cat->print_all_ways (); $ways = $cat->print_all_ways ();
foreach ($ways as $way) foreach ($ways as $way)
{ {
$i = !$i; $var = ! $var;
print "<tr ".$bc[$i]."><td>".$way."</td>"; print "<tr ".$bc[$var]."><td>".$way."</td>";
print '<td align="right">'.img_delete($langs->trans("DeleteFromCat"))." <a href= '".DOL_URL_ROOT."/product/categorie.php?id=".$product->id."&amp;cat=".$cat->id."'>".$langs->trans("DeleteFromCat")."</a></td></tr>\n"; print '<td align="right">'.img_delete($langs->trans("DeleteFromCat"))." <a href= '".DOL_URL_ROOT."/product/categorie.php?id=".$product->id."&amp;cat=".$cat->id."'>".$langs->trans("DeleteFromCat")."</a></td></tr>\n";
} }