* Copyright (C) 2005 Eric Seigne * Copyright (C) 2006-2010 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * \file htdocs/categories/index.php * \ingroup category * \brief Home page of category area * \version $Id$ */ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/treeview.lib.php"); $type=isset($_GET['type'])?$_GET['type']:(isset($_POST['type'])?$_POST['type']:0); if (!$user->rights->categorie->lire) accessforbidden(); $langs->load("categories"); /* * View */ $categstatic = new Categorie($db); $html = new Form($db); if ($type == 0) $title=$langs->trans("ProductsCategoriesArea"); elseif ($type == 1) $title=$langs->trans("SuppliersCategoriesArea"); elseif ($type == 2) $title=$langs->trans("CustomersCategoriesArea"); elseif ($type == 3) $title=$langs->trans("MembersCategoriesArea"); else $title=$langs->trans("CategoriesArea"); llxHeader("","",$title); print_fiche_titre($title); print ''; print '
'; /* * Zone recherche produit/service */ print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; /* // faire une rech dans une sous categorie uniquement print ''; print ''; */ print '
'.$langs->trans("Search").'
'; print $langs->trans("Name").':
'; print $langs->trans("SubCatOf").':'; print $html->select_all_categories('','subcatof'); print '
'; print '
'; /* * Categories found */ if($_POST['catname'] || $_REQUEST['id']) { $cats = $categstatic->rechercher($_REQUEST['id'],$_POST['catname'],$_POST['type']); print ''; print ''; $var=true; foreach ($cats as $cat) { $var = ! $var; print "\t\n"; print "\t\t\n"; print "\t\t\n"; print "\t\n"; } print "
'.$langs->trans("FoundCats").'
"; $categstatic->id=$cat->id; $categstatic->ref=$cat->label; $categstatic->label=$cat->label; $categstatic->type=$cat->type; print $categstatic->getNomUrl(1,''); print "".$cat->description."
"; } print '
'; print '
'; // Charge tableau des categories $cate_arbo = $categstatic->get_full_arbo($type); // Define fulltree array $fulltree=$cate_arbo; print ''; print ''; $section=isset($_GET["section"])?$_GET["section"]:$_POST['section']; if (! $section) $section=0; // ----- 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=''; foreach($fulltree as $key => $val) { //print $val['id']."-".$section."
"; if ($val['id'] == $section) { $fullpathselected=$val['fullpath']; break; } } //print "fullpathselected=".$fullpathselected."
"; // Update expandedsectionarray in session $expandedsectionarray=array(); if (isset($_SESSION['dol_catexpandedsectionarray'.$type])) $expandedsectionarray=explode(',',$_SESSION['dol_catexpandedsectionarray'.$type]); if ($section && $_GET['sectionexpand'] == 'true') { // 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 ($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) { $var=false; //$fullpathparent=preg_replace('/_[^_]+$/i','',$val['fullpath']); // Define showline $showline=0; // If directory is son of expanded directory, we show line if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4; // If directory is brother of selected directory, we show line elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3; // 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; if ($showline) { 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 "
'.$langs->trans("Categories").''.$langs->trans("Description").'
'; print ''; print ''; print '
'; print img_picto_common('','treemenu/base.gif'); print ''.$langs->trans("AllCats"); print '
   
'; print ''; // Show picto print ''; // Show link print ''; print '
'; $resarray=tree_showpad($fulltree,$key); $a=$resarray[0]; $nbofsubdir=$resarray[1]; $c=$resarray[2]; $nboffilesinsubdir=$resarray[3]; print ''; //print $val['fullpath']."(".$showline.")"; $n='2'; if ($b == 0 || ! 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 $categstatic->id=$val['id']; $categstatic->ref=$val['label']; $categstatic->type=$type; print $categstatic->getNomUrl(0,'',28); */ print '  '.dol_trunc($val['label'],28); //if ($section == $val['id']) print ''; print '
'; print "
'; print dol_trunc($categstatic->get_desc($val['id']),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 ' 
 
"; $db->close(); llxFooter('$Date$ - $Revision$'); ?>