dolibarr 22.0.5
viewcat.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
3 * Copyright (C) 2006-2024 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
7 * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
8 * Copyright (C) 2020 Josep Lluís Amador <joseplluis@lliuretic.cat>
9 * Copyright (C) 2022-2023 Solution Libre SAS <contact@solution-libre.fr>
10 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
11 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
12 * Copyright (C) 2024-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
13 * Copyright (C) 2023-2024 Charlene Benke <charlene@patas-monkey.com>
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <https://www.gnu.org/licenses/>.
27 */
28
35// Load Dolibarr environment
36require '../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
41
50// Load translation files required by the page
51$langs->loadLangs(array("categories", "compta"));
52
53$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
54$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
55$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
56$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
57$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
58$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
59$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'categorylist'; // To manage different context of search
60$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
61$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
62
63$id = GETPOSTINT('id');
64$label = GETPOST('label', 'alpha');
65$removeelem = GETPOSTINT('removeelem');
66$elemid = GETPOSTINT('elemid');
67
68if (GETPOST('addintocategory')) {
69 $action = 'addintocategory';
70}
71
72
73// Load variable for pagination
74$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
75$sortfield = GETPOST('sortfield', 'aZ09comma');
76$sortorder = GETPOST('sortorder', 'aZ09comma');
77$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
78if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
79 $page = 0;
80} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
81$offset = $limit * $page;
82$pageprev = $page - 1;
83$pagenext = $page + 1;
84
85if ($id == "" && $label == "") {
86 dol_print_error(null, 'Missing parameter id');
87 exit();
88}
89
90// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array
91$hookmanager->initHooks(array('categorycard', 'globalcard'));
92
93$object = new Categorie($db);
94$result = $object->fetch($id, $label);
95if ($result <= 0) {
96 dol_print_error($db, $object->error);
97 exit;
98}
99
100// Security check
101$result = restrictedArea($user, 'categorie', $object->id, '&category');
102
103$type = $object->type;
104if (is_numeric($type)) {
105 $type = array_search($type, $object->MAP_ID); // For backward compatibility
106}
107
108$extrafields = new ExtraFields($db);
109$extrafields->fetch_name_optionals_label($object->table_element);
110
111/*
112 * Actions
113 */
114
115if ($confirm == 'no') {
116 if ($backtopage) {
117 header("Location: ".$backtopage);
118 exit;
119 }
120}
121$parameters = array('type' => $type, 'id' => $id, 'label' => $label);
122$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
123// Remove element from category
124if ($id > 0 && $removeelem > 0 && $action == 'unlink') { // Test on permission not required here. Done later according to type of object.
125 $tmpobject = null;
126 $elementtype = '';
127 if ($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
128 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
129 $tmpobject = new Product($db);
130 $result = $tmpobject->fetch($removeelem);
131 $elementtype = 'product';
132 } elseif ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) {
133 $tmpobject = new Societe($db);
134 $result = $tmpobject->fetch($removeelem);
135 $elementtype = 'supplier';
136 } elseif ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) {
137 $tmpobject = new Societe($db);
138 $result = $tmpobject->fetch($removeelem);
139 $elementtype = 'customer';
140 } elseif ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) {
141 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
142 $tmpobject = new Adherent($db);
143 $result = $tmpobject->fetch($removeelem);
144 $elementtype = 'member';
145 } elseif ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) {
146 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
147 $tmpobject = new Contact($db);
148 $result = $tmpobject->fetch($removeelem);
149 $elementtype = 'contact';
150 } elseif ($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer')) {
151 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
152 $tmpobject = new Account($db);
153 $result = $tmpobject->fetch($removeelem);
154 $elementtype = 'account';
155 } elseif ($type == Categorie::TYPE_PROJECT && $user->hasRight('projet', 'creer')) {
156 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
157 $tmpobject = new Project($db);
158 $result = $tmpobject->fetch($removeelem);
159 $elementtype = 'project';
160 } elseif ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) {
161 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
162 $tmpobject = new User($db);
163 $result = $tmpobject->fetch($removeelem);
164 $elementtype = 'user';
165 } elseif ($type == Categorie::TYPE_TICKET && $user->hasRight('ticket', 'write')) {
166 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
167 $tmpobject = new Ticket($db);
168 $result = $tmpobject->fetch($removeelem);
169 $elementtype = 'ticket';
170 } elseif ($type == Categorie::TYPE_FICHINTER && $user->hasRight('ficheinter', 'write')) {
171 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
172 $tmpobject = new Fichinter($db);
173 $result = $tmpobject->fetch($removeelem);
174 $elementtype = 'fichinter';
175 } elseif ($type == Categorie::TYPE_ORDER && $user->hasRight('commande', 'creer')) {
176 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
177 $tmpobject = new Commande($db);
178 $result = $tmpobject->fetch($removeelem);
179 $elementtype = 'order';
180 } elseif ($type == Categorie::TYPE_INVOICE && $user->hasRight('facture', 'creer')) {
181 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
182 $tmpobject = new Facture($db);
183 $result = $tmpobject->fetch($removeelem);
184 $elementtype = 'invoice';
185 } elseif ($type == Categorie::TYPE_SUPPLIER_ORDER && $user->hasRight('fournisseur', 'commande', 'creer')) {
186 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
187 $tmpobject = new CommandeFournisseur($db);
188 $result = $tmpobject->fetch($removeelem);
189 $elementtype = 'supplier_order';
190 } else {
191 dol_print_error(null, "Not supported value of type = ".$type);
192 $result = -100;
193 }
194
195 if ($tmpobject !== null) {
196 // also enter here when item was not found to report error
197 $result = $object->del_type($tmpobject, $elementtype);
198 if ($result < 0) {
199 dol_print_error(null, $object->error);
200 }
201 }
202}
203
204if ($user->hasRight('categorie', 'supprimer') && $action == 'confirm_delete' && $confirm == 'yes') {
205 if ($object->delete($user) >= 0) {
206 if ($backtopage) {
207 header("Location: ".$backtopage);
208 exit;
209 } else {
210 header("Location: ".DOL_URL_ROOT.'/categories/categorie_list.php?type='.$type);
211 exit;
212 }
213 } else {
214 setEventMessages($object->error, $object->errors, 'errors');
215 }
216}
217
218if ($elemid && $action == 'addintocategory') { // Test on permission not required here. Done just after depending on object type
219 $newobject = null;
220 $elementtype = '';
221 if ($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
222 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
223 $newobject = new Product($db);
224 $elementtype = 'product';
225 } elseif ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) {
226 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
227 $newobject = new Societe($db);
228 $elementtype = 'customer';
229 } elseif ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) {
230 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
231 $newobject = new Societe($db);
232 $elementtype = 'supplier';
233 } elseif ($type == Categorie::TYPE_TICKET && $user->hasRight('ticket', 'write')) {
234 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
235 $newobject = new Ticket($db);
236 $elementtype = 'ticket';
237 } elseif ($type == Categorie::TYPE_FICHINTER && $user->hasRight('ficheinter', 'write')) {
238 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
239 $newobject = new Fichinter($db);
240 $elementtype = 'fichinter';
241 } elseif ($type == Categorie::TYPE_PROJECT && $user->hasRight('projet', 'creer')) {
242 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
243 $newobject = new Project($db);
244 $elementtype = 'project';
245 } elseif ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) {
246 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
247 $newobject = new Adherent($db);
248 $elementtype = 'member';
249 } elseif ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) {
250 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
251 $newobject = new Contact($db);
252 $elementtype = 'contact';
253 } elseif ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) {
254 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
255 $newobject = new User($db);
256 $elementtype = 'user';
257 } elseif ($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer')) {
258 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
259 $newobject = new Account($db);
260 $elementtype = 'bank_account';
261 } elseif ($type == Categorie::TYPE_ORDER && $user->hasRight('commande', 'creer')) {
262 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
263 $newobject = new Commande($db);
264 $elementtype = 'order';
265 } elseif ($type == Categorie::TYPE_INVOICE && $user->hasRight('facture', 'creer')) {
266 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
267 $newobject = new Facture($db);
268 $elementtype = 'invoice';
269 } elseif ($type == Categorie::TYPE_SUPPLIER_ORDER && $user->hasRight('fournisseur', 'commande', 'creer')) {
270 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
271 $newobject = new CommandeFournisseur($db);
272 $elementtype = 'supplier_order';
273 } elseif ($type == Categorie::TYPE_SUPPLIER_INVOICE && $user->hasRight('fournisseur', 'facture', 'creer')) {
274 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
275 $newobject = new FactureFournisseur($db);
276 $elementtype = 'supplier_invoice';
277 } else {
278 dol_print_error(null, "Not supported value of type = ".$type);
279 }
280 if ($newobject !== null) {
281 $result = $newobject->fetch($elemid);
282 }
283
284 if ($result >= 0 && $newobject !== null) {
285 // Add into category
286 $result = $object->add_type($newobject, $elementtype);
287 }
288 if ($result >= 0) {
289 setEventMessages($langs->trans("WasAddedSuccessfully", $newobject->ref), null, 'mesgs');
290 } else {
291 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
292 setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
293 } else {
294 setEventMessages($object->error, $object->errors, 'errors');
295 }
296 }
297}
298
299
300/*
301 * View
302 */
303
304$form = new Form($db);
305$formother = new FormOther($db);
306
307$arrayofjs = array(
308 '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
309 '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'
310);
311$arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
312
313$help_url = '';
314
315llxHeader("", $langs->trans("Categories"), $help_url, '', 0, 0, $arrayofjs, $arrayofcss);
316
317$title = $langs->trans("Categories");
318$title .= ' ('.$langs->trans(empty(Categorie::$MAP_TYPE_TITLE_AREA[$type]) ? ucfirst($type) : Categorie::$MAP_TYPE_TITLE_AREA[$type]).')';
319
320$head = categories_prepare_head($object, $type);
321print dol_get_fiche_head($head, 'card', $langs->trans($title), -1, 'category');
322
323$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/categorie_list.php?leftmenu=cat&type='.urlencode($type));
324$linkback = '<a href="'.dol_sanitizeUrl($backtolist).'">'.$langs->trans("BackToList").'</a>';
325$object->next_prev_filter = 'type:=:'.((int) $object->type);
326$object->ref = $object->label;
327$morehtmlref = '<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/categorie_list.php?leftmenu=cat&type='.urlencode($type).'">'.$langs->trans("Root").'</a> >> ';
328$ways = $object->print_all_ways(" &gt;&gt; ", '', 1);
329foreach ($ways as $way) {
330 $morehtmlref .= $way."<br>\n";
331}
332$morehtmlref .= '</div>';
333
334dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'label', $morehtmlref, '&type='.urlencode($type), 0, '', '', 1);
335
336
337// Confirmation of deletion
338if ($action == 'delete') {
339 if ($backtopage) {
340 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.urlencode($type).'&backtopage='.urlencode($backtopage), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 2);
341 } else {
342 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.urlencode($type), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1);
343 }
344}
345
346print '<br>';
347
348print '<div class="fichecenter">';
349print '<div class="underbanner clearboth"></div>';
350print '<table class="border centpercent tableforfield">';
351
352// Description
353print '<tr><td class="titlefield notopnoleft tdtop">';
354print $langs->trans("Description").'</td><td>';
355print dol_htmlentitiesbr($object->description);
356print '</td></tr>';
357
358// Color
359print '<tr><td class="notopnoleft">';
360print $langs->trans("Color").'</td><td>';
361print $formother->showColor($object->color);
362print '</td></tr>';
363
364// Position
365print '<tr><td class="titlefield notopnoleft">';
366print $langs->trans("Position").'</td><td>';
367print $object->position ? $object->position : '';
368print '</td></tr>';
369
370// Other attributes
371include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
372
373print '</table>';
374print '</div>';
375
376print dol_get_fiche_end();
377
378
379/*
380 * Boutons actions
381 */
382
383print "<div class='tabsAction'>\n";
384$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
385if ($reshook < 0) {
386 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
387}
388if (empty($reshook)) {
389 if ($user->hasRight('categorie', 'creer')) {
390 $socid = ($object->socid ? "&socid=".$object->socid : "");
391 print '<a class="butAction" href="edit.php?id='.$object->id.$socid.'&type='.urlencode($type).'">'.$langs->trans("Modify").'</a>';
392 }
393
394 if ($user->hasRight('categorie', 'supprimer')) {
395 print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id.'&type='.urlencode($type).'&backtolist='.urlencode($backtolist).'">'.$langs->trans("Delete").'</a>';
396 }
397}
398
399print "</div>";
400
401$newcardbutton = '';
402if ($user->hasRight('categorie', 'creer')) {
403 $link = DOL_URL_ROOT.'/categories/card.php';
404 $link .= '?action=create';
405 $link .= '&type='.urlencode($type);
406 $link .= '&catorigin='.((int) $object->id);
407 $link .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.'&id='.$id);
408
409 $newcardbutton = '<div class="right">';
410 $newcardbutton .= dolGetButtonTitle($langs->trans('NewCategory'), '', 'fa fa-plus-circle', $link);
411 $newcardbutton .= '</div>';
412}
413
414
415/*
416 * Sub-category tree view of this category
417 */
418
419print '<div class="fichecenter">';
420
421print load_fiche_titre($langs->trans("SubCats"), $newcardbutton, 'object_category');
422
423$cats = $object->get_filles();
424
425print '<table class="liste nohover noborder centpercent borderbottom">';
426
427print '<tr class="liste_titre">';
428print '<td>'.$langs->trans("SubCats").'</td>';
429print '<td></td>';
430print '<td class="right">';
431
432if (is_array($cats) && count($cats) > 1 && !empty($conf->use_javascript_ajax)) {
433 print '<div id="iddivjstreecontrol">';
434 print '<a class="notasortlink" href="#">'.img_picto('', 'folder').' '.$langs->trans("UndoExpandAll").'</a>';
435 print " | ";
436 print '<a class="notasortlink" href="#">'.img_picto('', 'folder-open').' '.$langs->trans("ExpandAll").'</a>';
437 print '</div>';
438}
439
440print '</td>';
441print '</tr>';
442
443if (is_numeric($cats) && $cats < 0) {
444 dol_print_error($db, $object->error, $object->errors);
445} elseif (count($cats) < 1) {
446 print '<tr class="oddeven nobottom nohover">';
447 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("NoSubCat").'</span></td>';
448 print '</tr>';
449} else {
450 $categstatic = new Categorie($db);
451
452 $fulltree = $categstatic->get_full_arbo($type, $object->id, 1);
453
454 // Load possible missing includes
455 if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) {
456 if ($type == Categorie::TYPE_MEMBER) {
457 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
458 }
459 if ($type == Categorie::TYPE_ACCOUNT) {
460 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
461 }
462 if ($type == Categorie::TYPE_PROJECT) {
463 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
464 }
465 if ($type == Categorie::TYPE_USER) {
466 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
467 }
468 }
469
470 // Define data (format for treeview)
471 $data = array();
472 $data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => 'racine', 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => '');
473 foreach ($fulltree as $key => $val) {
474 $categstatic->id = $val['id'];
475 $categstatic->ref = $val['label'];
476 $categstatic->color = $val['color'];
477 $categstatic->type = $type;
478 //$desc = dol_htmlcleanlastbr($val['description']);
479
480 $counter = '';
481 if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) {
482 // we need only a count of the elements, so it is enough to consume only the id's from the database
483 $elements = $categstatic->getObjectsInCateg($type, 1);
484
485 $counter = "<td class='left' width='40px;'>".(is_array($elements) ? count($elements) : '0')."</td>";
486 }
487
488 if ($categstatic->color) {
489 $stylecolor = ' style="background: #'.sprintf("%06s", $categstatic->color).';"';
490 } else {
491 $stylecolor = ' style="background: #bbb;"';
492 }
493 $li = $categstatic->getNomUrl(1, '', 60, '&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.((int) $id).'&type='.urlencode($type)), 0);
494
495 $entry = '<table class="nobordernopadding centpercent">';
496 $entry .= '<tr>';
497
498 $entry .= '<td>';
499 $entry .= '<span class="noborderoncategories" '.$stylecolor.'>'.$li.'</span>';
500 $entry .= '</td>';
501
502 $entry .= $counter;
503
504 $entry .= '<td class="right" width="20px;">';
505 $entry .= '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.urlencode($type).'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.urlencode($type)).'">'.img_view().'</a>';
506 $entry .= '</td>';
507 $entry .= '<td class="right" width="20px;">';
508 $entry .= '<a class="editfielda" href="'.DOL_URL_ROOT.'/categories/edit.php?id='.$val['id'].'&type='.urlencode($type).'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.urlencode($type)).'">'.img_edit().'</a>';
509 $entry .= '</td>';
510 $entry .= '<td class="right" width="20px;">';
511 $entry .= '<a class="deletefilelink" href="'.DOL_URL_ROOT.'/categories/viewcat.php?action=delete&token='.newToken().'&id='.$val['id'].'&type='.urlencode($type).'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.urlencode($type)).'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.urlencode($type)).'">'.img_delete().'</a>';
512 $entry .= '</td>';
513
514 $entry .= '</tr>';
515 $entry .= '</table>';
516
517 $data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry);
518 }
519
520 $nbofentries = (count($data) - 1);
521 if ($nbofentries > 0) {
522 require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
523 print '<tr class="pair">';
524 print '<td colspan="3">';
525
526 // $data[0] is the current shown category, to don'T show the current category use $data[1] instead
527 tree_recur($data, $data[1], 0);
528
529 print '</td>';
530 print '</tr>';
531 } else {
532 print '<tr class="pair">';
533 print '<td colspan="3">';
534 print '<table class="nobordernopadding">';
535
536 print '<tr class="nobordernopadding">';
537 print '<td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
538 print '<td class="valignmiddle"><span class="opacitymedium">'.$langs->trans("NoCategoryYet").'</span></td>';
539 print '<td>&nbsp;</td>';
540 print '</tr>';
541
542 print '</table>';
543 print '</td>';
544 print '</tr>';
545 }
546}
547
548print "</table>";
549print "</div>";
550
551// List of mass actions available
552$arrayofmassactions = array(
553 //'validate'=>$langs->trans("Validate"),
554 //'generate_doc'=>$langs->trans("ReGeneratePDF"),
555 //'builddoc'=>$langs->trans("PDFMerge"),
556 //'presend'=>$langs->trans("SendByMail"),
557);
558$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
559
560$typeid = $type; // warning, typeid can be a string
561
562
563// List of products or services (type is type of category)
564if ($type == Categorie::TYPE_PRODUCT) {
565 if ($user->hasRight("product", "read") || $user->hasRight("service", "read")) {
566 $permission = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'));
567 $showclassifyform = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'));
568
569 $prods = $object->getObjectsInCateg($type, 0, $limit, $offset, 'ref');
570 if ($prods < 0) {
571 dol_print_error($db, $object->error, $object->errors);
572 } else {
574 '@phan-var-force Product[] $prods';
575 // Form to add record into the category
576 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
577 print '<input type="hidden" name="token" value="'.newToken().'">';
578 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
579 print '<input type="hidden" name="type" value="'.$typeid.'">';
580 print '<input type="hidden" name="id" value="'.$object->id.'">';
581 print '<input type="hidden" name="page_y" value="">';
582 print '<input type="hidden" name="action" value="list">';
583
584 print '<br>';
585 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
586 $num = count($prods);
587 $nbtotalofrecords = '';
588 $newcardbutton = dolGetButtonTitle($langs->trans("AddProduct"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&categories[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->hasRight('societe', 'creer'));
589
590 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
591 print_barre_liste($langs->trans("ProductsAndServices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit);
592
593 if ($showclassifyform) {
594 print '<table class="noborder centpercent">';
595 print '<tr class="liste_titre"><td>';
596 print $langs->trans("AddProductServiceIntoCategory").' &nbsp;';
597 $form->select_produits(0, 'elemid', '', 0, 0, -1, 2, '', 1, array(), 0, 1, 0, '', 0, '', null);
598 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
599 print '</tr>';
600 print '</table>';
601 }
602
603 print '<table class="noborder centpercent">'."\n";
604 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
605
606 if (count($prods) > 0) {
607 $i = 0;
608 foreach ($prods as $prod) {
609 $i++;
610 if ($i > $limit) {
611 break;
612 }
613
614 print '<tr class="oddeven">'."\n";
615 print '<td class="nowrap tdtop">';
616 print $prod->getNomUrl(1);
617 print "</td>\n";
618 print '<td class="tdtop">'.dolPrintHTML($prod->label)."</td>\n";
619 // Link to delete from category
620 print '<td class="right">';
621 if ($permission) {
622 print '<a class="reposition" href= "'.$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".((int) $object->id)."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $prod->id).($limit ? '&limit='.$limit : '').'">';
623 //print $langs->trans("DeleteFromCat");
624 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
625 print "</a>";
626 }
627 print '</td>';
628 print "</tr>\n";
629 }
630 } else {
631 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
632 }
633 print "</table>\n";
634
635 print '</form>'."\n";
636 }
637 } else {
638 print_barre_liste($langs->trans("ProductsAndServices"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'products');
639 accessforbidden("NotEnoughPermissions", 0, 0);
640 }
641}
642
643// List of customers
644if ($type == Categorie::TYPE_CUSTOMER) {
645 if ($user->hasRight("societe", "read")) {
646 $permission = $user->hasRight('societe', 'creer');
647 $showclassifyform = $user->hasRight('societe', 'creer');
648
649 $socs = $object->getObjectsInCateg($type, 0, $limit, $offset, 'nom');
650 if ($socs < 0) {
651 dol_print_error($db, $object->error, $object->errors);
652 } else {
654 '@phan-var-force Societe[] $socs';
655 // Form to add record into a category
656 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
657 print '<input type="hidden" name="token" value="'.newToken().'">';
658 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
659 print '<input type="hidden" name="type" value="'.$typeid.'">';
660 print '<input type="hidden" name="id" value="'.$object->id.'">';
661 print '<input type="hidden" name="action" value="list">';
662 print '<input type="hidden" name="page_y" value="">';
663
664 print '<br>';
665 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
666 $num = count($socs);
667 $nbtotalofrecords = '';
668 $newcardbutton = dolGetButtonTitle($langs->trans("AddThirdParty"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&customer=3&custcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->hasRight('societe', 'creer'));
669
670 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
671 print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
672
673 if ($showclassifyform) {
674 print '<table class="noborder centpercent">';
675 print '<tr class="liste_titre"><td>';
676 print $langs->trans("AddCustomerIntoCategory").' &nbsp;';
677 $filter = '(s.client:IN:1,2,3)';
678 print $form->select_company('', 'elemid', $filter);
679 print '<input type="submit" class="reposition button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
680 print '</tr>';
681 print '</table>';
682 }
683
684 print '<table class="noborder centpercent">'."\n";
685 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Name").'</td></tr>'."\n";
686
687 if (count($socs) > 0) {
688 $i = 0;
689 foreach ($socs as $key => $soc) {
690 $i++;
691 if ($i > $limit) {
692 break;
693 }
694
695 print "\t".'<tr class="oddeven">'."\n";
696 print '<td class="nowrap tdtop tdoverflowmax250">';
697 print $soc->getNomUrl(1);
698 print "</td>\n";
699 // Link to delete from category
700 print '<td class="right">';
701 if ($permission) {
702 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $soc->id).($limit ? '&limit='.$limit : '')."'>";
703 //print $langs->trans("DeleteFromCat");
704 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
705 print "</a>";
706 }
707 print '</td>';
708 print "</tr>\n";
709 }
710 } else {
711 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
712 }
713 print "</table>\n";
714
715 print '</form>'."\n";
716 }
717 } else {
718 print_barre_liste($langs->trans("Customers"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'companies');
719 accessforbidden("NotEnoughPermissions", 0, 0);
720 }
721}
722
723// List of suppliers
724if ($type == Categorie::TYPE_SUPPLIER) {
725 if ($user->hasRight("fournisseur", "read")) {
726 $permission = $user->hasRight('societe', 'creer');
727 $showclassifyform = $user->hasRight('societe', 'creer');
728
729 $socs = $object->getObjectsInCateg($type, 0, $limit, $offset, 'nom');
730
731 if ($socs < 0) {
732 dol_print_error($db, $object->error, $object->errors);
733 } else {
735 '@phan-var-force Fournisseur[] $socs';
736 // Form to add record into a category
737 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
738 print '<input type="hidden" name="token" value="'.newToken().'">';
739 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
740 print '<input type="hidden" name="type" value="'.$typeid.'">';
741 print '<input type="hidden" name="id" value="'.$object->id.'">';
742 print '<input type="hidden" name="page_y" value="">';
743 print '<input type="hidden" name="action" value="list">';
744
745 print '<br>';
746 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
747 $num = count($socs);
748 $nbtotalofrecords = '';
749 $newcardbutton = dolGetButtonTitle($langs->trans("AddSupplier"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&fournisseur=1&suppcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->hasRight('societe', 'creer'));
750
751 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
752 print_barre_liste($langs->trans("Suppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
753
754 if ($showclassifyform) {
755 print '<table class="noborder centpercent">';
756 print '<tr class="liste_titre"><td>';
757 print $langs->trans("AddSupplierIntoCategory").' &nbsp;';
758 $filter = '(s.fournisseur:=:1)';
759 print $form->select_company('', 'elemid', $filter);
760 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
761 print '</tr>';
762 print '</table>';
763 }
764
765 print '<table class="noborder centpercent">'."\n";
766 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Name")."</td></tr>\n";
767
768 if (count($socs) > 0) {
769 $i = 0;
770 foreach ($socs as $soc) {
771 $i++;
772 if ($i > $limit) {
773 break;
774 }
775
776 print "\t".'<tr class="oddeven">'."\n";
777 print '<td class="nowrap tdtop">';
778 print $soc->getNomUrl(1);
779 print "</td>\n";
780 // Link to delete from category
781 print '<td class="right">';
782 if ($permission) {
783 print '<a class="reposition" href="'.$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $soc->id).($limit ? '&limit='.$limit : '').'">';
784 //print $langs->trans("DeleteFromCat");
785 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
786 print "</a>";
787 }
788 print '</td>';
789
790 print "</tr>\n";
791 }
792 } else {
793 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
794 }
795 print "</table>\n";
796
797 print '</form>'."\n";
798 }
799 } else {
800 print_barre_liste($langs->trans("Suppliers"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'companies');
801 accessforbidden("NotEnoughPermissions", 0, 0);
802 }
803}
804
805// List of members
806if ($type == Categorie::TYPE_MEMBER) {
807 if ($user->hasRight("adherent", "read")) {
808 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
809
810 $permission = $user->hasRight('adherent', 'creer');
811 $showclassifyform = $user->hasRight('adherent', 'creer');
812
813 $members = $object->getObjectsInCateg($type, 0, $limit, $offset, 'lastname');
814 if ($members < 0) {
815 dol_print_error($db, $object->error, $object->errors);
816 } else {
818 '@phan-var-force Adherent[] $members';
819 // Form to add record into a category
820 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
821 print '<input type="hidden" name="token" value="'.newToken().'">';
822 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
823 print '<input type="hidden" name="type" value="'.$typeid.'">';
824 print '<input type="hidden" name="id" value="'.$object->id.'">';
825 print '<input type="hidden" name="page_y" value="">';
826 print '<input type="hidden" name="action" value="list">';
827
828 print '<br>';
829 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
830 $num = count($members);
831 $nbtotalofrecords = '';
832 $newcardbutton = dolGetButtonTitle($langs->trans("AddMember"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create&memcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->hasRight('adherent', 'creer'));
833
834 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
835 print_barre_liste($langs->trans("Member"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit);
836
837 if ($showclassifyform) {
838 print '<table class="noborder centpercent">';
839 print '<tr class="liste_titre"><td>';
840 print $langs->trans("AssignCategoryTo").' &nbsp;';
841 print $form->selectMembers('', 'elemid');
842 print '<input type="submit" class="button buttongen" value="'.$langs->trans("Save").'"></td>';
843 print '</tr>';
844 print '</table>';
845 }
846
847 print '<table class="noborder centpercent">'."\n";
848 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Name").'</td></tr>'."\n";
849
850 if (count($members) > 0) {
851 $i = 0;
852 foreach ($members as $key => $member) {
853 $i++;
854 if ($i > $limit) {
855 break;
856 }
857
858 print "\t".'<tr class="oddeven">'."\n";
859 print '<td class="nowrap tdtop">';
860 $member->ref = $member->login;
861 print $member->getNomUrl(1, 0);
862 print "</td>\n";
863 print '<td class="tdtop">'.$member->lastname."</td>\n";
864 print '<td class="tdtop">'.$member->firstname."</td>\n";
865 // Link to delete from category
866 print '<td class="right">';
867 if ($permission) {
868 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $member->id).($limit ? '&limit='.$limit : '')."'>";
869 //print $langs->trans("DeleteFromCat");
870 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
871 print "</a>";
872 }
873 print '</td>';
874 print "</tr>\n";
875 }
876 } else {
877 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
878 }
879 print "</table>\n";
880
881 print '</form>'."\n";
882 }
883 } else {
884 print_barre_liste($langs->trans("Member"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'members');
885 accessforbidden("NotEnoughPermissions", 0, 0);
886 }
887}
888
889// List of contacts
890if ($type == Categorie::TYPE_CONTACT) {
891 if ($user->hasRight("societe", "read")) {
892 $permission = $user->hasRight('societe', 'creer');
893 $showclassifyform = $user->hasRight('societe', 'creer');
894
895 $contacts = $object->getObjectsInCateg($type, 0, $limit, $offset, 'lastname');
896 if (is_numeric($contacts) && $contacts < 0) {
897 dol_print_error($db, $object->error, $object->errors);
898 } else {
900 '@phan-var-force Contact[] $contacts';
901 // Form to add record into a category
902 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
903 print '<input type="hidden" name="token" value="'.newToken().'">';
904 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
905 print '<input type="hidden" name="type" value="'.$typeid.'">';
906 print '<input type="hidden" name="id" value="'.$object->id.'">';
907 print '<input type="hidden" name="page_y" value="">';
908 print '<input type="hidden" name="action" value="list">';
909
910 print '<br>';
911 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
912 $num = count($contacts);
913 $nbtotalofrecords = '';
914 $newcardbutton = dolGetButtonTitle($langs->trans("AddContact"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create&contcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->hasRight('societe', 'creer'));
915
916 $objsoc = new Societe($db);
917
918 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
919 print_barre_liste($langs->trans("Contact"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contact', 0, $newcardbutton, '', $limit);
920
921 if ($showclassifyform) {
922 print '<table class="noborder centpercent">';
923 print '<tr class="liste_titre"><td>';
924 print $langs->trans("AssignCategoryTo").' &nbsp;';
925 print $form->select_contact(0, '', 'elemid', '', '', '', 0, 'maxwidth300 widthcentpercentminusx');
926 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
927 print '</tr>';
928 print '</table>';
929 }
930
931 print '<table class="noborder centpercent">'."\n";
932 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Ref").'</td></tr>'."\n";
933
934 if (is_array($contacts) && count($contacts) > 0) {
935 $i = 0;
936 foreach ($contacts as $key => $contact) {
937 $i++;
938 if ($i > $limit) {
939 break;
940 }
941
942 print "\t".'<tr class="oddeven">'."\n";
943 print '<td class="nowrap tdtop">';
944 print $contact->getNomUrl(1, 'category');
945 if ($contact->socid > 0) {
946 $objsoc->fetch($contact->socid);
947 print ' - ';
948 print $objsoc->getNomUrl(1, 'contact');
949 }
950 print "</td>\n";
951 // Link to delete from category
952 print '<td class="right">';
953 if ($permission) {
954 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $contact->id).($limit ? '&limit='.$limit : '')."'>";
955 //print $langs->trans("DeleteFromCat");
956 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
957 print "</a>";
958 }
959 print '</td>';
960 print "</tr>\n";
961 }
962 } else {
963 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
964 }
965 print "</table>\n";
966
967 print '</form>'."\n";
968 }
969 } else {
970 print_barre_liste($langs->trans("Contact"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'contact');
971 accessforbidden("NotEnoughPermissions", 0, 0);
972 }
973}
974
975// List of bank accounts
976if ($type == Categorie::TYPE_ACCOUNT) {
977 if ($user->hasRight("banque", "read")) {
978 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
979
980 $permission = $user->hasRight('banque', 'creer');
981 $showclassifyform = $user->hasRight('banque', 'creer');
982
983 $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset);
984 if ($accounts < 0) {
985 dol_print_error($db, $object->error, $object->errors);
986 } else {
988 '@phan-var-force Account[] $accounts';
989 // Form to add record into a category
990 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
991 print '<input type="hidden" name="token" value="'.newToken().'">';
992 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
993 print '<input type="hidden" name="type" value="'.$typeid.'">';
994 print '<input type="hidden" name="id" value="'.$object->id.'">';
995 print '<input type="hidden" name="page_y" value="">';
996 print '<input type="hidden" name="action" value="list">';
997
998 print '<br>';
999 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1000 $num = count($accounts);
1001 $nbtotalofrecords = '';
1002 $newcardbutton = '';
1003
1004 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1005 print_barre_liste($langs->trans("Account"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit);
1006
1007 if ($showclassifyform) {
1008 print '<table class="noborder centpercent">';
1009 print '<tr class="liste_titre"><td>';
1010 print $langs->trans("AddObjectIntoCategory").' &nbsp;';
1011 print $form->select_comptes('', 'elemid', 0, '', 0, '', 0, '', 1);
1012 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1013 print '</tr>';
1014 print '</table>';
1015 }
1016
1017 print '<table class="noborder centpercent">'."\n";
1018 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1019
1020 if (count($accounts) > 0) {
1021 $i = 0;
1022 foreach ($accounts as $key => $account) {
1023 $i++;
1024 if ($i > $limit) {
1025 break;
1026 }
1027
1028 print "\t".'<tr class="oddeven">'."\n";
1029 print '<td class="nowrap tdtop">';
1030 print $account->getNomUrl(1, '0');
1031 print "</td>\n";
1032 print '<td class="tdtop">'.$account->bank."</td>\n";
1033 print '<td class="tdtop">'.$account->number."</td>\n";
1034 // Link to delete from category
1035 print '<td class="right">';
1036 if ($permission) {
1037 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $account->id).($limit ? '&limit='.$limit : '')."'>";
1038 //print $langs->trans("DeleteFromCat");
1039 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1040 print "</a>";
1041 }
1042 print '</td>';
1043 print "</tr>\n";
1044 }
1045 } else {
1046 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1047 }
1048 print "</table>\n";
1049
1050 print '</form>'."\n";
1051 }
1052 } else {
1053 print_barre_liste($langs->trans("Banque"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'bank');
1054 accessforbidden("NotEnoughPermissions", 0, 0);
1055 }
1056}
1057
1058// List of Project
1059if ($type == Categorie::TYPE_PROJECT) {
1060 if ($user->hasRight("project", "read")) {
1061 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
1062
1063 $permission = $user->hasRight('projet', 'creer');
1064 $showclassifyform = $user->hasRight('projet', 'creer');
1065
1066 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1067 if ($objects < 0) {
1068 dol_print_error($db, $object->error, $object->errors);
1069 } else {
1071 '@phan-var-force Project $object';
1072 // Form to add record into a category
1073 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1074 print '<input type="hidden" name="token" value="'.newToken().'">';
1075 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1076 print '<input type="hidden" name="type" value="'.$typeid.'">';
1077 print '<input type="hidden" name="id" value="'.$object->id.'">';
1078 print '<input type="hidden" name="page_y" value="">';
1079 print '<input type="hidden" name="action" value="list">';
1080
1081 print '<br>';
1082 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1083 $num = count($objects);
1084 $nbtotalofrecords = '';
1085 $newcardbutton = '';
1086
1087 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1088 print_barre_liste($langs->trans("Project"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit);
1089
1090 if ($showclassifyform) {
1091 print '<table class="noborder centpercent">';
1092 print '<tr class="liste_titre"><td>';
1093 print $langs->trans("AddObjectIntoCategory").' &nbsp;';
1094 $form->selectProjects('', 'elemid');
1095 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1096 print '</tr>';
1097 print '</table>';
1098 }
1099
1100 print '<table class="noborder centpercent">'."\n";
1101 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1102
1103 if (count($objects) > 0) {
1104 $i = 0;
1105 foreach ($objects as $key => $project) {
1106 $i++;
1107 if ($i > $limit) {
1108 break;
1109 }
1110
1111 print "\t".'<tr class="oddeven">'."\n";
1112 print '<td class="nowrap tdtop">';
1113 print $project->getNomUrl(1);
1114 print "</td>\n";
1115 print '<td class="tdtop">'.$project->title."</td>\n";
1116 // Link to delete from category
1117 print '<td class="right">';
1118 if ($permission) {
1119 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $project->id).($limit ? '&limit='.$limit : '')."'>";
1120 //print $langs->trans("DeleteFromCat");
1121 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1122 print "</a>";
1123 }
1124 print '</td>';
1125 print "</tr>\n";
1126 }
1127 } else {
1128 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1129 }
1130 print "</table>\n";
1131
1132 print '</form>'."\n";
1133 }
1134 } else {
1135 print_barre_liste($langs->trans("Project"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'project');
1136 accessforbidden("NotEnoughPermissions", 0, 0);
1137 }
1138}
1139
1140// List of users
1141if ($type == Categorie::TYPE_USER) {
1142 if ($user->hasRight("user", "user", "read")) {
1143 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
1144 $showclassifyform = $user->hasRight("user", "user", "creer");
1145
1146 $users = $object->getObjectsInCateg($type, 0, 0, 0, 'lastname');
1147 if ($users < 0) {
1148 dol_print_error($db, $object->error, $object->errors);
1149 } else {
1151 '@phan-var-force User[] $users';
1152 // Form to add record into a category
1153 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1154 print '<input type="hidden" name="token" value="'.newToken().'">';
1155 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1156 print '<input type="hidden" name="type" value="'.$typeid.'">';
1157 print '<input type="hidden" name="id" value="'.$object->id.'">';
1158 print '<input type="hidden" name="page_y" value="">';
1159 print '<input type="hidden" name="action" value="list">';
1160
1161 print '<br>';
1162
1163 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1164 $num = count($users);
1165 $nbtotalofrecords = '';
1166 $newcardbutton = '';
1167
1168 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1169 print_barre_liste($langs->trans("Users"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'user', 0, '', '', $limit);
1170
1171 if ($showclassifyform) {
1172 print '<table class="noborder centpercent">';
1173 print '<tr class="liste_titre"><td>';
1174 $force_entity = getEntity($object->element); // So we will get same filter than the getObjectsInCateg()
1175 print img_picto('', $type, 'class="pictofixedwidth"');
1176 print $form->select_dolusers('', 'elemid', 1, null, 0, '', '', $force_entity);
1177 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1178 print '</tr>';
1179 print '</table>';
1180 }
1181
1182 print '<table class="noborder centpercent">'."\n";
1183 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Users").' <span class="badge">'.$num.'</span></td></tr>'."\n";
1184
1185 if (count($users) > 0) {
1186 // Use "$userentry" here, because "$user" is the current user
1187 foreach ($users as $key => $userentry) {
1188 print "\t".'<tr class="oddeven">'."\n";
1189 print '<td class="nowrap tdtop">';
1190 print $userentry->getNomUrl(-1);
1191 print "</td>\n";
1192 print '<td class="tdtop">'.$userentry->job."</td>\n";
1193
1194 // Link to delete from category
1195 print '<td class="right">';
1196 if ($user->hasRight('user', 'user', 'creer')) {
1197 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $userentry->id).($limit ? '&limit='.$limit : '')."'>";
1198 //print $langs->trans("DeleteFromCat");
1199 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1200 print "</a>";
1201 }
1202 print '</td>';
1203 print "</tr>\n";
1204 }
1205 } else {
1206 print '<tr class="oddeven"><td colspan="3"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1207 }
1208 print "</table>\n";
1209
1210 print '</form>'."\n";
1211 }
1212 } else {
1213 print_barre_liste($langs->trans("Users"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'user');
1214 accessforbidden("NotEnoughPermissions", 0, 0);
1215 }
1216}
1217
1218// List of warehouses
1219if ($type == Categorie::TYPE_WAREHOUSE) {
1220 if ($user->hasRight("stock", "read")) {
1221 $permission = $user->hasRight('stock', 'creer');
1222
1223 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
1224
1225 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1226 if ($objects < 0) {
1227 dol_print_error($db, $object->error, $object->errors);
1228 } else {
1230 '@phan-var-force Entrepot[] $objects';
1231 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1232 print '<input type="hidden" name="token" value="'.newToken().'">';
1233 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1234 print '<input type="hidden" name="type" value="'.$typeid.'">';
1235 print '<input type="hidden" name="id" value="'.$object->id.'">';
1236 print '<input type="hidden" name="page_y" value="">';
1237 print '<input type="hidden" name="action" value="list">';
1238
1239 print '<br>';
1240 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1241 $num = count($objects);
1242 $nbtotalofrecords = '';
1243 $newcardbutton = '';
1244
1245 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1246 print_barre_liste($langs->trans("Warehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, $newcardbutton, '', $limit);
1247
1248 print '<table class="noborder centpercent">'."\n";
1249 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1250
1251 if (count($objects) > 0) {
1252 $i = 0;
1253 foreach ($objects as $key => $warehouse) {
1254 $i++;
1255 if ($i > $limit) {
1256 break;
1257 }
1258
1259 print "\t".'<tr class="oddeven">'."\n";
1260 print '<td class="nowrap tdtop">';
1261 print $warehouse->getNomUrl(1);
1262 print "</td>\n";
1263 print '<td class="tdtop">'.$warehouse->ref."</td>\n";
1264 print '<td class="tdtop">'.$warehouse->lieu."</td>\n";
1265 // Link to delete from category
1266 print '<td class="right">';
1267 if ($permission) {
1268 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $warehouse->id).($limit ? '&limit='.$limit : '')."'>";
1269 //print $langs->trans("DeleteFromCat");
1270 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1271 print "</a>";
1272 }
1273 print '</td>';
1274 print "</tr>\n";
1275 }
1276 } else {
1277 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1278 }
1279 print "</table>\n";
1280
1281 print '</form>'."\n";
1282 }
1283 } else {
1284 print_barre_liste($langs->trans("Warehouse"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'stock');
1285 accessforbidden("NotEnoughPermissions", 0, 0);
1286 }
1287}
1288
1289// List of tickets
1290if ($type == Categorie::TYPE_TICKET) {
1291 if ($user->hasRight("ticket", "read")) {
1292 $permission = $user->hasRight('categorie', 'creer');
1293 $showclassifyform = $user->hasRight('categorie', 'creer');
1294
1295 $tickets = $object->getObjectsInCateg($type, 0, $limit, $offset);
1296 if ($tickets < 0) {
1297 dol_print_error($db, $object->error, $object->errors);
1298 } else {
1300 '@phan-var-force Ticket[] $tickets';
1301 // Form to add record into a category
1302 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1303 print '<input type="hidden" name="token" value="'.newToken().'">';
1304 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1305 print '<input type="hidden" name="type" value="'.$typeid.'">';
1306 print '<input type="hidden" name="id" value="'.$object->id.'">';
1307 print '<input type="hidden" name="page_y" value="">';
1308 print '<input type="hidden" name="action" value="list">';
1309
1310 print '<br>';
1311 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1312 $num = count($tickets);
1313 $nbtotalofrecords = '';
1314 $newcardbutton = '';
1315
1316 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1317 print_barre_liste($langs->trans("Ticket"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'ticket', 0, $newcardbutton, '', $limit);
1318
1319 if ($showclassifyform) {
1320 print '<table class="noborder centpercent">';
1321 print '<tr class="liste_titre"><td>';
1322 print $langs->trans("AddTicketIntoCategory").' &nbsp;';
1323 $form->selectTickets('', 'elemid');
1324 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1325 print '</tr>';
1326 print '</table>';
1327 }
1328
1329 print '<table class="noborder centpercent">'."\n";
1330 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
1331
1332 if (count($tickets) > 0) {
1333 $i = 0;
1334 foreach ($tickets as $ticket) {
1335 $i++;
1336 if ($i > $limit) {
1337 break;
1338 }
1339
1340 print "\t".'<tr class="oddeven">'."\n";
1341 print '<td class="nowrap tdtop">';
1342 print $ticket->getNomUrl(1);
1343 print "</td>\n";
1344 print '<td class="tdtop">'.$ticket->label."</td>\n";
1345 // Link to delete from category
1346 print '<td class="right">';
1347 if ($permission) {
1348 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $ticket->id).($limit ? '&limit='.$limit : '')."'>";
1349 //print $langs->trans("DeleteFromCat");
1350 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1351 print "</a>";
1352 }
1353 print '</td>';
1354 print "</tr>\n";
1355 }
1356 } else {
1357 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1358 }
1359 print "</table>\n";
1360
1361 print '</form>'."\n";
1362 }
1363 } else {
1364 print_barre_liste($langs->trans("Ticket"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'ticket');
1365 accessforbidden("NotEnoughPermissions", 0, 0);
1366 }
1367}
1368
1369// List of Interventions
1370if ($type == Categorie::TYPE_FICHINTER) {
1371 if ($user->hasRight("fichinter", "lire")) {
1372 $permission = $user->hasRight('categorie', 'creer');
1373 $showclassifyform = $user->hasRight('categorie', 'creer');
1374
1375 $fichinters = $object->getObjectsInCateg($type, 0, $limit, $offset);
1376 if ($fichinters < 0) {
1377 dol_print_error($db, $object->error, $object->errors);
1378 } else {
1379 // Form to add record into a category
1380 if ($showclassifyform) {
1381 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formintervention.class.php';
1382 $formfichinter = new FormIntervention($db);
1383
1384 print '<br>';
1385 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1386 print '<input type="hidden" name="token" value="'.newToken().'">';
1387 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1388 print '<input type="hidden" name="type" value="'.$typeid.'">';
1389 print '<input type="hidden" name="id" value="'.$object->id.'">';
1390 print '<input type="hidden" name="action" value="addintocategory">';
1391 print '<table class="noborder centpercent">';
1392 print '<tr class="liste_titre"><td>';
1393 print $langs->trans("AddFichinterIntoCategory").' &nbsp;';
1394 print $formfichinter->select_interventions(-1, 0, 'elemid');
1395 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1396 print '</tr>';
1397 print '</table>';
1398 print '</form>';
1399 }
1400
1401 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1402 print '<input type="hidden" name="token" value="'.newToken().'">';
1403 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1404 print '<input type="hidden" name="type" value="'.$typeid.'">';
1405 print '<input type="hidden" name="id" value="'.$object->id.'">';
1406 print '<input type="hidden" name="action" value="list">';
1407
1408 print '<br>';
1409 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1410 $num = count($fichinters);
1411 $nbtotalofrecords = '';
1412 $newcardbutton = '';
1413
1414 $langs->load('interventions');
1415 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1416 print_barre_liste($langs->trans("Intervention"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_intervention', 0, $newcardbutton, '', $limit);
1417 print '<table class="noborder centpercent">'."\n";
1418 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
1419
1420 if (count($fichinters) > 0) {
1421 $i = 0;
1422 foreach ($fichinters as $fichinter) {
1423 $i++;
1424 if ($i > $limit) {
1425 break;
1426 }
1427
1428 print "\t".'<tr class="oddeven">'."\n";
1429 print '<td class="nowrap tdtop">';
1430 print $fichinter->getNomUrl(1);
1431 print "</td>\n";
1432 print '<td class="tdtop">'.$fichinter->description."</td>\n";
1433 // Link to delete from category
1434 print '<td class="right">';
1435 if ($permission) {
1436 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".((int) $object->id)."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".((int) $fichinter->id).($limit ? '&limit='.$limit : '')."'>";
1437 print $langs->trans("DeleteFromCat");
1438 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1439 print "</a>";
1440 }
1441 print '</td>';
1442 print "</tr>\n";
1443 }
1444 } else {
1445 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1446 }
1447 print "</table>\n";
1448 print '</form>'."\n";
1449 }
1450 } else {
1451 print_barre_liste($langs->trans("Intervention"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'fichinter');
1452 accessforbidden("NotEnoughPermissions", 0, 0);
1453 }
1454}
1455
1456// List of Orders
1457if ($type == Categorie::TYPE_ORDER) {
1458 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
1459
1460 $permission = $user->rights->commande->creer;
1461
1462 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1463 if ($objects < 0) {
1464 dol_print_error($db, $object->error, $object->errors);
1465 } else {
1466 // Form to add record into a category
1467 $showclassifyform = $user->hasRight('order', 'write');
1468 if ($showclassifyform) {
1469 print '<br>';
1470 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1471 print '<input type="hidden" name="token" value="'.newToken().'">';
1472 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1473 print '<input type="hidden" name="type" value="'.$typeid.'">';
1474 print '<input type="hidden" name="id" value="'.$object->id.'">';
1475 print '<input type="hidden" name="action" value="addintocategory">';
1476 print '<table class="noborder centpercent">';
1477 print '<tr class="liste_titre"><td>';
1478 print $langs->trans("AddOrderIntoCategory").' &nbsp;';
1479 $form->selectOrder('', 'elemid');
1480 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1481 print '</tr>';
1482 print '</table>';
1483 print '</form>';
1484 }
1485
1486 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1487 print '<input type="hidden" name="token" value="'.newToken().'">';
1488 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1489 print '<input type="hidden" name="type" value="'.$typeid.'">';
1490 print '<input type="hidden" name="id" value="'.$object->id.'">';
1491 print '<input type="hidden" name="action" value="list">';
1492
1493 print '<br>';
1494 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1495 $num = count($objects);
1496 $nbtotalofrecords = '';
1497 $newcardbutton = '';
1498
1499 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1500 print_barre_liste($langs->trans("Orders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit);
1501
1502 print "<table class='noborder centpercent'>\n";
1503 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1504
1505 if (count($objects) > 0) {
1506 $i = 0;
1507 foreach ($objects as $key => $order) {
1508 $i++;
1509 if ($i > $limit) {
1510 break;
1511 }
1512
1513 print "\t".'<tr class="oddeven">'."\n";
1514 print '<td class="nowrap tdtop">';
1515 print $order->getNomUrl(1);
1516 print "</td>\n";
1517 print '<td class="tdtop">'.$order->ref."</td>\n";
1518 // Link to delete from category
1519 print '<td class="right">';
1520 if ($permission) {
1521 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$order->id."'>";
1522 print $langs->trans("DeleteFromCat");
1523 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1524 print "</a>";
1525 }
1526 print "</tr>\n";
1527 }
1528 } else {
1529 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1530 }
1531 print "</table>\n";
1532
1533 print '</form>'."\n";
1534 }
1535}
1536
1537// List of Invoices
1538if ($type == Categorie::TYPE_INVOICE) {
1539 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1540
1541 $permission = $user->rights->facture->creer;
1542
1543 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1544 if ($objects < 0) {
1545 dol_print_error($db, $object->error, $object->errors);
1546 } else {
1547 // Form to add record into a category
1548 $showclassifyform = $user->hasRight('facture', 'write');
1549 if ($showclassifyform) {
1550 print '<br>';
1551 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1552 print '<input type="hidden" name="token" value="'.newToken().'">';
1553 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1554 print '<input type="hidden" name="type" value="'.$typeid.'">';
1555 print '<input type="hidden" name="id" value="'.$object->id.'">';
1556 print '<input type="hidden" name="action" value="addintocategory">';
1557 print '<table class="noborder centpercent">';
1558 print '<tr class="liste_titre"><td>';
1559 print $langs->trans("AddInvoiceIntoCategory").' &nbsp;';
1560 $form->selectInvoice(-1, '', 'elemid', 24, 0, '1', 0, 0, 0, 'maxwidth500', '', '');
1561 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1562 print '</tr>';
1563 print '</table>';
1564 print '</form>';
1565 }
1566
1567 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1568 print '<input type="hidden" name="token" value="'.newToken().'">';
1569 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1570 print '<input type="hidden" name="type" value="'.$typeid.'">';
1571 print '<input type="hidden" name="id" value="'.$object->id.'">';
1572 print '<input type="hidden" name="action" value="list">';
1573
1574 print '<br>';
1575 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1576 $num = count($objects);
1577 $nbtotalofrecords = '';
1578 $newcardbutton = '';
1579
1580 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1581 print_barre_liste($langs->trans("BillsCustomers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit);
1582
1583 print "<table class='noborder centpercent'>\n";
1584 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1585
1586 if (count($objects) > 0) {
1587 $i = 0;
1588 foreach ($objects as $key => $invoice) {
1589 $i++;
1590 if ($i > $limit) {
1591 break;
1592 }
1593
1594 print "\t".'<tr class="oddeven">'."\n";
1595 print '<td class="nowrap tdtop">';
1596 print $invoice->getNomUrl(1);
1597 print "</td>\n";
1598 print '<td class="tdtop">'.$invoice->ref."</td>\n";
1599 // Link to delete from category
1600 print '<td class="right">';
1601 if ($permission) {
1602 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$invoice->id."'>";
1603 print $langs->trans("DeleteFromCat");
1604 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1605 print "</a>";
1606 }
1607 print "</tr>\n";
1608 }
1609 } else {
1610 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1611 }
1612 print "</table>\n";
1613
1614 print '</form>'."\n";
1615 }
1616}
1617
1618// List of Supplier Orders
1619if ($type == Categorie::TYPE_SUPPLIER_ORDER) {
1620 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
1621
1622 $permission = $user->rights->fournisseur->commande->creer;
1623
1624 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1625 if ($objects < 0) {
1626 dol_print_error($db, $object->error, $object->errors);
1627 } else {
1628 // Form to add record into a category
1629 $showclassifyform = $user->hasRight('fournisseur', 'commande', 'creer');
1630 ;
1631 if ($showclassifyform) {
1632 print '<br>';
1633 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1634 print '<input type="hidden" name="token" value="'.newToken().'">';
1635 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1636 print '<input type="hidden" name="type" value="'.$typeid.'">';
1637 print '<input type="hidden" name="id" value="'.$object->id.'">';
1638 print '<input type="hidden" name="action" value="addintocategory">';
1639 print '<table class="noborder centpercent">';
1640 print '<tr class="liste_titre"><td>';
1641 print $langs->trans("AddSupplierOrderIntoCategory").' &nbsp;';
1642 $form->selectSupplierOrder('', 'elemid');
1643 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1644 print '</tr>';
1645 print '</table>';
1646 print '</form>';
1647 }
1648
1649 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1650 print '<input type="hidden" name="token" value="'.newToken().'">';
1651 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1652 print '<input type="hidden" name="type" value="'.$typeid.'">';
1653 print '<input type="hidden" name="id" value="'.$object->id.'">';
1654 print '<input type="hidden" name="action" value="list">';
1655
1656 print '<br>';
1657 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1658 $num = count($objects);
1659 $nbtotalofrecords = '';
1660 $newcardbutton = '';
1661
1662 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1663 print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_order', 0, $newcardbutton, '', $limit);
1664
1665 print "<table class='noborder centpercent'>\n";
1666 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1667
1668 if (count($objects) > 0) {
1669 $i = 0;
1670 foreach ($objects as $key => $supplier_order) {
1671 $i++;
1672 if ($i > $limit) {
1673 break;
1674 }
1675
1676 print "\t".'<tr class="oddeven">'."\n";
1677 print '<td class="nowrap tdtop">';
1678 print $supplier_order->getNomUrl(1);
1679 print "</td>\n";
1680 print '<td class="tdtop">'.$supplier_order->ref."</td>\n";
1681 // Link to delete from category
1682 print '<td class="right">';
1683 if ($permission) {
1684 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$supplier_order->id."'>";
1685 print $langs->trans("DeleteFromCat");
1686 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1687 print "</a>";
1688 }
1689 print "</tr>\n";
1690 }
1691 } else {
1692 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1693 }
1694 print "</table>\n";
1695
1696 print '</form>'."\n";
1697 }
1698}
1699
1700// List of Supplier Invoices
1701if ($type == Categorie::TYPE_SUPPLIER_INVOICE) {
1702 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1703
1704 $permission = $user->rights->fournisseur->facture->creer;
1705
1706 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1707 if ($objects < 0) {
1708 dol_print_error($db, $object->error, $object->errors);
1709 } else {
1710 // Form to add record into a category
1711 $showclassifyform = $user->hasRight('fournisseur', 'facture', 'creer');;
1712 if ($showclassifyform) {
1713 print '<br>';
1714 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1715 print '<input type="hidden" name="token" value="'.newToken().'">';
1716 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1717 print '<input type="hidden" name="type" value="'.$typeid.'">';
1718 print '<input type="hidden" name="id" value="'.$object->id.'">';
1719 print '<input type="hidden" name="action" value="addintocategory">';
1720 print '<table class="noborder centpercent">';
1721 print '<tr class="liste_titre"><td>';
1722 print $langs->trans("AddSupplierInvoiceIntoCategory").' &nbsp;';
1723 $form->selectSupplierInvoice('', 'elemid');
1724 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1725 print '</tr>';
1726 print '</table>';
1727 print '</form>';
1728 }
1729
1730 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1731 print '<input type="hidden" name="token" value="'.newToken().'">';
1732 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1733 print '<input type="hidden" name="type" value="'.$typeid.'">';
1734 print '<input type="hidden" name="id" value="'.$object->id.'">';
1735 print '<input type="hidden" name="action" value="list">';
1736
1737 print '<br>';
1738 $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = '';
1739
1740 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1741 print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_order', 0, $newcardbutton, '', $limit);
1742
1743 print "<table class='noborder centpercent'>\n";
1744 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1745
1746 if (count($objects) > 0) {
1747 $i = 0;
1748 foreach ($objects as $key => $supplier_invoice) {
1749 $i++;
1750 if ($i > $limit) {
1751 break;
1752 }
1753
1754 print "\t".'<tr class="oddeven">'."\n";
1755 print '<td class="nowrap tdtop">';
1756 print $supplier_invoice->getNomUrl(1);
1757 print "</td>\n";
1758 print '<td class="tdtop">'.$supplier_invoice->ref."</td>\n";
1759 // Link to delete from category
1760 print '<td class="right">';
1761 if ($permission) {
1762 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$supplier_invoice->id."'>";
1763 print $langs->trans("DeleteFromCat");
1764 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1765 print "</a>";
1766 }
1767 print "</tr>\n";
1768 }
1769 } else {
1770 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1771 }
1772 print "</table>\n";
1773
1774 print '</form>'."\n";
1775 }
1776}
1777
1778// Note that $action and $object may have been modified by some hooks
1779$parameters = array('type' => $type, 'id' => $id, 'label' => $label);
1780$reshook = $hookmanager->executeHooks('addMoreCategoriesList', $parameters, $object, $action);
1781
1782// End of page
1783llxFooter();
1784$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
categories_prepare_head(Categorie $object, $type)
Prepare array with list of tabs.
Class to manage bank accounts.
Class to manage members of a foundation.
Class to manage categories.
Class to manage predefined suppliers products.
Class to manage customers orders.
Class to manage contact/addresses.
Class to manage standard extra fields.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage generation of HTML components Only common components must be here.
Class to manage generation of HTML components for contract module.
Class permettant la generation de composants html autre Only common components are here.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_view($titlealt='default', $float=0, $other='class="valignmiddle"')
Show logo view card.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
Class to generate the form for creating a new ticket.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
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.