예제 #1
1
 /**
  * 	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);
 }
예제 #2
0
 /**
  * Adds boxes
  *
  * @param   string  $option Options when disabling module ('newboxdefonly'=insert only boxes definition)
  *
  * @return  int             Error count (0 if OK)
  */
 function insert_boxes($option = '')
 {
     require_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php';
     global $conf;
     $err = 0;
     if (is_array($this->boxes)) {
         $pos_name = InfoBox::getListOfPagesForBoxes();
         foreach ($this->boxes as $key => $value) {
             $file = isset($this->boxes[$key]['file']) ? $this->boxes[$key]['file'] : '';
             $note = isset($this->boxes[$key]['note']) ? $this->boxes[$key]['note'] : '';
             $enabledbydefaulton = isset($this->boxes[$key]['enabledbydefaulton']) ? $this->boxes[$key]['enabledbydefaulton'] : 'Home';
             if (empty($file)) {
                 $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] : '';
             }
             // For backward compatibility
             if (empty($note)) {
                 $note = isset($this->boxes[$key][2]) ? $this->boxes[$key][2] : '';
             }
             // For backward compatibility
             // Search if boxes def already present
             $sql = "SELECT count(*) as nb FROM " . MAIN_DB_PREFIX . "boxes_def";
             $sql .= " WHERE file = '" . $this->db->escape($file) . "'";
             $sql .= " AND entity = " . $conf->entity;
             if ($note) {
                 $sql .= " AND note ='" . $this->db->escape($note) . "'";
             }
             dol_syslog(get_class($this) . "::insert_boxes", LOG_DEBUG);
             $result = $this->db->query($sql);
             if ($result) {
                 $obj = $this->db->fetch_object($result);
                 if ($obj->nb == 0) {
                     $this->db->begin();
                     if (!$err) {
                         $sql = "INSERT INTO " . MAIN_DB_PREFIX . "boxes_def (file, entity, note)";
                         $sql .= " VALUES ('" . $this->db->escape($file) . "', ";
                         $sql .= $conf->entity . ", ";
                         $sql .= $note ? "'" . $this->db->escape($note) . "'" : "null";
                         $sql .= ")";
                         dol_syslog(get_class($this) . "::insert_boxes", LOG_DEBUG);
                         $resql = $this->db->query($sql);
                         if (!$resql) {
                             $err++;
                         }
                     }
                     if (!$err && !preg_match('/newboxdefonly/', $option)) {
                         $lastid = $this->db->last_insert_id(MAIN_DB_PREFIX . "boxes_def", "rowid");
                         foreach ($pos_name as $key2 => $val2) {
                             //print 'key2='.$key2.'-val2='.$val2."<br>\n";
                             if ($enabledbydefaulton && $val2 != $enabledbydefaulton) {
                                 continue;
                             }
                             // Not enabled by default onto this page.
                             $sql = "INSERT INTO " . MAIN_DB_PREFIX . "boxes (box_id,position,box_order,fk_user,entity)";
                             $sql .= " VALUES (" . $lastid . ", " . $key2 . ", '0', 0, " . $conf->entity . ")";
                             dol_syslog(get_class($this) . "::insert_boxes onto page " . $key2 . "=" . $val2 . "", LOG_DEBUG);
                             $resql = $this->db->query($sql);
                             if (!$resql) {
                                 $err++;
                             }
                         }
                     }
                     if (!$err) {
                         $this->db->commit();
                     } else {
                         $this->error = $this->db->lasterror();
                         $this->db->rollback();
                     }
                 }
                 // else box already registered into database
             } else {
                 $this->error = $this->db->lasterror();
                 $err++;
             }
         }
     }
     return $err;
 }
예제 #3
0
$userid = GETPOST('userid');
$zone = GETPOST('zone', 'int');
$userid = GETPOST('userid', 'int');
/*
 * View
 */
