|
@@ -97,8 +97,10 @@ if ($action == 'add') {
|
|
|
{
|
|
|
if (!$error && $fk_user != '')
|
|
|
{
|
|
|
+ $arrayofexistingboxid = array();
|
|
|
$nbboxonleft = $nbboxonright = 0;
|
|
|
- $sql = "SELECT box_order FROM ".MAIN_DB_PREFIX."boxes WHERE position = ".$pos." AND fk_user = ".$fk_user." AND entity = ".$conf->entity;
|
|
|
+ $sql = "SELECT box_id, box_order FROM ".MAIN_DB_PREFIX."boxes";
|
|
|
+ $sql .= " 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)
|
|
@@ -108,22 +110,27 @@ if ($action == 'add') {
|
|
|
$boxorder = $obj->box_order;
|
|
|
if (preg_match('/A/', $boxorder)) $nbboxonleft++;
|
|
|
if (preg_match('/B/', $boxorder)) $nbboxonright++;
|
|
|
+ $arrayofexistingboxid[$obj->box_id] = 1;
|
|
|
}
|
|
|
}
|
|
|
else dol_print_error($db);
|
|
|
|
|
|
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
|
|
|
- $sql .= "box_id, position, box_order, fk_user, entity";
|
|
|
- $sql .= ") values (";
|
|
|
- $sql .= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity;
|
|
|
- $sql .= ")";
|
|
|
-
|
|
|
- dol_syslog("boxes.php activate box", LOG_DEBUG);
|
|
|
- $resql = $db->query($sql);
|
|
|
- if (!$resql)
|
|
|
- {
|
|
|
- setEventMessages($db->lasterror(), null, 'errors');
|
|
|
- $error++;
|
|
|
+ if (! $arrayofexistingboxid[$boxid['value']]) {
|
|
|
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
|
|
|
+ $sql .= "box_id, position, box_order, fk_user, entity";
|
|
|
+ $sql .= ") values (";
|
|
|
+ $sql .= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity;
|
|
|
+ $sql .= ")";
|
|
|
+
|
|
|
+ dol_syslog("boxes.php activate box", LOG_DEBUG);
|
|
|
+ $resql = $db->query($sql);
|
|
|
+ if (!$resql)
|
|
|
+ {
|
|
|
+ setEventMessages($db->lasterror(), null, 'errors');
|
|
|
+ $error++;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dol_syslog("boxes.php activate box - already exists in database", LOG_DEBUG);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -353,7 +360,7 @@ foreach ($boxtoadd as $box)
|
|
|
|
|
|
print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
|
|
|
print '<tr class="oddeven">'."\n";
|
|
|
- print '<td>'.img_object("", $logo).' '.$langs->transnoentitiesnoconv($box->boxlabel);
|
|
|
+ print '<td>'.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel);
|
|
|
if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')';
|
|
|
print '</td>'."\n";
|
|
|
print '<td>';
|
|
@@ -368,7 +375,7 @@ foreach ($boxtoadd as $box)
|
|
|
|
|
|
// For each possible position, an activation link is displayed if the box is not already active for that position
|
|
|
print '<td class="center">';
|
|
|
- print $form->selectarray("boxid[".$box->box_id."][pos]", $pos_name, 0, 1, 0, 0, '', 1)."\n";
|
|
|
+ print $form->selectarray("boxid[".$box->box_id."][pos]", $pos_name, -1, 1, 0, 0, '', 1)."\n";
|
|
|
print '<input type="hidden" name="boxid['.$box->box_id.'][value]" value="'.$box->box_id.'">'."\n";
|
|
|
print '</td>';
|
|
|
|
|
@@ -418,7 +425,7 @@ foreach ($boxactivated as $key => $box)
|
|
|
|
|
|
print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
|
|
|
print '<tr class="oddeven">';
|
|
|
- print '<td>'.img_object("", $logo).' '.$langs->transnoentitiesnoconv($box->boxlabel);
|
|
|
+ print '<td>'.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel);
|
|
|
if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')';
|
|
|
print '</td>';
|
|
|
print '<td>';
|