30 require
'../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
36 $langs->load(
"categories");
40 $catname =
GETPOST(
'catname',
'alpha');
41 $nosearch =
GETPOST(
'nosearch',
'int');
44 if (is_numeric($type)) {
45 $type = Categorie::$MAP_ID_TO_CODE[$type];
49 $hookmanager->initHooks(array(
'categoryindex'));
51 if (!$user->rights->categorie->lire) {
62 $moreparam = ($nosearch ?
'&nosearch=1' :
'');
65 if ($type == Categorie::TYPE_ACCOUNT) {
66 $title = $langs->trans(
'AccountsCategoriesArea');
67 } elseif ($type == Categorie::TYPE_WAREHOUSE) {
68 $title = $langs->trans(
'StocksCategoriesArea');
69 } elseif ($type == Categorie::TYPE_ACTIONCOMM) {
70 $title = $langs->trans(
'ActionCommCategoriesArea');
71 } elseif ($type == Categorie::TYPE_WEBSITE_PAGE) {
72 $title = $langs->trans(
'WebsitePagesCategoriesArea');
74 $title = $langs->trans(ucfirst($type).
'sCategoriesArea');
77 $arrayofjs = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
'/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
78 $arrayofcss = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
80 llxHeader(
'', $title,
'',
'', 0, 0, $arrayofjs, $arrayofcss);
83 if (!empty($user->rights->categorie->creer)) {
84 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewCategory'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/categories/card.php?action=create&type='.$type.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?type='.$type.$moreparam).$moreparam);
90 if (empty($nosearch)) {
91 print
'<div class="fichecenter"><div class="fichehalfleft">';
94 print
'<form method="post" action="index.php?type='.$type.
'">';
95 print
'<input type="hidden" name="token" value="'.newToken().
'">';
96 print
'<input type="hidden" name="type" value="'.$type.
'">';
97 print
'<input type="hidden" name="nosearch" value="'.$nosearch.
'">';
100 print
'<table class="noborder nohover centpercent">';
101 print
'<tr class="liste_titre">';
102 print
'<td colspan="3">'.$langs->trans(
"Search").
'</td>';
104 print
'<tr class="oddeven nohover"><td>';
105 print $langs->trans(
"Name").
':</td><td><input class="flat inputsearch" type="text" name="catname" value="'.
dol_escape_htmltag($catname).
'"></td>';
106 print
'<td><input type="submit" class="button small" value="'.$langs->trans(
"Search").
'"></td></tr>';
107 print
'</table></form>';
110 print
'</div><div class="fichehalfright">';
116 if ($catname || $id > 0) {
117 $cats = $categstatic->rechercher($id, $catname, $typetext);
119 print
'<table class="noborder centpercent">';
120 print
'<tr class="liste_titre"><td colspan="2">'.$langs->trans(
"FoundCats").
'</td></tr>';
122 foreach ($cats as $cat) {
123 $categstatic->id = $cat->id;
124 $categstatic->ref = $cat->label;
125 $categstatic->label = $cat->label;
126 $categstatic->type = $cat->type;
127 $categstatic->color = $cat->color;
128 $color = $categstatic->color ?
' style="background: #'.sprintf(
"%06s", $categstatic->color).
';"' :
' style="background: #bbb"';
130 print
"\t".
'<tr class="oddeven">'.
"\n";
132 print
'<span class="noborderoncategories"'.$color.
'>';
133 print $categstatic->getNomUrl(1,
'');
139 print
$form->textwithtooltip(
dol_trunc($text, $trunclength), $cat->description);
148 print
'</div></div>';
151 print
'<div class="fichecenter"><br>';
155 $cate_arbo = $categstatic->get_full_arbo($typetext);
158 $fulltree = $cate_arbo;
161 if (!empty($conf->global->CATEGORY_SHOW_COUNTS)) {
162 if ($type == Categorie::TYPE_MEMBER) {
163 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
165 if ($type == Categorie::TYPE_ACCOUNT) {
166 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
168 if ($type == Categorie::TYPE_PROJECT) {
169 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
171 if ($type == Categorie::TYPE_USER) {
172 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
178 $data[] = array(
'rowid'=>0,
'fk_menu'=>-1,
'title'=>
"racine",
'mainmenu'=>
'',
'leftmenu'=>
'',
'fk_mainmenu'=>
'',
'fk_leftmenu'=>
'');
179 foreach ($fulltree as $key => $val) {
180 $categstatic->id = $val[
'id'];
181 $categstatic->ref = $val[
'label'];
182 $categstatic->color = $val[
'color'];
183 $categstatic->type = $type;
187 if (!empty($conf->global->CATEGORY_SHOW_COUNTS)) {
189 $elements = $type == Categorie::TYPE_ACCOUNT
190 ? $categstatic->getObjectsInCateg(
"account", 1)
191 : $categstatic->getObjectsInCateg($type, 1);
193 $counter =
"<td class='left' width='40px;'>".(is_array($elements) ? count($elements) :
'0').
"</td>";
196 $color = $categstatic->color ?
' style="background: #'.sprintf(
"%06s", $categstatic->color).
';"' :
' style="background: #bbb"';
197 $li = $categstatic->getNomUrl(1,
'', 60,
'&backtolist='.urlencode($_SERVER[
"PHP_SELF"].
'?type='.$type.$moreparam));
199 $entry =
'<table class="nobordernopadding centpercent">';
203 $entry .=
'<span class="noborderoncategories" '.$color.
'>'.$li.
'</span>';
208 $entry .=
'<td class="right" width="20px;">';
209 $entry .=
'<a href="'.DOL_URL_ROOT.
'/categories/viewcat.php?id='.$val[
'id'].
'&type='.$type.$moreparam.
'&backtolist='.urlencode($_SERVER[
"PHP_SELF"].
'?type='.$type).
'">'.
img_view().
'</a>';
211 $entry .=
'<td class="right" width="20px;">';
212 if ($user->rights->categorie->creer) {
213 $entry .=
'<a class="editfielda" href="' . DOL_URL_ROOT .
'/categories/edit.php?id=' . $val[
'id'] .
'&type=' . $type . $moreparam .
'&backtopage=' . urlencode($_SERVER[
"PHP_SELF"] .
'?type=' . $type) .
'">' .
img_edit() .
'</a>';
216 $entry .=
'<td class="right" width="20px;">';
217 if ($user->rights->categorie->supprimer) {
218 $entry .=
'<a class="deletefilelink" href="' . DOL_URL_ROOT .
'/categories/viewcat.php?action=delete&token=' .
newToken() .
'&id=' . $val[
'id'] .
'&type=' . $type . $moreparam .
'&backtopage=' . urlencode($_SERVER[
"PHP_SELF"] .
'?type=' . $type . $moreparam) .
'&backtolist=' . urlencode($_SERVER[
"PHP_SELF"] .
'?type=' . $type . $moreparam) .
'">' .
img_delete() .
'</a>';
223 $entry .=
'</table>';
225 $data[] = array(
'rowid' => $val[
'rowid'],
'fk_menu' => $val[
'fk_parent'],
'entry' => $entry);
229 $nbofentries = (count($data) - 1);
232 foreach ($data as $record) {
233 if (!empty($record[
'fk_menu']) && $record[
'fk_menu'] > 0) {
239 print
'<table class="liste nohover centpercent">';
240 print
'<tr class="liste_titre"><td>'.$langs->trans(
"Categories").
'</td><td></td><td class="right">';
241 if ($morethan1level && !empty($conf->use_javascript_ajax)) {
242 print
'<div id="iddivjstreecontrol">';
243 print
'<a class="notasortlink" href="#">'.img_picto(
'',
'folder',
'class="paddingright"').
'<span class="hideonsmartphone">'.$langs->trans(
"UndoExpandAll").
'</span></a>';
245 print
'<a class="notasortlink" href="#">'.img_picto(
'',
'folder-open',
'class="paddingright"').
'<span class="hideonsmartphone">'.$langs->trans(
"ExpandAll").
'</span></a>';
250 if ($nbofentries > 0) {
251 print
'<tr class="pair"><td colspan="3">';
255 print
'<tr class="pair">';
256 print
'<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common(
'',
'treemenu/branchbottom.gif').
'</td>';
257 print
'<td valign="middle">';
258 print $langs->trans(
"NoCategoryYet");
260 print
'<td> </td>';
261 print
'</table></td>';