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>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
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.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
Class to manage categories.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dolGetFirstLineOfText($text, $nboflines=1, $charset= 'UTF-8')
Return first line of text.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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. ...
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
tree_recur($tab, $pere, $rang, $iddivjstree= 'iddivjstree', $donoresetalreadyloaded=0, $showfk=0, $moreparam= '')
Recursive function to output a tree.