dolibarr  9.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-2015 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  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
28 require '../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
33 
34 // Load translation files required by the page
35 $langs->load("categories");
36 
37 $id = GETPOST('id','int');
38 $label= GETPOST('label','alpha');
39 $type = GETPOST('type','az09');
40 $action=GETPOST('action','aZ09');
41 $confirm = GETPOST('confirm','alpha');
42 $removeelem = GETPOST('removeelem','int');
43 $elemid = GETPOST('elemid','alpha');
44 
45 if ($id == "" && $label == "")
46 {
47  dol_print_error('','Missing parameter id');
48  exit();
49 }
50 
51 // Security check
52 $result = restrictedArea($user, 'categorie', $id, '&category');
53 
54 $object = new Categorie($db);
55 $result=$object->fetch($id, $label);
56 if ($result <= 0) {
57  dol_print_error($db,$object->error); exit;
58 }
59 $object->fetch_optionals();
60 if ($result <= 0) {
61  dol_print_error($db,$object->error); exit;
62 }
63 
64 $type=$object->type;
65 if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
66 
67 $extrafields = new ExtraFields($db);
68 $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
69 
70 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
71 $hookmanager->initHooks(array('categorycard','globalcard'));
72 
73 
74 /*
75  * Actions
76  */
77 $parameters=array();
78 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
79 // Remove element from category
80 if ($id > 0 && $removeelem > 0)
81 {
82  if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer))
83  {
84  require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
85  $tmpobject = new Product($db);
86  $result = $tmpobject->fetch($removeelem);
87  $elementtype = 'product';
88  }
89  else if ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer)
90  {
91  $tmpobject = new Societe($db);
92  $result = $tmpobject->fetch($removeelem);
93  $elementtype = 'supplier';
94  }
95  else if ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer)
96  {
97  $tmpobject = new Societe($db);
98  $result = $tmpobject->fetch($removeelem);
99  $elementtype = 'customer';
100  }
101  else if ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer)
102  {
103  require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
104  $tmpobject = new Adherent($db);
105  $result = $tmpobject->fetch($removeelem);
106  $elementtype = 'member';
107  }
108  else if ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) {
109 
110  require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
111  $tmpobject = new Contact($db);
112  $result = $tmpobject->fetch($removeelem);
113  $elementtype = 'contact';
114  }
115  else if ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer)
116  {
117  require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
118  $tmpobject = new Account($db);
119  $result = $tmpobject->fetch($removeelem);
120  $elementtype = 'account';
121  }
122  else if ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer)
123  {
124  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
125  $tmpobject = new Project($db);
126  $result = $tmpobject->fetch($removeelem);
127  $elementtype = 'project';
128  }
129 
130  $result=$object->del_type($tmpobject,$elementtype);
131  if ($result < 0) dol_print_error('',$object->error);
132 }
133 
134 if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confirm == 'yes')
135 {
136  if ($object->delete($user) >= 0)
137  {
138  header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type);
139  exit;
140  }
141  else
142  {
143  setEventMessages($object->error, $object->errors, 'errors');
144  }
145 }
146 
147 if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory' && ($user->rights->produit->creer || $user->rights->service->creer))
148 {
149  require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
150  $newobject = new Product($db);
151  $result = $newobject->fetch($elemid);
152  $elementtype = 'product';
153 
154  // TODO Add into categ
155  $result=$object->add_type($newobject,$elementtype);
156  if ($result >= 0)
157  {
158  setEventMessages($langs->trans("WasAddedSuccessfully",$newobject->ref), null, 'mesgs');
159  }
160  else
161  {
162  if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
163  {
164  setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
165  }
166  else
167  {
168  setEventMessages($object->error,$object->errors,'errors');
169  }
170  }
171 }
172 
173 
174 
175 /*
176  * View
177  */
178 
179 $form = new Form($db);
180 $formother = new FormOther($db);
181 
182 $helpurl='';
183 llxHeader("",$langs->trans("Categories"),$helpurl);
184 
185 if ($type == Categorie::TYPE_PRODUCT) $title=$langs->trans("ProductsCategoryShort");
186 elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCategoryShort");
187 elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoryShort");
188 elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort");
189 elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort");
190 elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort");
191 elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort");
192 elseif ($type == Categorie::TYPE_USER) $title=$langs->trans("ProjectsCategoriesShort");
193 else $title=$langs->trans("Category");
194 
195 $head = categories_prepare_head($object,$type);
196 
197 
198 dol_fiche_head($head, 'card', $title, -1, 'category');
199 
200 $linkback = '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("BackToList").'</a>';
201 $object->next_prev_filter=" type = ".$object->type;
202 $object->ref = $object->label;
203 $morehtmlref='<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
204 $ways = $object->print_all_ways(" &gt;&gt; ", '', 1);
205 foreach ($ways as $way)
206 {
207  $morehtmlref.=$way."<br>\n";
208 }
209 $morehtmlref.='</div>';
210 
211 dol_banner_tab($object, 'label', $linkback, ($user->societe_id?0:1), 'label', 'label', $morehtmlref, '', 0, '', '', 1);
212 
213 
214 /*
215  * Confirmation suppression
216  */
217 
218 if ($action == 'delete')
219 {
220  print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;type='.$type, $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1);
221 }
222 
223 print '<br>';
224 
225 print '<div class="fichecenter">';
226 print '<div class="underbanner clearboth"></div>';
227 print '<table width="100%" class="border">';
228 
229 // Description
230 print '<tr><td class="titlefield notopnoleft tdtop">';
231 print $langs->trans("Description").'</td><td>';
232 print dol_htmlentitiesbr($object->description);
233 print '</td></tr>';
234 
235 // Color
236 print '<tr><td class="notopnoleft">';
237 print $langs->trans("Color").'</td><td>';
238 print $formother->showColor($object->color);
239 print '</td></tr>';
240 
241 // Other attributes
242 include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
243 
244 print '</table>';
245 print '</div>';
246 
247 dol_fiche_end();
248 
249 
250 /*
251  * Boutons actions
252  */
253 
254 print "<div class='tabsAction'>\n";
255 
256 if ($user->rights->categorie->creer)
257 {
258  $socid = ($object->socid ? "&amp;socid=".$object->socid : "");
259  print "<a class='butAction' href='edit.php?id=".$object->id.$socid."&amp;type=".$type."'>".$langs->trans("Modify")."</a>";
260 }
261 
262 if ($user->rights->categorie->supprimer)
263 {
264  print "<a class='butActionDelete' href='".DOL_URL_ROOT."/categories/viewcat.php?action=delete&amp;id=".$object->id."&amp;type=".$type."'>".$langs->trans("Delete")."</a>";
265 }
266 
267 print "</div>";
268 
269 
270 
271 
272 $cats = $object->get_filles();
273 if ($cats < 0)
274 {
275  dol_print_error($db, $cats->error, $cats->errors);
276 }
277 else
278 {
279  print "<br>";
280  print "<table class='noborder' width='100%'>\n";
281  print "<tr class='liste_titre'><td colspan='2'>".$langs->trans("SubCats").'</td><td align="right">';
282  if ($user->rights->categorie->creer)
283  {
284  print "<a href='".DOL_URL_ROOT."/categories/card.php?action=create&amp;catorigin=".$object->id."&amp;socid=".$object->socid."&amp;type=".$type."&amp;urlfrom=".urlencode($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type)."'>";
285  print img_picto($langs->trans("Create"),'filenew');
286  print "</a>";
287  }
288  print "</td>";
289  print "</tr>\n";
290  if (count($cats) > 0)
291  {
292  foreach ($cats as $cat)
293  {
294  print "\t".'<tr class="oddeven">'."\n";
295  print "\t\t".'<td class="nowrap">';
296  print "<a href='viewcat.php?id=".$cat->id."&amp;type=".$type."'>".$cat->label."</a>";
297  print "</td>\n";
298  print "\t\t".'<td colspan="2">'.$cat->description."</td>\n";
299 
300  /*
301  if ($cat->visible == 1)
302  {
303  print "\t\t<td>".$langs->trans("ContentsVisibleByAllShort")."</td>\n";
304  }
305  else
306  {
307  print "\t\t<td>".$langs->trans("ContentsNotVisibleByAllShort")."</td>\n";
308  }
309  */
310 
311  print "\t</tr>\n";
312  }
313  }
314  else
315  {
316  print "<tr ".$bc[false].'><td colspan="3" class="opacitymedium">'.$langs->trans("NoSubCat")."</td></tr>";
317  }
318  print "</table>\n";
319 }
320 
321 
322 // List of products or services (type is type of category)
323 if ($type == Categorie::TYPE_PRODUCT)
324 {
325  $prods = $object->getObjectsInCateg("product");
326  if ($prods < 0)
327  {
328  dol_print_error($db, $prods->error, $prods->errors);
329  }
330  else
331  {
332  $showclassifyform=1; $typeid=Categorie::TYPE_PRODUCT;
333 
334  // Form to add record into a category
335  if ($showclassifyform)
336  {
337  print '<br>';
338  print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
339  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
340  print '<input type="hidden" name="typeid" value="'.$typeid.'">';
341  print '<input type="hidden" name="type" value="'.$typeid.'">';
342  print '<input type="hidden" name="id" value="'.$object->id.'">';
343  print '<input type="hidden" name="action" value="addintocategory">';
344  print '<table class="noborder" width="100%">';
345  print '<tr class="liste_titre"><td width="40%">';
346  print $langs->trans("AddProductServiceIntoCategory").' &nbsp;';
347  print $form->select_produits('','elemid','',0,0,-1,2,'',1);
348  print '</td><td>';
349  print '<input type="submit" class="button" value="'.$langs->trans("ClassifyInCategory").'"></td>';
350  print '</tr>';
351  print '</table>';
352  print '</form>';
353  }
354 
355  print "<br>";
356  print "<table class='noborder' width='100%'>\n";
357  print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("ProductsAndServices")." (".count($prods).")</td></tr>\n";
358 
359  if (count($prods) > 0)
360  {
361  foreach ($prods as $prod)
362  {
363  print "\t".'<tr class="oddeven">'."\n";
364  print '<td class="nowrap" valign="top">';
365  print $prod->getNomUrl(1);
366  print "</td>\n";
367  print '<td class="tdtop">'.$prod->label."</td>\n";
368  // Link to delete from category
369  print '<td align="right">';
370  $permission=0;
371  if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer);
372  if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
373  if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
374  if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
375  if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
376  if ($permission)
377  {
378  print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$prod->id."'>";
379  print img_delete($langs->trans("DeleteFromCat")).' ';
380  print $langs->trans("DeleteFromCat")."</a>";
381  }
382  print '</td>';
383  print "</tr>\n";
384  }
385  }
386  else
387  {
388  print "<tr ".$bc[false].'><td colspan="2" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoProduct")."</td></tr>";
389  }
390  print "</table>\n";
391  }
392 }
393 
394 if ($type == Categorie::TYPE_SUPPLIER)
395 {
396  $socs = $object->getObjectsInCateg("supplier");
397  if ($socs < 0)
398  {
399  dol_print_error($db, $socs->error, $socs->errors);
400  }
401  else
402  {
403  print "<br>";
404  print '<table class="noborder" width="100%">'."\n";
405  print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Suppliers")." (".count($socs).")</td></tr>\n";
406 
407  if (count($socs) > 0)
408  {
409  foreach ($socs as $soc)
410  {
411  print "\t".'<tr class="oddeven">'."\n";
412  print '<td class="nowrap" valign="top">';
413  print $soc->getNomUrl(1);
414  print "</td>\n";
415  // Link to delete from category
416  print '<td align="right">';
417  $permission=0;
418  if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer);
419  if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
420  if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
421  if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
422  if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
423  if ($permission)
424  {
425  print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$soc->id."'>";
426  print img_delete($langs->trans("DeleteFromCat")).' ';
427  print $langs->trans("DeleteFromCat")."</a>";
428  }
429  print '</td>';
430 
431  print "</tr>\n";
432  }
433  }
434  else
435  {
436  print '<tr '.$bc[false].'><td class="opacitymedium">'.$langs->trans("ThisCategoryHasNoSupplier").'</td></tr>';
437  }
438  print "</table>\n";
439  }
440 }
441 
442 if($type == Categorie::TYPE_CUSTOMER)
443 {
444  $socs = $object->getObjectsInCateg("customer");
445  if ($socs < 0)
446  {
447  dol_print_error($db, $socs->error, $socs->errors);
448  }
449  else
450  {
451  print "<br>";
452  print '<table class="noborder" width="100%">'."\n";
453  print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Customers")." (".count($socs).")</td></tr>\n";
454 
455  if (count($socs) > 0)
456  {
457  $i = 0;
458  foreach ($socs as $key => $soc)
459  {
460  if ($user->societe_id > 0 && $soc->id != $user->societe_id) continue; // External user always see only themself
461 
462  $i++;
463 
464  print "\t".'<tr class="oddeven">'."\n";
465  print '<td class="nowrap" valign="top">';
466  print $soc->getNomUrl(1);
467  print "</td>\n";
468  // Link to delete from category
469  print '<td align="right">';
470  $permission=0;
471  if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer);
472  if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
473  if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
474  if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
475  if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
476  if ($permission)
477  {
478  print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$soc->id."'>";
479  print img_delete($langs->trans("DeleteFromCat")).' ';
480  print $langs->trans("DeleteFromCat")."</a>";
481  }
482  print '</td>';
483  print "</tr>\n";
484  }
485  }
486  else
487  {
488  print '<tr '.$bc[false].'><td class="opacitymedium">'.$langs->trans("ThisCategoryHasNoCustomer").'</td></tr>';
489  }
490  print "</table>\n";
491  }
492 }
493 
494 // List of members
495 if ($type == Categorie::TYPE_MEMBER)
496 {
497  require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
498 
499  $prods = $object->getObjectsInCateg("member");
500  if ($prods < 0)
501  {
502  dol_print_error($db, $prods->error, $prods->errors);
503  }
504  else
505  {
506  print "<br>";
507  print "<table class='noborder' width='100%'>\n";
508  print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Member")." (".count($prods).")</td></tr>\n";
509 
510  if (count($prods) > 0)
511  {
512  foreach ($prods as $key => $member)
513  {
514  print "\t".'<tr class="oddeven">'."\n";
515  print '<td class="nowrap" valign="top">';
516  $member->ref=$member->login;
517  print $member->getNomUrl(1,0);
518  print "</td>\n";
519  print '<td class="tdtop">'.$member->lastname."</td>\n";
520  print '<td class="tdtop">'.$member->firstname."</td>\n";
521  // Link to delete from category
522  print '<td align="right">';
523  $permission=0;
524  if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer);
525  if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
526  if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
527  if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
528  if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
529  if ($permission)
530  {
531  print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$member->id."'>";
532  print img_delete($langs->trans("DeleteFromCat")).' ';
533  print $langs->trans("DeleteFromCat")."</a>";
534  }
535  print "</tr>\n";
536  }
537  }
538  else
539  {
540  print '<tr '.$bc[false].'><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoMember").'</td></tr>';
541  }
542  print "</table>\n";
543  }
544 }
545 
546 // Categorie contact
547 if ($type == Categorie::TYPE_CONTACT)
548 {
549  $contacts = $object->getObjectsInCateg("contact");
550  if ($contacts < 0)
551  {
552  dol_print_error($db, $contacts->error, $contacts->errors);
553  }
554  else
555  {
556  print "<br>";
557  print '<table class="noborder" width="100%">'."\n";
558  print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Contact")." (".count($contacts).")</td></tr>\n";
559 
560  if (count($contacts) > 0)
561  {
562  $i = 0;
563  foreach ($contacts as $key => $contact)
564  {
565  $i++;
566 
567  print "\t".'<tr class="oddeven">'."\n";
568  print '<td class="nowrap" valign="top">';
569  print $contact->getNomUrl(1,'category');
570  print "</td>\n";
571  // Link to delete from category
572  print '<td align="right">';
573  $permission=0;
574  if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer);
575  if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
576  if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
577  if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
578  if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
579  if ($permission)
580  {
581  print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$contact->id."'>";
582  print img_delete($langs->trans("DeleteFromCat")).' ';
583  print $langs->trans("DeleteFromCat")."</a>";
584  }
585  print '</td>';
586  print "</tr>\n";
587  }
588  }
589  else
590  {
591  print '<tr '.$bc[false].'><td class="opacitymedium">'.$langs->trans("ThisCategoryHasNoContact").'</td></tr>';
592  }
593  print "</table>\n";
594  }
595 }
596 
597 // List of accounts
598 if ($type == Categorie::TYPE_ACCOUNT)
599 {
600  require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
601 
602  $accounts = $object->getObjectsInCateg("account");
603  if ($accounts < 0)
604  {
605  dol_print_error($db, $accounts->error, $accounts->errors);
606  }
607  else
608  {
609  print "<br>";
610  print "<table class='noborder' width='100%'>\n";
611  print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Account")." (".count($accounts).")</td></tr>\n";
612 
613  if (count($accounts) > 0)
614  {
615  foreach ($accounts as $key => $account)
616  {
617  print "\t".'<tr class="oddeven">'."\n";
618  print '<td class="nowrap" valign="top">';
619  print $account->getNomUrl(1,0);
620  print "</td>\n";
621  print '<td class="tdtop">'.$account->bank."</td>\n";
622  print '<td class="tdtop">'.$account->number."</td>\n";
623  // Link to delete from category
624  print '<td align="right">';
625  $permission=0;
626  if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer);
627  if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
628  if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
629  if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
630  if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
631  if ($permission)
632  {
633  print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$account->id."'>";
634  print img_delete($langs->trans("DeleteFromCat")).' ';
635  print $langs->trans("DeleteFromCat")."</a>";
636  }
637  print "</tr>\n";
638  }
639  }
640  else
641  {
642  print '<tr '.$bc[false].'><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoAccount").'</td></tr>';
643  }
644  print "</table>\n";
645  }
646 }
647 
648 // List of Project
649 if ($type == Categorie::TYPE_PROJECT)
650 {
651  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
652 
653  $projects = $object->getObjectsInCateg("project");
654  if ($projects < 0)
655  {
656  dol_print_error($db, $object->error, $object->errors);
657  }
658  else
659  {
660  print "<br>";
661  print "<table class='noborder' width='100%'>\n";
662  print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Project")." (".count($projects).")</td></tr>\n";
663 
664  if (count($projects) > 0)
665  {
666  foreach ($projects as $key => $project)
667  {
668  print "\t".'<tr class="oddeven">'."\n";
669  print '<td class="nowrap" valign="top">';
670  print $project->getNomUrl(1);
671  print "</td>\n";
672  print '<td class="tdtop">'.$project->ref."</td>\n";
673  print '<td class="tdtop">'.$project->title."</td>\n";
674  // Link to delete from category
675  print '<td align="right">';
676  $permission=0;
677  if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer);
678  if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
679  if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
680  if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
681  if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
682  if ($permission)
683  {
684  print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$project->id."'>";
685  print img_delete($langs->trans("DeleteFromCat")).' ';
686  print $langs->trans("DeleteFromCat")."</a>";
687  }
688  print "</tr>\n";
689  }
690  }
691  else
692  {
693  print '<tr '.$bc[false].'><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoProject").'</td></tr>';
694  }
695  print "</table>\n";
696  }
697 }
698 
699 // End of page
700 llxFooter();
701 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:56
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
Class to manage contact/addresses.
Class to manage products or services.
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.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
Class to manage bank accounts.
img_delete($titlealt='default', $other='class="pictodelete"')
Show delete logo.
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage categories.
Class to manage projects.
dol_fiche_end($notab=0)
Show tab footer of a card.
Classe permettant la generation de composants html autre Only common components are here...
Class to manage members of a foundation.
llxHeader()
Empty header.
Definition: wrapper.php:44
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
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...
categories_prepare_head($object, $type)
Prepare array with list of tabs.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.