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