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 } elseif ($type == Categorie::TYPE_SUPPLIER_INVOICE && $user->hasRight('fournisseur', 'facture', 'creer')) {
191 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
192 $tmpobject = new FactureFournisseur($db);
193 $result = $tmpobject->fetch($removeelem);
194 $elementtype = 'supplier_invoice';
195 } else {
196 dol_print_error(null, "Not supported value of type = ".$type);
197 $result = -100;
198 }
199
200 if ($tmpobject !== null) {
201 // also enter here when item was not found to report error
202 $result = $object->del_type($tmpobject, $elementtype);
203 if ($result < 0) {
204 dol_print_error(null, $object->error);
205 }
206 }
207}
208
209if ($user->hasRight('categorie', 'supprimer') && $action == 'confirm_delete' && $confirm == 'yes') {
210 if ($object->delete($user) >= 0) {
211 if ($backtopage) {
212 header("Location: ".$backtopage);
213 exit;
214 } else {
215 header("Location: ".DOL_URL_ROOT.'/categories/categorie_list.php?type='.$type);
216 exit;
217 }
218 } else {
219 setEventMessages($object->error, $object->errors, 'errors');
220 }
221}
222
223if ($elemid && $action == 'addintocategory') { // Test on permission not required here. Done just after depending on object type
224 $newobject = null;
225 $elementtype = '';
226 if ($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
227 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
228 $newobject = new Product($db);
229 $elementtype = 'product';
230 } elseif ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) {
231 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
232 $newobject = new Societe($db);
233 $elementtype = 'customer';
234 } elseif ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) {
235 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
236 $newobject = new Societe($db);
237 $elementtype = 'supplier';
238 } elseif ($type == Categorie::TYPE_TICKET && $user->hasRight('ticket', 'write')) {
239 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
240 $newobject = new Ticket($db);
241 $elementtype = 'ticket';
242 } elseif ($type == Categorie::TYPE_FICHINTER && $user->hasRight('ficheinter', 'write')) {
243 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
244 $newobject = new Fichinter($db);
245 $elementtype = 'fichinter';
246 } elseif ($type == Categorie::TYPE_PROJECT && $user->hasRight('projet', 'creer')) {
247 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
248 $newobject = new Project($db);
249 $elementtype = 'project';
250 } elseif ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) {
251 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
252 $newobject = new Adherent($db);
253 $elementtype = 'member';
254 } elseif ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) {
255 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
256 $newobject = new Contact($db);
257 $elementtype = 'contact';
258 } elseif ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) {
259 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
260 $newobject = new User($db);
261 $elementtype = 'user';
262 } elseif ($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer')) {
263 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
264 $newobject = new Account($db);
265 $elementtype = 'bank_account';
266 } elseif ($type == Categorie::TYPE_ORDER && $user->hasRight('commande', 'creer')) {
267 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
268 $newobject = new Commande($db);
269 $elementtype = 'order';
270 } elseif ($type == Categorie::TYPE_INVOICE && $user->hasRight('facture', 'creer')) {
271 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
272 $newobject = new Facture($db);
273 $elementtype = 'invoice';
274 } elseif ($type == Categorie::TYPE_SUPPLIER_ORDER && $user->hasRight('fournisseur', 'commande', 'creer')) {
275 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
276 $newobject = new CommandeFournisseur($db);
277 $elementtype = 'supplier_order';
278 } elseif ($type == Categorie::TYPE_SUPPLIER_INVOICE && $user->hasRight('fournisseur', 'facture', 'creer')) {
279 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
280 $newobject = new FactureFournisseur($db);
281 $elementtype = 'supplier_invoice';
282 } else {
283 // No permission to modify the objects of this type: refuse instead of reporting a success
284 $result = -1;
285 $object->error = $langs->trans("NotEnoughPermissions");
286 }
287 if ($newobject !== null) {
288 $result = $newobject->fetch($elemid);
289 }
290
291 if ($result >= 0 && $newobject !== null) {
292 // Add into category
293 $result = $object->add_type($newobject, $elementtype);
294 }
295 if ($result >= 0) {
296 setEventMessages($langs->trans("WasAddedSuccessfully", $newobject->ref), null, 'mesgs');
297 } else {
298 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
299 setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
300 } else {
301 setEventMessages($object->error, $object->errors, 'errors');
302 }
303 }
304}
305
306
307/*
308 * View
309 */
310
311$form = new Form($db);
312$formother = new FormOther($db);
313
314$arrayofjs = array(
315 '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
316 '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'
317);
318$arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
319
320$help_url = '';
321
322llxHeader("", $langs->trans("Categories"), $help_url, '', 0, 0, $arrayofjs, $arrayofcss);
323
324$title = $langs->trans("Categories");
325$title .= ' ('.$langs->trans(empty(Categorie::$MAP_TYPE_TITLE_AREA[$type]) ? ucfirst($type) : Categorie::$MAP_TYPE_TITLE_AREA[$type]).')';
326
327$head = categories_prepare_head($object, $type);
328print dol_get_fiche_head($head, 'card', $langs->trans($title), -1, 'category');
329
330$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/categorie_list.php?leftmenu=cat&type='.urlencode($type));
331$linkback = '<a href="'.dol_sanitizeUrl($backtolist).'">'.$langs->trans("BackToList").'</a>';
332$object->next_prev_filter = 'type:=:'.((int) $object->type);
333$object->ref = $object->label;
334$morehtmlref = '<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/categorie_list.php?leftmenu=cat&type='.urlencode($type).'">'.$langs->trans("Root").'</a> >> ';
335$ways = $object->print_all_ways(" &gt;&gt; ", '', 1);
336foreach ($ways as $way) {
337 $morehtmlref .= $way."<br>\n";
338}
339$morehtmlref .= '</div>';
340
341dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'label', $morehtmlref, '&type='.urlencode($type), 0, '', '', 1);
342
343
344// Confirmation of deletion
345if ($action == 'delete') {
346 if ($backtopage) {
347 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.urlencode($type).'&backtopage='.urlencode($backtopage), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 2);
348 } else {
349 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.urlencode($type), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1);
350 }
351}
352
353print '<br>';
354
355print '<div class="fichecenter">';
356print '<div class="underbanner clearboth"></div>';
357print '<table class="border centpercent tableforfield">';
358
359// Description
360print '<tr><td class="titlefield notopnoleft tdtop">';
361print $langs->trans("Description").'</td><td>';
362print dol_htmlentitiesbr($object->description);
363print '</td></tr>';
364
365// Color
366print '<tr><td class="notopnoleft">';
367print $langs->trans("Color").'</td><td>';
368print $formother->showColor($object->color);
369print '</td></tr>';
370
371// Position
372print '<tr><td class="titlefield notopnoleft">';
373print $langs->trans("Position").'</td><td>';
374print $object->position ? $object->position : '';
375print '</td></tr>';
376
377// Other attributes
378include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
379
380print '</table>';
381print '</div>';
382
383print dol_get_fiche_end();
384
385
386/*
387 * Boutons actions
388 */
389
390print "<div class='tabsAction'>\n";
391$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
392if ($reshook < 0) {
393 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
394}
395if (empty($reshook)) {
396 if ($user->hasRight('categorie', 'creer')) {
397 $socid = ($object->socid ? "&socid=".$object->socid : "");
398 print '<a class="butAction" href="edit.php?id='.$object->id.$socid.'&type='.urlencode($type).'">'.$langs->trans("Modify").'</a>';
399 }
400
401 if ($user->hasRight('categorie', 'supprimer')) {
402 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>';
403 }
404}
405
406print "</div>";
407
408$newcardbutton = '';
409if ($user->hasRight('categorie', 'creer')) {
410 $link = DOL_URL_ROOT.'/categories/card.php';
411 $link .= '?action=create';
412 $link .= '&type='.urlencode($type);
413 $link .= '&catorigin='.((int) $object->id);
414 $link .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.'&id='.$id);
415
416 $newcardbutton = '<div class="right">';
417 $newcardbutton .= dolGetButtonTitle($langs->trans('NewCategory'), '', 'fa fa-plus-circle', $link);
418 $newcardbutton .= '</div>';
419}
420
421
422/*
423 * Sub-category tree view of this category
424 */
425
426print '<div class="fichecenter">';
427
428print load_fiche_titre($langs->trans("SubCats"), $newcardbutton, 'object_category');
429
430$cats = $object->get_filles();
431
432print '<table class="liste nohover noborder centpercent borderbottom">';
433
434print '<tr class="liste_titre">';
435print '<td>'.$langs->trans("SubCats").'</td>';
436print '<td></td>';
437print '<td class="right">';
438
439if (is_array($cats) && count($cats) > 1 && !empty($conf->use_javascript_ajax)) {
440 print '<div id="iddivjstreecontrol">';
441 print '<a class="notasortlink" href="#">'.img_picto('', 'folder').' '.$langs->trans("UndoExpandAll").'</a>';
442 print " | ";
443 print '<a class="notasortlink" href="#">'.img_picto('', 'folder-open').' '.$langs->trans("ExpandAll").'</a>';
444 print '</div>';
445}
446
447print '</td>';
448print '</tr>';
449
450if (is_numeric($cats) && $cats < 0) {
451 dol_print_error($db, $object->error, $object->errors);
452} elseif (count($cats) < 1) {
453 print '<tr class="oddeven nobottom nohover">';
454 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("NoSubCat").'</span></td>';
455 print '</tr>';
456} else {
457 $categstatic = new Categorie($db);
458
459 $fulltree = $categstatic->get_full_arbo($type, $object->id, 1);
460
461 // Load possible missing includes
462 if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) {
463 if ($type == Categorie::TYPE_MEMBER) {
464 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
465 }
466 if ($type == Categorie::TYPE_ACCOUNT) {
467 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
468 }
469 if ($type == Categorie::TYPE_PROJECT) {
470 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
471 }
472 if ($type == Categorie::TYPE_USER) {
473 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
474 }
475 }
476
477 // Define data (format for treeview)
478 $data = array();
479 $data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => 'racine', 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => '');
480 foreach ($fulltree as $key => $val) {
481 $categstatic->id = $val['id'];
482 $categstatic->ref = $val['label'];
483 $categstatic->color = $val['color'];
484 $categstatic->type = $type;
485 //$desc = dol_htmlcleanlastbr($val['description']);
486
487 $counter = '';
488 if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) {
489 // we need only a count of the elements, so it is enough to consume only the id's from the database
490 $elements = $categstatic->getObjectsInCateg($type, 1);
491
492 $counter = "<td class='left' width='40px;'>".(is_array($elements) ? count($elements) : '0')."</td>";
493 }
494
495 if ($categstatic->color) {
496 $stylecolor = ' style="background: #'.sprintf("%06s", $categstatic->color).';"';
497 } else {
498 $stylecolor = ' style="background: #bbb;"';
499 }
500 $li = $categstatic->getNomUrl(1, '', 60, '&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.((int) $id).'&type='.urlencode($type)), 0);
501
502 $entry = '<table class="nobordernopadding centpercent">';
503 $entry .= '<tr>';
504
505 $entry .= '<td>';
506 $entry .= '<span class="noborderoncategories" '.$stylecolor.'>'.$li.'</span>';
507 $entry .= '</td>';
508
509 $entry .= $counter;
510
511 $entry .= '<td class="right" width="20px;">';
512 $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>';
513 $entry .= '</td>';
514 $entry .= '<td class="right" width="20px;">';
515 $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>';
516 $entry .= '</td>';
517 $entry .= '<td class="right" width="20px;">';
518 $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>';
519 $entry .= '</td>';
520
521 $entry .= '</tr>';
522 $entry .= '</table>';
523
524 $data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry);
525 }
526
527 $nbofentries = (count($data) - 1);
528 if ($nbofentries > 0) {
529 require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
530 print '<tr class="pair">';
531 print '<td colspan="3">';
532
533 // $data[0] is the current shown category, to don'T show the current category use $data[1] instead
534 tree_recur($data, $data[1], 0);
535
536 print '</td>';
537 print '</tr>';
538 } else {
539 print '<tr class="pair">';
540 print '<td colspan="3">';
541 print '<table class="nobordernopadding">';
542
543 print '<tr class="nobordernopadding">';
544 print '<td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
545 print '<td class="valignmiddle"><span class="opacitymedium">'.$langs->trans("NoCategoryYet").'</span></td>';
546 print '<td>&nbsp;</td>';
547 print '</tr>';
548
549 print '</table>';
550 print '</td>';
551 print '</tr>';
552 }
553}
554
555print "</table>";
556print "</div>";
557
558// List of mass actions available
559$arrayofmassactions = array(
560 //'validate'=>$langs->trans("Validate"),
561 //'generate_doc'=>$langs->trans("ReGeneratePDF"),
562 //'builddoc'=>$langs->trans("PDFMerge"),
563 //'presend'=>$langs->trans("SendByMail"),
564);
565$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
566
567$typeid = $type; // warning, typeid can be a string
568
569
570// List of products or services (type is type of category)
571if ($type == Categorie::TYPE_PRODUCT) {
572 if ($user->hasRight("product", "read") || $user->hasRight("service", "read")) {
573 $permission = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'));
574 $showclassifyform = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'));
575
576 $prods = $object->getObjectsInCateg($type, 0, $limit, $offset, 'ref');
577 if ($prods < 0) {
578 dol_print_error($db, $object->error, $object->errors);
579 } else {
581 '@phan-var-force Product[] $prods';
582 // Form to add record into the category
583 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
584 print '<input type="hidden" name="token" value="'.newToken().'">';
585 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
586 print '<input type="hidden" name="type" value="'.$typeid.'">';
587 print '<input type="hidden" name="id" value="'.$object->id.'">';
588 print '<input type="hidden" name="page_y" value="">';
589 print '<input type="hidden" name="action" value="list">';
590
591 print '<br>';
592 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
593 $num = count($prods);
594 $nbtotalofrecords = '';
595 $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'));
596
597 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
598 print_barre_liste($langs->trans("ProductsAndServices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit);
599
600 if ($showclassifyform) {
601 print '<table class="noborder centpercent">';
602 print '<tr class="liste_titre"><td>';
603 print $langs->trans("AddProductServiceIntoCategory").' &nbsp;';
604 $form->select_produits(0, 'elemid', '', 0, 0, -1, 2, '', 1, array(), 0, 1, 0, '', 0, '', null);
605 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
606 print '</tr>';
607 print '</table>';
608 }
609
610 print '<table class="noborder centpercent">'."\n";
611 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
612
613 if (count($prods) > 0) {
614 $i = 0;
615 foreach ($prods as $prod) {
616 $i++;
617 if ($i > $limit) {
618 break;
619 }
620
621 print '<tr class="oddeven">'."\n";
622 print '<td class="nowrap tdtop">';
623 print $prod->getNomUrl(1);
624 print "</td>\n";
625 print '<td class="tdtop">'.dolPrintHTML($prod->label)."</td>\n";
626 // Link to delete from category
627 print '<td class="right">';
628 if ($permission) {
629 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 : '').'">';
630 //print $langs->trans("DeleteFromCat");
631 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
632 print "</a>";
633 }
634 print '</td>';
635 print "</tr>\n";
636 }
637 } else {
638 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
639 }
640 print "</table>\n";
641
642 print '</form>'."\n";
643 }
644 } else {
645 print_barre_liste($langs->trans("ProductsAndServices"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'products');
646 accessforbidden("NotEnoughPermissions", 0, 0);
647 }
648}
649
650// List of customers
651if ($type == Categorie::TYPE_CUSTOMER) {
652 if ($user->hasRight("societe", "read")) {
653 $permission = $user->hasRight('societe', 'creer');
654 $showclassifyform = $user->hasRight('societe', 'creer');
655
656 $socs = $object->getObjectsInCateg($type, 0, $limit, $offset, 'nom');
657 if ($socs < 0) {
658 dol_print_error($db, $object->error, $object->errors);
659 } else {
661 '@phan-var-force Societe[] $socs';
662 // Form to add record into a category
663 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
664 print '<input type="hidden" name="token" value="'.newToken().'">';
665 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
666 print '<input type="hidden" name="type" value="'.$typeid.'">';
667 print '<input type="hidden" name="id" value="'.$object->id.'">';
668 print '<input type="hidden" name="action" value="list">';
669 print '<input type="hidden" name="page_y" value="">';
670
671 print '<br>';
672 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
673 $num = count($socs);
674 $nbtotalofrecords = '';
675 $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'));
676
677 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
678 print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
679
680 if ($showclassifyform) {
681 print '<table class="noborder centpercent">';
682 print '<tr class="liste_titre"><td>';
683 print $langs->trans("AddCustomerIntoCategory").' &nbsp;';
684 $filter = '(s.client:IN:1,2,3)';
685 print $form->select_company('', 'elemid', $filter);
686 print '<input type="submit" class="reposition button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
687 print '</tr>';
688 print '</table>';
689 }
690
691 print '<table class="noborder centpercent">'."\n";
692 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Name").'</td></tr>'."\n";
693
694 if (count($socs) > 0) {
695 $i = 0;
696 foreach ($socs as $key => $soc) {
697 $i++;
698 if ($i > $limit) {
699 break;
700 }
701
702 print "\t".'<tr class="oddeven">'."\n";
703 print '<td class="nowrap tdtop tdoverflowmax250">';
704 print $soc->getNomUrl(1);
705 print "</td>\n";
706 // Link to delete from category
707 print '<td class="right">';
708 if ($permission) {
709 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 : '')."'>";
710 //print $langs->trans("DeleteFromCat");
711 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
712 print "</a>";
713 }
714 print '</td>';
715 print "</tr>\n";
716 }
717 } else {
718 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
719 }
720 print "</table>\n";
721
722 print '</form>'."\n";
723 }
724 } else {
725 print_barre_liste($langs->trans("Customers"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'companies');
726 accessforbidden("NotEnoughPermissions", 0, 0);
727 }
728}
729
730// List of suppliers
731if ($type == Categorie::TYPE_SUPPLIER) {
732 if ($user->hasRight("fournisseur", "read")) {
733 $permission = $user->hasRight('societe', 'creer');
734 $showclassifyform = $user->hasRight('societe', 'creer');
735
736 $socs = $object->getObjectsInCateg($type, 0, $limit, $offset, 'nom');
737
738 if ($socs < 0) {
739 dol_print_error($db, $object->error, $object->errors);
740 } else {
742 '@phan-var-force Fournisseur[] $socs';
743 // Form to add record into a category
744 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
745 print '<input type="hidden" name="token" value="'.newToken().'">';
746 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
747 print '<input type="hidden" name="type" value="'.$typeid.'">';
748 print '<input type="hidden" name="id" value="'.$object->id.'">';
749 print '<input type="hidden" name="page_y" value="">';
750 print '<input type="hidden" name="action" value="list">';
751
752 print '<br>';
753 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
754 $num = count($socs);
755 $nbtotalofrecords = '';
756 $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'));
757
758 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
759 print_barre_liste($langs->trans("Suppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
760
761 if ($showclassifyform) {
762 print '<table class="noborder centpercent">';
763 print '<tr class="liste_titre"><td>';
764 print $langs->trans("AddSupplierIntoCategory").' &nbsp;';
765 $filter = '(s.fournisseur:=:1)';
766 print $form->select_company('', 'elemid', $filter);
767 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
768 print '</tr>';
769 print '</table>';
770 }
771
772 print '<table class="noborder centpercent">'."\n";
773 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Name")."</td></tr>\n";
774
775 if (count($socs) > 0) {
776 $i = 0;
777 foreach ($socs as $soc) {
778 $i++;
779 if ($i > $limit) {
780 break;
781 }
782
783 print "\t".'<tr class="oddeven">'."\n";
784 print '<td class="nowrap tdtop">';
785 print $soc->getNomUrl(1);
786 print "</td>\n";
787 // Link to delete from category
788 print '<td class="right">';
789 if ($permission) {
790 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 : '').'">';
791 //print $langs->trans("DeleteFromCat");
792 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
793 print "</a>";
794 }
795 print '</td>';
796
797 print "</tr>\n";
798 }
799 } else {
800 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
801 }
802 print "</table>\n";
803
804 print '</form>'."\n";
805 }
806 } else {
807 print_barre_liste($langs->trans("Suppliers"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'companies');
808 accessforbidden("NotEnoughPermissions", 0, 0);
809 }
810}
811
812// List of members
813if ($type == Categorie::TYPE_MEMBER) {
814 if ($user->hasRight("adherent", "read")) {
815 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
816
817 $permission = $user->hasRight('adherent', 'creer');
818 $showclassifyform = $user->hasRight('adherent', 'creer');
819
820 $members = $object->getObjectsInCateg($type, 0, $limit, $offset, 'lastname');
821 if ($members < 0) {
822 dol_print_error($db, $object->error, $object->errors);
823 } else {
825 '@phan-var-force Adherent[] $members';
826 // Form to add record into a category
827 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
828 print '<input type="hidden" name="token" value="'.newToken().'">';
829 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
830 print '<input type="hidden" name="type" value="'.$typeid.'">';
831 print '<input type="hidden" name="id" value="'.$object->id.'">';
832 print '<input type="hidden" name="page_y" value="">';
833 print '<input type="hidden" name="action" value="list">';
834
835 print '<br>';
836 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
837 $num = count($members);
838 $nbtotalofrecords = '';
839 $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'));
840
841 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
842 print_barre_liste($langs->trans("Member"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit);
843
844 if ($showclassifyform) {
845 print '<table class="noborder centpercent">';
846 print '<tr class="liste_titre"><td>';
847 print $langs->trans("AssignCategoryTo").' &nbsp;';
848 print $form->selectMembers('', 'elemid');
849 print '<input type="submit" class="button buttongen" value="'.$langs->trans("Save").'"></td>';
850 print '</tr>';
851 print '</table>';
852 }
853
854 print '<table class="noborder centpercent">'."\n";
855 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Name").'</td></tr>'."\n";
856
857 if (count($members) > 0) {
858 $i = 0;
859 foreach ($members as $key => $member) {
860 $i++;
861 if ($i > $limit) {
862 break;
863 }
864
865 print "\t".'<tr class="oddeven">'."\n";
866 print '<td class="nowrap tdtop">';
867 $member->ref = $member->login;
868 print $member->getNomUrl(1, 0);
869 print "</td>\n";
870 print '<td class="tdtop">'.$member->lastname."</td>\n";
871 print '<td class="tdtop">'.$member->firstname."</td>\n";
872 // Link to delete from category
873 print '<td class="right">';
874 if ($permission) {
875 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 : '')."'>";
876 //print $langs->trans("DeleteFromCat");
877 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
878 print "</a>";
879 }
880 print '</td>';
881 print "</tr>\n";
882 }
883 } else {
884 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
885 }
886 print "</table>\n";
887
888 print '</form>'."\n";
889 }
890 } else {
891 print_barre_liste($langs->trans("Member"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'members');
892 accessforbidden("NotEnoughPermissions", 0, 0);
893 }
894}
895
896// List of contacts
897if ($type == Categorie::TYPE_CONTACT) {
898 if ($user->hasRight("societe", "read")) {
899 $permission = $user->hasRight('societe', 'creer');
900 $showclassifyform = $user->hasRight('societe', 'creer');
901
902 $contacts = $object->getObjectsInCateg($type, 0, $limit, $offset, 'lastname');
903 if (is_numeric($contacts) && $contacts < 0) {
904 dol_print_error($db, $object->error, $object->errors);
905 } else {
907 '@phan-var-force Contact[] $contacts';
908 // Form to add record into a category
909 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
910 print '<input type="hidden" name="token" value="'.newToken().'">';
911 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
912 print '<input type="hidden" name="type" value="'.$typeid.'">';
913 print '<input type="hidden" name="id" value="'.$object->id.'">';
914 print '<input type="hidden" name="page_y" value="">';
915 print '<input type="hidden" name="action" value="list">';
916
917 print '<br>';
918 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
919 $num = count($contacts);
920 $nbtotalofrecords = '';
921 $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'));
922
923 $objsoc = new Societe($db);
924
925 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
926 print_barre_liste($langs->trans("Contact"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contact', 0, $newcardbutton, '', $limit);
927
928 if ($showclassifyform) {
929 print '<table class="noborder centpercent">';
930 print '<tr class="liste_titre"><td>';
931 print $langs->trans("AssignCategoryTo").' &nbsp;';
932 print $form->select_contact(0, '', 'elemid', '', '', '', 0, 'maxwidth300 widthcentpercentminusx');
933 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
934 print '</tr>';
935 print '</table>';
936 }
937
938 print '<table class="noborder centpercent">'."\n";
939 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Ref").'</td></tr>'."\n";
940
941 if (is_array($contacts) && count($contacts) > 0) {
942 $i = 0;
943 foreach ($contacts as $key => $contact) {
944 $i++;
945 if ($i > $limit) {
946 break;
947 }
948
949 print "\t".'<tr class="oddeven">'."\n";
950 print '<td class="nowrap tdtop">';
951 print $contact->getNomUrl(1, 'category');
952 if ($contact->socid > 0) {
953 $objsoc->fetch($contact->socid);
954 print ' - ';
955 print $objsoc->getNomUrl(1, 'contact');
956 }
957 print "</td>\n";
958 // Link to delete from category
959 print '<td class="right">';
960 if ($permission) {
961 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 : '')."'>";
962 //print $langs->trans("DeleteFromCat");
963 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
964 print "</a>";
965 }
966 print '</td>';
967 print "</tr>\n";
968 }
969 } else {
970 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
971 }
972 print "</table>\n";
973
974 print '</form>'."\n";
975 }
976 } else {
977 print_barre_liste($langs->trans("Contact"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'contact');
978 accessforbidden("NotEnoughPermissions", 0, 0);
979 }
980}
981
982// List of bank accounts
983if ($type == Categorie::TYPE_ACCOUNT) {
984 if ($user->hasRight("banque", "read")) {
985 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
986
987 $permission = $user->hasRight('banque', 'creer');
988 $showclassifyform = $user->hasRight('banque', 'creer');
989
990 $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset);
991 if ($accounts < 0) {
992 dol_print_error($db, $object->error, $object->errors);
993 } else {
995 '@phan-var-force Account[] $accounts';
996 // Form to add record into a category
997 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
998 print '<input type="hidden" name="token" value="'.newToken().'">';
999 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1000 print '<input type="hidden" name="type" value="'.$typeid.'">';
1001 print '<input type="hidden" name="id" value="'.$object->id.'">';
1002 print '<input type="hidden" name="page_y" value="">';
1003 print '<input type="hidden" name="action" value="list">';
1004
1005 print '<br>';
1006 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1007 $num = count($accounts);
1008 $nbtotalofrecords = '';
1009 $newcardbutton = '';
1010
1011 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1012 print_barre_liste($langs->trans("Account"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit);
1013
1014 if ($showclassifyform) {
1015 print '<table class="noborder centpercent">';
1016 print '<tr class="liste_titre"><td>';
1017 print $langs->trans("AddObjectIntoCategory").' &nbsp;';
1018 print $form->select_comptes('', 'elemid', 0, '', 0, '', 0, '', 1);
1019 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1020 print '</tr>';
1021 print '</table>';
1022 }
1023
1024 print '<table class="noborder centpercent">'."\n";
1025 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1026
1027 if (count($accounts) > 0) {
1028 $i = 0;
1029 foreach ($accounts as $key => $account) {
1030 $i++;
1031 if ($i > $limit) {
1032 break;
1033 }
1034
1035 print "\t".'<tr class="oddeven">'."\n";
1036 print '<td class="nowrap tdtop">';
1037 print $account->getNomUrl(1, '0');
1038 print "</td>\n";
1039 print '<td class="tdtop">'.$account->bank."</td>\n";
1040 print '<td class="tdtop">'.$account->number."</td>\n";
1041 // Link to delete from category
1042 print '<td class="right">';
1043 if ($permission) {
1044 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 : '')."'>";
1045 //print $langs->trans("DeleteFromCat");
1046 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1047 print "</a>";
1048 }
1049 print '</td>';
1050 print "</tr>\n";
1051 }
1052 } else {
1053 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1054 }
1055 print "</table>\n";
1056
1057 print '</form>'."\n";
1058 }
1059 } else {
1060 print_barre_liste($langs->trans("Banque"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'bank');
1061 accessforbidden("NotEnoughPermissions", 0, 0);
1062 }
1063}
1064
1065// List of Project
1066if ($type == Categorie::TYPE_PROJECT) {
1067 if ($user->hasRight("project", "read")) {
1068 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
1069
1070 $permission = $user->hasRight('projet', 'creer');
1071 $showclassifyform = $user->hasRight('projet', 'creer');
1072
1073 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1074 if ($objects < 0) {
1075 dol_print_error($db, $object->error, $object->errors);
1076 } else {
1078 '@phan-var-force Project $object';
1079 // Form to add record into a category
1080 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1081 print '<input type="hidden" name="token" value="'.newToken().'">';
1082 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1083 print '<input type="hidden" name="type" value="'.$typeid.'">';
1084 print '<input type="hidden" name="id" value="'.$object->id.'">';
1085 print '<input type="hidden" name="page_y" value="">';
1086 print '<input type="hidden" name="action" value="list">';
1087
1088 print '<br>';
1089 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1090 $num = count($objects);
1091 $nbtotalofrecords = '';
1092 $newcardbutton = '';
1093
1094 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1095 print_barre_liste($langs->trans("Project"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit);
1096
1097 if ($showclassifyform) {
1098 print '<table class="noborder centpercent">';
1099 print '<tr class="liste_titre"><td>';
1100 print $langs->trans("AddObjectIntoCategory").' &nbsp;';
1101 $form->selectProjects('', 'elemid');
1102 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1103 print '</tr>';
1104 print '</table>';
1105 }
1106
1107 print '<table class="noborder centpercent">'."\n";
1108 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1109
1110 if (count($objects) > 0) {
1111 $i = 0;
1112 foreach ($objects as $key => $project) {
1113 $i++;
1114 if ($i > $limit) {
1115 break;
1116 }
1117
1118 print "\t".'<tr class="oddeven">'."\n";
1119 print '<td class="nowrap tdtop">';
1120 print $project->getNomUrl(1);
1121 print "</td>\n";
1122 print '<td class="tdtop">'.$project->title."</td>\n";
1123 // Link to delete from category
1124 print '<td class="right">';
1125 if ($permission) {
1126 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 : '')."'>";
1127 //print $langs->trans("DeleteFromCat");
1128 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1129 print "</a>";
1130 }
1131 print '</td>';
1132 print "</tr>\n";
1133 }
1134 } else {
1135 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1136 }
1137 print "</table>\n";
1138
1139 print '</form>'."\n";
1140 }
1141 } else {
1142 print_barre_liste($langs->trans("Project"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'project');
1143 accessforbidden("NotEnoughPermissions", 0, 0);
1144 }
1145}
1146
1147// List of users
1148if ($type == Categorie::TYPE_USER) {
1149 if ($user->hasRight("user", "user", "read")) {
1150 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
1151 $showclassifyform = $user->hasRight("user", "user", "creer");
1152
1153 $users = $object->getObjectsInCateg($type, 0, 0, 0, 'lastname');
1154 if ($users < 0) {
1155 dol_print_error($db, $object->error, $object->errors);
1156 } else {
1158 '@phan-var-force User[] $users';
1159 // Form to add record into a category
1160 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1161 print '<input type="hidden" name="token" value="'.newToken().'">';
1162 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1163 print '<input type="hidden" name="type" value="'.$typeid.'">';
1164 print '<input type="hidden" name="id" value="'.$object->id.'">';
1165 print '<input type="hidden" name="page_y" value="">';
1166 print '<input type="hidden" name="action" value="list">';
1167
1168 print '<br>';
1169
1170 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1171 $num = count($users);
1172 $nbtotalofrecords = '';
1173 $newcardbutton = '';
1174
1175 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1176 print_barre_liste($langs->trans("Users"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'user', 0, '', '', $limit);
1177
1178 if ($showclassifyform) {
1179 print '<table class="noborder centpercent">';
1180 print '<tr class="liste_titre"><td>';
1181 $force_entity = getEntity($object->element); // So we will get same filter than the getObjectsInCateg()
1182 print img_picto('', $type, 'class="pictofixedwidth"');
1183 print $form->select_dolusers('', 'elemid', 1, null, 0, '', '', $force_entity);
1184 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1185 print '</tr>';
1186 print '</table>';
1187 }
1188
1189 print '<table class="noborder centpercent">'."\n";
1190 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Users").' <span class="badge">'.$num.'</span></td></tr>'."\n";
1191
1192 if (count($users) > 0) {
1193 // Use "$userentry" here, because "$user" is the current user
1194 foreach ($users as $key => $userentry) {
1195 print "\t".'<tr class="oddeven">'."\n";
1196 print '<td class="nowrap tdtop">';
1197 print $userentry->getNomUrl(-1);
1198 print "</td>\n";
1199 print '<td class="tdtop">'.$userentry->job."</td>\n";
1200
1201 // Link to delete from category
1202 print '<td class="right">';
1203 if ($user->hasRight('user', 'user', 'creer')) {
1204 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 : '')."'>";
1205 //print $langs->trans("DeleteFromCat");
1206 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1207 print "</a>";
1208 }
1209 print '</td>';
1210 print "</tr>\n";
1211 }
1212 } else {
1213 print '<tr class="oddeven"><td colspan="3"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1214 }
1215 print "</table>\n";
1216
1217 print '</form>'."\n";
1218 }
1219 } else {
1220 print_barre_liste($langs->trans("Users"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'user');
1221 accessforbidden("NotEnoughPermissions", 0, 0);
1222 }
1223}
1224
1225// List of warehouses
1226if ($type == Categorie::TYPE_WAREHOUSE) {
1227 if ($user->hasRight("stock", "read")) {
1228 $permission = $user->hasRight('stock', 'creer');
1229
1230 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
1231
1232 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1233 if ($objects < 0) {
1234 dol_print_error($db, $object->error, $object->errors);
1235 } else {
1237 '@phan-var-force Entrepot[] $objects';
1238 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1239 print '<input type="hidden" name="token" value="'.newToken().'">';
1240 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1241 print '<input type="hidden" name="type" value="'.$typeid.'">';
1242 print '<input type="hidden" name="id" value="'.$object->id.'">';
1243 print '<input type="hidden" name="page_y" value="">';
1244 print '<input type="hidden" name="action" value="list">';
1245
1246 print '<br>';
1247 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1248 $num = count($objects);
1249 $nbtotalofrecords = '';
1250 $newcardbutton = '';
1251
1252 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1253 print_barre_liste($langs->trans("Warehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, $newcardbutton, '', $limit);
1254
1255 print '<table class="noborder centpercent">'."\n";
1256 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1257
1258 if (count($objects) > 0) {
1259 $i = 0;
1260 foreach ($objects as $key => $warehouse) {
1261 $i++;
1262 if ($i > $limit) {
1263 break;
1264 }
1265
1266 print "\t".'<tr class="oddeven">'."\n";
1267 print '<td class="nowrap tdtop">';
1268 print $warehouse->getNomUrl(1);
1269 print "</td>\n";
1270 print '<td class="tdtop">'.$warehouse->ref."</td>\n";
1271 print '<td class="tdtop">'.$warehouse->lieu."</td>\n";
1272 // Link to delete from category
1273 print '<td class="right">';
1274 if ($permission) {
1275 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 : '')."'>";
1276 //print $langs->trans("DeleteFromCat");
1277 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1278 print "</a>";
1279 }
1280 print '</td>';
1281 print "</tr>\n";
1282 }
1283 } else {
1284 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1285 }
1286 print "</table>\n";
1287
1288 print '</form>'."\n";
1289 }
1290 } else {
1291 print_barre_liste($langs->trans("Warehouse"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'stock');
1292 accessforbidden("NotEnoughPermissions", 0, 0);
1293 }
1294}
1295
1296// List of tickets
1297if ($type == Categorie::TYPE_TICKET) {
1298 if ($user->hasRight("ticket", "read")) {
1299 $permission = $user->hasRight('categorie', 'creer');
1300 $showclassifyform = $user->hasRight('categorie', 'creer');
1301
1302 $tickets = $object->getObjectsInCateg($type, 0, $limit, $offset);
1303 if ($tickets < 0) {
1304 dol_print_error($db, $object->error, $object->errors);
1305 } else {
1307 '@phan-var-force Ticket[] $tickets';
1308 // Form to add record into a category
1309 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1310 print '<input type="hidden" name="token" value="'.newToken().'">';
1311 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1312 print '<input type="hidden" name="type" value="'.$typeid.'">';
1313 print '<input type="hidden" name="id" value="'.$object->id.'">';
1314 print '<input type="hidden" name="page_y" value="">';
1315 print '<input type="hidden" name="action" value="list">';
1316
1317 print '<br>';
1318 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1319 $num = count($tickets);
1320 $nbtotalofrecords = '';
1321 $newcardbutton = '';
1322
1323 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1324 print_barre_liste($langs->trans("Ticket"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'ticket', 0, $newcardbutton, '', $limit);
1325
1326 if ($showclassifyform) {
1327 print '<table class="noborder centpercent">';
1328 print '<tr class="liste_titre"><td>';
1329 print $langs->trans("AddTicketIntoCategory").' &nbsp;';
1330 $form->selectTickets('', 'elemid');
1331 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1332 print '</tr>';
1333 print '</table>';
1334 }
1335
1336 print '<table class="noborder centpercent">'."\n";
1337 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
1338
1339 if (count($tickets) > 0) {
1340 $i = 0;
1341 foreach ($tickets as $ticket) {
1342 $i++;
1343 if ($i > $limit) {
1344 break;
1345 }
1346
1347 print "\t".'<tr class="oddeven">'."\n";
1348 print '<td class="nowrap tdtop">';
1349 print $ticket->getNomUrl(1);
1350 print "</td>\n";
1351 print '<td class="tdtop">'.$ticket->label."</td>\n";
1352 // Link to delete from category
1353 print '<td class="right">';
1354 if ($permission) {
1355 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 : '')."'>";
1356 //print $langs->trans("DeleteFromCat");
1357 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1358 print "</a>";
1359 }
1360 print '</td>';
1361 print "</tr>\n";
1362 }
1363 } else {
1364 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1365 }
1366 print "</table>\n";
1367
1368 print '</form>'."\n";
1369 }
1370 } else {
1371 print_barre_liste($langs->trans("Ticket"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'ticket');
1372 accessforbidden("NotEnoughPermissions", 0, 0);
1373 }
1374}
1375
1376// List of Interventions
1377if ($type == Categorie::TYPE_FICHINTER) {
1378 if ($user->hasRight("fichinter", "lire")) {
1379 $permission = $user->hasRight('categorie', 'creer');
1380 $showclassifyform = $user->hasRight('categorie', 'creer');
1381
1382 $fichinters = $object->getObjectsInCateg($type, 0, $limit, $offset);
1383 if ($fichinters < 0) {
1384 dol_print_error($db, $object->error, $object->errors);
1385 } else {
1386 // Form to add record into a category
1387 if ($showclassifyform) {
1388 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formintervention.class.php';
1389 $formfichinter = new FormIntervention($db);
1390
1391 print '<br>';
1392 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1393 print '<input type="hidden" name="token" value="'.newToken().'">';
1394 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1395 print '<input type="hidden" name="type" value="'.$typeid.'">';
1396 print '<input type="hidden" name="id" value="'.$object->id.'">';
1397 print '<input type="hidden" name="action" value="addintocategory">';
1398 print '<table class="noborder centpercent">';
1399 print '<tr class="liste_titre"><td>';
1400 print $langs->trans("AddFichinterIntoCategory").' &nbsp;';
1401 print $formfichinter->select_interventions(-1, 0, 'elemid');
1402 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1403 print '</tr>';
1404 print '</table>';
1405 print '</form>';
1406 }
1407
1408 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1409 print '<input type="hidden" name="token" value="'.newToken().'">';
1410 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1411 print '<input type="hidden" name="type" value="'.$typeid.'">';
1412 print '<input type="hidden" name="id" value="'.$object->id.'">';
1413 print '<input type="hidden" name="action" value="list">';
1414
1415 print '<br>';
1416 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1417 $num = count($fichinters);
1418 $nbtotalofrecords = '';
1419 $newcardbutton = '';
1420
1421 $langs->load('interventions');
1422 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1423 print_barre_liste($langs->trans("Intervention"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_intervention', 0, $newcardbutton, '', $limit);
1424 print '<table class="noborder centpercent">'."\n";
1425 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
1426
1427 if (count($fichinters) > 0) {
1428 $i = 0;
1429 foreach ($fichinters as $fichinter) {
1430 $i++;
1431 if ($i > $limit) {
1432 break;
1433 }
1434
1435 print "\t".'<tr class="oddeven">'."\n";
1436 print '<td class="nowrap tdtop">';
1437 print $fichinter->getNomUrl(1);
1438 print "</td>\n";
1439 print '<td class="tdtop">'.$fichinter->description."</td>\n";
1440 // Link to delete from category
1441 print '<td class="right">';
1442 if ($permission) {
1443 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 : '')."'>";
1444 print $langs->trans("DeleteFromCat");
1445 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1446 print "</a>";
1447 }
1448 print '</td>';
1449 print "</tr>\n";
1450 }
1451 } else {
1452 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1453 }
1454 print "</table>\n";
1455 print '</form>'."\n";
1456 }
1457 } else {
1458 print_barre_liste($langs->trans("Intervention"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'fichinter');
1459 accessforbidden("NotEnoughPermissions", 0, 0);
1460 }
1461}
1462
1463// List of Orders
1464// The objects of the category are listed only to a user allowed to read them
1465if ($type == Categorie::TYPE_ORDER && !$user->hasRight('commande', 'lire')) {
1466 accessforbidden("NotEnoughPermissions", 0, 0);
1467}
1468if ($type == Categorie::TYPE_ORDER) {
1469 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
1470
1471 $permission = $user->rights->commande->creer;
1472
1473 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1474 if ($objects < 0) {
1475 dol_print_error($db, $object->error, $object->errors);
1476 } else {
1477 // Form to add record into a category
1478 $showclassifyform = $user->hasRight('order', 'write');
1479 if ($showclassifyform) {
1480 print '<br>';
1481 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1482 print '<input type="hidden" name="token" value="'.newToken().'">';
1483 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1484 print '<input type="hidden" name="type" value="'.$typeid.'">';
1485 print '<input type="hidden" name="id" value="'.$object->id.'">';
1486 print '<input type="hidden" name="action" value="addintocategory">';
1487 print '<table class="noborder centpercent">';
1488 print '<tr class="liste_titre"><td>';
1489 print $langs->trans("AddOrderIntoCategory").' &nbsp;';
1490 $form->selectOrder('', 'elemid');
1491 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1492 print '</tr>';
1493 print '</table>';
1494 print '</form>';
1495 }
1496
1497 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1498 print '<input type="hidden" name="token" value="'.newToken().'">';
1499 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1500 print '<input type="hidden" name="type" value="'.$typeid.'">';
1501 print '<input type="hidden" name="id" value="'.$object->id.'">';
1502 print '<input type="hidden" name="action" value="list">';
1503
1504 print '<br>';
1505 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1506 $num = count($objects);
1507 $nbtotalofrecords = '';
1508 $newcardbutton = '';
1509
1510 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1511 print_barre_liste($langs->trans("Orders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit);
1512
1513 print "<table class='noborder centpercent'>\n";
1514 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1515
1516 if (count($objects) > 0) {
1517 $i = 0;
1518 foreach ($objects as $key => $order) {
1519 $i++;
1520 if ($i > $limit) {
1521 break;
1522 }
1523
1524 print "\t".'<tr class="oddeven">'."\n";
1525 print '<td class="nowrap tdtop">';
1526 print $order->getNomUrl(1);
1527 print "</td>\n";
1528 print '<td class="tdtop">'.$order->ref."</td>\n";
1529 // Link to delete from category
1530 print '<td class="right">';
1531 if ($permission) {
1532 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$order->id."'>";
1533 print $langs->trans("DeleteFromCat");
1534 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1535 print "</a>";
1536 }
1537 print "</tr>\n";
1538 }
1539 } else {
1540 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1541 }
1542 print "</table>\n";
1543
1544 print '</form>'."\n";
1545 }
1546}
1547
1548// List of Invoices
1549if ($type == Categorie::TYPE_INVOICE && !$user->hasRight('facture', 'lire')) {
1550 accessforbidden("NotEnoughPermissions", 0, 0);
1551}
1552if ($type == Categorie::TYPE_INVOICE) {
1553 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1554
1555 $permission = $user->rights->facture->creer;
1556
1557 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1558 if ($objects < 0) {
1559 dol_print_error($db, $object->error, $object->errors);
1560 } else {
1561 // Form to add record into a category
1562 $showclassifyform = $user->hasRight('facture', 'write');
1563 if ($showclassifyform) {
1564 print '<br>';
1565 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1566 print '<input type="hidden" name="token" value="'.newToken().'">';
1567 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1568 print '<input type="hidden" name="type" value="'.$typeid.'">';
1569 print '<input type="hidden" name="id" value="'.$object->id.'">';
1570 print '<input type="hidden" name="action" value="addintocategory">';
1571 print '<table class="noborder centpercent">';
1572 print '<tr class="liste_titre"><td>';
1573 print $langs->trans("AddInvoiceIntoCategory").' &nbsp;';
1574 $form->selectInvoice(-1, '', 'elemid', 24, 0, '1', 0, 0, 0, 'maxwidth500', '', '');
1575 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1576 print '</tr>';
1577 print '</table>';
1578 print '</form>';
1579 }
1580
1581 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1582 print '<input type="hidden" name="token" value="'.newToken().'">';
1583 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1584 print '<input type="hidden" name="type" value="'.$typeid.'">';
1585 print '<input type="hidden" name="id" value="'.$object->id.'">';
1586 print '<input type="hidden" name="action" value="list">';
1587
1588 print '<br>';
1589 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1590 $num = count($objects);
1591 $nbtotalofrecords = '';
1592 $newcardbutton = '';
1593
1594 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1595 print_barre_liste($langs->trans("BillsCustomers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit);
1596
1597 print "<table class='noborder centpercent'>\n";
1598 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1599
1600 if (count($objects) > 0) {
1601 $i = 0;
1602 foreach ($objects as $key => $invoice) {
1603 $i++;
1604 if ($i > $limit) {
1605 break;
1606 }
1607
1608 print "\t".'<tr class="oddeven">'."\n";
1609 print '<td class="nowrap tdtop">';
1610 print $invoice->getNomUrl(1);
1611 print "</td>\n";
1612 print '<td class="tdtop">'.$invoice->ref."</td>\n";
1613 // Link to delete from category
1614 print '<td class="right">';
1615 if ($permission) {
1616 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$invoice->id."'>";
1617 print $langs->trans("DeleteFromCat");
1618 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1619 print "</a>";
1620 }
1621 print "</tr>\n";
1622 }
1623 } else {
1624 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1625 }
1626 print "</table>\n";
1627
1628 print '</form>'."\n";
1629 }
1630}
1631
1632// List of Supplier Orders
1633if ($type == Categorie::TYPE_SUPPLIER_ORDER && !((isModEnabled('fournisseur') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight('fournisseur', 'commande', 'lire')) || (isModEnabled('supplier_order') && $user->hasRight('supplier_order', 'lire')))) {
1634 accessforbidden("NotEnoughPermissions", 0, 0);
1635}
1636if ($type == Categorie::TYPE_SUPPLIER_ORDER) {
1637 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
1638
1639 $permission = $user->rights->fournisseur->commande->creer;
1640
1641 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1642 if ($objects < 0) {
1643 dol_print_error($db, $object->error, $object->errors);
1644 } else {
1645 // Form to add record into a category
1646 $showclassifyform = $user->hasRight('fournisseur', 'commande', 'creer');
1647 ;
1648 if ($showclassifyform) {
1649 print '<br>';
1650 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1651 print '<input type="hidden" name="token" value="'.newToken().'">';
1652 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1653 print '<input type="hidden" name="type" value="'.$typeid.'">';
1654 print '<input type="hidden" name="id" value="'.$object->id.'">';
1655 print '<input type="hidden" name="action" value="addintocategory">';
1656 print '<table class="noborder centpercent">';
1657 print '<tr class="liste_titre"><td>';
1658 print $langs->trans("AddSupplierOrderIntoCategory").' &nbsp;';
1659 $form->selectSupplierOrder('', 'elemid');
1660 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1661 print '</tr>';
1662 print '</table>';
1663 print '</form>';
1664 }
1665
1666 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1667 print '<input type="hidden" name="token" value="'.newToken().'">';
1668 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1669 print '<input type="hidden" name="type" value="'.$typeid.'">';
1670 print '<input type="hidden" name="id" value="'.$object->id.'">';
1671 print '<input type="hidden" name="action" value="list">';
1672
1673 print '<br>';
1674 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1675 $num = count($objects);
1676 $nbtotalofrecords = '';
1677 $newcardbutton = '';
1678
1679 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1680 print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_order', 0, $newcardbutton, '', $limit);
1681
1682 print "<table class='noborder centpercent'>\n";
1683 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1684
1685 if (count($objects) > 0) {
1686 $i = 0;
1687 foreach ($objects as $key => $supplier_order) {
1688 $i++;
1689 if ($i > $limit) {
1690 break;
1691 }
1692
1693 print "\t".'<tr class="oddeven">'."\n";
1694 print '<td class="nowrap tdtop">';
1695 print $supplier_order->getNomUrl(1);
1696 print "</td>\n";
1697 print '<td class="tdtop">'.$supplier_order->ref."</td>\n";
1698 // Link to delete from category
1699 print '<td class="right">';
1700 if ($permission) {
1701 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$supplier_order->id."'>";
1702 print $langs->trans("DeleteFromCat");
1703 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1704 print "</a>";
1705 }
1706 print "</tr>\n";
1707 }
1708 } else {
1709 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1710 }
1711 print "</table>\n";
1712
1713 print '</form>'."\n";
1714 }
1715}
1716
1717// List of Supplier Invoices
1718if ($type == Categorie::TYPE_SUPPLIER_INVOICE && !((isModEnabled('fournisseur') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight('fournisseur', 'facture', 'lire')) || (isModEnabled('supplier_invoice') && $user->hasRight('supplier_invoice', 'lire')))) {
1719 accessforbidden("NotEnoughPermissions", 0, 0);
1720}
1721if ($type == Categorie::TYPE_SUPPLIER_INVOICE) {
1722 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1723
1724 $permission = $user->rights->fournisseur->facture->creer;
1725
1726 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1727 if ($objects < 0) {
1728 dol_print_error($db, $object->error, $object->errors);
1729 } else {
1730 // Form to add record into a category
1731 $showclassifyform = $user->hasRight('fournisseur', 'facture', 'creer');;
1732 if ($showclassifyform) {
1733 print '<br>';
1734 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1735 print '<input type="hidden" name="token" value="'.newToken().'">';
1736 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1737 print '<input type="hidden" name="type" value="'.$typeid.'">';
1738 print '<input type="hidden" name="id" value="'.$object->id.'">';
1739 print '<input type="hidden" name="action" value="addintocategory">';
1740 print '<table class="noborder centpercent">';
1741 print '<tr class="liste_titre"><td>';
1742 print $langs->trans("AddSupplierInvoiceIntoCategory").' &nbsp;';
1743 $form->selectSupplierInvoice('', 'elemid');
1744 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1745 print '</tr>';
1746 print '</table>';
1747 print '</form>';
1748 }
1749
1750 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1751 print '<input type="hidden" name="token" value="'.newToken().'">';
1752 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1753 print '<input type="hidden" name="type" value="'.$typeid.'">';
1754 print '<input type="hidden" name="id" value="'.$object->id.'">';
1755 print '<input type="hidden" name="action" value="list">';
1756
1757 print '<br>';
1758 $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = '';
1759
1760 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1761 print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_order', 0, $newcardbutton, '', $limit);
1762
1763 print "<table class='noborder centpercent'>\n";
1764 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1765
1766 if (count($objects) > 0) {
1767 $i = 0;
1768 foreach ($objects as $key => $supplier_invoice) {
1769 $i++;
1770 if ($i > $limit) {
1771 break;
1772 }
1773
1774 print "\t".'<tr class="oddeven">'."\n";
1775 print '<td class="nowrap tdtop">';
1776 print $supplier_invoice->getNomUrl(1);
1777 print "</td>\n";
1778 print '<td class="tdtop">'.$supplier_invoice->ref."</td>\n";
1779 // Link to delete from category
1780 print '<td class="right">';
1781 if ($permission) {
1782 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$supplier_invoice->id."'>";
1783 print $langs->trans("DeleteFromCat");
1784 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1785 print "</a>";
1786 }
1787 print "</tr>\n";
1788 }
1789 } else {
1790 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
1791 }
1792 print "</table>\n";
1793
1794 print '</form>'."\n";
1795 }
1796}
1797
1798// Note that $action and $object may have been modified by some hooks
1799$parameters = array('type' => $type, 'id' => $id, 'label' => $label);
1800$reshook = $hookmanager->executeHooks('addMoreCategoriesList', $parameters, $object, $action);
1801
1802// End of page
1803llxFooter();
1804$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.