21 |
*/ |
*/ |
22 |
|
|
23 |
/** |
/** |
24 |
\file htdocs/admin/boxes.php |
\file htdocs/admin/boxes.php |
25 |
\brief Page d'administration/configuration des boites |
\brief Page d'administration/configuration des boites |
26 |
\version $Revision$ |
\version $Revision$ |
27 |
*/ |
*/ |
28 |
|
|
29 |
require("./pre.inc.php"); |
require("./pre.inc.php"); |
43 |
|
|
44 |
if ($_POST["action"] == 'add') |
if ($_POST["action"] == 'add') |
45 |
{ |
{ |
46 |
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."boxes WHERE box_id=".$_POST["boxid"]." AND position=".$_POST["pos"]; |
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."boxes WHERE box_id=".$_POST["boxid"]." AND position=".$_POST["pos"]; |
47 |
$result = $db->query($sql); |
$result = $db->query($sql); |
48 |
|
|
49 |
$num = $db->num_rows($result); |
$num = $db->num_rows($result); |
50 |
if ($num == 0) |
if ($num == 0) |
51 |
{ |
{ |
52 |
// Si la boite n'est pas deja active |
// Si la boite n'est pas deja active |
53 |
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id, position) values (".$_POST["boxid"].",".$_POST["pos"].");"; |
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id, position) values (".$_POST["boxid"].",".$_POST["pos"].");"; |
54 |
$result = $db->query($sql); |
$result = $db->query($sql); |
55 |
} |
} |
56 |
|
|
57 |
Header("Location: boxes.php"); |
Header("Location: boxes.php"); |
58 |
|
exit; |
59 |
} |
} |
60 |
|
|
|
|
|
|
llxHeader(); |
|
|
|
|
|
print_titre($langs->trans("Boxes")); |
|
|
|
|
|
print "<br>".$langs->trans("BoxesDesc")."<br>\n"; |
|
|
|
|
|
|
|
|
|
|
61 |
if ($_GET["action"] == 'delete') |
if ($_GET["action"] == 'delete') |
62 |
{ |
{ |
63 |
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes WHERE rowid=".$_GET["rowid"]; |
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes WHERE rowid=".$_GET["rowid"]; |
66 |
|
|
67 |
if ($_GET["action"] == 'switch') |
if ($_GET["action"] == 'switch') |
68 |
{ |
{ |
69 |
// On permute les valeur du champ box_order des 2 lignes de la table boxes |
// On permute les valeur du champ box_order des 2 lignes de la table boxes |
70 |
$db->begin(); |
$db->begin(); |
71 |
|
|
72 |
$sql="SELECT box_order FROM ".MAIN_DB_PREFIX."boxes WHERE rowid=".$_GET["switchfrom"]; |
$sql="SELECT box_order FROM ".MAIN_DB_PREFIX."boxes WHERE rowid=".$_GET["switchfrom"]; |
73 |
$resultfrom = $db->query($sql); |
$resultfrom = $db->query($sql); |
74 |
if ($resultfrom) |
if ($resultfrom) |
75 |
{ |
{ |
76 |
$objfrom = $db->fetch_object($resultfrom); |
$objfrom = $db->fetch_object($resultfrom); |
77 |
} |
} |
78 |
else |
else |
79 |
{ |
{ |
80 |
dolibarr_print_error($db); |
dolibarr_print_error($db); |
81 |
} |
} |
|
|
|
|
$sql="SELECT box_order FROM ".MAIN_DB_PREFIX."boxes WHERE rowid=".$_GET["switchto"]; |
|
|
$resultto = $db->query($sql); |
|
82 |
|
|
83 |
if ($resultto) |
$sql="SELECT box_order FROM ".MAIN_DB_PREFIX."boxes WHERE rowid=".$_GET["switchto"]; |
84 |
|
$resultto = $db->query($sql); |
85 |
|
|
86 |
|
if ($resultto) |
87 |
{ |
{ |
88 |
$objto = $db->fetch_object($resultto); |
$objto = $db->fetch_object($resultto); |
89 |
} |
} |
90 |
else |
else |
91 |
{ |
{ |
92 |
dolibarr_print_error($db); |
dolibarr_print_error($db); |
93 |
} |
} |
94 |
|
|
95 |
if ($objfrom && $objto) { |
if ($objfrom && $objto) { |
96 |
$sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order=".$objto->box_order." WHERE rowid=".$_GET["switchfrom"]; |
$sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order=".$objto->box_order." WHERE rowid=".$_GET["switchfrom"]; |
97 |
$resultupdatefrom = $db->query($sql); |
$resultupdatefrom = $db->query($sql); |
98 |
if (! $resultupdatefrom) { dolibarr_print_error($db); } |
if (! $resultupdatefrom) { dolibarr_print_error($db); } |
99 |
$sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order=".$objfrom->box_order." WHERE rowid=".$_GET["switchto"]; |
$sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order=".$objfrom->box_order." WHERE rowid=".$_GET["switchto"]; |
100 |
$resultupdateto = $db->query($sql); |
$resultupdateto = $db->query($sql); |
101 |
if (! $resultupdateto) { dolibarr_print_error($db); } |
if (! $resultupdateto) { dolibarr_print_error($db); } |
102 |
} |
} |
103 |
|
|
104 |
if ($resultupdatefrom && $resultupdateto) |
if ($resultupdatefrom && $resultupdateto) |
105 |
{ |
{ |
106 |
$db->commit(); |
$db->commit(); |
107 |
} |
} |
108 |
else |
else |
109 |
{ |
{ |
110 |
$db->rollback(); |
$db->rollback(); |
111 |
} |
} |
112 |
|
|
113 |
} |
} |
114 |
|
|
115 |
|
|
116 |
|
llxHeader(); |
117 |
|
|
118 |
|
print_fiche_titre($langs->trans("Boxes")); |
119 |
|
|
120 |
|
print $langs->trans("BoxesDesc")."<br>\n"; |
121 |
|
|
122 |
/* |
/* |
123 |
* Recherche des boites actives par position possible |
* Recherche des boites actives par position possible |
124 |
* On stocke les boites actives par $boxes[position][id_boite]=1 |
* On stocke les boites actives par $boxes[position][id_boite]=1 |