/** * Show a HTML Tab with boxes of a particular area including personalized choices of user * * @param User $user Object User * @param String $areacode Code of area for pages (0=value for Home page) * @return int <0 if KO, Nb of boxes shown of OK (0 to n) */ static function printBoxesArea($user, $areacode) { global $conf, $langs, $db; include_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php'; //$infobox=new InfoBox($db); $boxactivated = InfoBox::listboxes($db, 'activated', $areacode, $user); $arrayboxactivatedid = array(); foreach ($boxactivated as $box) { $arrayboxactivatedid[$box->id] = $box->id; } $selectboxlist = ''; if ($conf->use_javascript_ajax) { $emptyuser = new User($db); $boxavailable = InfoBox::listboxes($db, 'activated', $areacode, $emptyuser, $arrayboxactivatedid); // Available here is activated for empty user $arrayboxtoactivatelabel = array(); foreach ($boxavailable as $box) { $arrayboxtoactivatelabel[$box->id] = $box->boxlabel; } $form = new Form($db); $selectboxlist = $form->selectarray('boxcombo', $arrayboxtoactivatelabel, '', 1); } print '<script type="text/javascript" language="javascript"> jQuery(document).ready(function() { jQuery("#boxcombo").change(function() { var boxid=jQuery("#boxcombo").val(); if (boxid > 0) { var left_list = cleanSerialize(jQuery("#left").sortable("serialize")); var right_list = cleanSerialize(jQuery("#right").sortable("serialize")); var boxorder = \'A:\' + left_list + \'-B:\' + right_list; jQuery.ajax({ url: \'' . DOL_URL_ROOT . '/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone=' . $areacode . '&userid=' . $user->id . '\', async: false }); //jQuery.get(\'' . DOL_URL_ROOT . '/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone=' . $areacode . '&userid=' . $user->id . '\'); window.location.search=\'mainmenu=' . GETPOST("mainmenu") . '&leftmenu=' . GETPOST('leftmenu') . '&action=addbox&boxid=\'+boxid; //window.location.href=\'' . $_SERVER["PHP_SELF"] . '\'; } });'; if (!count($arrayboxtoactivatelabel)) { print 'jQuery("#boxcombo").hide();'; } print ' }); </script>'; print load_fiche_titre(count($boxactivated) ? $langs->trans("OtherInformationsBoxes") : '', $selectboxlist, '', '', 'otherboxes'); if (count($boxactivated)) { print '<table width="100%" class="notopnoleftnoright">'; print '<tr><td class="notopnoleftnoright">' . "\n"; print '<div class="fichehalfleft">'; print "\n<!-- Box left container -->\n"; print '<div id="left" class="connectedSortable">' . "\n"; // Define $box_max_lines $box_max_lines = 5; if (!empty($conf->global->MAIN_BOXES_MAXLINES)) { $box_max_lines = $conf->global->MAIN_BOXES_MAXLINES; } $ii = 0; foreach ($boxactivated as $key => $box) { if (preg_match('/^A/i', $box->box_order)) { $ii++; //print 'box_id '.$boxactivated[$ii]->box_id.' '; //print 'box_order '.$boxactivated[$ii]->box_order.'<br>'; // Affichage boite key $box->loadBox($box_max_lines); $box->showBox(); } } $emptybox = new ModeleBoxes($db); $emptybox->box_id = 'A'; $emptybox->info_box_head = array(); $emptybox->info_box_contents = array(); $emptybox->showBox(array(), array()); print "</div>\n"; print "<!-- End box container -->\n"; print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print "\n<!-- Box right container -->\n"; print '<div id="right" class="connectedSortable">' . "\n"; $ii = 0; foreach ($boxactivated as $key => $box) { if (preg_match('/^B/i', $box->box_order)) { $ii++; //print 'box_id '.$boxactivated[$ii]->box_id.' '; //print 'box_order '.$boxactivated[$ii]->box_order.'<br>'; // Affichage boite key $box->loadBox($box_max_lines); $box->showBox(); } } $emptybox = new ModeleBoxes($db); $emptybox->box_id = 'B'; $emptybox->info_box_head = array(); $emptybox->info_box_contents = array(); $emptybox->showBox(array(), array()); print "</div>\n"; print "<!-- End box container -->\n"; print '</div></div>'; print "\n"; print "</td></tr>"; print "</table>"; if ($conf->use_javascript_ajax) { print "\n"; print '<script type="text/javascript" language="javascript">'; // For moving print 'jQuery(function() { jQuery("#left, #right").sortable({ /* placeholder: \'ui-state-highlight\', */ handle: \'.boxhandle\', revert: \'invalid\', items: \'.box\', containment: \'.fiche\', connectWith: \'.connectedSortable\', stop: function(event, ui) { updateOrder(0); } }); }); ' . "\n"; print 'function updateOrder() { var left_list = cleanSerialize(jQuery("#left").sortable("serialize")); var right_list = cleanSerialize(jQuery("#right").sortable("serialize")); var boxorder = \'A:\' + left_list + \'-B:\' + right_list; jQuery.get(\'' . DOL_URL_ROOT . '/core/ajax/box.php?boxorder=\'+boxorder+\'&zone=' . $areacode . '&userid=\'+' . $user->id . '); }' . "\n"; // For closing print 'jQuery(document).ready(function() { jQuery(".boxclose").click(function() { var self = this; // because JQuery can modify this var boxid=self.id.substring(8); jQuery(\'#boxto_\'+boxid).remove(); updateOrder(); }); });' . "\n"; print '</script>' . "\n"; } } return count($boxactivated); }
print '<td>' . img_object("", $logo) . ' ' . $box->boxlabel . '</td>'; print '<td>' . ($box->note ? $box->note : ' ') . '</td>'; print '<td>' . $box->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="' . $box->box_id . '">'; print ' <input type="submit" class="nice button tiny" name="button" value="' . $langs->trans("Activate") . '">'; print '</td>'; print '</tr>'; print '</form>'; } print '</table>'; // Activated boxes $boxactivated = InfoBox::listboxes($db, 'activated', -1, $emptyuser); print "<br>\n\n"; print_titre($langs->trans("BoxesActivated")); print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<td width="300">' . $langs->trans("Box") . '</td>'; print '<td>' . $langs->trans("Note") . '/' . $langs->trans("Parameters") . '</td>'; print '<td align="center" width="160">' . $langs->trans("ActiveOn") . '</td>'; print '<td align="center" width="60" colspan="2">' . $langs->trans("PositionByDefault") . '</td>'; print '<td align="center" width="80">' . $langs->trans("Disable") . '</td>'; print '</tr>' . "\n"; $var = true; $box_order = 1; $foundrupture = 1; foreach ($boxactivated as $key => $box) { $var = !$var;
/** * Show a HTML Tab with boxes of a particular area including personalized choices of user * * @param User $user Object User * @param String $areacode Code of area for pages (0=value for Home page) * @return int <0 if KO, Nb of boxes shown of OK (0 to n) */ function printBoxesArea($user,$areacode) { global $conf,$langs,$db; $infobox=new InfoBox($db); $boxarray=$infobox->listboxes($areacode,$user); //$boxid_left = array(); //$boxid_right = array(); if (count($boxarray)) { print_fiche_titre($langs->trans("OtherInformationsBoxes"),'','','','otherboxes'); print '<table width="100%" class="notopnoleftnoright">'; print '<tr><td class="notopnoleftnoright">'."\n"; print '<table width="100%" style="border-collapse: collapse; border: 0px; margin: 0px; padding: 0px;"><tr>'; // Affichage colonne gauche print '<td width="50%" valign="top" class="notopnoleft" style="padding-right: 8px;">'."\n"; print "\n<!-- Box left container -->\n"; print '<div id="left" class="connectedSortable">'."\n"; $ii=0; foreach ($boxarray as $key => $box) { if (preg_match('/^A/i',$box->box_order)) // column A { $ii++; //print 'box_id '.$boxarray[$ii]->box_id.' '; //print 'box_order '.$boxarray[$ii]->box_order.'<br>'; //$boxid_left[$key] = $box->box_id; // Affichage boite key $box->loadBox($conf->box_max_lines); $box->showBox(); } } // If no box on left, we add an invisible empty box // if ($ii==0) // { $emptybox=new ModeleBoxes($db); $emptybox->box_id='A'; $emptybox->info_box_head=array(); $emptybox->info_box_contents=array(); $emptybox->showBox(array(),array()); // } print "</div>\n"; print "<!-- End box container -->\n"; print "</td>\n"; // Affichage colonne droite print '<td width="50%" valign="top">'; print "\n<!-- Box right container -->\n"; print '<div id="right" class="connectedSortable">'."\n"; $ii=0; foreach ($boxarray as $key => $box) { if (preg_match('/^B/i',$box->box_order)) // colonne B { $ii++; //print 'box_id '.$boxarray[$ii]->box_id.' '; //print 'box_order '.$boxarray[$ii]->box_order.'<br>'; //$boxid_right[$key] = $boxarray[$key]->box_id; // Affichage boite key $box->loadBox($conf->box_max_lines); $box->showBox(); } } // If no box on right, we show add an invisible empty box // if ($ii==0) // { $emptybox=new ModeleBoxes($db); $emptybox->box_id='B'; $emptybox->info_box_head=array(); $emptybox->info_box_contents=array(); $emptybox->showBox(array(),array()); // } print "</div>\n"; print "<!-- End box container -->\n"; print "</td>"; print "</tr></table>\n"; print "\n"; print "</td></tr>"; print "</table>"; if ($conf->use_javascript_ajax) { print "\n"; print '<script type="text/javascript" language="javascript">'; print 'jQuery(function() { jQuery("#left, #right").sortable({ /* placeholder: \'ui-state-highlight\', */ handle: \'.boxhandle\', revert: \'invalid\', items: \'.box\', containment: \'.fiche\', connectWith: \'.connectedSortable\', stop: function(event, ui) { updateOrder(); } }); }); '; print "\n"; print 'function updateOrder(){'."\n"; print 'var left_list = cleanSerialize(jQuery("#left").sortable( "serialize" ));'."\n"; print 'var right_list = cleanSerialize(jQuery("#right").sortable( "serialize" ));'."\n"; print 'var boxorder = \'A:\' + left_list + \'-B:\' + right_list;'."\n"; //print 'alert( \'boxorder=\' + boxorder );'; print 'var userid = \''.$user->id.'\';'."\n"; print 'jQuery.get(\'core/ajaxbox.php?boxorder=\'+boxorder+\'&userid=\'+'.$user->id.');'."\n"; print '}'."\n"; print '</script>'."\n"; } } return count($boxarray); }