New: Add button collapse/expand for menu, category and user views.

This commit is contained in:
Laurent Destailleur
2013-02-20 21:16:31 +01:00
parent 320b4bde1f
commit 2852aded3a
8 changed files with 229 additions and 419 deletions

View File

@@ -6,15 +6,27 @@ English Dolibarr ChangeLog
For users: For users:
- New: Some performance enhancements. - New: Some performance enhancements.
- New: Can attach files onto trip and expenses modules. - New: Can attach files onto trip and expenses modules.
- New: Add option MAIN_PDF_TITLE_BACKGROUND_COLOR - New: Add option MAIN_PDF_TITLE_BACKGROUND_COLOR.
- New: Can define a hierarchical responsible on user - New: Merge tab customer and prospect.
- New: Merge tab customer and prospect - New: Add ES formated address country rule.
- New: Add ES formated address country rule - New: Can define a hierarchical responsible on user.
- New: Add a hierarchical view for users.
- New: Can expand/collapse menus, categories and users list.
- New: extra parameters are supported into ODT templates.
- New: total per vat rate are available as tags for ODT templates.
- New: Add more types for extra parameters (lists, phone, emails, checkbox, prices)
- New: Some part of interface use more CSS3 (ie: agenda)
For developers: For developers:
- System of menu managers has been rewritten to reduce code to do same things. - System of menu managers has been rewritten to reduce code to do same things.
- An external module can force its theme. - An external module can force its theme.
- Add function dol_set_focus('#xxx'). - Add function dol_set_focus('#xxx').
- A mymodule can bring its own core/modules/mymodule/modules_mymodule.php file.
- Removed not used libraries.
- More web services.
- Renamed some french fields into english.
- First change to manage margins on contracts.
- Add hook getFormMail.
For translators: For translators:
- Update language files. - Update language files.

View File

@@ -209,8 +209,8 @@ elseif ($action == 'confirm_delete' && $confirm == 'yes')
$form=new Form($db); $form=new Form($db);
$formadmin=new FormAdmin($db); $formadmin=new FormAdmin($db);
$arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js?lang='.$langs->defaultlang); $arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
$arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css?lang='.$langs->defaultlang); $arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
llxHeader('',$langs->trans("Menus"),'','',0,0,$arrayofjs,$arrayofcss); llxHeader('',$langs->trans("Menus"),'','',0,0,$arrayofjs,$arrayofcss);

View File

