31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
37$langs->load(
"categories");
41$catname =
GETPOST(
'catname',
'alpha');
42$nosearch =
GETPOST(
'nosearch',
'int');
45if (is_numeric($type)) {
46 $type = Categorie::$MAP_ID_TO_CODE[$type];
50$hookmanager->initHooks(array(
'categoryindex'));
52if (!$user->hasRight(
'categorie',
'lire')) {
63$moreparam = ($nosearch ?
'&nosearch=1' :
'');
66if ($type == Categorie::TYPE_ACCOUNT) {
67 $title = $langs->trans(
'AccountsCategoriesArea');
68} elseif ($type == Categorie::TYPE_WAREHOUSE) {
69 $title = $langs->trans(
'StocksCategoriesArea');
70} elseif ($type == Categorie::TYPE_ACTIONCOMM) {
71 $title = $langs->trans(
'ActionCommCategoriesArea');
72} elseif ($type == Categorie::TYPE_WEBSITE_PAGE) {
73 $title = $langs->trans(
'WebsitePagesCategoriesArea');
75 $title = $langs->trans(ucfirst($type).
'sCategoriesArea');
78$arrayofjs = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
'/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
79$arrayofcss = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
81llxHeader(
'', $title,
'',
'', 0, 0, $arrayofjs, $arrayofcss);
84if ($user->hasRight(
'categorie',
'creer')) {
85 $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);
91if (empty($nosearch)) {
92 print
'<div class="fichecenter"><div class="fichehalfleft">';
95 print
'<form method="post" action="index.php?type='.$type.
'">';
96 print
'<input type="hidden" name="token" value="'.newToken().
'">';
97 print
'<input type="hidden" name="type" value="'.$type.
'">';
98 print
'<input type="hidden" name="nosearch" value="'.$nosearch.
'">';
101 print
'<table class="noborder nohover centpercent">';
102 print
'<tr class="liste_titre">';
103 print
'<td colspan="3">'.$langs->trans(
"Search").
'</td>';
105 print
'<tr class="oddeven nohover"><td>';
106 print $langs->trans(
"Name").
':</td><td><input class="flat inputsearch" type="text" name="catname" value="'.
dol_escape_htmltag($catname).
'"></td>';
107 print
'<td><input type="submit" class="button small" value="'.$langs->trans(
"Search").
'"></td></tr>';
108 print
'</table></form>';
111 print
'</div><div class="fichehalfright">';
117 if ($catname || $id > 0) {
118 $cats = $categstatic->rechercher($id, $catname, $typetext);
120 print
'<table class="noborder centpercent">';
121 print
'<tr class="liste_titre"><td colspan="2">'.$langs->trans(
"FoundCats").
'</td></tr>';
123 foreach ($cats as $cat) {
124 $categstatic->id = $cat->id;
125 $categstatic->ref = $cat->label;
126 $categstatic->label = $cat->label;
127 $categstatic->type = $cat->type;
128 $categstatic->color = $cat->color;
129 $color = $categstatic->color ?
' style="background: #'.sprintf(
"%06s", $categstatic->color).
';"' :
' style="background: #bbb"';
131 print
"\t".
'<tr class="oddeven">'.
"\n";
133 print
'<span class="noborderoncategories"'.$color.
'>';
134 print $categstatic->getNomUrl(1,
'');
140 print $form->textwithtooltip(
dol_trunc($text, $trunclength), $cat->description);
149 print
'</div></div>';
152print
'<div class="fichecenter"><br>';
156$cate_arbo = $categstatic->get_full_arbo($typetext);
159$fulltree = $cate_arbo;
163 if ($type == Categorie::TYPE_MEMBER) {
164 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
166 if ($type == Categorie::TYPE_ACCOUNT) {
167 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
169 if ($type == Categorie::TYPE_PROJECT) {
170 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
172 if ($type == Categorie::TYPE_USER) {
173 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
179$data[] = array(
'rowid'=>0,
'fk_menu'=>-1,
'title'=>
"racine",
'mainmenu'=>
'',
'leftmenu'=>
'',
'fk_mainmenu'=>
'',
'fk_leftmenu'=>
'');
180foreach ($fulltree as $key => $val) {
181 $categstatic->id = $val[
'id'];
182 $categstatic->ref = $val[
'label'];
183 $categstatic->color = $val[
'color'];
184 $categstatic->type = $type;
190 $elements = $type == Categorie::TYPE_ACCOUNT
191 ? $categstatic->getObjectsInCateg(
"account", 1)
192 : $categstatic->getObjectsInCateg($type, 1);
194 $counter =
"<td class='left' width='40px;'>".(is_array($elements) ? count($elements) :
'0').
"</td>";
197 $color = $categstatic->color ?
' style="background: #'.sprintf(
"%06s", $categstatic->color).
';"' :
' style="background: #bbb"';
198 $li = $categstatic->getNomUrl(1,
'', 60,
'&backtolist='.urlencode($_SERVER[
"PHP_SELF"].
'?type='.$type.$moreparam));
200 $entry =
'<table class="nobordernopadding centpercent">';
204 $entry .=
'<span class="noborderoncategories" '.$color.
'>'.$li.
'</span>';
210 $entry .=
'<td class="right" width="20px;">';
211 $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>';
213 $entry .=
'<td class="right" width="20px;">';
214 if ($user->hasRight(
'categorie',
'creer')) {
215 $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>';
218 $entry .=
'<td class="right" width="20px;">';
219 if ($user->hasRight(
'categorie',
'supprimer')) {
220 $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>';
225 $entry .=
'</table>';
227 $data[] = array(
'rowid' => $val[
'rowid'],
'fk_menu' => $val[
'fk_parent'],
'entry' => $entry);
231$nbofentries = (count($data) - 1);
234foreach ($data as $record) {
235 if (!empty($record[
'fk_menu']) && $record[
'fk_menu'] > 0) {
241print
'<table class="liste nohover centpercent">';
242print
'<tr class="liste_titre"><td>'.$langs->trans(
"Categories").
'</td><td></td><td class="right">';
243if ($morethan1level && !empty($conf->use_javascript_ajax)) {
244 print
'<div id="iddivjstreecontrol">';
245 print
'<a class="notasortlink" href="#">'.img_picto(
'',
'folder',
'class="paddingright"').
'<span class="hideonsmartphone">'.$langs->trans(
"UndoExpandAll").
'</span></a>';
247 print
'<a class="notasortlink" href="#">'.img_picto(
'',
'folder-open',
'class="paddingright"').
'<span class="hideonsmartphone">'.$langs->trans(
"ExpandAll").
'</span></a>';
252if ($nbofentries > 0) {
253 print
'<tr class="oddeven"><td colspan="3">';
257 print
'<tr class="oddeven">';
258 print
'<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common(
'',
'treemenu/branchbottom.gif').
'</td>';
259 print
'<td class="valignmiddle">';
260 print $langs->trans(
"NoCategoryYet");
262 print
'<td> </td>';
263 print
'</table></td>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage categories.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
img_view($titlealt='default', $float=0, $other='class="valignmiddle"')
Show logo view card.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetalreadyloaded=0, $showfk=0, $moreparam='')
Recursive function to output a tree.