diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index c7242077da4..513d411d188 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -51,7 +51,6 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myo $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') - // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); @@ -196,7 +195,6 @@ if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory' } - /* * View */ @@ -204,18 +202,21 @@ if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory' $form = new Form($db); $formother = new FormOther($db); +$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'); $helpurl = ''; -llxHeader("", $langs->trans("Categories"), $helpurl); +llxHeader("", $langs->trans("Categories"), $helpurl, '', 0, 0, $arrayofjs, $arrayofcss); -if ($type == Categorie::TYPE_PRODUCT) $title = $langs->trans("ProductsCategoryShort"); -elseif ($type == Categorie::TYPE_SUPPLIER) $title = $langs->trans("SuppliersCategoryShort"); -elseif ($type == Categorie::TYPE_CUSTOMER) $title = $langs->trans("CustomersCategoryShort"); -elseif ($type == Categorie::TYPE_MEMBER) $title = $langs->trans("MembersCategoryShort"); -elseif ($type == Categorie::TYPE_CONTACT) $title = $langs->trans("ContactCategoriesShort"); -elseif ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans("AccountsCategoriesShort"); -elseif ($type == Categorie::TYPE_PROJECT) $title = $langs->trans("ProjectsCategoriesShort"); -elseif ($type == Categorie::TYPE_USER) $title = $langs->trans("UsersCategoriesShort"); -else $title = $langs->trans("Category"); +if ($type == Categorie::TYPE_PRODUCT) { $title=$langs->trans("ProductsCategoriesArea"); $typetext='product'; } +elseif ($type == Categorie::TYPE_SUPPLIER) { $title=$langs->trans("SuppliersCategoriesArea"); $typetext='supplier'; } +elseif ($type == Categorie::TYPE_CUSTOMER) { $title=$langs->trans("CustomersCategoriesArea"); $typetext='customer'; } +elseif ($type == Categorie::TYPE_MEMBER) { $title=$langs->trans("MembersCategoriesArea"); $typetext='member'; } +elseif ($type == Categorie::TYPE_CONTACT) { $title=$langs->trans("ContactsCategoriesArea"); $typetext='contact'; } +elseif ($type == Categorie::TYPE_ACCOUNT) { $title=$langs->trans("AccountsCategoriesArea"); $typetext='bank_account'; } +elseif ($type == Categorie::TYPE_PROJECT) { $title=$langs->trans("ProjectsCategoriesArea"); $typetext='project'; } +elseif ($type == Categorie::TYPE_USER) { $title=$langs->trans("UsersCategoriesArea"); $typetext='user'; } +elseif ($type == Categorie::TYPE_WAREHOUSE) { $title=$langs->trans("StocksCategoriesArea"); $typetext='warehouse'; } +else { $title=$langs->trans("CategoriesArea"); $typetext='unknown'; } $head = categories_prepare_head($object, $type); @@ -304,55 +305,133 @@ if (! empty($user->rights->categorie->creer)) print ""; } + +/* + * Sub-category tree view of this category + */ + +print '
'; +print ''; + +print ''; +print ''; +print ''; +print ''; +print ''; + $cats = $object->get_filles(); if ($cats < 0) { dol_print_error($db, $cats->error, $cats->errors); } +elseif(count($cats) < 1) +{ + print ''; + print ''; + print ''; +} else { - print "
"; - print "
'.$langs->trans("SubCats").''; + +if (!empty($conf->use_javascript_ajax)) +{ + print ''; +} + +print '
'.$langs->trans("NoSubCat").'
\n"; - print ""; - print "\n"; - if (count($cats) > 0) + + // 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) { - foreach ($cats as $cat) + $categstatic->id = $val['id']; + $categstatic->ref = $val['label']; + $categstatic->color = $val['color']; + $categstatic->type = $type; + $desc = dol_htmlcleanlastbr($val['description']); + + $counter = 0; + + if($conf->global->CATEGORY_SHOW_COUNTS) { - print "\t".''."\n"; - print "\t\t".'\n"; - print "\t\t".'\n"; + // we need only a count of the elements, so it is enough to consume only the id's from the database + $elements = $type == Categorie::TYPE_ACCOUNT + ? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account" + : $categstatic->getObjectsInCateg($type, 1); - /* - if ($cat->visible == 1) - { - print "\t\t\n"; - } - else - { - print "\t\t\n"; - } - */ - - print "\t\n"; + $counter = is_countable($elements) ? count($elements) : 0; } + + $color = $categstatic->color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #aaa"'; + + $entry = '
".$langs->trans("SubCats").''; - if ($user->rights->categorie->creer) + $categstatic = new Categorie($db); + + $fulltree = $categstatic->get_full_arbo($typetext, $object->id, 1); + + // Load possible missing includes + if($conf->global->CATEGORY_SHOW_COUNTS) { - print ""; - print img_picto($langs->trans("Create"), 'filenew'); - print ""; + if ($type == Categorie::TYPE_MEMBER) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + if ($type == Categorie::TYPE_ACCOUNT) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + if ($type == Categorie::TYPE_PROJECT) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + if ($type == Categorie::TYPE_USER) require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; } - print "
'; - print "".$cat->label.""; - print "'.$cat->description."".$langs->trans("ContentsVisibleByAllShort")."".$langs->trans("ContentsNotVisibleByAllShort")."
'; + $entry .= ''; + + $entry .= ''; + + $entry .= ''; + + $entry .= ''; + + $entry .= ''; + $entry .= '
'; + $entry .= ''.$categstatic->getNomUrl(1, '', 60).''; + $entry .= ''.$counter.''; + $entry .= ''.img_view().''; + $entry .= '
'; + + $data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry); + } + + if ((count($data) - 1)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; + print ''; + print ''; + + // $data[0] is the current shown category, to don'T show the current category use $data[1] instead + tree_recur($data, $data[1], 0); + + print ''; + print ''; } else { - print ''.$langs->trans("NoSubCat").''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'.img_picto_common('', 'treemenu/branchbottom.gif').''.$langs->trans("NoCategoryYet").' 
'; + print ''; + print ''; } - print "\n"; } +print ""; +print "
"; // List of mass actions available $arrayofmassactions = array( @@ -363,7 +442,6 @@ $arrayofmassactions = array( ); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - // List of products or services (type is type of category) if ($type == Categorie::TYPE_PRODUCT) {