@@ -52,7 +52,11 @@ elseif ($type == 2) $title=$langs->trans("CustomersCategoriesArea");
elseif ($type == 3) $title=$langs->trans("MembersCategoriesArea"); elseif ($type == 3) $title=$langs->trans("MembersCategoriesArea");
else $title=$langs->trans("CategoriesArea"); else $title=$langs->trans("CategoriesArea");
llxHeader("","",$title); $arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
$arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
llxHeader('',$title,'','',0,0,$arrayofjs,$arrayofcss);
print_fiche_titre($title); print_fiche_titre($title);
@@ -128,187 +132,56 @@ $cate_arbo = $categstatic->get_full_arbo($type);
// Define fulltree array // Define fulltree array
$fulltree=$cate_arbo; $fulltree=$cate_arbo;
// Define data (format for treeview)
$data=array();
$data[] = array('rowid'=>0,'fk_menu'=>-1,'title'=>"racine",'mainmenu'=>'','leftmenu'=>'','fk_mainmenu'=>'','fk_leftmenu'=>'');
foreach($fulltree as $key => $val)
{
$categstatic->id=$val['id'];
$categstatic->ref=$val['label'];
$categstatic->type=$type;
$li=$categstatic->getNomUrl(1,'',60);
$data[] = array(
'rowid'=>$val['rowid'],
'fk_menu'=>$val['fk_parent'],
'entry'=>'<table class="nobordernopadding centpercent"><tr><td>'.$li.
'</td><td width="50%">'.
' '.$val['description'].'</td>'.
'<td align="right" width="20px;"><a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.$type.'">'.img_view().'</a></td>'.
'</tr></table>'
);
}
print '<table class="liste" width="100%">'; print '<table class="liste" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Categories").'</td><td colspan="3">'.$langs->trans("Description").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Categories").'</td><td>'.$langs->trans("Description").'</td><td align="right"><div id="iddivjstreecontrol"><a href="#">'.img_picto('','object_category').' '.$langs->trans("UndoExpandAll").'</a>';
print ' | <a href="#">'.img_picto('','object_category-expanded').' '.$langs->trans("ExpandAll").'</a></div></td></tr>';
$nbofentries=(count($data) - 1);
// ----- This section will show a tree from a fulltree array ----- if ($nbofentries > 0)
// $section must also be defined
// ---------------------------------------------------------------
// Root title line
print '<tr><td>';
print '<table class="nobordernopadding"><tr class="nobordernopadding">';
print '<td align="left" width="24">';
print img_picto_common('','treemenu/base.gif');
print '</td><td align="left">'.$langs->trans("AllCats");
print '</td>';
print '</tr></table></td>';
print '<td align="right">&nbsp;</td>';
print '<td align="right">&nbsp;</td>';
//print '<td align="right">&nbsp;</td>';
print '</tr>';
// Define fullpathselected ( _x_y_z ) of $section parameter
$fullpathselected='';
if (! empty($section))
{ {
foreach($fulltree as $key => $val) print '<tr><td colspan="3">';
{ tree_recur($data,$data[0],0);
//print $val['id']."-".$section."<br>"; print '</td></tr>';
if ($val['id'] == $section)
{
$fullpathselected=$val['fullpath'];
break;
}
}
} }
//print "fullpathselected=".$fullpathselected."<br>"; else
// Update expandedsectionarray in session
$expandedsectionarray=array();
if (isset($_SESSION['dol_catexpandedsectionarray'.$type])) $expandedsectionarray=explode(',',$_SESSION['dol_catexpandedsectionarray'.$type]);
if (! empty($section) && $_GET['sectionexpand'] == 'true')
{ {
// We add all sections that are parent of opened section print '<tr>';
$pathtosection=explode('_',$fullpathselected); print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('','treemenu/branchbottom.gif').'</td>';
foreach($pathtosection as $idcursor) print '<td valign="middle">';
{ print $langs->trans("NoCategoryYet");
if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) // Not already in array print '</td>';
{ print '<td>&nbsp;</td>';
$expandedsectionarray[]=$idcursor; print '</table></td>';
} print '</tr>';
} }
$_SESSION['dol_catexpandedsectionarray'.$type]=join(',',$expandedsectionarray);
}
if (! empty($section) && $_GET['sectionexpand'] == 'false')
{
// We removed all expanded sections that are child of the closed section
$oldexpandedsectionarray=$expandedsectionarray;
$expandedsectionarray=array();
foreach($oldexpandedsectionarray as $sectioncursor)
{
// is_in_subtree(fulltree,sectionparent,sectionchild)
if ($sectioncursor && ! is_in_subtree($fulltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor;
}
$_SESSION['dol_catexpandedsectionarray'.$type]=join(',',$expandedsectionarray);
}
//print $_SESSION['dol_catexpandedsectionarray'.$type].'<br>';
$nbofentries=0;
$oldvallevel=0;
$var=true;
foreach($fulltree as $key => $val)
{
//$fullpathparent=preg_replace('/_[^_]+$/i','',$val['fullpath']);
// Define showline
$showline=0;
//var_dump($expandedsectionarray);
// If directory is son of expanded directory, we show line
if (isset($val['fk_parent']) && in_array($val['fk_parent'],$expandedsectionarray)) $showline=4;
// If directory is parent of selected directory or is selected directory, we show line
elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2;
// If we are level one we show line
elseif ($val['level'] < 2) $showline=1;
//print 'xxx '.$val['level'].' - '.$fullpathselected.' - '.$val['fullpath'].' - '.$val['fk_parent'].' showline='.$showline.'<br>'."\n";
if ($showline)
{
$var=!$var;
if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded';
else $option='indexnotexpanded';
//print $option;
print "<tr ".$bc[$var].">";
// Show tree graph pictos
print '<td align="left">';
print '<table class="nobordernopadding"><tr class="nobordernopadding"><td>';
$resarray=tree_showpad($fulltree,$key);
$a=$resarray[0];
$nbofsubdir=$resarray[1];
$nboffilesinsubdir=$resarray[2];
print '</td>';
// Show picto
print '<td valign="top">';
//print $val['fullpath']."(".$showline.")";
$n='2';
if (! in_array($val['id'],$expandedsectionarray)) $n='3';
if (! in_array($val['id'],$expandedsectionarray)) $ref=img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/plustop'.$n.'.gif','',1);
else $ref=img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/minustop'.$n.'.gif','',1);
if ($option == 'indexexpanded') $lien = '<a href="'.$_SERVER["PHP_SELF"].'?section='.$val['id'].'&amp;type='.$type.'&amp;sectionexpand=false">';
if ($option == 'indexnotexpanded') $lien = '<a href="'.$_SERVER["PHP_SELF"].'?section='.$val['id'].'&amp;type='.$type.'&amp;sectionexpand=true">';
$newref=str_replace('_',' ',$ref);
$lienfin='</a>';
print $lien.$newref.$lienfin;
if (! in_array($val['id'],$expandedsectionarray)) print img_picto('','object_category');
else print img_picto('','object_category-expanded');
print '</td>';
// Show link
print '<td valign="middle">';
//if ($section == $val['id']) print ' <u>';
// We don't want a link ... why ?
$categstatic->id=$val['id'];
$categstatic->ref=$val['label'];
$categstatic->type=$type;
print ' &nbsp;'.$categstatic->getNomUrl(0,'',60);
//print ' &nbsp;'.dol_trunc($val['label'],28);
//if ($section == $val['id']) print '</u>';
print '</td>';
print '</tr></table>';
print "</td>\n";
// Description
print '<td>';
print dol_trunc($val['description'],48);
print '</td>';
// Link to category card
print '<td align="right"><a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.$type.'">'.img_view().'</a></td>';
// Add link
//print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create&amp;catParent='.$val['id'].'">'.img_edit_add().'</a></td>';
//print '<td align="right">&nbsp;</td>';
print "</tr>\n";
}
$oldvallevel=$val['level'];
$nbofentries++;
}
// If nothing to show
if ($nbofentries == 0)
{
print '<tr>';
print '<td class="left"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('','treemenu/branchbottom.gif').'</td>';
print '<td>'.img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/minustop3.gif','',1).'</td>';
print '<td valign="middle">';
print $langs->trans("NoCategoryYet");
print '</td>';
print '<td>&nbsp;</td>';
print '</table></td>';
print '<td colspan="4">&nbsp;</td>';
print '</tr>';
}
// ----- End of section -----
// --------------------------
print "</table>"; print "</table>";
llxFooter(); llxFooter();
$db->close(); $db->close();
?> ?>

View File

@@ -23,55 +23,7 @@
*/ */
// ------------------------------- Used by category tree view ----------------- // ------------------------------- Used by ajax tree view -----------------
/**
* Return if a child id is in descendance of parentid
*
* @param array $fulltree Full tree. Tree must be an array of records that looks like:
* id = id record
* id_mere = id record mother
* id_children = array of direct child id
* label = record label
* fullpath = Full path of id
* level = Level of record
* @param int $parentid Parent id
* @param int $childid Child id
* @return int 1=Yes, 0=No
*/
function is_in_subtree($fulltree,$parentid,$childid)
{
if ($parentid == $childid) return 1;
// Get fullpath of parent
$fullpathparent='';
foreach($fulltree as $key => $val)
{
//print $val['id']."-".$section."<br>";
if ($val['id'] == $parentid)
{
$fullpathparent=$val['fullpath'];
break;
}
}
//print '> parent='.$parentid.' - child='.$childid.' - '.$fullpathparent.'<br>';
foreach($fulltree as $record)
{
if ($record['id'] == $childid)
{
//print $record['fullpath'].'_'.' - '.$fullpathparent.'_';
if (preg_match('/'.$fullpathparent.'_/i',$record['fullpath'].'_'))
{
//print 'DEL='.$childid;
return 1;
}
}
}
return 0;
}
/** /**
* Show indent and picto of a tree line. Return array with information of line. * Show indent and picto of a tree line. Return array with information of line.
@@ -145,11 +97,16 @@ function tree_showpad(&$fulltree,$key,$silent=0)
// ------------------------------- Used by menu editor ----------------- // ------------------------------- Used by menu editor -----------------
/** /**
* Recursive function to output menu tree. <ul><li>...</li></ul> * Recursive function to output menu tree. <ul id="iddivjstree"><li>...</li></ul>
* Note: To have this function working, check you have loaded the js and css for treeview.
* $arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
* '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
* $arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
* *
* @param array $tab Array of all elements * @param array $tab Array of all elements
* @param int $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu=>,'fk_leftmenu=>) * @param int $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu=>,'fk_leftmenu=>)
* @param int $rang Level of element * @param int $rang Level of element
* @param string $iddivjstree Id to use for parent ul element
* @return void * @return void
*/ */
function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree') function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree')
@@ -162,13 +119,16 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree')
$("#'.$iddivjstree.'").treeview({ $("#'.$iddivjstree.'").treeview({
collapsed: true, collapsed: true,
animated: "fast", animated: "fast",
persist: "location", persist: "cookie",
control: "#'.$iddivjstree.'control" control: "#'.$iddivjstree.'control",
toggle: function() {
/* window.console && console.log("%o was toggled", this); */
}
}); });
}) })
</script>'; </script>';
print '<ul id="'.$iddivjstree.'" style="min-height:300px;">'; print '<ul id="'.$iddivjstree.'">';
} }
if ($rang > 10) return; // Protection contre boucle infinie if ($rang > 10) return; // Protection contre boucle infinie

