From f800bb8d55c1b874201bd4d5420400a9d703085a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jan 2005 21:51:04 +0000 Subject: [PATCH] =?UTF-8?q?New:=20d=E9but=20gestion=20ordres=20affichage?= =?UTF-8?q?=20des=20boites?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/boxes.php | 86 +++++++++++++++++++++++++++++++++--------- htdocs/index.php | 9 ++++- 2 files changed, 76 insertions(+), 19 deletions(-) diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index bb07ac9cb48..f243c6be940 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004 Laurent Destailleur + * Copyright (C) 2004-2005 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ * $Source$ */ -/*! \file htdocs/admin/boxes.php +/** \file htdocs/admin/boxes.php \brief Page d'administration/configuration des boites \version $Revision$ */ @@ -33,6 +33,12 @@ if (!$user->admin) 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=... +$boxes = array(); + + llxHeader(); print_titre($langs->trans("Boxes")); @@ -40,6 +46,10 @@ print_titre($langs->trans("Boxes")); 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"]; @@ -59,12 +69,19 @@ if ($_GET["action"] == 'delete') $result = $db->query($sql); } +if ($_GET["action"] == 'switch') +{ + // \todo faire permutation + +} + + + + +// On renumérote l'ordre des boites si tout est à 0 (pour compatibilite avec anciennes versions) +// \todo + -// Définition des positions possibles pour les boites -$pos_array = array(0); // Positions possibles pour une boite (0,1,2,...) -$pos_name = array(); // Nom des position 0=Homepage, 1=... -$pos_name[0]="Homepage"; -$boxes = array(); /* @@ -73,7 +90,10 @@ $boxes = array(); * */ -$sql = "SELECT b.rowid, b.box_id, b.position, d.name FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d where b.box_id = d.rowid"; +$sql = "SELECT b.rowid, b.box_id, b.position, d.name"; +$sql .= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; +$sql .= " where b.box_id = d.rowid"; +$sql .= " ORDER by position, box_order"; $result = $db->query($sql); if ($result) @@ -85,7 +105,6 @@ if ($result) { $var = ! $var; $obj = $db->fetch_object($result); - //print "pos ".$obj->position; $boxes[$obj->position][$obj->box_id]=1; $i++; } @@ -100,7 +119,7 @@ $db->free(); print "
\n"; print_titre($langs->trans("BoxesAvailable")); -print ''; +print '
'; print ''; print ''; print ''; @@ -152,15 +171,19 @@ print '
'.$langs->trans("Boxe").''.$langs->trans("SourceFile").'
'; print "
\n\n"; print_titre($langs->trans("BoxesActivated")); -print ''; +print '
'; print ''; print ''; print ''; print ''; +print ''; print ''; print "\n"; -$sql = "SELECT b.rowid, b.box_id, b.position, d.name FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d where b.box_id = d.rowid"; +$sql = "SELECT b.rowid, b.box_id, b.position, d.name"; +$sql .= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; +$sql .= " where b.box_id = d.rowid"; +$sql .= " ORDER by position, box_order"; $result = $db->query($sql); if ($result) @@ -168,27 +191,54 @@ if ($result) $num = $db->num_rows(); $i = 0; - while ($i < $num) + $box_order=1; + $foundrupture=1; + + // On lit avec un coup d'avance + $obj = $db->fetch_object($result); + + while ($obj && $i < $num) { - $var = ! $var; - $obj = $db->fetch_object($result); + $var = ! $var; + $objnext = $db->fetch_object($result); print ''; print ''; print ''; + $hasnext=true; + $hasprevious=true; + if ($foundrupture) { $hasprevious=false; $foundrupture=0; } + if (! $objnext || $obj->position != $objnext->position) { $hasnext=false; $foundrupture=1; } + print ''; + print ''; print ''; print "\n"; $i++; + + $box_order++; + + if (! $foundrupture) $objprevious = $obj; + else $box_order=1; + $obj=$objnext; } + + + } + + + + + $db->free(); - -print '
'.$langs->trans("Boxe").' '.$langs->trans("ActiveOn").''.$langs->trans("Position").''.$langs->trans("Disable").'
'.$obj->name.' ' . $pos_name[$obj->position] . ''.$box_order.''; + print ($hasnext?''.img_down().' ':''); + print ($hasprevious?''.img_up().'':''); + print ''; print ''.img_delete().''; print '
'; - +print '
'; $db->close(); diff --git a/htdocs/index.php b/htdocs/index.php index 37120347ff3..44b511d317d 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -54,7 +54,11 @@ print "
\n"; */ $user->getrights(''); -$sql = "SELECT b.rowid, b.box_id, d.file FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d WHERE b.box_id = d.rowid"; +$sql = "SELECT b.rowid, b.box_id, d.file"; +$sql .= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; +$sql .= " WHERE b.box_id = d.rowid"; +$sql .= " AND position = 0"; // 0 = valeur pour la page accueil +$sql .= " ORDER BY box_order"; $result = $db->query($sql); if ($result) { @@ -68,6 +72,9 @@ if ($result) $j++; } } +else { + dolibarr_print_error($db); +} print '';