début restructuration du code des catégories
This commit is contained in:
parent
2211c24253
commit
fff20a58f2
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
require "./pre.inc.php";
|
require "./pre.inc.php";
|
||||||
|
|
||||||
if (!$user->rights->categorie->creer) accessforbidden();
|
if (!$user->rights->categorie->lire) accessforbidden();
|
||||||
|
|
||||||
if (isset ($_REQUEST['choix']))
|
if (isset ($_REQUEST['choix']))
|
||||||
{
|
{
|
||||||
@ -45,50 +45,31 @@ else
|
|||||||
|
|
||||||
llxHeader("","",$langs->trans("Categories"));
|
llxHeader("","",$langs->trans("Categories"));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Action création du produit
|
||||||
|
*/
|
||||||
|
if ($_GET["action"] == 'create' && $user->rights->produit->creer)
|
||||||
|
{
|
||||||
|
print '<form action="fiche.php" method="post">';
|
||||||
|
print '<input type="hidden" name="nom" value="'.$nom.'">';
|
||||||
|
print '<input type="hidden" name="description" value="'.$description.'">';
|
||||||
|
|
||||||
print_fiche_titre($langs->trans("CreateCat"));
|
print_fiche_titre($langs->trans("CreateCat"));
|
||||||
|
|
||||||
print '<table border="0" width="100%" class="notopnoleftnoright">';
|
print '<table class="border" width="100%" class="notopnoleftnoright">';
|
||||||
|
print '<tr>';
|
||||||
print '<tr><td valign="top" width="30%" class="notopnoleft">';
|
print '<td>'.$langs->trans("Label").'</td><td><input name="nom" size"25" value="'.$categorie->nom.'">';
|
||||||
|
if ($_error == 1)
|
||||||
?>
|
|
||||||
<form method="post" action="<?php print $_SERVER['REQUEST_URI']; ?>">
|
|
||||||
<table class="border">
|
|
||||||
<tr>
|
|
||||||
<td><?php print $langs->trans ("Label"); ?> :</td>
|
|
||||||
|
|
||||||
<td><input type='text' size='25' id='nom' name ='nom' value='<?php
|
|
||||||
print htmlspecialchars (stripslashes ($_REQUEST['nom']), ENT_QUOTES);
|
|
||||||
?>' />
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><?php print $langs->trans ("Description"); ?> :</td>
|
|
||||||
|
|
||||||
<td><textarea name='description' cols='40' rows='6' id='description'><?php
|
|
||||||
print htmlspecialchars (stripslashes ($_REQUEST['description']), ENT_QUOTES);
|
|
||||||
?></textarea></td>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><?php print $langs->trans ("In"); ?> <select name="choix">
|
|
||||||
<?php
|
|
||||||
// création d'un objet de type catégorie pour faire des requêtes sur la table
|
|
||||||
$categorie = new Categorie ($db);
|
|
||||||
|
|
||||||
$nb = $categorie->get_nb_categories();
|
|
||||||
|
|
||||||
for ($i = 0 ; $i <= $nb ; $i++)
|
|
||||||
{
|
{
|
||||||
echo "<option value='$i' ";//creation d'une valeur dans la liste
|
print $lang->trans("ErrCatAlreadyExists");
|
||||||
|
|
||||||
if ($_REQUEST['choix'] == $i)
|
|
||||||
echo 'selected="true"'; // permet de rendre le choix toujours selectionne
|
|
||||||
else if (!isset ($_REQUEST['choix']) && $i == $nbcats) // nombre de catégories mères par défaut.
|
|
||||||
echo 'selected="true"';
|
|
||||||
|
|
||||||
echo ">$i</option>";
|
|
||||||
}
|
}
|
||||||
?>
|
print'</td></tr>';
|
||||||
|
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
|
||||||
|
print '<textarea name="description" rows="6" cols=""40"';
|
||||||
|
print '</textarea></td></tr>';
|
||||||
|
print '<tr><td>'.$html->select_nombre_sous_categorie("choix", $nbcats);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
</select> <?php print $langs->trans ("categories"); ?>
|
</select> <?php print $langs->trans ("categories"); ?>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@ -912,6 +912,34 @@ class Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Retourne la liste déroulante de création en sous catégories possible
|
||||||
|
* \param selected nombre de sous catégorie pré-sélectionnée
|
||||||
|
*/
|
||||||
|
function select_nombre_sous_categorie($selected='', $nbcats=1)
|
||||||
|
{
|
||||||
|
global $conf,$langs;
|
||||||
|
$langs->load("categorie");
|
||||||
|
|
||||||
|
$categorie = new Categorie ($db);
|
||||||
|
$nb = $categorie->get_nb_categories();
|
||||||
|
|
||||||
|
for ($i = 0 ; $i <= $nb ; $i++)
|
||||||
|
{
|
||||||
|
print '<select class="flat" name="choix">';
|
||||||
|
print '<option value="'.$i.'" ';//creation d'une valeur dans la liste
|
||||||
|
if ($selected == $i)
|
||||||
|
{
|
||||||
|
print 'selected="true"'; // permet de rendre le choix toujours selectionne
|
||||||
|
}
|
||||||
|
else if (!isset($selected) && $i == $nbcats) // nombre de catégories mères par défaut.
|
||||||
|
{
|
||||||
|
print 'selected="true">';
|
||||||
|
}
|
||||||
|
print '$i</option>';
|
||||||
|
print '</select>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retourne la liste déroulante des civilite actives
|
* \brief Retourne la liste déroulante des civilite actives
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user