dolibarr 21.0.0-beta
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) 2024 MDW <mdeweerd@users.noreply.github.com>
10 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
11 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
12 * Copyright (C) 2023-2024 Charlene Benke <charlene@patas-monkey.com>
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <https://www.gnu.org/licenses/>.
26 */
27
34// Load Dolibarr environment
35require '../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
40
49// Load translation files required by the page
50$langs->loadLangs(array("categories", "compta"));
51
52$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
53$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
54$show_files = GETPOSTINT('show_files'); // Show files area generated by bulk actions ?
55$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
56$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
57$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
58$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'categorylist'; // To manage different context of search
59$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
60$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
61
62$id = GETPOSTINT('id');
63$label = GETPOST('label', 'alpha');
64$removeelem = GETPOSTINT('removeelem');
65$elemid = GETPOSTINT('elemid');
66
67if (GETPOST('addintocategory')) {
68 $action = 'addintocategory';
69}
70
71
72// Load variable for pagination
73$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
74$sortfield = GETPOST('sortfield', 'aZ09comma');
75$sortorder = GETPOST('sortorder', 'aZ09comma');
76$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
77if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
78 $page = 0;
79} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
80$offset = $limit * $page;
81$pageprev = $page - 1;
82$pagenext = $page + 1;
83
84if ($id == "" && $label == "") {
85 dol_print_error(null, 'Missing parameter id');
86 exit();
87}
88
89// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array
90$hookmanager->initHooks(array('categorycard', 'globalcard'));
91
92// Security check
93$result = restrictedArea($user, 'categorie', $id, '&category');
94
95$object = new Categorie($db);
96$result = $object->fetch($id, $label);
97if ($result <= 0) {
98 dol_print_error($db, $object->error);
99 exit;
100}
101
102$type = $object->type;
103if (is_numeric($type)) {
104 $type = Categorie::$MAP_ID_TO_CODE[(int) $type]; // For backward compatibility
105}
106
107$extrafields = new ExtraFields($db);
108$extrafields->fetch_name_optionals_label($object->table_element);
109
110/*
111 * Actions
112 */
113
114if ($confirm == 'no') {
115 if ($backtopage) {
116 header("Location: ".$backtopage);
117 exit;
118 }
119}
120$parameters = array('type' => $type, 'id' => $id, 'label' => $label);
121$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
122// Remove element from category
123if ($id > 0 && $removeelem > 0 && $action == 'unlink') { // Test on permission not required here. Done later according to type of object.
124 $tmpobject = null;
125 $elementtype = '';
126 if ($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
127 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
128 $tmpobject = new Product($db);
129 $result = $tmpobject->fetch($removeelem);
130 $elementtype = 'product';
131 } elseif ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) {
132 $tmpobject = new Societe($db);
133 $result = $tmpobject->fetch($removeelem);
134 $elementtype = 'supplier';
135 } elseif ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) {
136 $tmpobject = new Societe($db);
137 $result = $tmpobject->fetch($removeelem);
138 $elementtype = 'customer';
139 } elseif ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) {
140 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
141 $tmpobject = new Adherent($db);
142 $result = $tmpobject->fetch($removeelem);
143 $elementtype = 'member';
144 } elseif ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) {
145 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
146 $tmpobject = new Contact($db);
147 $result = $tmpobject->fetch($removeelem);
148 $elementtype = 'contact';
149 } elseif ($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer')) {
150 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
151 $tmpobject = new Account($db);
152 $result = $tmpobject->fetch($removeelem);
153 $elementtype = 'account';
154 } elseif ($type == Categorie::TYPE_PROJECT && $user->hasRight('projet', 'creer')) {
155 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
156 $tmpobject = new Project($db);
157 $result = $tmpobject->fetch($removeelem);
158 $elementtype = 'project';
159 } elseif ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) {
160 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
161 $tmpobject = new User($db);
162 $result = $tmpobject->fetch($removeelem);
163 $elementtype = 'user';
164 } elseif ($type == Categorie::TYPE_TICKET && $user->hasRight('ticket', 'write')) {
165 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
166 $tmpobject = new Ticket($db);
167 $result = $tmpobject->fetch($removeelem);
168 $elementtype = 'ticket';
169 } elseif ($type == Categorie::TYPE_FICHINTER && $user->hasRight('ficheinter', 'write')) {
170 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
171 $tmpobject = new Fichinter($db);
172 $result = $tmpobject->fetch($removeelem);
173 $elementtype = 'fichinter';
174 } else {
175 dol_print_error(null, "Not supported value of type = ".$type);
176 }
177
178 $result = $object->del_type($tmpobject, $elementtype);
179 if ($result < 0) {
180 dol_print_error(null, $object->error);
181 }
182}
183
184if ($user->hasRight('categorie', 'supprimer') && $action == 'confirm_delete' && $confirm == 'yes') {
185 if ($object->delete($user) >= 0) {
186 if ($backtopage) {
187 header("Location: ".$backtopage);
188 exit;
189 } else {
190 header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type);
191 exit;
192 }
193 } else {
194 setEventMessages($object->error, $object->errors, 'errors');
195 }
196}
197
198if ($elemid && $action == 'addintocategory') { // Test on permission not required here. Done just after depending on object type
199 $newobject = null;
200 $elementtype = '';
201 if ($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
202 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
203 $newobject = new Product($db);
204 $elementtype = 'product';
205 } elseif ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) {
206 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
207 $newobject = new Societe($db);
208 $elementtype = 'customer';
209 } elseif ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) {
210 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
211 $newobject = new Societe($db);
212 $elementtype = 'supplier';
213 } elseif ($type == Categorie::TYPE_TICKET && $user->hasRight('ticket', 'write')) {
214 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
215 $newobject = new Ticket($db);
216 $elementtype = 'ticket';
217 } elseif ($type == Categorie::TYPE_FICHINTER && $user->hasRight('ficheinter', 'write')) {
218 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
219 $newobject = new Fichinter($db);
220 $elementtype = 'fichinter';
221 } elseif ($type == Categorie::TYPE_PROJECT && $user->hasRight('projet', 'creer')) {
222 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
223 $newobject = new Project($db);
224 $elementtype = 'project';
225 } elseif ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) {
226 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
227 $newobject = new Adherent($db);
228 $elementtype = 'member';
229 } elseif ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) {
230 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
231 $newobject = new Contact($db);
232 $elementtype = 'contact';
233 } elseif ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) {
234 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
235 $newobject = new User($db);
236 $elementtype = 'user';
237 } elseif ($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer')) {
238 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
239 $newobject = new Account($db);
240 $elementtype = 'bank_account';
241 } else {
242 dol_print_error(null, "Not supported value of type = ".$type);
243 }
244 if ($newobject !== null) {
245 $result = $newobject->fetch($elemid);
246 }
247
248 // Add into category
249 $result = $object->add_type($newobject, $elementtype);
250 if ($result >= 0) {
251 setEventMessages($langs->trans("WasAddedSuccessfully", $newobject->ref), null, 'mesgs');
252 } else {
253 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
254 setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
255 } else {
256 setEventMessages($object->error, $object->errors, 'errors');
257 }
258 }
259}
260
261
262/*
263 * View
264 */
265
266$form = new Form($db);
267$formother = new FormOther($db);
268
269$arrayofjs = array(
270 '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
271 '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'
272);
273$arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
274
275$help_url = '';
276
277llxHeader("", $langs->trans("Categories"), $help_url, '', 0, 0, $arrayofjs, $arrayofcss);
278
279$title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
280
281$head = categories_prepare_head($object, $type);
282print dol_get_fiche_head($head, 'card', $langs->trans($title), -1, 'category');
283
284$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.urlencode($type));
285$linkback = '<a href="'.dol_sanitizeUrl($backtolist).'">'.$langs->trans("BackToList").'</a>';
286$object->next_prev_filter = 'type:=:'.((int) $object->type);
287$object->ref = $object->label;
288$morehtmlref = '<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.urlencode($type).'">'.$langs->trans("Root").'</a> >> ';
289$ways = $object->print_all_ways(" &gt;&gt; ", '', 1);
290foreach ($ways as $way) {
291 $morehtmlref .= $way."<br>\n";
292}
293$morehtmlref .= '</div>';
294
295dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'label', $morehtmlref, '&type='.urlencode($type), 0, '', '', 1);
296
297
298// Confirmation of deletion
299if ($action == 'delete') {
300 if ($backtopage) {
301 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&backtopage='.urlencode($backtopage), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 2);
302 } else {
303 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type, $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1);
304 }
305}
306
307print '<br>';
308
309print '<div class="fichecenter">';
310print '<div class="underbanner clearboth"></div>';
311print '<table class="border centpercent tableforfield">';
312
313// Description
314print '<tr><td class="titlefield notopnoleft tdtop">';
315print $langs->trans("Description").'</td><td>';
316print dol_htmlentitiesbr($object->description);
317print '</td></tr>';
318
319// Color
320print '<tr><td class="notopnoleft">';
321print $langs->trans("Color").'</td><td>';
322print $formother->showColor($object->color);
323print '</td></tr>';
324
325// Position
326print '<tr><td class="titlefield notopnoleft">';
327print $langs->trans("Position").'</td><td>';
328print $object->position;
329print '</td></tr>';
330
331// Other attributes
332include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
333
334print '</table>';
335print '</div>';
336
337print dol_get_fiche_end();
338
339
340/*
341 * Boutons actions
342 */
343
344print "<div class='tabsAction'>\n";
345$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
346if ($reshook < 0) {
347 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
348}
349if (empty($reshook)) {
350 if ($user->hasRight('categorie', 'creer')) {
351 $socid = ($object->socid ? "&socid=".$object->socid : "");
352 print '<a class="butAction" href="edit.php?id='.$object->id.$socid.'&type='.$type.'">'.$langs->trans("Modify").'</a>';
353 }
354
355 if ($user->hasRight('categorie', 'supprimer')) {
356 print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id.'&type='.$type.'&backtolist='.urlencode($backtolist).'">'.$langs->trans("Delete").'</a>';
357 }
358}
359
360print "</div>";
361
362$newcardbutton = '';
363if ($user->hasRight('categorie', 'creer')) {
364 $link = DOL_URL_ROOT.'/categories/card.php';
365 $link .= '?action=create';
366 $link .= '&type='.$type;
367 $link .= '&catorigin='.$object->id;
368 $link .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.'&id='.$id);
369
370 $newcardbutton = '<div class="right">';
371 $newcardbutton .= dolGetButtonTitle($langs->trans('NewCategory'), '', 'fa fa-plus-circle', $link);
372 $newcardbutton .= '</div>';
373}
374
375
376/*
377 * Sub-category tree view of this category
378 */
379
380print '<div class="fichecenter">';
381
382print load_fiche_titre($langs->trans("SubCats"), $newcardbutton, 'object_category');
383
384print '<table class="liste nohover noborder centpercent borderbottom">';
385
386print '<tr class="liste_titre">';
387print '<td>'.$langs->trans("SubCats").'</td>';
388print '<td></td>';
389print '<td class="right">';
390
391if (!empty($conf->use_javascript_ajax)) {
392 print '<div id="iddivjstreecontrol">';
393 print '<a class="notasortlink" href="#">'.img_picto('', 'folder').' '.$langs->trans("UndoExpandAll").'</a>';
394 print " | ";
395 print '<a class="notasortlink" href="#">'.img_picto('', 'folder-open').' '.$langs->trans("ExpandAll").'</a>';
396 print '</div>';
397}
398
399print '</td>';
400print '</tr>';
401
402$cats = $object->get_filles();
403if ($cats < 0) {
404 dol_print_error($db, $object->error, $object->errors);
405} elseif (count($cats) < 1) {
406 print '<tr class="oddeven nobottom">';
407 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("NoSubCat").'</span></td>';
408 print '</tr>';
409} else {
410 $categstatic = new Categorie($db);
411
412 $fulltree = $categstatic->get_full_arbo($type, $object->id, 1);
413
414 // Load possible missing includes
415 if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) {
416 if ($type == Categorie::TYPE_MEMBER) {
417 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
418 }
419 if ($type == Categorie::TYPE_ACCOUNT) {
420 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
421 }
422 if ($type == Categorie::TYPE_PROJECT) {
423 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
424 }
425 if ($type == Categorie::TYPE_USER) {
426 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
427 }
428 }
429
430 // Define data (format for treeview)
431 $data = array();
432 $data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => 'racine', 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => '');
433 foreach ($fulltree as $key => $val) {
434 $categstatic->id = $val['id'];
435 $categstatic->ref = $val['label'];
436 $categstatic->color = $val['color'];
437 $categstatic->type = $type;
438 //$desc = dol_htmlcleanlastbr($val['description']);
439
440 $counter = '';
441 if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) {
442 // we need only a count of the elements, so it is enough to consume only the id's from the database
443 $elements = $categstatic->getObjectsInCateg($type, 1);
444
445 $counter = "<td class='left' width='40px;'>".(is_array($elements) ? count($elements) : '0')."</td>";
446 }
447
448 if ($categstatic->color) {
449 $stylecolor = ' style="background: #'.sprintf("%06s", $categstatic->color).';"';
450 } else {
451 $stylecolor = ' style="background: #bbb;"';
452 }
453 $li = $categstatic->getNomUrl(1, '', 60, '&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.((int) $id).'&type='.urlencode($type)), 0);
454
455 $entry = '<table class="nobordernopadding centpercent">';
456 $entry .= '<tr>';
457
458 $entry .= '<td>';
459 $entry .= '<span class="noborderoncategories" '.$stylecolor.'>'.$li.'</span>';
460 $entry .= '</td>';
461
462 $entry .= $counter;
463
464 $entry .= '<td class="right" width="20px;">';
465 $entry .= '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.$type.'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type).'">'.img_view().'</a>';
466 $entry .= '</td>';
467 $entry .= '<td class="right" width="20px;">';
468 $entry .= '<a class="editfielda" href="'.DOL_URL_ROOT.'/categories/edit.php?id='.$val['id'].'&type='.$type.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type).'">'.img_edit().'</a>';
469 $entry .= '</td>';
470 $entry .= '<td class="right" width="20px;">';
471 $entry .= '<a class="deletefilelink" href="'.DOL_URL_ROOT.'/categories/viewcat.php?action=delete&token='.newToken().'&id='.$val['id'].'&type='.$type.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type).'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type).'">'.img_delete().'</a>';
472 $entry .= '</td>';
473
474 $entry .= '</tr>';
475 $entry .= '</table>';
476
477 $data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry);
478 }
479
480 $nbofentries = (count($data) - 1);
481 if ($nbofentries > 0) {
482 require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
483 print '<tr class="pair">';
484 print '<td colspan="3">';
485
486 // $data[0] is the current shown category, to don'T show the current category use $data[1] instead
487 tree_recur($data, $data[1], 0);
488
489 print '</td>';
490 print '</tr>';
491 } else {
492 print '<tr class="pair">';
493 print '<td colspan="3">';
494 print '<table class="nobordernopadding">';
495
496 print '<tr class="nobordernopadding">';
497 print '<td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
498 print '<td class="valignmiddle"><span class="opacitymedium">'.$langs->trans("NoCategoryYet").'</span></td>';
499 print '<td>&nbsp;</td>';
500 print '</tr>';
501
502 print '</table>';
503 print '</td>';
504 print '</tr>';
505 }
506}
507
508print "</table>";
509print "</div>";
510
511// List of mass actions available
512$arrayofmassactions = array(
513 //'validate'=>$langs->trans("Validate"),
514 //'generate_doc'=>$langs->trans("ReGeneratePDF"),
515 //'builddoc'=>$langs->trans("PDFMerge"),
516 //'presend'=>$langs->trans("SendByMail"),
517);
518$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
519
520$typeid = $type;
521
522
523// List of products or services (type is type of category)
524if ($type == Categorie::TYPE_PRODUCT) {
525 if ($user->hasRight("product", "read") || $user->hasRight("service", "read")) {
526 $permission = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'));
527 $showclassifyform = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'));
528
529 $prods = $object->getObjectsInCateg($type, 0, $limit, $offset);
530 if ($prods < 0) {
531 dol_print_error($db, $object->error, $object->errors);
532 } else {
534 '@phan-var-force Product[] $prods';
535 // Form to add record into the category
536 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
537 print '<input type="hidden" name="token" value="'.newToken().'">';
538 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
539 print '<input type="hidden" name="type" value="'.$typeid.'">';
540 print '<input type="hidden" name="id" value="'.$object->id.'">';
541 print '<input type="hidden" name="page_y" value="">';
542 print '<input type="hidden" name="action" value="list">';
543
544 print '<br>';
545 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
546 $num = count($prods);
547 $nbtotalofrecords = '';
548 $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'));
549
550 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
551 print_barre_liste($langs->trans("ProductsAndServices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit);
552
553 if ($showclassifyform) {
554 print '<table class="noborder centpercent">';
555 print '<tr class="liste_titre"><td>';
556 print $langs->trans("AddProductServiceIntoCategory").' &nbsp;';
557 $form->select_produits(0, 'elemid', '', 0, 0, -1, 2, '', 1, array(), 0, 1, 0, '', 0, '', null);
558 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
559 print '</tr>';
560 print '</table>';
561 }
562
563 print '<table class="noborder centpercent">'."\n";
564 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
565
566 if (count($prods) > 0) {
567 $i = 0;
568 foreach ($prods as $prod) {
569 $i++;
570 if ($i > $limit) {
571 break;
572 }
573
574 print "\t".'<tr class="oddeven">'."\n";
575 print '<td class="nowrap" valign="top">';
576 print $prod->getNomUrl(1);
577 print "</td>\n";
578 print '<td class="tdtop">'.$prod->label."</td>\n";
579 // Link to delete from category
580 print '<td class="right">';
581 if ($permission) {
582 print '<a class="reposition" href= "'.$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".((int) $object->id)."&type=".urlencode($typeid)."&action=unlink&token=".newToken()."&removeelem=".$prod->id.'">';
583 //print $langs->trans("DeleteFromCat");
584 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
585 print "</a>";
586 }
587 print '</td>';
588 print "</tr>\n";
589 }
590 } else {
591 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
592 }
593 print "</table>\n";
594
595 print '</form>'."\n";
596 }
597 } else {
598 print_barre_liste($langs->trans("ProductsAndServices"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'products');
599 accessforbidden("NotEnoughPermissions", 0, 0);
600 }
601}
602
603// List of customers
604if ($type == Categorie::TYPE_CUSTOMER) {
605 if ($user->hasRight("societe", "read")) {
606 $permission = $user->hasRight('societe', 'creer');
607 $showclassifyform = $user->hasRight('societe', 'creer');
608
609 $socs = $object->getObjectsInCateg($type, 0, $limit, $offset);
610 if ($socs < 0) {
611 dol_print_error($db, $object->error, $object->errors);
612 } else {
614 '@phan-var-force Societe[] $socs';
615 // Form to add record into a category
616 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
617 print '<input type="hidden" name="token" value="'.newToken().'">';
618 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
619 print '<input type="hidden" name="type" value="'.$typeid.'">';
620 print '<input type="hidden" name="id" value="'.$object->id.'">';
621 print '<input type="hidden" name="action" value="list">';
622 print '<input type="hidden" name="page_y" value="">';
623
624 print '<br>';
625 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
626 $num = count($socs);
627 $nbtotalofrecords = '';
628 $newcardbutton = dolGetButtonTitle($langs->trans("AddThirdParty"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&client=3&custcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->hasRight('societe', 'creer'));
629
630 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
631 print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
632
633 if ($showclassifyform) {
634 print '<table class="noborder centpercent">';
635 print '<tr class="liste_titre"><td>';
636 print $langs->trans("AddCustomerIntoCategory").' &nbsp;';
637 $filter = '(s.client:IN:1,2,3)';
638 print $form->select_company('', 'elemid', $filter);
639 print '<input type="submit" class="reposition button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
640 print '</tr>';
641 print '</table>';
642 }
643
644 print '<table class="noborder centpercent">'."\n";
645 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Name").'</td></tr>'."\n";
646
647 if (count($socs) > 0) {
648 $i = 0;
649 foreach ($socs as $key => $soc) {
650 $i++;
651 if ($i > $limit) {
652 break;
653 }
654
655 print "\t".'<tr class="oddeven">'."\n";
656 print '<td class="nowrap tdtop tdoverflowmax250">';
657 print $soc->getNomUrl(1);
658 print "</td>\n";
659 // Link to delete from category
660 print '<td class="right">';
661 if ($permission) {
662 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$soc->id."'>";
663 //print $langs->trans("DeleteFromCat");
664 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
665 print "</a>";
666 }
667 print '</td>';
668 print "</tr>\n";
669 }
670 } else {
671 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
672 }
673 print "</table>\n";
674
675 print '</form>'."\n";
676 }
677 } else {
678 print_barre_liste($langs->trans("Customers"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'companies');
679 accessforbidden("NotEnoughPermissions", 0, 0);
680 }
681}
682
683// List of suppliers
684if ($type == Categorie::TYPE_SUPPLIER) {
685 if ($user->hasRight("fournisseur", "read")) {
686 $permission = $user->hasRight('societe', 'creer');
687 $showclassifyform = $user->hasRight('societe', 'creer');
688
689 $socs = $object->getObjectsInCateg($type, 0, $limit, $offset);
690
691 if ($socs < 0) {
692 dol_print_error($db, $object->error, $object->errors);
693 } else {
695 '@phan-var-force Fournisseur[] $socs';
696 // Form to add record into a category
697 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
698 print '<input type="hidden" name="token" value="'.newToken().'">';
699 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
700 print '<input type="hidden" name="type" value="'.$typeid.'">';
701 print '<input type="hidden" name="id" value="'.$object->id.'">';
702 print '<input type="hidden" name="page_y" value="">';
703 print '<input type="hidden" name="action" value="list">';
704
705 print '<br>';
706 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
707 $num = count($socs);
708 $nbtotalofrecords = '';
709 $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'));
710
711 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
712 print_barre_liste($langs->trans("Suppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit);
713
714 if ($showclassifyform) {
715 print '<table class="noborder centpercent">';
716 print '<tr class="liste_titre"><td>';
717 print $langs->trans("AddSupplierIntoCategory").' &nbsp;';
718 $filter = '(s.fournisseur:=:1)';
719 print $form->select_company('', 'elemid', $filter);
720 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
721 print '</tr>';
722 print '</table>';
723 }
724
725 print '<table class="noborder centpercent">'."\n";
726 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Name")."</td></tr>\n";
727
728 if (count($socs) > 0) {
729 $i = 0;
730 foreach ($socs as $soc) {
731 $i++;
732 if ($i > $limit) {
733 break;
734 }
735
736 print "\t".'<tr class="oddeven">'."\n";
737 print '<td class="nowrap tdtop">';
738 print $soc->getNomUrl(1);
739 print "</td>\n";
740 // Link to delete from category
741 print '<td class="right">';
742 if ($permission) {
743 print '<a class="reposition" href="'.$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$soc->id.($limit ? '&limit='.$limit : '').'">';
744 //print $langs->trans("DeleteFromCat");
745 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
746 print "</a>";
747 }
748 print '</td>';
749
750 print "</tr>\n";
751 }
752 } else {
753 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
754 }
755 print "</table>\n";
756
757 print '</form>'."\n";
758 }
759 } else {
760 print_barre_liste($langs->trans("Suppliers"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'companies');
761 accessforbidden("NotEnoughPermissions", 0, 0);
762 }
763}
764
765// List of members
766if ($type == Categorie::TYPE_MEMBER) {
767 if ($user->hasRight("adherent", "read")) {
768 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
769
770 $permission = $user->hasRight('adherent', 'creer');
771 $showclassifyform = $user->hasRight('adherent', 'creer');
772
773 $members = $object->getObjectsInCateg($type, 0, $limit, $offset);
774 if ($members < 0) {
775 dol_print_error($db, $object->error, $object->errors);
776 } else {
778 '@phan-var-force Adherent[] $members';
779 // Form to add record into a category
780 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
781 print '<input type="hidden" name="token" value="'.newToken().'">';
782 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
783 print '<input type="hidden" name="type" value="'.$typeid.'">';
784 print '<input type="hidden" name="id" value="'.$object->id.'">';
785 print '<input type="hidden" name="page_y" value="">';
786 print '<input type="hidden" name="action" value="list">';
787
788 print '<br>';
789 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
790 $num = count($members);
791 $nbtotalofrecords = '';
792 $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'));
793
794 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
795 print_barre_liste($langs->trans("Member"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit);
796
797 if ($showclassifyform) {
798 print '<table class="noborder centpercent">';
799 print '<tr class="liste_titre"><td>';
800 print $langs->trans("AssignCategoryTo").' &nbsp;';
801 print $form->selectMembers('', 'elemid');
802 print '<input type="submit" class="button buttongen" value="'.$langs->trans("Save").'"></td>';
803 print '</tr>';
804 print '</table>';
805 }
806
807 print '<table class="noborder centpercent">'."\n";
808 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Name").'</td></tr>'."\n";
809
810 if (count($members) > 0) {
811 $i = 0;
812 foreach ($members as $key => $member) {
813 $i++;
814 if ($i > $limit) {
815 break;
816 }
817
818 print "\t".'<tr class="oddeven">'."\n";
819 print '<td class="nowrap tdtop">';
820 $member->ref = $member->login;
821 print $member->getNomUrl(1, 0);
822 print "</td>\n";
823 print '<td class="tdtop">'.$member->lastname."</td>\n";
824 print '<td class="tdtop">'.$member->firstname."</td>\n";
825 // Link to delete from category
826 print '<td class="right">';
827 if ($permission) {
828 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$member->id."'>";
829 //print $langs->trans("DeleteFromCat");
830 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
831 print "</a>";
832 }
833 print '</td>';
834 print "</tr>\n";
835 }
836 } else {
837 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
838 }
839 print "</table>\n";
840
841 print '</form>'."\n";
842 }
843 } else {
844 print_barre_liste($langs->trans("Member"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'members');
845 accessforbidden("NotEnoughPermissions", 0, 0);
846 }
847}
848
849// List of contacts
850if ($type == Categorie::TYPE_CONTACT) {
851 if ($user->hasRight("societe", "read")) {
852 $permission = $user->hasRight('societe', 'creer');
853 $showclassifyform = $user->hasRight('societe', 'creer');
854
855 $contacts = $object->getObjectsInCateg($type, 0, $limit, $offset);
856 if (is_numeric($contacts) && $contacts < 0) {
857 dol_print_error($db, $object->error, $object->errors);
858 } else {
860 '@phan-var-force Contact[] $contacts';
861 // Form to add record into a category
862 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
863 print '<input type="hidden" name="token" value="'.newToken().'">';
864 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
865 print '<input type="hidden" name="type" value="'.$typeid.'">';
866 print '<input type="hidden" name="id" value="'.$object->id.'">';
867 print '<input type="hidden" name="page_y" value="">';
868 print '<input type="hidden" name="action" value="list">';
869
870 print '<br>';
871 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
872 $num = count($contacts);
873 $nbtotalofrecords = '';
874 $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'));
875
876 $objsoc = new Societe($db);
877
878 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
879 print_barre_liste($langs->trans("Contact"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contact', 0, $newcardbutton, '', $limit);
880
881 if ($showclassifyform) {
882 print '<table class="noborder centpercent">';
883 print '<tr class="liste_titre"><td>';
884 print $langs->trans("AssignCategoryTo").' &nbsp;';
885 print $form->select_contact(0, '', 'elemid', '', '', '', 0, 'maxwidth300 widthcentpercentminusx');
886 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
887 print '</tr>';
888 print '</table>';
889 }
890
891 print '<table class="noborder centpercent">'."\n";
892 print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Ref").'</td></tr>'."\n";
893
894 if (is_array($contacts) && count($contacts) > 0) {
895 $i = 0;
896 foreach ($contacts as $key => $contact) {
897 $i++;
898 if ($i > $limit) {
899 break;
900 }
901
902 print "\t".'<tr class="oddeven">'."\n";
903 print '<td class="nowrap tdtop">';
904 print $contact->getNomUrl(1, 'category');
905 if ($contact->socid > 0) {
906 $objsoc->fetch($contact->socid);
907 print ' - ';
908 print $objsoc->getNomUrl(1, 'contact');
909 }
910 print "</td>\n";
911 // Link to delete from category
912 print '<td class="right">';
913 if ($permission) {
914 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$contact->id."'>";
915 //print $langs->trans("DeleteFromCat");
916 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
917 print "</a>";
918 }
919 print '</td>';
920 print "</tr>\n";
921 }
922 } else {
923 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
924 }
925 print "</table>\n";
926
927 print '</form>'."\n";
928 }
929 } else {
930 print_barre_liste($langs->trans("Contact"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'contact');
931 accessforbidden("NotEnoughPermissions", 0, 0);
932 }
933}
934
935// List of bank accounts
936if ($type == Categorie::TYPE_ACCOUNT) {
937 if ($user->hasRight("banque", "read")) {
938 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
939
940 $permission = $user->hasRight('banque', 'creer');
941 $showclassifyform = $user->hasRight('banque', 'creer');
942
943 $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset);
944 if ($accounts < 0) {
945 dol_print_error($db, $object->error, $object->errors);
946 } else {
948 '@phan-var-force Account[] $accounts';
949 // Form to add record into a category
950 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
951 print '<input type="hidden" name="token" value="'.newToken().'">';
952 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
953 print '<input type="hidden" name="type" value="'.$typeid.'">';
954 print '<input type="hidden" name="id" value="'.$object->id.'">';
955 print '<input type="hidden" name="page_y" value="">';
956 print '<input type="hidden" name="action" value="list">';
957
958 print '<br>';
959 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
960 $num = count($accounts);
961 $nbtotalofrecords = '';
962 $newcardbutton = '';
963
964 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
965 print_barre_liste($langs->trans("Account"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit);
966
967 if ($showclassifyform) {
968 print '<table class="noborder centpercent">';
969 print '<tr class="liste_titre"><td>';
970 print $langs->trans("AddObjectIntoCategory").' &nbsp;';
971 print $form->select_comptes('', 'elemid', 0, '', 0, '', 0, '', 1);
972 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
973 print '</tr>';
974 print '</table>';
975 }
976
977 print '<table class="noborder centpercent">'."\n";
978 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
979
980 if (count($accounts) > 0) {
981 $i = 0;
982 foreach ($accounts as $key => $account) {
983 $i++;
984 if ($i > $limit) {
985 break;
986 }
987
988 print "\t".'<tr class="oddeven">'."\n";
989 print '<td class="nowrap tdtop">';
990 print $account->getNomUrl(1, 0);
991 print "</td>\n";
992 print '<td class="tdtop">'.$account->bank."</td>\n";
993 print '<td class="tdtop">'.$account->number."</td>\n";
994 // Link to delete from category
995 print '<td class="right">';
996 if ($permission) {
997 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$account->id."'>";
998 //print $langs->trans("DeleteFromCat");
999 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1000 print "</a>";
1001 }
1002 print '</td>';
1003 print "</tr>\n";
1004 }
1005 } else {
1006 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1007 }
1008 print "</table>\n";
1009
1010 print '</form>'."\n";
1011 }
1012 } else {
1013 print_barre_liste($langs->trans("Banque"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'bank');
1014 accessforbidden("NotEnoughPermissions", 0, 0);
1015 }
1016}
1017
1018// List of Project
1019if ($type == Categorie::TYPE_PROJECT) {
1020 if ($user->hasRight("project", "read")) {
1021 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
1022
1023 $permission = $user->hasRight('projet', 'creer');
1024 $showclassifyform = $user->hasRight('projet', 'creer');
1025
1026 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1027 if ($objects < 0) {
1028 dol_print_error($db, $object->error, $object->errors);
1029 } else {
1031 '@phan-var-force Project $object';
1032 // Form to add record into a category
1033 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1034 print '<input type="hidden" name="token" value="'.newToken().'">';
1035 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1036 print '<input type="hidden" name="type" value="'.$typeid.'">';
1037 print '<input type="hidden" name="id" value="'.$object->id.'">';
1038 print '<input type="hidden" name="page_y" value="">';
1039 print '<input type="hidden" name="action" value="list">';
1040
1041 print '<br>';
1042 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1043 $num = count($objects);
1044 $nbtotalofrecords = '';
1045 $newcardbutton = '';
1046
1047 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1048 print_barre_liste($langs->trans("Project"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit);
1049
1050 if ($showclassifyform) {
1051 print '<table class="noborder centpercent">';
1052 print '<tr class="liste_titre"><td>';
1053 print $langs->trans("AddObjectIntoCategory").' &nbsp;';
1054 $form->selectProjects('', 'elemid');
1055 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1056 print '</tr>';
1057 print '</table>';
1058 }
1059
1060 print '<table class="noborder centpercent">'."\n";
1061 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1062
1063 if (count($objects) > 0) {
1064 $i = 0;
1065 foreach ($objects as $key => $project) {
1066 $i++;
1067 if ($i > $limit) {
1068 break;
1069 }
1070
1071 print "\t".'<tr class="oddeven">'."\n";
1072 print '<td class="nowrap tdtop">';
1073 print $project->getNomUrl(1);
1074 print "</td>\n";
1075 print '<td class="tdtop">'.$project->title."</td>\n";
1076 // Link to delete from category
1077 print '<td class="right">';
1078 if ($permission) {
1079 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$project->id."'>";
1080 //print $langs->trans("DeleteFromCat");
1081 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1082 print "</a>";
1083 }
1084 print '</td>';
1085 print "</tr>\n";
1086 }
1087 } else {
1088 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1089 }
1090 print "</table>\n";
1091
1092 print '</form>'."\n";
1093 }
1094 } else {
1095 print_barre_liste($langs->trans("Project"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'project');
1096 accessforbidden("NotEnoughPermissions", 0, 0);
1097 }
1098}
1099
1100// List of users
1101if ($type == Categorie::TYPE_USER) {
1102 if ($user->hasRight("user", "user", "read")) {
1103 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
1104 $showclassifyform = $user->hasRight("user", "user", "creer");
1105
1106 $users = $object->getObjectsInCateg($type);
1107 if ($users < 0) {
1108 dol_print_error($db, $object->error, $object->errors);
1109 } else {
1111 '@phan-var-force User[] $users';
1112 // Form to add record into a category
1113 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1114 print '<input type="hidden" name="token" value="'.newToken().'">';
1115 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1116 print '<input type="hidden" name="type" value="'.$typeid.'">';
1117 print '<input type="hidden" name="id" value="'.$object->id.'">';
1118 print '<input type="hidden" name="page_y" value="">';
1119 print '<input type="hidden" name="action" value="list">';
1120
1121 print '<br>';
1122
1123 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1124 $num = count($users);
1125 $nbtotalofrecords = '';
1126 $newcardbutton = '';
1127
1128 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1129 print_barre_liste($langs->trans("Users"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'user', 0, '', '', $limit);
1130
1131 if ($showclassifyform) {
1132 print '<table class="noborder centpercent">';
1133 print '<tr class="liste_titre"><td>';
1134 $force_entity = getEntity($object->element); // So we will get same filter than the getObjectsInCateg()
1135 print img_picto('', $type, 'class="pictofixedwidth"');
1136 print $form->select_dolusers('', 'elemid', 1, null, 0, '', '', $force_entity);
1137 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1138 print '</tr>';
1139 print '</table>';
1140 }
1141
1142 print '<table class="noborder centpercent">'."\n";
1143 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Users").' <span class="badge">'.$num.'</span></td></tr>'."\n";
1144
1145 if (count($users) > 0) {
1146 // Use "$userentry" here, because "$user" is the current user
1147 foreach ($users as $key => $userentry) {
1148 print "\t".'<tr class="oddeven">'."\n";
1149 print '<td class="nowrap tdtop">';
1150 print $userentry->getNomUrl(-1);
1151 print "</td>\n";
1152 print '<td class="tdtop">'.$userentry->job."</td>\n";
1153
1154 // Link to delete from category
1155 print '<td class="right">';
1156 if ($user->hasRight('user', 'user', 'creer')) {
1157 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$userentry->id."'>";
1158 //print $langs->trans("DeleteFromCat");
1159 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1160 print "</a>";
1161 }
1162 print '</td>';
1163 print "</tr>\n";
1164 }
1165 } else {
1166 print '<tr class="oddeven"><td colspan="3"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1167 }
1168 print "</table>\n";
1169
1170 print '</form>'."\n";
1171 }
1172 } else {
1173 print_barre_liste($langs->trans("Users"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'user');
1174 accessforbidden("NotEnoughPermissions", 0, 0);
1175 }
1176}
1177
1178// List of warehouses
1179if ($type == Categorie::TYPE_WAREHOUSE) {
1180 if ($user->hasRight("stock", "read")) {
1181 $permission = $user->hasRight('stock', 'creer');
1182
1183 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
1184
1185 $objects = $object->getObjectsInCateg($type, 0, $limit, $offset);
1186 if ($objects < 0) {
1187 dol_print_error($db, $object->error, $object->errors);
1188 } else {
1190 '@phan-var-force Entrepot[] $objects';
1191 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1192 print '<input type="hidden" name="token" value="'.newToken().'">';
1193 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1194 print '<input type="hidden" name="type" value="'.$typeid.'">';
1195 print '<input type="hidden" name="id" value="'.$object->id.'">';
1196 print '<input type="hidden" name="page_y" value="">';
1197 print '<input type="hidden" name="action" value="list">';
1198
1199 print '<br>';
1200 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1201 $num = count($objects);
1202 $nbtotalofrecords = '';
1203 $newcardbutton = '';
1204
1205 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1206 print_barre_liste($langs->trans("Warehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, $newcardbutton, '', $limit);
1207
1208 print '<table class="noborder centpercent">'."\n";
1209 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Ref").'</td></tr>'."\n";
1210
1211 if (count($objects) > 0) {
1212 $i = 0;
1213 foreach ($objects as $key => $warehouse) {
1214 $i++;
1215 if ($i > $limit) {
1216 break;
1217 }
1218
1219 print "\t".'<tr class="oddeven">'."\n";
1220 print '<td class="nowrap tdtop">';
1221 print $warehouse->getNomUrl(1);
1222 print "</td>\n";
1223 print '<td class="tdtop">'.$warehouse->ref."</td>\n";
1224 print '<td class="tdtop">'.$warehouse->lieu."</td>\n";
1225 // Link to delete from category
1226 print '<td class="right">';
1227 if ($permission) {
1228 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$warehouse->id."'>";
1229 //print $langs->trans("DeleteFromCat");
1230 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1231 print "</a>";
1232 }
1233 print '</td>';
1234 print "</tr>\n";
1235 }
1236 } else {
1237 print '<tr class="oddeven"><td colspan="4"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1238 }
1239 print "</table>\n";
1240
1241 print '</form>'."\n";
1242 }
1243 } else {
1244 print_barre_liste($langs->trans("Warehouse"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'stock');
1245 accessforbidden("NotEnoughPermissions", 0, 0);
1246 }
1247}
1248
1249// List of tickets
1250if ($type == Categorie::TYPE_TICKET) {
1251 if ($user->hasRight("ticket", "read")) {
1252 $permission = $user->hasRight('categorie', 'creer');
1253 $showclassifyform = $user->hasRight('categorie', 'creer');
1254
1255 $tickets = $object->getObjectsInCateg($type, 0, $limit, $offset);
1256 if ($tickets < 0) {
1257 dol_print_error($db, $object->error, $object->errors);
1258 } else {
1260 '@phan-var-force Ticket[] $tickets';
1261 // Form to add record into a category
1262 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1263 print '<input type="hidden" name="token" value="'.newToken().'">';
1264 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1265 print '<input type="hidden" name="type" value="'.$typeid.'">';
1266 print '<input type="hidden" name="id" value="'.$object->id.'">';
1267 print '<input type="hidden" name="page_y" value="">';
1268 print '<input type="hidden" name="action" value="list">';
1269
1270 print '<br>';
1271 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1272 $num = count($tickets);
1273 $nbtotalofrecords = '';
1274 $newcardbutton = '';
1275
1276 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1277 print_barre_liste($langs->trans("Ticket"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'ticket', 0, $newcardbutton, '', $limit);
1278
1279 if ($showclassifyform) {
1280 print '<table class="noborder centpercent">';
1281 print '<tr class="liste_titre"><td>';
1282 print $langs->trans("AddTicketIntoCategory").' &nbsp;';
1283 $form->selectTickets('', 'elemid');
1284 print '<input type="submit" class="button buttongen" name="addintocategory" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1285 print '</tr>';
1286 print '</table>';
1287 }
1288
1289 print '<table class="noborder centpercent">'."\n";
1290 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
1291
1292 if (count($tickets) > 0) {
1293 $i = 0;
1294 foreach ($tickets as $ticket) {
1295 $i++;
1296 if ($i > $limit) {
1297 break;
1298 }
1299
1300 print "\t".'<tr class="oddeven">'."\n";
1301 print '<td class="nowrap tdtop">';
1302 print $ticket->getNomUrl(1);
1303 print "</td>\n";
1304 print '<td class="tdtop">'.$ticket->label."</td>\n";
1305 // Link to delete from category
1306 print '<td class="right">';
1307 if ($permission) {
1308 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$ticket->id."'>";
1309 //print $langs->trans("DeleteFromCat");
1310 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1311 print "</a>";
1312 }
1313 print '</td>';
1314 print "</tr>\n";
1315 }
1316 } else {
1317 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1318 }
1319 print "</table>\n";
1320
1321 print '</form>'."\n";
1322 }
1323 } else {
1324 print_barre_liste($langs->trans("Ticket"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'ticket');
1325 accessforbidden("NotEnoughPermissions", 0, 0);
1326 }
1327}
1328
1329// List of Interventions
1330if ($type == Categorie::TYPE_FICHINTER) {
1331 if ($user->hasRight("fichinter", "lire")) {
1332 $permission = $user->hasRight('categorie', 'creer');
1333 $showclassifyform = $user->hasRight('categorie', 'creer');
1334
1335 $fichinters = $object->getObjectsInCateg($type, 0, $limit, $offset);
1336 if ($fichinters < 0) {
1337 dol_print_error($db, $object->error, $object->errors);
1338 } else {
1339 // Form to add record into a category
1340 if ($showclassifyform) {
1341 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formintervention.class.php';
1342 $formfichinter = new FormIntervention($db);
1343
1344 print '<br>';
1345 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1346 print '<input type="hidden" name="token" value="'.newToken().'">';
1347 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1348 print '<input type="hidden" name="type" value="'.$typeid.'">';
1349 print '<input type="hidden" name="id" value="'.$object->id.'">';
1350 print '<input type="hidden" name="action" value="addintocategory">';
1351 print '<table class="noborder centpercent">';
1352 print '<tr class="liste_titre"><td>';
1353 print $langs->trans("AddFichinterIntoCategory").' &nbsp;';
1354 print $formfichinter->select_interventions(-1, 0, 'elemid');
1355 print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
1356 print '</tr>';
1357 print '</table>';
1358 print '</form>';
1359 }
1360
1361 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
1362 print '<input type="hidden" name="token" value="'.newToken().'">';
1363 print '<input type="hidden" name="typeid" value="'.$typeid.'">';
1364 print '<input type="hidden" name="type" value="'.$typeid.'">';
1365 print '<input type="hidden" name="id" value="'.$object->id.'">';
1366 print '<input type="hidden" name="action" value="list">';
1367
1368 print '<br>';
1369 $param = '&limit='.$limit.'&id='.$id.'&type='.$type;
1370 $num = count($fichinters);
1371 $nbtotalofrecords = '';
1372 $newcardbutton = '';
1373
1374 $langs->load('interventions');
1375 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
1376 print_barre_liste($langs->trans("Intervention"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_intervention', 0, $newcardbutton, '', $limit);
1377 print '<table class="noborder centpercent">'."\n";
1378 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
1379
1380 if (count($fichinters) > 0) {
1381 $i = 0;
1382 foreach ($fichinters as $fichinter) {
1383 $i++;
1384 if ($i > $limit) break;
1385
1386 print "\t".'<tr class="oddeven">'."\n";
1387 print '<td class="nowrap tdtop">';
1388 print $fichinter->getNomUrl(1);
1389 print "</td>\n";
1390 print '<td class="tdtop">'.$fichinter->description."</td>\n";
1391 // Link to delete from category
1392 print '<td class="right">';
1393 if ($permission) {
1394 print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&type=".$typeid."&action=unlink&token=".newToken()."&removeelem=".$fichinter->id."'>";
1395 print $langs->trans("DeleteFromCat");
1396 print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', 0, 0, 0, '', 'paddingleft');
1397 print "</a>";
1398 }
1399 print '</td>';
1400 print "</tr>\n";
1401 }
1402 } else {
1403 print '<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</span></td></tr>';
1404 }
1405 print "</table>\n";
1406 print '</form>'."\n";
1407 }
1408 } else {
1409 print_barre_liste($langs->trans("Intervention"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'fichinter');
1410 accessforbidden("NotEnoughPermissions", 0, 0);
1411 }
1412}
1413
1414// Note that $action and $object may have been modified by some hooks
1415$parameters = array('type' => $type, 'id' => $id, 'label' => $label);
1416$reshook = $hookmanager->executeHooks('addMoreCategoriesList', $parameters, $object, $action);
1417
1418// End of page
1419llxFooter();
1420$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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:71
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 contact/addresses.
Class to manage standard extra fields.
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.
llxFooter()
Footer empty.
Definition document.php:107
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_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
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.