View File

@@ -0,0 +1,92 @@
/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
/**
* Create a cookie with the given name and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true});
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value.
*
* @param String name The name of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
* If set to null or omitted, the cookie will be a session cookie and will not be retained
* when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
* require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
}
var path = options.path ? '; path=' + options.path : '';
var domain = options.domain ? '; domain=' + options.domain : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else { // only name given, get cookie
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
};

View File

@@ -44,4 +44,4 @@ alter table llx_extrafields add column param text after pos;
alter table llx_propal CHANGE COLUMN fk_adresse_livraison fk_delivery_address integer; alter table llx_propal CHANGE COLUMN fk_adresse_livraison fk_delivery_address integer;
alter table llx_commande CHANGE COLUMN fk_adresse_livraison fk_delivery_address integer; alter table llx_commande CHANGE COLUMN fk_adresse_livraison fk_delivery_address integer;
alter table llx_don CHANGE COLUMN adresse address text; alter table llx_don CHANGE COLUMN adresse address text;
alter table llx_adherent CHANGE COLUMN adresse address text;

View File

@@ -1785,7 +1785,7 @@ class User extends CommonObject
/** /**
* Retourne le libelle du statut d'un user (actif, inactif) * Retourne le libelle du statut d'un user (actif, inactif)
* *
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label of status * @return string Label of status
*/ */
function getLibStatut($mode=0) function getLibStatut($mode=0)
@@ -2191,7 +2191,7 @@ class User extends CommonObject
$this->load_parentof(); $this->load_parentof();
// Init $this->users array // Init $this->users array
$sql = "SELECT DISTINCT u.rowid, u.firstname, u.name, u.fk_user"; // Distinct reduce pb with old tables with duplicates $sql = "SELECT DISTINCT u.rowid, u.firstname, u.name, u.fk_user, u.login, u.statut"; // Distinct reduce pb with old tables with duplicates
$sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE u.entity IN (".getEntity('user',1).")"; $sql.= " WHERE u.entity IN (".getEntity('user',1).")";
@@ -2204,9 +2204,11 @@ class User extends CommonObject
{ {
$this->users[$obj->rowid]['rowid'] = $obj->rowid; $this->users[$obj->rowid]['rowid'] = $obj->rowid;
$this->users[$obj->rowid]['id'] = $obj->rowid; $this->users[$obj->rowid]['id'] = $obj->rowid;
$this->users[$obj->rowid]['fk_user'] = $obj->fk_parent; $this->users[$obj->rowid]['fk_user'] = $obj->fk_user;
$this->users[$obj->rowid]['firstname'] = $obj->firstname; $this->users[$obj->rowid]['firstname'] = $obj->firstname;
$this->users[$obj->rowid]['name'] = $obj->name; $this->users[$obj->rowid]['name'] = $obj->name;
$this->users[$obj->rowid]['login'] = $obj->login;
$this->users[$obj->rowid]['statut'] = $obj->statut;
$i++; $i++;
} }
} }
@@ -2297,7 +2299,7 @@ class User extends CommonObject
{ {
print 'id: '.$this->users[$key]['id']; print 'id: '.$this->users[$key]['id'];
print ' name: '.$this->users[$key]['name']; print ' name: '.$this->users[$key]['name'];
print ' parent: '.$this->users[$key]['fk_parent']; print ' parent: '.$this->users[$key]['fk_user'];
print ' fullpath: '.$this->users[$key]['fullpath']; print ' fullpath: '.$this->users[$key]['fullpath'];
print ' fullname: '.$this->users[$key]['fullname']; print ' fullname: '.$this->users[$key]['fullname'];
print "<br>\n"; print "<br>\n";

View File

@@ -53,9 +53,12 @@ $companystatic = new Societe($db);
$form = new Form($db); $form = new Form($db);
llxHeader(); $arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
$arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
llxHeader('',$langs->trans("ListOfUsers"). ' ('.$langs->trans("HierarchicView").')','','',0,0,$arrayofjs,$arrayofcss);
print_fiche_titre($langs->trans("ListOfUsers"). ' ('.$langs->trans("HierarchicView").')', '<form action="'.DOL_URL_ROOT.'/user/index.php" method="POST"><input type="submit" class="button" style="width:120px" name="viewcal" value="'.dol_escape_htmltag($langs->trans("List")).'"></form>'); print_fiche_titre($langs->trans("ListOfUsers"). ' ('.$langs->trans("HierarchicView").')', '<form action="'.DOL_URL_ROOT.'/user/index.php" method="POST"><input type="submit" class="button" style="width:120px" name="viewcal" value="'.dol_escape_htmltag($langs->trans("ViewList")).'"></form>');
@@ -64,187 +67,55 @@ $user_arbo = $userstatic->get_full_tree();
// Define fulltree array // Define fulltree array
$fulltree=$user_arbo; $fulltree=$user_arbo;
print '<table class="liste" width="100%">'; // Define data (format for treeview)
$data=array();
$data[] = array('rowid'=>0,'fk_menu'=>-1,'title'=>"racine",'mainmenu'=>'','leftmenu'=>'','fk_mainmenu'=>'','fk_leftmenu'=>'');
// ----- This section will show a tree from a fulltree array ----- foreach($fulltree as $key => $val)
// $section must also be defined
// ---------------------------------------------------------------
// Root title line
print '<tr><td>';
print '<table class="nobordernopadding"><tr class="nobordernopadding">';
print '<td align="left" width="24">';
print img_picto_common('','treemenu/base.gif');
print '</td><td align="left">'.$langs->trans("All");
print '</td>';
print '</tr></table></td>';
print '<td align="right">&nbsp;</td>';
print '<td align="right">&nbsp;</td>';
//print '<td align="right">&nbsp;</td>';
print '</tr>';
// Define fullpathselected ( _x_y_z ) of $section parameter
$fullpathselected='';
if (! empty($section))
{ {
foreach($fulltree as $key => $val) $userstatic->id=$val['id'];
{ $userstatic->ref=$val['label'];
//print $val['id']."-".$section."<br>"; $userstatic->firstname=$val['firstname'];
if ($val['id'] == $section) $userstatic->lastname=$val['name'];
{ $userstatic->statut=$val['statut'];
$fullpathselected=$val['fullpath']; $li=$userstatic->getNomUrl(1,'').' ('.$val['login'].')';
break;
} $data[] = array(
} 'rowid'=>$val['rowid'],
} 'fk_menu'=>$val['fk_user'],
//print "fullpathselected=".$fullpathselected."<br>"; 'entry'=>'<table class="nobordernopadding centpercent"><tr><td>'.$li.'</td><td align="right">'.$userstatic->getLibStatut(5).'</td></tr></table>'
);
// Update expandedsectionarray in session }
$expandedsectionarray=array();
if (isset($_SESSION['dol_catexpandedsectionarray'.$type])) $expandedsectionarray=explode(',',$_SESSION['dol_catexpandedsectionarray'.$type]);
print '<table class="liste" width="100%">';
if (! empty($section) && $_GET['sectionexpand'] == 'true') print '<tr class="liste_titre"><td>'.$langs->trans("HierarchicView").'</td><td></td><td align="right"><div id="iddivjstreecontrol"><a href="#">'.img_picto('','object_category').' '.$langs->trans("UndoExpandAll").'</a>';
{ print ' | <a href="#">'.img_picto('','object_category-expanded').' '.$langs->trans("ExpandAll").'</a></div></td></tr>';
// We add all sections that are parent of opened section
$pathtosection=explode('_',$fullpathselected); $nbofentries=(count($data) - 1);
foreach($pathtosection as $idcursor)
{ if ($nbofentries > 0)
if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) // Not already in array {
{ print '<tr><td colspan="3">';
$expandedsectionarray[]=$idcursor; tree_recur($data,$data[0],0);
} print '</td></tr>';
} }
$_SESSION['dol_catexpandedsectionarray'.$type]=join(',',$expandedsectionarray); else
} {
if (! empty($section) && $_GET['sectionexpand'] == 'false') print '<tr>';
{ print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('','treemenu/branchbottom.gif').'</td>';
// We removed all expanded sections that are child of the closed section print '<td valign="middle">';
$oldexpandedsectionarray=$expandedsectionarray; print $langs->trans("NoCategoryYet");
$expandedsectionarray=array(); print '</td>';
foreach($oldexpandedsectionarray as $sectioncursor) print '<td>&nbsp;</td>';
{ print '</table></td>';
// is_in_subtree(fulltree,sectionparent,sectionchild) print '</tr>';
if ($sectioncursor && ! is_in_subtree($fulltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor; }
}
$_SESSION['dol_catexpandedsectionarray'.$type]=join(',',$expandedsectionarray);
}
//print $_SESSION['dol_catexpandedsectionarray'.$type].'<br>';
$nbofentries=0;
$oldvallevel=0;
$var=true;
foreach($fulltree as $key => $val)
{
//$fullpathparent=preg_replace('/_[^_]+$/i','',$val['fullpath']);
// Define showline
$showline=0;
//var_dump($expandedsectionarray);
// If directory is son of expanded directory, we show line
if (isset($val['fk_parent']) && in_array($val['fk_parent'],$expandedsectionarray)) $showline=4;
// If directory is parent of selected directory or is selected directory, we show line
elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2;
// If we are level one we show line
elseif ($val['level'] < 2) $showline=1;
//print 'xxx '.$val['level'].' - '.$fullpathselected.' - '.$val['fullpath'].' - '.$val['fk_parent'].' showline='.$showline.'<br>'."\n";
if ($showline)
{
$var=!$var;
if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded';
else $option='indexnotexpanded';
//print $option;
print "<tr ".$bc[$var].">";
// Show tree graph pictos
print '<td align="left">';
print '<table class="nobordernopadding"><tr class="nobordernopadding"><td>';
$resarray=tree_showpad($fulltree,$key);
$a=$resarray[0];
$nbofsubdir=$resarray[1];
$nboffilesinsubdir=$resarray[2];
print '</td>';
// Show picto
print '<td valign="top">';
//print $val['fullpath']."(".$showline.")";
$n='2';
if (! in_array($val['id'],$expandedsectionarray)) $n='3';
if (! in_array($val['id'],$expandedsectionarray)) $ref=img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/plustop'.$n.'.gif','',1);
else $ref=img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/minustop'.$n.'.gif','',1);
if ($option == 'indexexpanded') $lien = '<a href="'.$_SERVER["PHP_SELF"].'?section='.$val['id'].'&amp;type='.$type.'&amp;sectionexpand=false">';
if ($option == 'indexnotexpanded') $lien = '<a href="'.$_SERVER["PHP_SELF"].'?section='.$val['id'].'&amp;type='.$type.'&amp;sectionexpand=true">';
$newref=str_replace('_',' ',$ref);
$lienfin='</a>';
print $lien.$newref.$lienfin;
if (! in_array($val['id'],$expandedsectionarray)) print img_picto('','object_category');
else print img_picto('','object_category-expanded');
print '</td>';
// Show link
print '<td valign="middle">';
//if ($section == $val['id']) print ' <u>';
// We don't want a link ... why ?
$userstatic->id=$val['id'];
$userstatic->ref=$val['label'];
$userstatic->type=$type;
print ' &nbsp;'.$userstatic->getNomUrl(0,'',60);
//print ' &nbsp;'.dol_trunc($val['label'],28);
//if ($section == $val['id']) print '</u>';
print '</td>';
print '</tr></table>';
print "</td>\n";
// Description
print '<td>';
print dol_trunc($val['description'],48);
print '</td>';
// Link to category card
print '<td align="right"><a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.$type.'">'.img_view().'</a></td>';
// Add link
//print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create&amp;catParent='.$val['id'].'">'.img_edit_add().'</a></td>';
//print '<td align="right">&nbsp;</td>';
print "</tr>\n";
}
$oldvallevel=$val['level'];
$nbofentries++;
}
// If nothing to show
if ($nbofentries == 0)
{
print '<tr>';
print '<td class="left"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('','treemenu/branchbottom.gif').'</td>';
print '<td>'.img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/minustop3.gif','',1).'</td>';
print '<td valign="middle">';
print $langs->trans("NoCategoryYet");
print '</td>';
print '<td>&nbsp;</td>';
print '</table></td>';
print '<td colspan="4">&nbsp;</td>';
print '</tr>';
}
// ----- End of section -----
// --------------------------
print "</table>"; print "</table>";
llxFooter(); llxFooter();
$db->close(); $db->close();
?> ?>