// Ajout directives pour resoudre bug IE
//header('Cache-Control: Public, must-revalidate');
//header('Pragma: public');
//top_htmlhead("", "", 1);  // Replaced with top_httphead. An ajax page does not need html header.
top_httphead();
print '<!-- Ajax page called with url ' . $_SERVER["PHP_SELF"] . '?' . $_SERVER["QUERY_STRING"] . ' -->' . "\n";
// Add a box
if ($boxid > 0 && $zone != '' && $userid > 0) {
    $tmp = explode('-', $boxorder);
    $nbboxonleft = substr_count($tmp[0], ',');
    $nbboxonright = substr_count($tmp[1], ',');
    print $nbboxonleft . '-' . $nbboxonright;
    if ($nbboxonleft > $nbboxonright) {
        $boxorder = preg_replace('/B:/', 'B:' . $boxid . ',', $boxorder);
    } else {
        $boxorder = preg_replace('/^A:/', 'A:' . $boxid . ',', $boxorder);
    }
    // Insert id of new box into list
}
// Registering the location of boxes after a move
if ($boxorder && $zone != '' && $userid > 0) {
    // boxorder value is the target order: "A:idboxA1,idboxA2,A-B:idboxB1,idboxB2,B"
    dol_syslog("AjaxBox boxorder=" . $boxorder . " zone=" . $zone . " userid=" . $userid, LOG_DEBUG);
    $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
}
예제 #4
0
    /**
     * 	Show a HTML Tab with boxes of a particular area including personalized choices of user.
     *  Class 'Form' must be known.
     *
     * 	@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';
        $confuserzone = 'MAIN_BOXES_' . $areacode;
        $boxactivated = InfoBox::listBoxes($db, 'activated', $areacode, empty($user->conf->{$confuserzone}) ? null : $user);
        // Search boxes of common+user (or common only if user has no specific setup)
        $boxidactivatedforuser = array();
        foreach ($boxactivated as $box) {
            if (empty($user->conf->{$confuserzone}) || $box->fk_user == $user->id) {
                $boxidactivatedforuser[$box->id] = $box->id;
            }
            // We keep only boxes to show for user
        }
        $selectboxlist = '';
        $arrayboxtoactivatelabel = array();
        if (!empty($user->conf->{$confuserzone})) {
            $boxorder = '';
            $langs->load("boxes");
            // Load label of boxes
            foreach ($boxactivated as $box) {
                if (!empty($boxidactivatedforuser[$box->id])) {
                    continue;
                }
                // Already visible for user
                $label = $langs->transnoentitiesnoconv($box->boxlabel);
                if (preg_match('/graph/', $box->class)) {
                    $label .= ' (' . $langs->trans("Graph") . ')';
                }
                $arrayboxtoactivatelabel[$box->id] = $label;
                // We keep only boxes not shown for user, to show into combo list
            }
            foreach ($boxidactivatedforuser as $boxid) {
                if (empty($boxorder)) {
                    $boxorder .= 'A:';
                }
                $boxorder .= $boxid . ',';
            }
            //var_dump($boxidactivatedforuser);
            // Class Form must have been already loaded
            $selectboxlist .= '<form name="addbox" method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
            $selectboxlist .= '<input type="hidden" name="addbox" value="addbox">';
            $selectboxlist .= '<input type="hidden" name="userid" value="' . $user->id . '">';
            $selectboxlist .= '<input type="hidden" name="areacode" value="' . $areacode . '">';
            $selectboxlist .= '<input type="hidden" name="boxorder" value="' . $boxorder . '">';
            $selectboxlist .= Form::selectarray('boxcombo', $arrayboxtoactivatelabel, '', 1);
            if (empty($conf->use_javascript_ajax)) {
                $selectboxlist .= ' <input type="submit" class="button" value="' . $langs->trans("AddBox") . '">';
            }
            $selectboxlist .= '</form>';
        }
        // Javascript code for dynamic actions
        if (!empty($conf->use_javascript_ajax)) {
            print '<script type="text/javascript" language="javascript">

	        // To update list of activated boxes
	        function updateBoxOrder(closing) {
	        	var left_list = cleanSerialize(jQuery("#left").sortable("serialize"));
	        	var right_list = cleanSerialize(jQuery("#right").sortable("serialize"));
	        	var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
	        	if (boxorder==\'A:A-B:B\' && closing == 1)	// There is no more boxes on screen, and we are after a delete of a box so we must hide title
	        	{
	        		jQuery.ajax({
	        			url: \'' . DOL_URL_ROOT . '/core/ajax/box.php?boxorder=\'+boxorder+\'&zone=' . $areacode . '&userid=\'+' . $user->id . ',
	        			async: false
	        		});
	        		// We force reload to be sure to get all boxes into list
	        		window.location.search=\'mainmenu=' . GETPOST("mainmenu") . '&leftmenu=' . GETPOST('leftmenu') . '&action=delbox\';
	        	}
	        	else
	        	{
	        		jQuery.ajax({
	        			url: \'' . DOL_URL_ROOT . '/core/ajax/box.php?boxorder=\'+boxorder+\'&zone=' . $areacode . '&userid=\'+' . $user->id . ',
	        			async: true
	        		});
	        	}
	        }

	        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
	    		        });
	        			window.location.search=\'mainmenu=' . GETPOST("mainmenu") . '&leftmenu=' . GETPOST('leftmenu') . '&action=addbox&boxid=\'+boxid;
	                }
	        	});';
            if (!count($arrayboxtoactivatelabel)) {
                print 'jQuery("#boxcombo").hide();';
            }
            print '

	        	jQuery("#left, #right").sortable({
		        	/* placeholder: \'ui-state-highlight\', */
	    	    	handle: \'.boxhandle\',
	    	    	revert: \'invalid\',
	       			items: \'.box\',
	        		containment: \'.fiche\',
	        		connectWith: \'.connectedSortable\',
	        		stop: function(event, ui) {
	        			updateBoxOrder(0);
	        		}
	    		});

	        	jQuery(".boxclose").click(function() {
	        		var self = this;	// because JQuery can modify this
	        		var boxid=self.id.substring(8);
	        		var label=jQuery(\'#boxlabelentry\'+boxid).val();
	        		jQuery(\'#boxto_\'+boxid).remove();
	        		if (boxid > 0) jQuery(\'#boxcombo\').append(new Option(label, boxid));
	        		updateBoxOrder(1);
	        	});

        	});' . "\n";
            print '</script>' . "\n";
        }
        $nbboxactivated = count($boxidactivatedforuser);
        print load_fiche_titre($nbboxactivated ? $langs->trans("OtherInformationsBoxes") : '', $selectboxlist, '', '', 'otherboxes');
        if ($nbboxactivated) {
            $langs->load("boxes");
            $langs->load("projects");
            $emptybox = new ModeleBoxes($db);
            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 (!empty($user->conf->{$confuserzone}) && $box->fk_user == 0 || empty($user->conf->{$confuserzone}) && $box->fk_user != 0) {
                    continue;
                }
                if (empty($box->box_order) && $ii < $nbboxactivated / 2) {
                    $box->box_order = 'A' . sprintf("%02d", $ii + 1);
                }
                // When box_order was not yet set to Axx or Bxx and is still 0
                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();
                }
            }
            if (empty($conf->browser->phone)) {
                $emptybox->box_id = 'A';
                $emptybox->info_box_head = array();
                $emptybox->info_box_contents = array();
                $emptybox->showBox(array(), array());
            }
            print "</div>\n";
            print "<!-- End box left 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 (!empty($user->conf->{$confuserzone}) && $box->fk_user == 0 || empty($user->conf->{$confuserzone}) && $box->fk_user != 0) {
                    continue;
                }
                if (empty($box->box_order) && $ii < $nbboxactivated / 2) {
                    $box->box_order = 'B' . sprintf("%02d", $ii + 1);
                }
                // When box_order was not yet set to Axx or Bxx and is still 0
                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();
                }
            }
            if (empty($conf->browser->phone)) {
                $emptybox->box_id = 'B';
                $emptybox->info_box_head = array();
                $emptybox->info_box_contents = array();
                $emptybox->showBox(array(), array());
            }
            print "</div>\n";
            print "<!-- End box right container -->\n";
            print '</div></div>';
            print "\n";
            print "</td></tr>";
            print "</table>";
        }
        return count($boxactivated);
    }
