Perf: Reduce quantity of code for boxes.
This commit is contained in:
parent
88a1a0f06d
commit
1d51ee3aab
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -25,6 +25,7 @@
|
|||||||
require("../main.inc.php");
|
require("../main.inc.php");
|
||||||
include_once(DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php");
|
include_once(DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php");
|
||||||
include_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
|
include_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/boxes.php");
|
||||||
|
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
@ -82,7 +83,7 @@ if ($action == 'add')
|
|||||||
dol_syslog("boxes.php activate box sql=".$sql);
|
dol_syslog("boxes.php activate box sql=".$sql);
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
|
|
||||||
// Remove all personalized setup when a box is activated or disabled
|
// Remove all personalized setup when a box is activated or disabled (to be sure user see new box)
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
|
||||||
$sql.= " WHERE param LIKE 'MAIN_BOXES_%'";
|
$sql.= " WHERE param LIKE 'MAIN_BOXES_%'";
|
||||||
dol_syslog("boxes.php delete user_param sql=".$sql);
|
dol_syslog("boxes.php delete user_param sql=".$sql);
|
||||||
@ -102,18 +103,26 @@ if ($action == 'add')
|
|||||||
|
|
||||||
if ($action == 'delete')
|
if ($action == 'delete')
|
||||||
{
|
{
|
||||||
$db->begin();
|
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
|
$sql = "SELECT box_id FROM ".MAIN_DB_PREFIX."boxes";
|
||||||
$sql.= " WHERE rowid=".$rowid;
|
$sql.= " WHERE rowid=".$rowid;
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
|
$obj=$db->fetch_object($resql);
|
||||||
|
if (! empty($obj->box_id))
|
||||||
|
{
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
// Remove all personalized setup when a box is activated or disabled
|
// Remove all personalized setup when a box is activated or disabled (why removing all ? We removed only removed boxes)
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
|
// $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
|
||||||
$sql.= " WHERE param LIKE 'MAIN_BOXES_%'";
|
// $sql.= " WHERE param LIKE 'MAIN_BOXES_%'";
|
||||||
$resql = $db->query($sql);
|
// $resql = $db->query($sql);
|
||||||
|
|
||||||
$db->commit();
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
|
||||||
|
$sql.= " WHERE box_id=".$obj->box_id;
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
|
||||||
|
$db->commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'switch')
|
if ($action == 'switch')
|
||||||
@ -154,12 +163,17 @@ if ($action == 'switch')
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$form=new Form($db);
|
||||||
|
$emptyuser=new User($db);
|
||||||
|
$infobox=new InfoBox($db);
|
||||||
|
|
||||||
llxHeader('',$langs->trans("Boxes"));
|
llxHeader('',$langs->trans("Boxes"));
|
||||||
|
|
||||||
print_fiche_titre($langs->trans("Boxes"),'','setup');
|
print_fiche_titre($langs->trans("Boxes"),'','setup');
|
||||||
|
|
||||||
print $langs->trans("BoxesDesc")." ".$langs->trans("OnlyActiveElementsAreShown")."<br>\n";
|
print $langs->trans("BoxesDesc")." ".$langs->trans("OnlyActiveElementsAreShown")."<br>\n";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Recherche des boites actives par defaut pour chaque position possible
|
* Recherche des boites actives par defaut pour chaque position possible
|
||||||
* On stocke les boites actives par defaut dans $boxes[position][id_boite]=1
|
* On stocke les boites actives par defaut dans $boxes[position][id_boite]=1
|
||||||
@ -202,13 +216,14 @@ if ($resql)
|
|||||||
|
|
||||||
if ($decalage)
|
if ($decalage)
|
||||||
{
|
{
|
||||||
// Si on a renumerote, on corrige champ box_order
|
// Si on a renumerote, on corrige champ box_order
|
||||||
// This occurs just after an insert.
|
// This occurs just after an insert.
|
||||||
$sql = "SELECT box_order";
|
$sql = "SELECT box_order";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."boxes";
|
$sql.= " FROM ".MAIN_DB_PREFIX."boxes";
|
||||||
$sql.= " WHERE length(box_order) <= 2";
|
$sql.= " WHERE length(box_order) <= 2";
|
||||||
$result = $db->query($sql);
|
|
||||||
|
|
||||||
|
dol_syslog("Execute requests to renumber box order sql=".$sql);
|
||||||
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
while ($record = $db->fetch_array($result))
|
while ($record = $db->fetch_array($result))
|
||||||
@ -251,6 +266,7 @@ if ($resql)
|
|||||||
|
|
||||||
|
|
||||||
// Available boxes
|
// Available boxes
|
||||||
|
$boxtoadd=$infobox->listboxes('available',-1,$emptyuser,$actives);
|
||||||
|
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
print_titre($langs->trans("BoxesAvailable"));
|
print_titre($langs->trans("BoxesAvailable"));
|
||||||
@ -262,103 +278,45 @@ print '<td>'.$langs->trans("Note").'/'.$langs->trans("Parameters").'</td>';
|
|||||||
print '<td>'.$langs->trans("SourceFile").'</td>';
|
print '<td>'.$langs->trans("SourceFile").'</td>';
|
||||||
print '<td width="160">'.$langs->trans("ActivateOn").'</td>';
|
print '<td width="160">'.$langs->trans("ActivateOn").'</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$sql = "SELECT rowid, file, note, tms";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."boxes_def";
|
|
||||||
$sql.= " WHERE entity = ".$conf->entity;
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
$var=true;
|
$var=true;
|
||||||
|
foreach($boxtoadd as $box)
|
||||||
if ($resql)
|
|
||||||
{
|
{
|
||||||
$form=new Form($db);
|
$var=!$var;
|
||||||
|
|
||||||
$num = $db->num_rows($resql);
|
if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg))
|
||||||
$i = 0;
|
{
|
||||||
|
$logo = $box->boximg;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$logo=preg_replace("/^object_/i","",$box->boximg);
|
||||||
|
}
|
||||||
|
|
||||||
// Boucle sur toutes les boites
|
print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
|
||||||
while ($i < $num)
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
{
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
$obj = $db->fetch_object($resql);
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td>'.img_object("",$logo).' '.$box->boxlabel.'</td>';
|
||||||
|
print '<td>' . ($box->note?$box->note:' ') . '</td>';
|
||||||
|
print '<td>' . $box->sourcefile . '</td>';
|
||||||
|
|
||||||
if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs))
|
// Pour chaque position possible, on affiche un lien d'activation si boite non deja active pour cette position
|
||||||
{
|
print '<td>';
|
||||||
$boxname = $regs[1];
|
print $form->selectarray("pos",$pos_name);
|
||||||
$module = $regs[2];
|
print '<input type="hidden" name="action" value="add">';
|
||||||
$sourcefile = "/".$module."/core/boxes/".$boxname.".php";
|
print '<input type="hidden" name="boxid" value="'.$box->box_id.'">';
|
||||||
}
|
print ' <input type="submit" class="button" name="button" value="'.$langs->trans("Activate").'">';
|
||||||
else
|
print '</td>';
|
||||||
{
|
|
||||||
$boxname=preg_replace('/.php$/i','',$obj->file);
|
|
||||||
$sourcefile = "/core/boxes/".$boxname.".php";
|
|
||||||
}
|
|
||||||
|
|
||||||
dol_include_once($sourcefile);
|
print '</tr>';
|
||||||
if (class_exists($boxname))
|
print '</form>';
|
||||||
{
|
|
||||||
$box=new $boxname($db,$obj->note);
|
|
||||||
|
|
||||||
$enabled=true;
|
|
||||||
if ($box->depends && count($box->depends) > 0)
|
|
||||||
{
|
|
||||||
foreach($box->depends as $module)
|
|
||||||
{
|
|
||||||
if (empty($conf->$module->enabled)) $enabled=false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($enabled)
|
|
||||||
{
|
|
||||||
//if (in_array($obj->rowid, $actives) && $box->box_multiple <> 1)
|
|
||||||
if (in_array($obj->rowid, $actives))
|
|
||||||
{
|
|
||||||
// La boite est deja activee
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$var=!$var;
|
|
||||||
|
|
||||||
if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg))
|
|
||||||
{
|
|
||||||
$logo = $box->boximg;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$logo=preg_replace("/^object_/i","",$box->boximg);
|
|
||||||
}
|
|
||||||
|
|
||||||
print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
|
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
||||||
print '<tr '.$bc[$var].'>';
|
|
||||||
print '<td>'.img_object("",$logo).' '.$box->boxlabel.'</td>';
|
|
||||||
print '<td>' . ($obj->note?$obj->note:' ') . '</td>';
|
|
||||||
print '<td>' . $sourcefile . '</td>';
|
|
||||||
|
|
||||||
// Pour chaque position possible, on affiche un lien
|
|
||||||
// d'activation si boite non deja active pour cette position
|
|
||||||
print '<td>';
|
|
||||||
print $form->selectarray("pos",$pos_name);
|
|
||||||
print '<input type="hidden" name="action" value="add">';
|
|
||||||
print '<input type="hidden" name="boxid" value="'.$obj->rowid.'">';
|
|
||||||
print ' <input type="submit" class="button" name="button" value="'.$langs->trans("Activate").'">';
|
|
||||||
print '</td>';
|
|
||||||
|
|
||||||
print '</tr></form>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->free($resql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|
||||||
// Activated boxes
|
// Activated boxes
|
||||||
|
$boxactivated=$infobox->listboxes('activated',-1,$emptyuser);
|
||||||
|
|
||||||
print "<br>\n\n";
|
print "<br>\n\n";
|
||||||
print_titre($langs->trans("BoxesActivated"));
|
print_titre($langs->trans("BoxesActivated"));
|
||||||
@ -372,89 +330,39 @@ print '<td align="center" width="60" colspan="2">'.$langs->trans("PositionByDefa
|
|||||||
print '<td align="center" width="80">'.$langs->trans("Disable").'</td>';
|
print '<td align="center" width="80">'.$langs->trans("Disable").'</td>';
|
||||||
print '</tr>'."\n";
|
print '</tr>'."\n";
|
||||||
|
|
||||||
$sql = "SELECT b.rowid, b.box_id, b.position,";
|
$var=true;
|
||||||
$sql.= " bd.file, bd.note, bd.tms";
|
$box_order=1;
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd";
|
$foundrupture=1;
|
||||||
$sql.= " WHERE b.box_id = bd.rowid";
|
foreach($boxactivated as $key => $box)
|
||||||
$sql.= " AND bd.entity = ".$conf->entity;
|
|
||||||
$sql.= " AND b.fk_user=0";
|
|
||||||
$sql.= " ORDER by b.position, b.box_order"; // Note box_order return A01,A03...,B02,B04...
|
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
|
|
||||||
if ($resql)
|
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($resql);
|
$var = ! $var;
|
||||||
$i = 0;
|
|
||||||
$var=true;
|
|
||||||
|
|
||||||
$box_order=1;
|
if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg))
|
||||||
$foundrupture=1;
|
|
||||||
|
|
||||||
// On lit avec un coup d'avance
|
|
||||||
$obj = $db->fetch_object($resql);
|
|
||||||
|
|
||||||
while ($obj && $i < $num)
|
|
||||||
{
|
{
|
||||||
$var = ! $var;
|
$logo = $box->boximg;
|
||||||
$objnext = $db->fetch_object($resql);
|
}
|
||||||
|
else
|
||||||
if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs))
|
{
|
||||||
{
|
$logo=preg_replace("/^object_/i","",$box->boximg);
|
||||||
$boxname = $regs[1];
|
|
||||||
$module = $regs[2];
|
|
||||||
$sourcefile = "/".$module."/core/boxes/".$boxname.".php";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$boxname=preg_replace('/.php$/i','',$obj->file);
|
|
||||||
$sourcefile = "/core/boxes/".$boxname.".php";
|
|
||||||
}
|
|
||||||
|
|
||||||
dol_include_once($sourcefile);
|
|
||||||
if (class_exists($boxname))
|
|
||||||
{
|
|
||||||
$box=new $boxname($db,$obj->note);
|
|
||||||
|
|
||||||
if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg))
|
|
||||||
{
|
|
||||||
$logo = $box->boximg;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$logo=preg_replace("/^object_/i","",$box->boximg);
|
|
||||||
}
|
|
||||||
|
|
||||||
print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
|
|
||||||
print '<tr '.$bc[$var].'>';
|
|
||||||
print '<td>'.img_object("",$logo).' '.$box->boxlabel.'</td>';
|
|
||||||
print '<td>' . ($obj->note?$obj->note:' ') . '</td>';
|
|
||||||
print '<td align="center">' . $pos_name[$obj->position] . '</td>';
|
|
||||||
$hasnext=true;
|
|
||||||
$hasprevious=true;
|
|
||||||
if ($foundrupture) { $hasprevious=false; $foundrupture=0; }
|
|
||||||
if (! $objnext || $obj->position != $objnext->position) { $hasnext=false; $foundrupture=1; }
|
|
||||||
print '<td align="center">'.$box_order.'</td>';
|
|
||||||
print '<td align="center">';
|
|
||||||
print ($hasnext?'<a href="boxes.php?action=switch&switchfrom='.$obj->rowid.'&switchto='.$objnext->rowid.'">'.img_down().'</a> ':'');
|
|
||||||
print ($hasprevious?'<a href="boxes.php?action=switch&switchfrom='.$obj->rowid.'&switchto='.$objprevious->rowid.'">'.img_up().'</a>':'');
|
|
||||||
print '</td>';
|
|
||||||
print '<td align="center">';
|
|
||||||
print '<a href="boxes.php?rowid='.$obj->rowid.'&action=delete">'.img_delete().'</a>';
|
|
||||||
print '</td>';
|
|
||||||
|
|
||||||
print '</tr>'."\n";
|
|
||||||
}
|
|
||||||
$i++;
|
|
||||||
|
|
||||||
$box_order++;
|
|
||||||
|
|
||||||
if (! $foundrupture) $objprevious = $obj;
|
|
||||||
else $box_order=1;
|
|
||||||
$obj=$objnext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->free($resql);
|
print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td>'.img_object("",$logo).' '.$box->boxlabel.'</td>';
|
||||||
|
print '<td>' . ($box->note?$box->note:' ') . '</td>';
|
||||||
|
print '<td align="center">' . $pos_name[$box->position] . '</td>';
|
||||||
|
$hasnext=($key < (count($boxactivated)-1));
|
||||||
|
$hasprevious=($key != 0);
|
||||||
|
print '<td align="center">'.($key+1).'</td>';
|
||||||
|
print '<td align="center">';
|
||||||
|
print ($hasnext?'<a href="boxes.php?action=switch&switchfrom='.$box->rowid.'&switchto='.$boxactivated[$key+1]->rowid.'">'.img_down().'</a> ':'');
|
||||||
|
print ($hasprevious?'<a href="boxes.php?action=switch&switchfrom='.$box->rowid.'&switchto='.$boxactivated[$key-1]->rowid.'">'.img_up().'</a>':'');
|
||||||
|
print '</td>';
|
||||||
|
print '<td align="center">';
|
||||||
|
print '<a href="boxes.php?rowid='.$box->rowid.'&action=delete">'.img_delete().'</a>';
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '</tr>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</table><br>';
|
print '</table><br>';
|
||||||
@ -490,7 +398,7 @@ print '</form>';
|
|||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|
||||||
|
$db->close();
|
||||||
?>
|
?>
|
||||||
|
|||||||
632
htdocs/boxes.php
632
htdocs/boxes.php
@ -1,21 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/boxes.php
|
* \file htdocs/boxes.php
|
||||||
@ -35,87 +35,114 @@
|
|||||||
*/
|
*/
|
||||||
function printBoxesArea($user,$areacode)
|
function printBoxesArea($user,$areacode)
|
||||||
{
|
{
|
||||||
global $conf,$langs,$db;
|
global $conf,$langs,$db;
|
||||||
|
|
||||||
$infobox=new InfoBox($db);
|
$infobox=new InfoBox($db);
|
||||||
$boxarray=$infobox->listboxes($areacode,$user);
|
$boxarray=$infobox->listboxes('activated',$areacode,$user);
|
||||||
|
|
||||||
if (count($boxarray))
|
$selectboxlist='';
|
||||||
{
|
/*
|
||||||
print load_fiche_titre($langs->trans("OtherInformationsBoxes"),'','','','otherboxes');
|
if ($conf->use_javascript_ajax)
|
||||||
print '<table width="100%" class="notopnoleftnoright">';
|
{
|
||||||
print '<tr><td class="notopnoleftnoright">'."\n";
|
$sql = "SELECT rowid, file, note, tms";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."boxes_def";
|
||||||
|
$sql.= " WHERE entity = ".$conf->entity;
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
$var=true;
|
||||||
|
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
// Boucle sur toutes les boites
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if (count($boxarray))
|
||||||
|
{
|
||||||
|
print load_fiche_titre($langs->trans("OtherInformationsBoxes"),$selectboxlist,'','','otherboxes');
|
||||||
|
|
||||||
|
print '<table width="100%" class="notopnoleftnoright">';
|
||||||
|
print '<tr><td class="notopnoleftnoright">'."\n";
|
||||||
|
|
||||||
print '<div class="fichehalfleft">';
|
print '<div class="fichehalfleft">';
|
||||||
|
|
||||||
print "\n<!-- Box left container -->\n";
|
print "\n<!-- Box left container -->\n";
|
||||||
print '<div id="left" class="connectedSortable">'."\n";
|
print '<div id="left" class="connectedSortable">'."\n";
|
||||||
|
|
||||||
// Define $box_max_lines
|
// Define $box_max_lines
|
||||||
$box_max_lines=5;
|
$box_max_lines=5;
|
||||||
if (! empty($conf->global->MAIN_BOXES_MAXLINES)) $box_max_lines=$conf->global->MAIN_BOXES_MAXLINES;
|
if (! empty($conf->global->MAIN_BOXES_MAXLINES)) $box_max_lines=$conf->global->MAIN_BOXES_MAXLINES;
|
||||||
|
|
||||||
$ii=0;
|
$ii=0;
|
||||||
foreach ($boxarray as $key => $box)
|
foreach ($boxarray as $key => $box)
|
||||||
{
|
{
|
||||||
if (preg_match('/^A/i',$box->box_order)) // column A
|
if (preg_match('/^A/i',$box->box_order)) // column A
|
||||||
{
|
{
|
||||||
$ii++;
|
$ii++;
|
||||||
//print 'box_id '.$boxarray[$ii]->box_id.' ';
|
//print 'box_id '.$boxarray[$ii]->box_id.' ';
|
||||||
//print 'box_order '.$boxarray[$ii]->box_order.'<br>';
|
//print 'box_order '.$boxarray[$ii]->box_order.'<br>';
|
||||||
// Affichage boite key
|
// Affichage boite key
|
||||||
$box->loadBox($box_max_lines);
|
$box->loadBox($box_max_lines);
|
||||||
$box->showBox();
|
$box->showBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$emptybox=new ModeleBoxes($db);
|
$emptybox=new ModeleBoxes($db);
|
||||||
$emptybox->box_id='A';
|
$emptybox->box_id='A';
|
||||||
$emptybox->info_box_head=array();
|
$emptybox->info_box_head=array();
|
||||||
$emptybox->info_box_contents=array();
|
$emptybox->info_box_contents=array();
|
||||||
$emptybox->showBox(array(),array());
|
$emptybox->showBox(array(),array());
|
||||||
|
|
||||||
print "</div>\n";
|
print "</div>\n";
|
||||||
print "<!-- End box container -->\n";
|
print "<!-- End box container -->\n";
|
||||||
|
|
||||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||||
|
|
||||||
print "\n<!-- Box right container -->\n";
|
print "\n<!-- Box right container -->\n";
|
||||||
print '<div id="right" class="connectedSortable">'."\n";
|
print '<div id="right" class="connectedSortable">'."\n";
|
||||||
|
|
||||||
$ii=0;
|
$ii=0;
|
||||||
foreach ($boxarray as $key => $box)
|
foreach ($boxarray as $key => $box)
|
||||||
{
|
{
|
||||||
if (preg_match('/^B/i',$box->box_order)) // colonne B
|
if (preg_match('/^B/i',$box->box_order)) // colonne B
|
||||||
{
|
{
|
||||||
$ii++;
|
$ii++;
|
||||||
//print 'box_id '.$boxarray[$ii]->box_id.' ';
|
//print 'box_id '.$boxarray[$ii]->box_id.' ';
|
||||||
//print 'box_order '.$boxarray[$ii]->box_order.'<br>';
|
//print 'box_order '.$boxarray[$ii]->box_order.'<br>';
|
||||||
// Affichage boite key
|
// Affichage boite key
|
||||||
$box->loadBox($box_max_lines);
|
$box->loadBox($box_max_lines);
|
||||||
$box->showBox();
|
$box->showBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$emptybox=new ModeleBoxes($db);
|
$emptybox=new ModeleBoxes($db);
|
||||||
$emptybox->box_id='B';
|
$emptybox->box_id='B';
|
||||||
$emptybox->info_box_head=array();
|
$emptybox->info_box_head=array();
|
||||||
$emptybox->info_box_contents=array();
|
$emptybox->info_box_contents=array();
|
||||||
$emptybox->showBox(array(),array());
|
$emptybox->showBox(array(),array());
|
||||||
|
|
||||||
print "</div>\n";
|
print "</div>\n";
|
||||||
print "<!-- End box container -->\n";
|
print "<!-- End box container -->\n";
|
||||||
|
|
||||||
print '</div></div>';
|
print '</div></div>';
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax)
|
||||||
{
|
{
|
||||||
print "\n";
|
print "\n";
|
||||||
print '<script type="text/javascript" language="javascript">';
|
print '<script type="text/javascript" language="javascript">';
|
||||||
print 'jQuery(function() {
|
print 'jQuery(function() {
|
||||||
jQuery("#left, #right").sortable({
|
jQuery("#left, #right").sortable({
|
||||||
/* placeholder: \'ui-state-highlight\', */
|
/* placeholder: \'ui-state-highlight\', */
|
||||||
@ -132,18 +159,18 @@ function printBoxesArea($user,$areacode)
|
|||||||
';
|
';
|
||||||
print "\n";
|
print "\n";
|
||||||
print 'function updateOrder(){'."\n";
|
print 'function updateOrder(){'."\n";
|
||||||
print 'var left_list = cleanSerialize(jQuery("#left").sortable("serialize" ));'."\n";
|
print 'var left_list = cleanSerialize(jQuery("#left").sortable("serialize" ));'."\n";
|
||||||
print 'var right_list = cleanSerialize(jQuery("#right").sortable("serialize" ));'."\n";
|
print 'var right_list = cleanSerialize(jQuery("#right").sortable("serialize" ));'."\n";
|
||||||
print 'var boxorder = \'A:\' + left_list + \'-B:\' + right_list;'."\n";
|
print 'var boxorder = \'A:\' + left_list + \'-B:\' + right_list;'."\n";
|
||||||
//print 'alert(\'boxorder=\' + boxorder);';
|
//print 'alert(\'boxorder=\' + boxorder);';
|
||||||
print 'var userid = \''.$user->id.'\';'."\n";
|
print 'var userid = \''.$user->id.'\';'."\n";
|
||||||
print 'jQuery.get(\'core/ajax/box.php?boxorder=\'+boxorder+\'&userid=\'+'.$user->id.');'."\n";
|
print 'jQuery.get(\'core/ajax/box.php?boxorder=\'+boxorder+\'&userid=\'+'.$user->id.');'."\n";
|
||||||
print '}'."\n";
|
print '}'."\n";
|
||||||
print '</script>'."\n";
|
print '</script>'."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return count($boxarray);
|
return count($boxarray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -153,171 +180,126 @@ function printBoxesArea($user,$areacode)
|
|||||||
*/
|
*/
|
||||||
class InfoBox
|
class InfoBox
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param DoliDb $db Database handler
|
* @param DoliDb $db Database handler
|
||||||
*/
|
*/
|
||||||
function InfoBox($db)
|
function InfoBox($db)
|
||||||
{
|
{
|
||||||
$this->db=$db;
|
$this->db=$db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return array of boxes qualified for area and user
|
* Return array of boxes qualified for area and user
|
||||||
*
|
*
|
||||||
* @param string $zone Name or area (0 for Homepage, ...)
|
* @param string $mode 'available' or 'activated'
|
||||||
* @param User $user Objet user
|
* @param string $zone Name or area (-1 for all, 0 for Homepage, 1 for xxx, ...)
|
||||||
* @return array Array of boxes
|
* @param User $user Objet user to filter (used only if $zone >= 0)
|
||||||
*/
|
* @param array $excludelist Array of box.box_id = boxes_def.rowid to exclude
|
||||||
function listBoxes($zone,$user)
|
* @return array Array of boxes
|
||||||
{
|
*/
|
||||||
global $conf;
|
function listBoxes($mode,$zone,$user,$excludelist=array())
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$boxes=array();
|
$boxes=array();
|
||||||
|
|
||||||
$confuserzone='MAIN_BOXES_'.$zone;
|
$confuserzone='MAIN_BOXES_'.$zone;
|
||||||
if ($user->id && $user->conf->$confuserzone)
|
if ($mode == 'activated')
|
||||||
{
|
{
|
||||||
// Get list of boxes of a particular user (if this one has its own list)
|
$sql = "SELECT b.rowid, b.position, b.box_order, b.fk_user,";
|
||||||
$sql = "SELECT b.rowid, b.box_id, b.position, b.box_order, b.fk_user,";
|
$sql.= " d.rowid as box_id, d.file, d.note, d.tms";
|
||||||
$sql.= " d.file, d.note";
|
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d";
|
$sql.= " WHERE b.box_id = d.rowid";
|
||||||
$sql.= " WHERE b.box_id = d.rowid";
|
$sql.= " AND d.entity = ".$conf->entity;
|
||||||
$sql.= " AND d.entity = ".$conf->entity;
|
if ($zone >= 0) $sql.= " AND b.position = ".$zone;
|
||||||
$sql.= " AND b.position = ".$zone;
|
if ($user->id && $user->conf->$confuserzone) $sql.= " AND b.fk_user = ".$user->id;
|
||||||
$sql.= " AND b.fk_user = ".$user->id;
|
else $sql.= " AND b.fk_user = 0";
|
||||||
$sql.= " ORDER BY b.box_order";
|
$sql.= " ORDER BY b.box_order";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d";
|
||||||
|
$sql.= " WHERE entity = ".$conf->entity;
|
||||||
|
}
|
||||||
|
|
||||||
dol_syslog("InfoBox::listBoxes get user box list sql=".$sql, LOG_DEBUG);
|
dol_syslog(get_class($this)."::listBoxes get default box list sql=".$sql, LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($result)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows($result);
|
$num = $this->db->num_rows($resql);
|
||||||
$j = 0;
|
$j = 0;
|
||||||
while ($j < $num)
|
while ($j < $num)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs))
|
if (! in_array($obj->box_id, $excludelist))
|
||||||
{
|
{
|
||||||
$boxname = $regs[1];
|
if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs))
|
||||||
$module = $regs[2];
|
{
|
||||||
$sourcefile = dol_buildpath("/".$module."/core/boxes/".$boxname.".php");
|
$boxname = $regs[1];
|
||||||
}
|
$module = $regs[2];
|
||||||
else
|
$relsourcefile = "/".$module."/core/boxes/".$boxname.".php";
|
||||||
{
|
}
|
||||||
$boxname=preg_replace('/\.php$/i','',$obj->file);
|
else
|
||||||
$sourcefile = "/core/boxes/".$boxname.".php";
|
{
|
||||||
}
|
$boxname=preg_replace('/.php$/i','',$obj->file);
|
||||||
|
$relsourcefile = "/core/boxes/".$boxname.".php";
|
||||||
|
}
|
||||||
|
|
||||||
dol_include_once($sourcefile); // Do not use dol_include_once here because sourcefile is already good fullpath
|
dol_include_once($relsourcefile);
|
||||||
if (class_exists($boxname))
|
if (class_exists($boxname))
|
||||||
{
|
{
|
||||||
$box=new $boxname($this->db,$obj->note);
|
$box=new $boxname($this->db,$obj->note);
|
||||||
|
|
||||||
$box->rowid=$obj->rowid;
|
// box properties
|
||||||
$box->box_id=$obj->box_id;
|
$box->rowid=$obj->rowid;
|
||||||
$box->position=$obj->position;
|
$box->position=$obj->position;
|
||||||
$box->box_order=$obj->box_order;
|
$box->box_order=$obj->box_order;
|
||||||
$box->fk_user=$obj->fk_user;
|
$box->fk_user=$obj->fk_user;
|
||||||
$enabled=true;
|
$box->sourcefile=$relsourcefile;
|
||||||
if ($box->depends && count($box->depends) > 0)
|
if ($mode == 'activated' && (! $user->id || ! $user->conf->$confuserzone))
|
||||||
{
|
{
|
||||||
foreach($box->depends as $module)
|
if (is_numeric($box->box_order))
|
||||||
{
|
{
|
||||||
//print $module.'<br>';
|
if ($box->box_order % 2 == 1) $box->box_order='A'.$box->box_order;
|
||||||
if (empty($conf->$module->enabled)) $enabled=false;
|
elseif ($box->box_order % 2 == 0) $box->box_order='B'.$box->box_order;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($enabled) $boxes[]=$box;
|
// box_def properties
|
||||||
}
|
$box->box_id=$obj->box_id;
|
||||||
$j++;
|
$box->note=$obj->note;
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->error=$this->db->error();
|
|
||||||
dol_syslog("InfoBox::listBoxes Error ".$this->error, LOG_ERR);
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Recupere liste des boites active par defaut pour tous
|
|
||||||
$sql = "SELECT b.rowid, b.box_id, b.position, b.box_order, b.fk_user,";
|
|
||||||
$sql.= " d.file, d.note";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d";
|
|
||||||
$sql.= " WHERE b.box_id = d.rowid";
|
|
||||||
$sql.= " AND d.entity = ".$conf->entity;
|
|
||||||
$sql.= " AND b.position = ".$zone;
|
|
||||||
$sql.= " AND b.fk_user = 0";
|
|
||||||
$sql.= " ORDER BY b.box_order";
|
|
||||||
|
|
||||||
dol_syslog("InfoBox::listBoxes get default box list sql=".$sql, LOG_DEBUG);
|
$enabled=true;
|
||||||
$result = $this->db->query($sql);
|
if ($box->depends && count($box->depends) > 0)
|
||||||
if ($result)
|
{
|
||||||
{
|
foreach($box->depends as $module)
|
||||||
$num = $this->db->num_rows($result);
|
{
|
||||||
$j = 0;
|
//print $boxname.'-'.$module.'<br>';
|
||||||
while ($j < $num)
|
if (empty($conf->$module->enabled)) $enabled=false;
|
||||||
{
|
}
|
||||||
$obj = $this->db->fetch_object($result);
|
}
|
||||||
|
if ($enabled) $boxes[]=$box;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//dol_print_error($this->db);
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
dol_syslog(get_class($this)."::listBoxes Error ".$this->error, LOG_ERR);
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs))
|
return $boxes;
|
||||||
{
|
}
|
||||||
$boxname = $regs[1];
|
|
||||||
$module = $regs[2];
|
|
||||||
$relsourcefile = "/".$module."/core/boxes/".$boxname.".php";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$boxname=preg_replace('/.php$/i','',$obj->file);
|
|
||||||
$relsourcefile = "/core/boxes/".$boxname.".php";
|
|
||||||
}
|
|
||||||
|
|
||||||
dol_include_once($relsourcefile);
|
|
||||||
if (class_exists($boxname))
|
|
||||||
{
|
|
||||||
$box=new $boxname($this->db,$obj->note);
|
|
||||||
|
|
||||||
$box->rowid=$obj->rowid;
|
|
||||||
$box->box_id=$obj->box_id;
|
|
||||||
$box->position=$obj->position;
|
|
||||||
$box->box_order=$obj->box_order;
|
|
||||||
if (is_numeric($box->box_order))
|
|
||||||
{
|
|
||||||
if ($box->box_order % 2 == 1) $box->box_order='A'.$box->box_order;
|
|
||||||
elseif ($box->box_order % 2 == 0) $box->box_order='B'.$box->box_order;
|
|
||||||
}
|
|
||||||
$box->fk_user=$obj->fk_user;
|
|
||||||
$enabled=true;
|
|
||||||
if ($box->depends && count($box->depends) > 0)
|
|
||||||
{
|
|
||||||
foreach($box->depends as $module)
|
|
||||||
{
|
|
||||||
//print $boxname.'-'.$module.'<br>';
|
|
||||||
if (empty($conf->$module->enabled)) $enabled=false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($enabled) $boxes[]=$box;
|
|
||||||
}
|
|
||||||
$j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->error=$this->db->error();
|
|
||||||
dol_syslog("InfoBox::listBoxes Error ".$this->error, LOG_ERR);
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $boxes;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -329,100 +311,100 @@ class InfoBox
|
|||||||
* @param int $userid Id of user
|
* @param int $userid Id of user
|
||||||
* @return int <0 if KO, >= 0 if OK
|
* @return int <0 if KO, >= 0 if OK
|
||||||
*/
|
*/
|
||||||
function saveboxorder($zone,$boxorder,$userid=0)
|
function saveboxorder($zone,$boxorder,$userid=0)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
|
||||||
|
|
||||||
dol_syslog("InfoBoxes::saveboxorder zone=".$zone." user=".$userid);
|
dol_syslog(get_class($this)."::saveboxorder zone=".$zone." user=".$userid);
|
||||||
|
|
||||||
if (! $userid || $userid == 0) return 0;
|
if (! $userid || $userid == 0) return 0;
|
||||||
|
|
||||||
$user = new User($this->db);
|
$user = new User($this->db);
|
||||||
$user->id=$userid;
|
$user->id=$userid;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Sauve parametre indiquant que le user a une
|
// Sauve parametre indiquant que le user a une
|
||||||
$confuserzone='MAIN_BOXES_'.$zone;
|
$confuserzone='MAIN_BOXES_'.$zone;
|
||||||
$tab[$confuserzone]=1;
|
$tab[$confuserzone]=1;
|
||||||
if (dol_set_user_param($this->db, $conf, $user, $tab) < 0)
|
if (dol_set_user_param($this->db, $conf, $user, $tab) < 0)
|
||||||
{
|
{
|
||||||
$this->error=$this->db->lasterror();
|
$this->error=$this->db->lasterror();
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
|
||||||
$sql.= " USING ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def";
|
$sql.= " USING ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def";
|
||||||
$sql.= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid";
|
$sql.= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid";
|
||||||
$sql.= " AND ".MAIN_DB_PREFIX."boxes_def.entity = ".$conf->entity;
|
$sql.= " AND ".MAIN_DB_PREFIX."boxes_def.entity = ".$conf->entity;
|
||||||
$sql.= " AND ".MAIN_DB_PREFIX."boxes.fk_user = ".$userid;
|
$sql.= " AND ".MAIN_DB_PREFIX."boxes.fk_user = ".$userid;
|
||||||
$sql.= " AND ".MAIN_DB_PREFIX."boxes.position = ".$zone;
|
$sql.= " AND ".MAIN_DB_PREFIX."boxes.position = ".$zone;
|
||||||
|
|
||||||
dol_syslog("InfoBox::saveboxorder sql=".$sql);
|
dol_syslog(get_class($this)."::saveboxorder sql=".$sql);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$colonnes=explode('-',$boxorder);
|
$colonnes=explode('-',$boxorder);
|
||||||
foreach ($colonnes as $collist)
|
foreach ($colonnes as $collist)
|
||||||
{
|
{
|
||||||
$part=explode(':',$collist);
|
$part=explode(':',$collist);
|
||||||
$colonne=$part[0];
|
$colonne=$part[0];
|
||||||
$list=$part[1];
|
$list=$part[1];
|
||||||
dol_syslog('InfoBox::saveboxorder column='.$colonne.' list='.$list);
|
dol_syslog('InfoBox::saveboxorder column='.$colonne.' list='.$list);
|
||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
$listarray=explode(',',$list);
|
$listarray=explode(',',$list);
|
||||||
foreach ($listarray as $id)
|
foreach ($listarray as $id)
|
||||||
{
|
{
|
||||||
if (is_numeric($id))
|
if (is_numeric($id))
|
||||||
{
|
{
|
||||||
//dol_syslog("aaaaa".count($listarray));
|
//dol_syslog("aaaaa".count($listarray));
|
||||||
$i++;
|
$i++;
|
||||||
$ii=sprintf('%02d',$i);
|
$ii=sprintf('%02d',$i);
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes";
|
||||||
$sql.= "(box_id, position, box_order, fk_user)";
|
$sql.= "(box_id, position, box_order, fk_user)";
|
||||||
$sql.= " values (";
|
$sql.= " values (";
|
||||||
$sql.= " ".$id.",";
|
$sql.= " ".$id.",";
|
||||||
$sql.= " ".$zone.",";
|
$sql.= " ".$zone.",";
|
||||||
$sql.= " '".$colonne.$ii."',";
|
$sql.= " '".$colonne.$ii."',";
|
||||||
$sql.= " ".$userid;
|
$sql.= " ".$userid;
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
dol_syslog("InfoBox::saveboxorder sql=".$sql);
|
dol_syslog(get_class($this)."::saveboxorder sql=".$sql);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($error)
|
if ($error)
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->lasterror();
|
$this->error=$this->db->lasterror();
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
dol_syslog("InfoBox::saveboxorder ".$this->error);
|
dol_syslog(get_class($this)."::saveboxorder ".$this->error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2429,7 +2429,7 @@ function print_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpat
|
|||||||
* @param string $titre Title to show
|
* @param string $titre Title to show
|
||||||
* @param string $mesg Added message to show on right
|
* @param string $mesg Added message to show on right
|
||||||
* @param string $picto Icon to use before title (should be a 32x32 transparent png file)
|
* @param string $picto Icon to use before title (should be a 32x32 transparent png file)
|
||||||
* @param int $pictoisfullpath 1=Icon name is a full absolute url of image
|
* @param int $pictoisfullpath 1=Icon name is a full absolute url of image
|
||||||
* @param int $id To force an id on html objects
|
* @param int $id To force an id on html objects
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user