* Copyright (C) 2005 Eric Seigne * Copyright (C) 2006-2015 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Raphaƫl Doursenaud * * 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 3 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, see . */ /** * \file htdocs/categories/index.php * \ingroup category * \brief Home page of category area */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $langs->load("categories"); if (! $user->rights->categorie->lire) accessforbidden(); $id=GETPOST('id','int'); $type=(GETPOST('type') ? GETPOST('type') : Categorie::TYPE_PRODUCT); $catname=GETPOST('catname','alpha'); $section=(GETPOST('section')?GETPOST('section'):0); /* * View */ $categstatic = new Categorie($db); $form = new Form($db); if ($type == Categorie::TYPE_PRODUCT) $title=$langs->trans("ProductsCategoriesArea"); elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCategoriesArea"); elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoriesArea"); elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoriesArea"); elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactsCategoriesArea"); else $title=$langs->trans("CategoriesArea"); $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 ''; //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 $form->select_all_categories('','subcatof'); print '
'; //print '
'; print '
'; /* * Categories found */ if ($catname || $id > 0) { $cats = $categstatic->rechercher($id,$catname,$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."
"; } else print ' '; //print '
'; print ''; print '

'; // Charge tableau des categories $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); $desc=dol_htmlcleanlastbr($val['description']); $data[] = array( 'rowid'=>$val['rowid'], 'fk_menu'=>$val['fk_parent'], 'entry'=>''. ''. '
'.$li. ''.dolGetFirstLineOfText($desc).''.img_view().'
' ); } print ''; print ''; $nbofentries=(count($data) - 1); if ($nbofentries > 0) { print ''; } else { print ''; print ''; print ''; } print "
'.$langs->trans("Categories").''; if (! empty($conf->use_javascript_ajax)) { print ''; } print '
'; tree_recur($data,$data[0],0); print '
'; print ''; print ''; print '
'.img_picto_common('','treemenu/branchbottom.gif').''; print $langs->trans("NoCategoryYet"); print ' 
"; print '
'; llxFooter(); $db->close();