diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php
index 5d40e79222e..4f6d313ffe3 100644
--- a/htdocs/admin/boxes.php
+++ b/htdocs/admin/boxes.php
@@ -20,9 +20,10 @@
* $Source$
*/
-/** \file htdocs/admin/boxes.php
- \brief Page d'administration/configuration des boites
- \version $Revision$
+/**
+ \file htdocs/admin/boxes.php
+ \brief Page d'administration/configuration des boites
+ \version $Revision$
*/
require("./pre.inc.php");
@@ -30,12 +31,12 @@ require("./pre.inc.php");
$langs->load("admin");
if (!$user->admin)
- accessforbidden();
+accessforbidden();
// Définition des positions possibles pour les boites
$pos_array = array(0); // Positions possibles pour une boite (0,1,2,...)
-$pos_name = array($langs->trans("Home")); // Nom des position 0=Homepage, 1=...
+$pos_name = array($langs->trans("Home")); // Nom des positions 0=Homepage, 1=...
$boxes = array();
@@ -49,24 +50,24 @@ print "
".$langs->trans("BoxesDesc")."
\n";
/*
* Actions
*/
-
+
if ($_POST["action"] == 'add')
{
- $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."boxes WHERE box_id=".$_POST["boxid"]." AND position=".$_POST["pos"];
- $result = $db->query($sql);
-
- $num = $db->num_rows();
- if ($num == 0) {
- // Si la boite n'est pas deja active
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id, position) values (".$_POST["boxid"].",".$_POST["pos"].");";
+ $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."boxes WHERE box_id=".$_POST["boxid"]." AND position=".$_POST["pos"];
$result = $db->query($sql);
- }
+
+ $num = $db->num_rows($result);
+ if ($num == 0) {
+ // Si la boite n'est pas deja active
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id, position) values (".$_POST["boxid"].",".$_POST["pos"].");";
+ $result = $db->query($sql);
+ }
}
if ($_GET["action"] == 'delete')
{
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes WHERE rowid=".$_GET["rowid"];
- $result = $db->query($sql);
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes WHERE rowid=".$_GET["rowid"];
+ $result = $db->query($sql);
}
if ($_GET["action"] == 'switch')
@@ -81,7 +82,7 @@ if ($_GET["action"] == 'switch')
$objfrom = $db->fetch_object($resultfrom);
} else
{
- dolibarr_print_error($db);
+ dolibarr_print_error($db);
}
$sql="SELECT box_order FROM ".MAIN_DB_PREFIX."boxes WHERE rowid=".$_GET["switchto"];
$resultto = $db->query($sql);
@@ -90,7 +91,7 @@ if ($_GET["action"] == 'switch')
$objto = $db->fetch_object($resultto);
} else
{
- dolibarr_print_error($db);
+ dolibarr_print_error($db);
}
if ($objfrom && $objto) {
$sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order=".$objto->box_order." WHERE rowid=".$_GET["switchfrom"];
@@ -99,7 +100,7 @@ if ($_GET["action"] == 'switch')
$sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order=".$objfrom->box_order." WHERE rowid=".$_GET["switchto"];
$resultupdateto = $db->query($sql);
if (! $resultupdateto) { dolibarr_print_error($db); }
- }
+ }
if ($resultupdatefrom && $resultupdateto)
{
@@ -115,7 +116,6 @@ if ($_GET["action"] == 'switch')
/*
* Recherche des boites actives par position possible
* On stocke les boites actives par $boxes[position][id_boite]=1
- *
*/
$sql = "SELECT b.rowid, b.box_id, b.position, b.box_order, d.name";
@@ -124,18 +124,18 @@ $sql .= " where b.box_id = d.rowid";
$sql .= " ORDER by position, box_order";
$result = $db->query($sql);
-if ($result)
+if ($result)
{
- $num = $db->num_rows();
+ $num = $db->num_rows($result);
$i = 0;
- $decalage=0;
+ $decalage=0;
while ($i < $num)
{
$var = ! $var;
$obj = $db->fetch_object($result);
$boxes[$obj->position][$obj->box_id]=1;
$i++;
-
+
// On renumérote l'ordre des boites si l'une d'elle est à 0 (Ne doit arriver que sur des anciennes versions)
if ($obj->box_order==0) $decalage++;
if ($decalage) {
@@ -150,14 +150,13 @@ if ($result)
/*
* Boites disponibles
- *
*/
print "
\n";
print_titre($langs->trans("BoxesAvailable"));
print '
| '.$langs->trans("Boxe").' | '; +print ''.$langs->trans("Box").' | '; print ''.$langs->trans("SourceFile").' | '; print ''.$langs->trans("ActivateOn").' | '; print ''; @@ -167,24 +166,29 @@ $sql = "SELECT rowid, name, file FROM ".MAIN_DB_PREFIX."boxes_def"; $result = $db->query($sql); $var=True; -if ($result) +if ($result) { - $num = $db->num_rows(); + $html=new Form($db); + + $num = $db->num_rows($result); $i = 0; - + // Boucle sur toutes les boites while ($i < $num) { $var = ! $var; $obj = $db->fetch_object($result); - - print ' |