dolibarr  7.0.0-beta
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
3  * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
4  * Copyright (C) 2006-2016 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
6  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
7  * Copyright (C) 2015 RaphaĆ«l Doursenaud <rdoursenaud@gpcsolutions.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
29 require '../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
33 
34 $langs->load("categories");
35 
36 if (! $user->rights->categorie->lire) accessforbidden();
37 
38 $id=GETPOST('id','int');
39 $type=(GETPOST('type','aZ09') ? GETPOST('type','aZ09') : Categorie::TYPE_PRODUCT);
40 $catname=GETPOST('catname','alpha');
41 
42 if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
43 
44 
45 /*
46  * View
47  */
48 
49 $categstatic = new Categorie($db);
50 $form = new Form($db);
51 
52 if ($type == Categorie::TYPE_PRODUCT) { $title=$langs->trans("ProductsCategoriesArea"); $typetext='product'; }
53 elseif ($type == Categorie::TYPE_SUPPLIER) { $title=$langs->trans("SuppliersCategoriesArea"); $typetext='supplier'; }
54 elseif ($type == Categorie::TYPE_CUSTOMER) { $title=$langs->trans("CustomersCategoriesArea"); $typetext='customer'; }
55 elseif ($type == Categorie::TYPE_MEMBER) { $title=$langs->trans("MembersCategoriesArea"); $typetext='member'; }
56 elseif ($type == Categorie::TYPE_CONTACT) { $title=$langs->trans("ContactsCategoriesArea"); $typetext='contact'; }
57 elseif ($type == Categorie::TYPE_ACCOUNT) { $title=$langs->trans("AccountsCategoriesArea"); $typetext='bank_account'; }
58 elseif ($type == Categorie::TYPE_PROJECT) { $title=$langs->trans("ProjectsCategoriesArea"); $typetext='project'; }
59 elseif ($type == Categorie::TYPE_USER) { $title=$langs->trans("UsersCategoriesArea"); $typetext='user'; }
60 else { $title=$langs->trans("CategoriesArea"); $typetext='unknown'; }
61 
62 $arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
63 $arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
64 
65 llxHeader('',$title,'','',0,0,$arrayofjs,$arrayofcss);
66 
67 
69 
70 //print '<table border="0" width="100%" class="notopnoleftnoright">';
71 //print '<tr><td valign="top" width="30%" class="notopnoleft">';
72 print '<div class="fichecenter"><div class="fichethirdleft">';
73 
74 
75 /*
76  * Zone recherche produit/service
77  */
78 print '<form method="post" action="index.php?type='.$type.'">';
79 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
80 print '<input type="hidden" name="type" value="'.$type.'">';
81 print '<table class="noborder nohover" width="100%">';
82 print '<tr class="liste_titre">';
83 print '<td colspan="3">'.$langs->trans("Search").'</td>';
84 print '</tr>';
85 print '<tr '.$bc[0].'><td>';
86 print $langs->trans("Name").':</td><td><input class="flat inputsearch" type="text" name="catname" value="' . $catname . '"/></td><td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
87 /*
88 // faire une rech dans une sous categorie uniquement
89 print '<tr '.$bc[0].'><td>';
90 print $langs->trans("SubCatOf").':</td><td>';
91 
92 print $form->select_all_categories('','subcatof');
93 print '</td>';
94 print '<td><input type="submit" class="button" value="'.$langs->trans ("Search").'"></td></tr>';
95 */
96 
97 print '</table></form>';
98 
99 
100 //print '</td><td valign="top" width="70%">';
101 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
102 
103 
104 /*
105  * Categories found
106  */
107 if ($catname || $id > 0)
108 {
109  $cats = $categstatic->rechercher($id, $catname, $typetext);
110 
111  print '<table class="noborder" width="100%">';
112  print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("FoundCats").'</td></tr>';
113 
114  $var=true;
115  foreach ($cats as $cat)
116  {
117  print "\t".'<tr class="oddeven">'."\n";
118  print "\t\t<td>";
119  $categstatic->id=$cat->id;
120  $categstatic->ref=$cat->label;
121  $categstatic->label=$cat->label;
122  $categstatic->type=$cat->type;
123  $categstatic->color=$cat->color;
124  print '<span class="noborderoncategories" '.($categstatic->color?' style="background: #'.$categstatic->color.';"':' style="background: #aaa"').'>';
125  print $categstatic->getNomUrl(1,'');
126  print '</span>';
127  print "</td>\n";
128  print "\t\t<td>";
129  print dolGetFirstLineOfText($cat->description);
130  print "</td>\n";
131  print "\t</tr>\n";
132  }
133  print "</table>";
134 }
135 else print '&nbsp;';
136 
137 
138 //print '</td></tr></table>';
139 print '</div></div></div>';
140 
141 print '<div class="fichecenter"><br>';
142 
143 
144 // Charge tableau des categories
145 $cate_arbo = $categstatic->get_full_arbo($typetext);
146 
147 // Define fulltree array
148 $fulltree=$cate_arbo;
149 
150 // Define data (format for treeview)
151 $data=array();
152 $data[] = array('rowid'=>0,'fk_menu'=>-1,'title'=>"racine",'mainmenu'=>'','leftmenu'=>'','fk_mainmenu'=>'','fk_leftmenu'=>'');
153 foreach($fulltree as $key => $val)
154 {
155  $categstatic->id=$val['id'];
156  $categstatic->ref=$val['label'];
157  $categstatic->color=$val['color'];
158  $categstatic->type=$type;
159  $li=$categstatic->getNomUrl(1,'',60);
160  $desc=dol_htmlcleanlastbr($val['description']);
161 
162  $data[] = array(
163  'rowid'=>$val['rowid'],
164  'fk_menu'=>$val['fk_parent'],
165  'entry'=>'<table class="nobordernopadding centpercent"><tr><td><span class="noborderoncategories" '.($categstatic->color?' style="background: #'.$categstatic->color.';"':' style="background: #aaa"').'>'.$li.'</span></td>'.
166  //'<td width="50%">'.dolGetFirstLineOfText($desc).'</td>'.
167  '<td align="right" width="20px;"><a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.$type.'">'.img_view().'</a></td>'.
168  '</tr></table>'
169  );
170 }
171 
172 
173 print '<table class="liste nohover" width="100%">';
174 print '<tr class="liste_titre"><td>'.$langs->trans("Categories").'</td><td></td><td align="right">';
175 if (! empty($conf->use_javascript_ajax))
176 {
177  print '<div id="iddivjstreecontrol"><a class="notasortlink" href="#">'.img_picto('','object_category').' '.$langs->trans("UndoExpandAll").'</a> | <a class="notasortlink" href="#">'.img_picto('','object_category-expanded').' '.$langs->trans("ExpandAll").'</a></div>';
178 }
179 print '</td></tr>';
180 
181 $nbofentries=(count($data) - 1);
182 
183 if ($nbofentries > 0)
184 {
185  print '<tr class="pair"><td colspan="3">';
186  tree_recur($data,$data[0],0);
187  print '</td></tr>';
188 }
189 else
190 {
191  print '<tr class="pair">';
192  print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('','treemenu/branchbottom.gif').'</td>';
193  print '<td valign="middle">';
194  print $langs->trans("NoCategoryYet");
195  print '</td>';
196  print '<td>&nbsp;</td>';
197  print '</table></td>';
198  print '</tr>';
199 }
200 
201 print "</table>";
202 
203 print '</div>';
204 
205 llxFooter();
206 
207 $db->close();
llxFooter()
Footer empty.
Definition: index.php:43
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetalreadyloaded=0, $showfk=0)
Recursive function to output a tree.
Class to manage generation of HTML components Only common components must be here.
llxHeader()
Header empty.
Definition: index.php:37
Class to manage categories.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dolGetFirstLineOfText($text, $nboflines=1)
Return first line of text.
print
Draft customers invoices.
Definition: index.php:91
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
img_view($titlealt= 'default', $float=0, $other= '')
Show logo view card.