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';
35 $langs->load(
"categories");
41 $catname =
GETPOST(
'catname',
'alpha');
42 $nosearch =
GETPOST(
'nosearch',
'int');
45 if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type];
52 $form =
new Form($db);
54 $moreparam = ($nosearch ?
'&nosearch=1' :
'');
57 if ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans(
'AccountsCategoriesArea');
58 elseif ($type == Categorie::TYPE_WAREHOUSE) $title = $langs->trans('StocksCategoriesArea');
59 elseif ($type ==
Categorie::TYPE_ACTIONCOMM) $title = $langs->trans('ActionCommCategoriesArea');
60 elseif ($type ==
Categorie::TYPE_WEBSITE_PAGE) $title = $langs->trans('WebsitePagesCategoriesArea');
62 $title = $langs->trans(ucfirst($type).
'sCategoriesArea');
65 $arrayofjs = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
'/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
66 $arrayofcss = array(
'/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
68 llxHeader(
'', $title,
'',
'', 0, 0, $arrayofjs, $arrayofcss);
71 if (!empty($user->rights->categorie->creer)) {
72 $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);
78 if (empty($nosearch)) {
79 print '<div class="fichecenter"><div class="fichehalfleft">';
82 print '<form method="post" action="index.php?type='.$type.
'">';
83 print '<input type="hidden" name="token" value="'.newToken().
'">';
84 print '<input type="hidden" name="type" value="'.$type.
'">';
85 print '<input type="hidden" name="nosearch" value="'.$nosearch.
'">';
88 print '<table class="noborder nohover centpercent">';
89 print '<tr class="liste_titre">';
90 print '<td colspan="3">'.$langs->trans(
"Search").
'</td>';
92 print '<tr class="oddeven nohover"><td>';
93 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>';
94 print '</table></form>';
97 print '</div><div class="fichehalfright">';
103 if ($catname || $id > 0)
105 $cats = $categstatic->rechercher($id, $catname, $typetext);
107 print '<table class="noborder centpercent">';
108 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans(
"FoundCats").
'</td></tr>';
110 foreach ($cats as $cat)
112 $color = $categstatic->color ?
' style="background: #'.$categstatic->color.
';"' :
' style="background: #bbb"';
114 print "\t".
'<tr class="oddeven">'.
"\n";
116 $categstatic->id = $cat->id;
117 $categstatic->ref = $cat->label;
118 $categstatic->label = $cat->label;
119 $categstatic->type = $cat->type;
120 $categstatic->color = $cat->color;
121 print '<span class="noborderoncategories"'.$color.
'>';
122 print $categstatic->getNomUrl(1,
'');
131 }
else print ' ';
133 print '</div></div>';
136 print '<div class="fichecenter"><br>';
140 $cate_arbo = $categstatic->get_full_arbo($typetext);
143 $fulltree = $cate_arbo;
146 if ($conf->global->CATEGORY_SHOW_COUNTS)
148 if ($type == Categorie::TYPE_MEMBER) require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
149 if ($type == Categorie::TYPE_ACCOUNT) require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
150 if ($type == Categorie::TYPE_PROJECT) require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
151 if ($type == Categorie::TYPE_USER) require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
156 $data[] = array(
'rowid'=>0,
'fk_menu'=>-1,
'title'=>
"racine",
'mainmenu'=>
'',
'leftmenu'=>
'',
'fk_mainmenu'=>
'',
'fk_leftmenu'=>
'');
157 foreach ($fulltree as $key => $val)
159 $categstatic->id = $val[
'id'];
160 $categstatic->ref = $val[
'label'];
161 $categstatic->color = $val[
'color'];
162 $categstatic->type = $type;
163 $li = $categstatic->getNomUrl(1,
'', 60, $moreparam.
'&backtolist='.urlencode(
$_SERVER[
"PHP_SELF"].
'?type='.$type.$moreparam));
168 if ($conf->global->CATEGORY_SHOW_COUNTS)
171 $elements = $categstatic->getObjectsInCateg($type, 1);
172 $counter =
"<td class='left' width='40px;'>".(is_countable($elements) ? count($elements) :
'0').
"</td>";
175 $color = $categstatic->color ?
' style="background: #'.sprintf(
"%06s", $categstatic->color).
';"' :
' style="background: #bbb"';
178 'rowid'=>$val[
'rowid'],
179 'fk_menu'=>$val[
'fk_parent'],
180 'entry'=>
'<table class="nobordernopadding centpercent"><tr><td><span class="noborderoncategories"'.$color.
'>'.$li.
'</span></td>'.$counter.
181 '<td class="right" width="20px;"><a href="'.DOL_URL_ROOT.
'/categories/viewcat.php?id='.$val[
'id'].
'&type='.$type.$moreparam.
'&backtolist='.urlencode(
$_SERVER[
"PHP_SELF"].
'?type='.$type.$moreparam).
'">'.
img_view().
'</a></td></tr></table>'
188 print '<table class="liste nohover" width="100%">';
189 print '<tr class="liste_titre"><td>'.$langs->trans(
"Categories").
'</td><td></td><td class="right">';
190 if (!empty($conf->use_javascript_ajax))
192 print '<div id="iddivjstreecontrol"><a class="notasortlink" href="#">'.img_picto(
'',
'folder',
'class="paddingright"').$langs->trans(
"UndoExpandAll").
'</a> | <a class="notasortlink" href="#">'.
img_picto(
'',
'folder-open',
'class="paddingright"').$langs->trans(
"ExpandAll").
'</a></div>';
196 $nbofentries = (count($data) - 1);
198 if ($nbofentries > 0)
200 print '<tr class="pair"><td colspan="3">';
204 print '<tr class="pair">';
205 print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common(
'',
'treemenu/branchbottom.gif').
'</td>';
206 print '<td valign="middle">';
207 print $langs->trans(
"NoCategoryYet");
209 print '<td> </td>';
210 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.
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.
Class to manage categories.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
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 ...
print $_SERVER["PHP_SELF"]
Edit parameters.
dolGetFirstLineOfText($text, $nboflines=1, $charset= 'UTF-8')
Return first line of text.
print
Draft customers invoices.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
img_view($titlealt= 'default', $float=0, $other= '')
Show logo view card.
tree_recur($tab, $pere, $rang, $iddivjstree= 'iddivjstree', $donoresetalreadyloaded=0, $showfk=0, $moreparam= '')
Recursive function to output a tree.