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