예제 #5
0
파일: boxes.php 프로젝트: ADDAdev/Dolibarr
    // Pour chaque position possible, on affiche un lien d'activation si boite non deja active pour cette position
    print '<td class="center">';
    print $form->selectarray("boxid[" . $box->box_id . "][pos]", $pos_name, 0, 1, 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>' . "\n";
}
print '</table>' . "\n";
print '<div class="right">';
print '<input type="submit" class="button"' . (count($boxtoadd) ? '' : ' disabled="disabled"') . ' value="' . $langs->trans("Activate") . '">';
print '</div>' . "\n";
print '</form>';
print "\n" . '<!-- End Boxes Available -->' . "\n";
// Activated boxes
$boxactivated = InfoBox::listBoxes($db, 'activated', -1, null);
//var_dump($boxactivated);
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) {
예제 #6
0
if (! defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN','1');

require('../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/boxes.php");


/*
 * View
 */

// Ajout directives pour resoudre bug IE
//header('Cache-Control: Public, must-revalidate');
//header('Pragma: public');

//top_htmlhead("", "", 1);  // Replaced with top_httphead. An ajax page does not need html header.
top_httphead();

print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";

// Registering the location of boxes
if((isset($_GET['boxorder']) && !empty($_GET['boxorder'])) && (isset($_GET['userid']) && !empty($_GET['userid'])))
{
	// boxorder value is the target order: "A:idboxA1,idboxA2,A-B:idboxB1,idboxB2,B"
	dol_syslog("AjaxBox boxorder=".$_GET['boxorder']." userid=".$_GET['userid'], LOG_DEBUG);

	$infobox=new InfoBox($db);
	$result=$infobox->saveboxorder("0",$_GET['boxorder'],$_GET['userid']);
}

?>
예제 #7
0
파일: boxes.php 프로젝트: nrjacker4/crm-php
    print '<td>' . img_object("", $logo) . ' ' . $box->boxlabel . '</td>';
    print '<td>' . ($box->note ? $box->note : '&nbsp;') . '</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;
예제 #8
0
/**
 * 		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);
}