diff --git a/ChangeLog b/ChangeLog index bf58724de36..f1a44ef58e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,15 +6,27 @@ English Dolibarr ChangeLog For users: - New: Some performance enhancements. - New: Can attach files onto trip and expenses modules. -- New: Add option MAIN_PDF_TITLE_BACKGROUND_COLOR -- New: Can define a hierarchical responsible on user -- New: Merge tab customer and prospect -- New: Add ES formated address country rule - +- New: Add option MAIN_PDF_TITLE_BACKGROUND_COLOR. +- New: Merge tab customer and prospect. +- 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: - System of menu managers has been rewritten to reduce code to do same things. - An external module can force its theme. - 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: - Update language files. diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index f0ba051450c..5a042a65679 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -209,8 +209,8 @@ elseif ($action == 'confirm_delete' && $confirm == 'yes') $form=new Form($db); $formadmin=new FormAdmin($db); -$arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js?lang='.$langs->defaultlang); -$arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css?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'); llxHeader('',$langs->trans("Menus"),'','',0,0,$arrayofjs,$arrayofcss); diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index c9102fdaa17..520619580a9 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -52,7 +52,11 @@ elseif ($type == 2) $title=$langs->trans("CustomersCategoriesArea"); elseif ($type == 3) $title=$langs->trans("MembersCategoriesArea"); 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); @@ -128,187 +132,56 @@ $cate_arbo = $categstatic->get_full_arbo($type); // Define fulltree array $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'=>''. + ''. + '
'.$li. + ''. + ' '.$val['description'].''.img_view().'
' + ); +} + + print ''; -print ''; +print ''; +$nbofentries=(count($data) - 1); -// ----- This section will show a tree from a fulltree array ----- -// $section must also be defined -// --------------------------------------------------------------- - - -// Root title line -print ''; -print ''; -print ''; -//print ''; -print ''; - - - -// Define fullpathselected ( _x_y_z ) of $section parameter -$fullpathselected=''; -if (! empty($section)) +if ($nbofentries > 0) { - foreach($fulltree as $key => $val) - { - //print $val['id']."-".$section."
"; - if ($val['id'] == $section) - { - $fullpathselected=$val['fullpath']; - break; - } - } + print ''; } -//print "fullpathselected=".$fullpathselected."
"; - -// Update expandedsectionarray in session -$expandedsectionarray=array(); -if (isset($_SESSION['dol_catexpandedsectionarray'.$type])) $expandedsectionarray=explode(',',$_SESSION['dol_catexpandedsectionarray'.$type]); - -if (! empty($section) && $_GET['sectionexpand'] == 'true') +else { - // We add all sections that are parent of opened section - $pathtosection=explode('_',$fullpathselected); - foreach($pathtosection as $idcursor) - { - if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) // Not already in array - { - $expandedsectionarray[]=$idcursor; - } - } - $_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].'
'; - -$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.'
'."\n"; - - if ($showline) - { - $var=!$var; - - if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded'; - else $option='indexnotexpanded'; - //print $option; - - print ""; - - // Show tree graph pictos - print '\n"; - - // Description - print ''; - - // Link to category card - print ''; - - // Add link - //print ''; - //print ''; - - print "\n"; - } - - $oldvallevel=$val['level']; - $nbofentries++; -} - - -// If nothing to show -if ($nbofentries == 0) -{ - print ''; - print ''; - print ''; - print ''; -} - -// ----- End of section ----- -// -------------------------- + print ''; + print ''; + print ''; +} print "
'.$langs->trans("Categories").''.$langs->trans("Description").'
'.$langs->trans("Categories").''.$langs->trans("Description").'
'; -print ''; -print ''; -print '
'; -print img_picto_common('','treemenu/base.gif'); -print ''.$langs->trans("AllCats"); -print '
   
'; + tree_recur($data,$data[0],0); + print '
'; - print ''; - - // Show picto - print ''; - // Show link - print ''; - print '
'; - $resarray=tree_showpad($fulltree,$key); - $a=$resarray[0]; - $nbofsubdir=$resarray[1]; - $nboffilesinsubdir=$resarray[2]; - print ''; - //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 = ''; - if ($option == 'indexnotexpanded') $lien = ''; - $newref=str_replace('_',' ',$ref); - $lienfin=''; - print $lien.$newref.$lienfin; - if (! in_array($val['id'],$expandedsectionarray)) print img_picto('','object_category'); - else print img_picto('','object_category-expanded'); - print ''; - //if ($section == $val['id']) print ' '; - // We don't want a link ... why ? - $categstatic->id=$val['id']; - $categstatic->ref=$val['label']; - $categstatic->type=$type; - print '  '.$categstatic->getNomUrl(0,'',60); - - //print '  '.dol_trunc($val['label'],28); - //if ($section == $val['id']) print ''; - print '
'; - print "
'; - print dol_trunc($val['description'],48); - print ''.img_view().''.img_edit_add().' 
'; - print ''; - print ''; - print ''; - print '
'.img_picto_common('','treemenu/branchbottom.gif').''.img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/minustop3.gif','',1).''; - print $langs->trans("NoCategoryYet"); - print ' 
 
'; + print ''; + print ''; + print '
'.img_picto_common('','treemenu/branchbottom.gif').''; + print $langs->trans("NoCategoryYet"); + print ' 
"; llxFooter(); + $db->close(); ?> diff --git a/htdocs/core/lib/treeview.lib.php b/htdocs/core/lib/treeview.lib.php index 65b2ca5d502..f565467575e 100644 --- a/htdocs/core/lib/treeview.lib.php +++ b/htdocs/core/lib/treeview.lib.php @@ -23,55 +23,7 @@ */ -// ------------------------------- Used by category 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."
"; - if ($val['id'] == $parentid) - { - $fullpathparent=$val['fullpath']; - break; - } - } - //print '> parent='.$parentid.' - child='.$childid.' - '.$fullpathparent.'
'; - - 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; -} - +// ------------------------------- Used by ajax tree view ----------------- /** * 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 ----------------- /** - * Recursive function to output menu tree. + * Recursive function to output menu tree. + * 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 int $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu=>,'fk_leftmenu=>) - * @param int $rang Level of element + * @param array $tab Array of all elements + * @param int $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu=>,'fk_leftmenu=>) + * @param int $rang Level of element + * @param string $iddivjstree Id to use for parent ul element * @return void */ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree') @@ -162,13 +119,16 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree') $("#'.$iddivjstree.'").treeview({ collapsed: true, animated: "fast", - persist: "location", - control: "#'.$iddivjstree.'control" + persist: "cookie", + control: "#'.$iddivjstree.'control", + toggle: function() { + /* window.console && console.log("%o was toggled", this); */ + } }); }) '; - print '