Skip to content
Snippets Groups Projects
Commit 6a09bca2 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Merge pull request #2120 from frederic34/patch-8

Update admin config for boxes
parents e90996b2 aade7309
No related branches found
No related tags found
No related merge requests found
......@@ -51,11 +51,13 @@ if ($action == 'addconst')
dolibarr_set_const($db, "MAIN_BOXES_MAXLINES",$_POST["MAIN_BOXES_MAXLINES"],'',0,'',$conf->entity);
}
if ($action == 'add')
{
if ($action == 'add') {
$error=0;
$db->begin();
if (isset($_POST['boxid']) && is_array($_POST['boxid'])) {
foreach($_POST['boxid'] as $boxid) {
if ($boxid['active']=='on') {
$pos = $boxid['pos'];
// Initialize distinct fkuser with all already existing values of fk_user (user that use a personalized view of boxes for page "pos")
$distinctfkuser=array();
......@@ -63,9 +65,8 @@ if ($action == 'add')
{
$sql = "SELECT fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."user_param";
$sql.= " WHERE param = 'MAIN_BOXES_".$db->escape(GETPOST("pos","alpha"))."' AND value = '1'";
$sql.= " WHERE param = 'MAIN_BOXES_".$db->escape($pos)."' AND value = '1'";
$sql.= " AND entity = ".$conf->entity;
dol_syslog("boxes.php search fk_user to activate box for", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
......@@ -93,7 +94,7 @@ if ($action == 'add')
if (! $error && $fk_user != '')
{
$nbboxonleft=$nbboxonright=0;
$sql = "SELECT box_order FROM ".MAIN_DB_PREFIX."boxes WHERE position = ".GETPOST("pos","alpha")." AND fk_user = ".$fk_user." AND entity = ".$conf->entity;
$sql = "SELECT box_order FROM ".MAIN_DB_PREFIX."boxes WHERE position = ".$pos." AND fk_user = ".$fk_user." AND entity = ".$conf->entity;
dol_syslog("boxes.php activate box", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
......@@ -110,7 +111,7 @@ if ($action == 'add')
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
$sql.= "box_id, position, box_order, fk_user, entity";
$sql.= ") values (";
$sql.= GETPOST("boxid","int").", ".GETPOST("pos","alpha").", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity;
$sql.= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity;
$sql.= ")";
dol_syslog("boxes.php activate box", LOG_DEBUG);
......@@ -122,12 +123,13 @@ if ($action == 'add')
}
}
}
}
}
}
if (! $error)
{
header("Location: boxes.php");
$db->commit();
exit;
$action='';
}
else
{
......@@ -317,14 +319,18 @@ if ($resql)
$boxtoadd=InfoBox::listBoxes($db,'available',-1,null,$actives);
print "<br>\n";
print "\n\n".'<!-- Boxes Available -->'."\n";
print_titre($langs->trans("BoxesAvailable"));
print '<table class="noborder" width="100%">';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
print '<input type="hidden" name="action" value="add">'."\n";
print '<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre">';
print '<td width="300">'.$langs->trans("Box").'</td>';
print '<td>'.$langs->trans("Note").'/'.$langs->trans("Parameters").'</td>';
print '<td>'.$langs->trans("SourceFile").'</td>';
print '<td width="160">'.$langs->trans("ActivateOn").'</td>';
print '<td class="center" width="160">'.$langs->trans("ActivateOn").'</td>';
print "</tr>\n";
$var=true;
foreach($boxtoadd as $box)
......@@ -341,12 +347,10 @@ foreach($boxtoadd as $box)
}
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 '<tr '.$bc[$var].'>'."\n";
print '<td>'.img_object("",$logo).' '.$langs->transnoentitiesnoconv($box->boxlabel);
if (! empty($box->class) && preg_match('/graph_/',$box->class)) print ' ('.$langs->trans("Graph").')';
print '</td>';
print '</td>'."\n";
print '<td>';
if ($box->note == '(WarningUsingThisBoxSlowDown)')
{
......@@ -354,22 +358,25 @@ foreach($boxtoadd as $box)
print $langs->trans("WarningUsingThisBoxSlowDown");
}
else print ($box->note?$box->note:'&nbsp;');
print '</td>';
print '<td>' . $box->sourcefile . '</td>';
print '</td>'."\n";
print '<td>' . $box->sourcefile . '</td>'."\n";
// 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,0,0,0,0,'',1);
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="boxid" value="'.$box->box_id.'">';
print ' <input type="submit" class="button" name="button" value="'.$langs->trans("Activate").'">';
print '<td class="center">';
print $form->selectarray("boxid[".$box->box_id."][pos]",$pos_name,0,0,0,0,'',1)."\n";
print '<input type="hidden" name="boxid['.$box->box_id.'][value]" value="'.$box->box_id.'">'."\n";
print '<input type="checkbox" class="flat" name="boxid['.$box->box_id.'][active]">'."\n";
print '</td>';
print '</tr>';
print '</form>';
print '</tr>'."\n";
}
print '</table>';
print '</table>'."\n";
print '<br><div class="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Activate").'">';
print '</div>'."\n";
print '</form>';
print "\n".'<!-- End Boxes Available -->'."\n";
// Activated boxes
......@@ -421,8 +428,8 @@ foreach($boxactivated as $key => $box)
$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>&nbsp;':'');
print ($hasprevious?'<a href="boxes.php?action=switch&switchfrom='.$box->rowid.'&switchto='.$boxactivated[$key-1]->rowid.'">'.img_up().'</a>':'');
print ($hasnext?'<a href="boxes.php?action=switch&amp;switchfrom='.$box->rowid.'&amp;switchto='.$boxactivated[$key+1]->rowid.'">'.img_down().'</a>&nbsp;':'');
print ($hasprevious?'<a href="boxes.php?action=switch&amp;switchfrom='.$box->rowid.'&amp;switchto='.$boxactivated[$key-1]->rowid.'">'.img_up().'</a>':'');
print '</td>';
print '<td align="center">';
print '<a href="boxes.php?rowid='.$box->rowid.'&amp;action=delete">'.img_delete().'</a>';
......@@ -436,13 +443,14 @@ print '</table><br>';
// Other parameters
print "\n\n".'<!-- Other Const -->'."\n";
print_titre($langs->trans("Other"));
print '<table class="noborder" width="100%">';
$var=false;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addconst">';
print '<table class="noborder" width="100%">';
$var=false;
print '<tr class="liste_titre">';
print '<td class="liste_titre">'.$langs->trans("Parameter").'</td>';
print '<td class="liste_titre">'.$langs->trans("Value").'</td>';
......@@ -459,9 +467,10 @@ print '<td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'" name="Button">';
print '</td>'."\n";
print '</tr>';
print '</form>';
print '</table>';
print '</form>';
print "\n".'<!-- End Other Const -->'."\n";
llxFooter();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment