29require
'../main.inc.php';
30include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
32include_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
43$langs->loadLangs(array(
'admin',
'boxes',
'accountancy'));
50$action =
GETPOST(
'action',
'aZ09');
62if ($action ==
'addconst') {
66if ($action ==
'add') {
68 $boxids =
GETPOST(
'boxid',
'array');
71 if (is_array($boxids)) {
72 foreach ($boxids as $boxid) {
73 if (is_numeric($boxid[
'pos']) && $boxid[
'pos'] >= 0) {
77 $distinctfkuser = array();
79 $sql =
"SELECT fk_user";
80 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user_param";
81 $sql .=
" WHERE param = 'MAIN_BOXES_".$db->escape($pos).
"' AND value = '1'";
82 $sql .=
" AND entity = ".$conf->entity;
83 dol_syslog(
"boxes.php search fk_user to activate box for", LOG_DEBUG);
84 $resql = $db->query($sql);
86 $num = $db->num_rows($resql);
89 $obj = $db->fetch_object($resql);
90 $distinctfkuser[$obj->fk_user] = $obj->fk_user;
99 $distinctfkuser[
'0'] =
'0';
101 foreach ($distinctfkuser as $fk_user) {
102 if (!$error && $fk_user !=
'') {
103 $arrayofexistingboxid = array();
104 $nbboxonleft = $nbboxonright = 0;
105 $sql =
"SELECT box_id, box_order FROM ".MAIN_DB_PREFIX.
"boxes";
106 $sql .=
" WHERE position = ".((int) $pos).
" AND fk_user = ".((int) $fk_user).
" AND entity = ".((int)
$conf->entity);
107 dol_syslog(
"boxes.php activate box", LOG_DEBUG);
108 $resql = $db->query($sql);
110 while ($obj = $db->fetch_object($resql)) {
111 $boxorder = $obj->box_order;
112 if (preg_match(
'/A/', $boxorder)) {
115 if (preg_match(
'/B/', $boxorder)) {
118 $arrayofexistingboxid[$obj->box_id] = 1;
124 if (empty($arrayofexistingboxid[$boxid[
'value']])) {
125 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"boxes (";
126 $sql .=
"box_id, position, box_order, fk_user, entity";
127 $sql .=
") VALUES (";
128 $sql .= ((int) $boxid[
'value']).
", ".((int) $pos).
", '".(($nbboxonleft > $nbboxonright) ?
'B01' :
'A01').
"', ".((int) $fk_user).
", ".
$conf->entity;
131 dol_syslog(
"boxes.php activate box", LOG_DEBUG);
132 $resql = $db->query($sql);
138 dol_syslog(
"boxes.php activate box - already exists in database", LOG_DEBUG);
153if ($action ==
'delete') {
154 $sql =
"SELECT box_id FROM ".MAIN_DB_PREFIX.
"boxes";
155 $sql .=
" WHERE rowid=".((int) $rowid);
157 $resql = $db->query($sql);
158 $obj = $db->fetch_object($resql);
159 if (!empty($obj->box_id)) {
162 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes";
163 $sql .=
" WHERE entity = ".$conf->entity;
164 $sql .=
" AND box_id=".((int) $obj->box_id);
166 $resql = $db->query($sql);
172if ($action ==
'switch') {
182 $resultupdatefrom = 0;
184 if (is_object($objfrom) && is_object($objto)) {
185 $newfirst = $objto->box_order;
186 $newsecond = $objfrom->box_order;
187 if ($newfirst == $newsecond) {
188 $newsecondchar = preg_replace(
'/[0-9]+/',
'', $newsecond);
189 $newsecondnum = (int) preg_replace(
'/[a-zA-Z]+/',
'', $newsecond);
190 $newsecond = sprintf(
"%s%02d", $newsecondchar ? $newsecondchar :
'A', $newsecondnum + 1);
193 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"boxes SET box_order='".$db->escape($newfirst).
"' WHERE rowid=".((int) $objfrom->rowid);
195 $resultupdatefrom = $db->query($sql);
196 if (!$resultupdatefrom) {
200 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"boxes SET box_order='".$db->escape($newsecond).
"' WHERE rowid=".((int) $objto->rowid);
202 $resultupdateto = $db->query($sql);
203 if (!$resultupdateto) {
208 if ($resultupdatefrom && $resultupdateto) {
220$form =
new Form($db);
222llxHeader(
'', $langs->trans(
"Boxes"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-boxes');
226print
'<span class="opacitymedium">'.$langs->trans(
"BoxesDesc").
" ".$langs->trans(
"OnlyActiveElementsAreShown").
"</span><br>\n";
236$sql =
"SELECT b.rowid, b.box_id, b.position, b.box_order,";
237$sql .=
" bd.rowid as boxid";
238$sql .=
" FROM ".MAIN_DB_PREFIX.
"boxes as b, ".MAIN_DB_PREFIX.
"boxes_def as bd";
239$sql .=
" WHERE b.box_id = bd.rowid";
240$sql .=
" AND b.entity IN (0,".$conf->entity.
")";
241$sql .=
" AND b.fk_user=0";
242$sql .=
" ORDER by b.position, b.box_order";
245dol_syslog(
"Search available boxes", LOG_DEBUG);
246$resql = $db->query($sql);
248 $num = $db->num_rows($resql);
254 $obj = $db->fetch_object($resql);
255 $boxes[$obj->position][$obj->box_id] = 1;
258 array_push($actives, $obj->box_id);
260 if ($obj->box_order ==
'' || $obj->box_order ==
'0' || $decalage) {
266 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"boxes SET box_order='".$db->escape($decalage).
"' WHERE rowid=".((int) $obj->rowid);
274 $sql =
"SELECT box_order";
275 $sql .=
" FROM ".MAIN_DB_PREFIX.
"boxes";
276 $sql .=
" WHERE entity = ".$conf->entity;
277 $sql .=
" AND LENGTH(box_order) <= 2";
279 dol_syslog(
"Execute requests to renumber box order", LOG_DEBUG);
280 $result = $db->query($sql);
282 while ($record = $db->fetch_array($result)) {
284 if (preg_match(
"/[13579]{1}/", substr($record[
'box_order'], -1))) {
285 $box_order =
"A0".$record[
'box_order'];
286 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"boxes SET box_order = '".$db->escape($box_order).
"' WHERE entity = ".
$conf->entity.
" AND box_order = '".$db->escape($record[
'box_order']).
"'";
287 $resql = $db->query($sql);
288 } elseif (preg_match(
"/[02468]{1}/", substr($record[
'box_order'], -1))) {
289 $box_order =
"B0".$record[
'box_order'];
290 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"boxes SET box_order = '".$db->escape($box_order).
"' WHERE entity = ".
$conf->entity.
" AND box_order = '".$db->escape($record[
'box_order']).
"'";
291 $resql = $db->query($sql);
293 } elseif (
dol_strlen($record[
'box_order']) == 2) {
294 if (preg_match(
"/[13579]{1}/", substr($record[
'box_order'], -1))) {
295 $box_order =
"A".$record[
'box_order'];
296 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"boxes SET box_order = '".$db->escape($box_order).
"' WHERE entity = ".
$conf->entity.
" AND box_order = '".$db->escape($record[
'box_order']).
"'";
297 $resql = $db->query($sql);
298 } elseif (preg_match(
"/[02468]{1}/", substr($record[
'box_order'], -1))) {
299 $box_order =
"B".$record[
'box_order'];
300 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"boxes SET box_order = '".$db->escape($box_order).
"' WHERE entity = ".
$conf->entity.
" AND box_order = '".$db->escape($record[
'box_order']).
"'";
301 $resql = $db->query($sql);
315print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
316print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
317print
'<input type="hidden" name="action" value="add">'.
"\n";
322print
'<div class="div-table-responsive-no-min">';
323print
'<table class="tagtable liste centpercent">'.
"\n";
325print
'<tr class="liste_titre">';
326print
'<td>'.$langs->trans(
"Box").
'</td>';
327print
'<td>'.$langs->trans(
"Note").
'/'.$langs->trans(
"Parameters").
'</td>';
329print
'<td class="center" width="160">'.$langs->trans(
"ActivatableOn").
'</td>';
330print
'<td class="center" width="60" colspan="2">'.$langs->trans(
"PositionByDefault").
'</td>';
331print
'<td class="center" width="80">'.$langs->trans(
"Disable").
'</td>';
334print
"\n\n".
'<!-- Boxes Available -->'.
"\n";
335foreach ($boxtoadd as $box) {
336 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $box->boximg)) {
337 $logo = $box->boximg;
339 $logo = preg_replace(
"/^object_/i",
"", $box->boximg);
342 print
"\n".
'<!-- Box '.$box->boxcode.
' -->'.
"\n";
343 print
'<tr class="oddeven" style="height:3em !important;">'.
"\n";
344 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv($box->boxlabel)).
'">'.
img_object(
"", $logo,
'class="pictofixedwidth" height="14px"').
' '.$langs->transnoentitiesnoconv($box->boxlabel);
345 if (!empty($box->class) && preg_match(
'/graph_/', $box->class)) {
346 print
img_picto(
'',
'graph',
'class="paddingleft"');
348 if (!empty($box->version)) {
349 if ($box->version ==
'experimental') {
350 print
' <span class="opacitymedium">('.$langs->trans(
"Experimental").
')</span>';
351 } elseif ($box->version ==
'development') {
352 print
' <span class="opacitymedium">('.$langs->trans(
"Development").
')</span>';
356 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($box->note).
'">';
357 if ($box->note ==
'(WarningUsingThisBoxSlowDown)') {
358 $langs->load(
"errors");
359 print $langs->trans(
"WarningUsingThisBoxSlowDown");
361 print($box->note ? $box->note :
' ');
365 print $form->textwithpicto(
'', $langs->trans(
"SourceFile").
' : '.$box->sourcefile);
369 print
'<td class="center">';
370 print $form->selectarray(
"boxid[".$box->box_id.
"][pos]", $arrayofhomepages, -1, 1, 0, 0,
'', 1, 0, 0,
'',
'minwidth75', 1).
"\n";
371 print
'<input type="hidden" name="boxid['.$box->box_id.
'][value]" value="'.$box->box_id.
'">'.
"\n";
381 print
'<input type="submit" class="button small smallpaddingimp" value="'.$langs->trans(
"Activate").
'">';
386print
"\n".
'<!-- End Boxes Available -->'.
"\n";
391foreach ($boxactivated as $key => $box) {
392 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $box->boximg)) {
393 $logo = $box->boximg;
395 $logo = preg_replace(
"/^object_/i",
"", $box->boximg);
398 print
"\n".
'<!-- Box '.$box->boxcode.
' -->'.
"\n";
399 print
'<tr class="oddeven" style="height:3em !important;">';
400 print
'<td>'.img_object(
"", $logo,
'class="pictofixedwidth" height="14px"').
' '.$langs->transnoentitiesnoconv($box->boxlabel);
401 if (!empty($box->class) && preg_match(
'/graph_/', $box->class)) {
402 print
img_picto(
'',
'graph',
'class="paddingleft"');
404 if (!empty($box->version)) {
405 if ($box->version ==
'experimental') {
406 print
' <span class="opacitymedium">('.$langs->trans(
"Experimental").
')</span>';
407 } elseif ($box->version ==
'development') {
408 print
' <span class="opacitymedium">('.$langs->trans(
"Development").
')</span>';
412 $langs->load(
"errors");
413 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($box->note ==
'(WarningUsingThisBoxSlowDown)' ? $langs->trans(
"WarningUsingThisBoxSlowDown") : $box->note).
'">';
414 if ($box->note ==
'(WarningUsingThisBoxSlowDown)') {
415 print
img_warning(
'',
'').
' '.$langs->trans(
"WarningUsingThisBoxSlowDown");
417 print($box->note ? $box->note :
' ');
421 print $form->textwithpicto(
'', $langs->trans(
"SourceFile").
' : '.$box->sourcefile);
423 print
'<td class="center">'.(empty($arrayofhomepages[$box->position]) ?
'' : $langs->trans($arrayofhomepages[$box->position])).
'</td>';
424 $hasnext = ($key < (count($boxactivated) - 1));
425 $hasprevious = ($key != 0);
426 print
'<td class="center">'.($key + 1).
'</td>';
427 print
'<td class="center nowraponall">';
428 print($hasnext ?
'<a class="reposition" href="boxes.php?action=switch&token='.
newToken().
'&switchfrom='.$box->rowid.
'&switchto='.$boxactivated[$key + 1]->rowid.
'">'.
img_down().
'</a> ' :
'');
429 print($hasprevious ?
'<a class="reposition" href="boxes.php?action=switch&token='.
newToken().
'&switchfrom='.$box->rowid.
'&switchto='.$boxactivated[$key - 1]->rowid.
'">'.
img_up().
'</a>' :
'');
431 print
'<td class="center">';
432 print
'<a class="reposition" href="boxes.php?rowid='.$box->rowid.
'&action=delete&token='.
newToken().
'">'.
img_delete().
'</a>';
447print
"\n\n".
'<!-- Other Const -->'.
"\n";
449print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
450print
'<input type="hidden" name="token" value="'.newToken().
'">';
451print
'<input type="hidden" name="action" value="addconst">';
452print
'<input type="hidden" name="page_y" value="">';
453print
'<div class="div-table-responsive-no-min">';
454print
'<table class="noborder centpercent">';
456print
'<tr class="liste_titre">';
457print
'<td class="liste_titre">'.$langs->trans(
"Parameter").
'</td>';
458print
'<td class="liste_titre"></td>';
462print
'<tr class="oddeven"><td>'.$langs->trans(
"EnableFileCache").
'</td><td>';
463if (
$conf->use_javascript_ajax) {
464 print ajax_constantonoff(
'MAIN_ACTIVATE_FILECACHE', array(),
null, 0, 0, 0, 2, 0, 1);
466 print $form->selectyesno(
'MAIN_ACTIVATE_FILECACHE',
getDolGlobalInt(
'MAIN_ACTIVATE_FILECACHE', 0), 1);
474print $form->buttonsSaveCancel(
"Save",
'', array(), 0,
'reposition');
477print
"\n".
'<!-- End Other Const -->'.
"\n";
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
static listBoxes($dbs, $mode, $zone, $user=null, $excludelist=array(), $includehidden=1)
Return array of boxes qualified for area and user.
static getListOfPagesForBoxes()
Name of positions (See below)
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.