dolibarr  7.0.0-beta
viewcat.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
3  * Copyright (C) 2006-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@capnetworks.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 
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 $object->fetch_optionals($id,$extralabels);
57 if ($result <= 0)
58 {
59  dol_print_error($db,$object->error);
60  exit;
61 }
62 
63 $type=$object->type;
64 if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
65 
66 $extrafields = new ExtraFields($db);
67 $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
68 
69 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
70 $hookmanager->initHooks(array('categorycard'));
71 
72 
73 /*
74  * Actions
75  */
76 
77 // Remove element from category
78 if ($id > 0 && $removeelem > 0)
79 {
80  if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer))
81  {
82  require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
83  $tmpobject = new Product($db);
84  $result = $tmpobject->fetch($removeelem);
85  $elementtype = 'product';
86  }
87  else if ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer)
88  {
89  $tmpobject = new Societe($db);
90  $result = $tmpobject->fetch($removeelem);
91  $elementtype = 'supplier';
92  }
93  else if ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer)
94  {
95  $tmpobject = new Societe($db);
96  $result = $tmpobject->fetch($removeelem);
97  $elementtype = 'customer';
98  }
99  else if ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer)
100  {
101  require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
102  $tmpobject = new Adherent($db);
103  $result = $tmpobject->fetch($removeelem);
104  $elementtype = 'member';
105  }
106  else if ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) {
107 
108  require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
109  $tmpobject = new Contact($db);
110  $result = $tmpobject->fetch($removeelem);
111  $elementtype = 'contact';
112  }
113  else if ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer)
114  {
115  require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
116  $tmpobject = new Account($db);
117  $result = $tmpobject->fetch($removeelem);
118  $elementtype = 'account';
119  }
120  else if ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer)
121  {
122  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
123  $tmpobject = new Project($db);
124  $result = $tmpobject->fetch($removeelem);
125  $elementtype = 'project';
126  }
127 
128  $result=$object->del_type($tmpobject,$elementtype);
129  if ($result < 0) dol_print_error('',$object->error);
130 }
131 
132 if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confirm == 'yes')
133 {
134  if ($object->delete($user) >= 0)
135  {
136  header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type);
137  exit;
138  }
139  else
140  {
141  setEventMessages($object->error, $object->errors, 'errors');
142  }
143 }
144 
145 if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory' && ($user->rights->produit->creer || $user->rights->service->creer))
146 {
147  require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
148  $newobject = new Product($db);
149  $result = $newobject->fetch($elemid);
150  $elementtype = 'product';
151 
152  // TODO Add into categ
153  $result=$object->add_type($newobject,$elementtype);
154  if ($result >= 0)
155  {
156  setEventMessages($langs->trans("WasAddedSuccessfully",$newobject->ref), null, 'mesgs');
157  }
158  else
159  {
160  if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
161  {
162  setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
163  }
164  else
165  {
166  setEventMessages($object->error,$object->errors,'errors');
167  }
168  }
169 
170 }
171 
172 
173 
174 /*
175  * View
176  */
177 
178 $form = new Form($db);
179 $formother = new FormOther($db);
180 
181 $helpurl='';
182 llxHeader("",$langs->trans("Categories"),$helpurl);
183 
184 if ($type == Categorie::TYPE_PRODUCT) $title=$langs->trans("ProductsCategoryShort");
185 elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCategoryShort");
186 elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoryShort");
187 elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort");
188 elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort");
189 elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort");
190 elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort");
191 elseif ($type == Categorie::TYPE_USER) $title=$langs->trans("ProjectsCategoriesShort");
192 else $title=$langs->trans("Category");
193 
194 $head = categories_prepare_head($object,$type);
195 
196 
197 dol_fiche_head($head, 'card', $title, -1, 'category');
198 
199 $linkback = '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("BackToList").'</a>';
200 $object->next_prev_filter=" type = ".$object->type;
201 $object->ref = $object->label;
202 $morehtmlref='<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
203 $ways = $object->print_all_ways(" &gt;&gt; ", '', 1);
204 foreach ($ways as $way)
205 {
206  $morehtmlref.=$way."<br>\n";
207 }
208 $morehtmlref.='</div>';
209 
210 dol_banner_tab($object, 'label', $linkback, ($user->societe_id?0:1), 'label', 'label', $morehtmlref, '', 0, '', '', 1);
211 
212 
213 /*
214  * Confirmation suppression
215  */
216 
217 if ($action == 'delete')
218 {
219  print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;type='.$type, $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1);
220 }
221 
222 print '<br>';
223 
224 print '<div class="fichecenter">';
225 print '<div class="underbanner clearboth"></div>';
226 print '<table width="100%" class="border">';
227 
228 // Description
229 print '<tr><td class="titlefield notopnoleft tdtop">';
230 print $langs->trans("Description").'</td><td>';
231 print dol_htmlentitiesbr($object->description);
232 print '</td></tr>';
233 
234 // Color
235 print '<tr><td class="notopnoleft">';
236 print $langs->trans("Color").'</td><td>';
237 print $formother->showColor($object->color);
238 print '</td></tr>';
239 
240 // Other attributes
241 include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
242 
243 print '</table>';
244 print '</div>';
245 
246 dol_fiche_end();
247 
248 
249 /*
250  * Boutons actions
251  */
252 
253 print "<div class='tabsAction'>\n";
254 
255 if ($user->rights->categorie->creer)
256 {
257  $socid = ($object->socid ? "&amp;socid=".$object->socid : "");
258  print "<a class='butAction' href='edit.php?id=".$object->id.$socid."&amp;type=".$type."'>".$langs->trans("Modify")."</a>";
259 }
260 
261 if ($user->rights->categorie->supprimer)
262 {
263  print "<a class='butActionDelete' href='".DOL_URL_ROOT."/categories/viewcat.php?action=delete&amp;id=".$object->id."&amp;type=".$type."'>".$langs->trans("Delete")."</a>";
264 }
265 
266 print "</div>";
267 
268 
269 
270 
271 $cats = $object->get_filles();
272 if ($cats < 0)
273 {
274  dol_print_error($db, $cats->error, $cats->errors);
275 }
276 else
277 {
278  print "<br>";
279  print "<table class='noborder' width='100%'>\n";
280  print "<tr class='liste_titre'><td colspan='2'>".$langs->trans("SubCats").'</td><td align="right">';
281  if ($user->rights->categorie->creer)
282  {
283  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)."'>";
284  print img_picto($langs->trans("Create"),'filenew');
285  print "</a>";
286  }
287  print "</td>";
288  print "</tr>\n";
289  if (count($cats) > 0)
290  {
291  foreach ($cats as $cat)
292  {
293  print "\t".'<tr class="oddeven">'."\n";
294  print "\t\t".'<td class="nowrap">';
295  print "<a href='viewcat.php?id=".$cat->id."&amp;type=".$type."'>".$cat->label."</a>";
296  print "</td>\n";
297  print "\t\t".'<td colspan="2">'.$cat->description."</td>\n";
298 
299  /*
300  if ($cat->visible == 1)
301  {
302  print "\t\t<td>".$langs->trans("ContentsVisibleByAllShort")."</td>\n";
303  }
304  else
305  {
306  print "\t\t<td>".$langs->trans("ContentsNotVisibleByAllShort")."</td>\n";
307  }
308  */
309 
310  print "\t</tr>\n";
311  }
312  }
313  else
314  {
315  print "<tr ".$bc[false].'><td colspan="3" class="opacitymedium">'.$langs->trans("NoSubCat")."</td></tr>";
316  }
317  print "</table>\n";
318 }
319 
320 
321 // List of products or services (type is type of category)
322 if ($type == Categorie::TYPE_PRODUCT)
323 {
324  $prods = $object->getObjectsInCateg("product");
325  if ($prods < 0)
326  {
327  dol_print_error($db, $prods->error, $prods->errors);
328  }
329  else
330  {
331  $showclassifyform=1; $typeid=Categorie::TYPE_PRODUCT;
332 
333  // Form to add record into a category
334  if ($showclassifyform)
335  {
336  print '<br>';
337  print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
338  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
339  print '<input type="hidden" name="typeid" value="'.$typeid.'">';
340  print '<input type="hidden" name="type" value="'.$typeid.'">';
341  print '<input type="hidden" name="id" value="'.$object->id.'">';
342  print '<input type="hidden" name="action" value="addintocategory">';
343  print '<table class="noborder" width="100%">';
344  print '<tr class="liste_titre"><td width="40%">';
345  print $langs->trans("AddProductServiceIntoCategory").' &nbsp;';
346  print $form->select_produits('','elemid','',0,0,-1,2,'',1);
347  print '</td><td>';
348  print '<input type="submit" class="button" value="'.$langs->trans("ClassifyInCategory").'"></td>';
349  print '</tr>';
350  print '</table>';
351  print '</form>';
352  }
353 
354  print "<br>";
355  print "<table class='noborder' width='100%'>\n";
356  print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("ProductsAndServices")."</td></tr>\n";
357 
358  if (count($prods) > 0)
359  {
360  foreach ($prods as $prod)
361  {
362  print "\t".'<tr class="oddeven">'."\n";
363  print '<td class="nowrap" valign="top">';
364  print $prod->getNomUrl(1);
365  print "</td>\n";
366  print '<td class="tdtop">'.$prod->label."</td>\n";
367  // Link to delete from category
368  print '<td align="right">';
369  $typeid=$object->type;
370  $permission=0;
371  if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer);
372  if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
373  if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
374  if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
375  if ($typeid == 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")."</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  $typeid=$object->type;
418  $permission=0;
419  if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer);
420  if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
421  if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
422  if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
423  if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
424  if ($permission)
425  {
426  print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$soc->id."'>";
427  print img_delete($langs->trans("DeleteFromCat")).' ';
428  print $langs->trans("DeleteFromCat")."</a>";
429  }
430  print '</td>';
431 
432  print "</tr>\n";
433  }
434  }
435  else
436  {
437  print '<tr '.$bc[false].'><td class="opacitymedium">'.$langs->trans("ThisCategoryHasNoSupplier").'</td></tr>';
438  }
439  print "</table>\n";
440  }
441 }
442 
443 if($type == Categorie::TYPE_CUSTOMER)
444 {
445  $socs = $object->getObjectsInCateg("customer");
446  if ($socs < 0)
447  {
448  dol_print_error($db, $socs->error, $socs->errors);
449  }
450  else
451  {
452  print "<br>";
453  print '<table class="noborder" width="100%">'."\n";
454  print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Customers")."</td></tr>\n";
455 
456  if (count($socs) > 0)
457  {
458  $i = 0;
459  foreach ($socs as $key => $soc)
460  {
461  if ($user->societe_id > 0 && $soc->id != $user->societe_id) continue; // External user always see only themself
462 
463  $i++;
464 
465  print "\t".'<tr class="oddeven">'."\n";
466  print '<td class="nowrap" valign="top">';
467  print $soc->getNomUrl(1);
468  print "</td>\n";
469  // Link to delete from category
470  print '<td align="right">';
471  $typeid=$object->type;
472  $permission=0;
473  if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer);
474  if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
475  if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
476  if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
477  if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
478  if ($permission)
479  {
480  print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$soc->id."'>";
481  print img_delete($langs->trans("DeleteFromCat")).' ';
482  print $langs->trans("DeleteFromCat")."</a>";
483  }
484  print '</td>';
485  print "</tr>\n";
486  }
487  }
488  else
489  {
490  print '<tr '.$bc[false].'><td class="opacitymedium">'.$langs->trans("ThisCategoryHasNoCustomer").'</td></tr>';
491  }
492  print "</table>\n";
493  }
494 }
495 
496 // List of members
497 if ($type == Categorie::TYPE_MEMBER)
498 {
499  require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
500 
501  $prods = $object->getObjectsInCateg("member");
502  if ($prods < 0)
503  {
504  dol_print_error($db, $prods->error, $prods->errors);
505  }
506  else
507  {
508  print "<br>";
509  print "<table class='noborder' width='100%'>\n";
510  print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Member")."</td></tr>\n";
511 
512  if (count($prods) > 0)
513  {
514  foreach ($prods as $key => $member)
515  {
516  print "\t".'<tr class="oddeven">'."\n";
517  print '<td class="nowrap" valign="top">';
518  $member->ref=$member->login;
519  print $member->getNomUrl(1,0);
520  print "</td>\n";
521  print '<td class="tdtop">'.$member->lastname."</td>\n";
522  print '<td class="tdtop">'.$member->firstname."</td>\n";
523  // Link to delete from category
524  print '<td align="right">';
525  $typeid=$object->type;
526  $permission=0;
527  if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer);
528  if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
529  if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
530  if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
531  if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
532  if ($permission)
533  {
534  print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$member->id."'>";
535  print img_delete($langs->trans("DeleteFromCat")).' ';
536  print $langs->trans("DeleteFromCat")."</a>";
537  }
538  print "</tr>\n";
539  }
540  }
541  else
542  {
543  print '<tr '.$bc[false].'><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoMember").'</td></tr>';
544  }
545  print "</table>\n";
546  }
547 }
548 
549 // Categorie contact
550 if ($type == Categorie::TYPE_CONTACT)
551 {
552  $contacts = $object->getObjectsInCateg("contact");
553  if ($contacts < 0)
554  {
555  dol_print_error($db, $contacts->error, $contacts->errors);
556  }
557  else
558  {
559  print "<br>";
560  print '<table class="noborder" width="100%">'."\n";
561  print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Contact")."</td></tr>\n";
562 
563  if (count($contacts) > 0)
564  {
565  $i = 0;
566  foreach ($contacts as $key => $contact)
567  {
568  $i++;
569 
570  print "\t".'<tr class="oddeven">'."\n";
571  print '<td class="nowrap" valign="top">';
572  print $contact->getNomUrl(1,'category');
573  print "</td>\n";
574  // Link to delete from category
575  print '<td align="right">';
576  $typeid=$object->type;
577  $permission=0;
578  if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer);
579  if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
580  if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
581  if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
582  if ($typeid == Categorie::TYPE_CONTACT) $permission=$user->rights->societe->creer;
583  if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
584  if ($permission)
585  {
586  print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$contact->id."'>";
587  print img_delete($langs->trans("DeleteFromCat")).' ';
588  print $langs->trans("DeleteFromCat")."</a>";
589  }
590  print '</td>';
591  print "</tr>\n";
592  }
593  }
594  else
595  {
596  print '<tr '.$bc[false].'><td class="opacitymedium">'.$langs->trans("ThisCategoryHasNoContact").'</td></tr>';
597  }
598  print "</table>\n";
599  }
600 }
601 
602 // List of accounts
603 if ($type == Categorie::TYPE_ACCOUNT)
604 {
605  require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
606 
607  $accounts = $object->getObjectsInCateg("account");
608  if ($accounts < 0)
609  {
610  dol_print_error($db, $accounts->error, $accounts->errors);
611  }
612  else
613  {
614  print "<br>";
615  print "<table class='noborder' width='100%'>\n";
616  print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Account")."</td></tr>\n";
617 
618  if (count($accounts) > 0)
619  {
620  foreach ($accounts as $key => $account)
621  {
622  print "\t".'<tr class="oddeven">'."\n";
623  print '<td class="nowrap" valign="top">';
624  print $account->getNomUrl(1,0);
625  print "</td>\n";
626  print '<td class="tdtop">'.$account->bank."</td>\n";
627  print '<td class="tdtop">'.$account->number."</td>\n";
628  // Link to delete from category
629  print '<td align="right">';
630  $typeid=$object->type;
631  $permission=0;
632  if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer);
633  if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
634  if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
635  if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
636  if ($typeid == Categorie::TYPE_ACCOUNT) $permission=$user->rights->banque->configurer;
637  if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
638  if ($permission)
639  {
640  print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$account->id."'>";
641  print img_delete($langs->trans("DeleteFromCat")).' ';
642  print $langs->trans("DeleteFromCat")."</a>";
643  }
644  print "</tr>\n";
645  }
646  }
647  else
648  {
649  print '<tr '.$bc[false].'><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoAccount").'</td></tr>';
650  }
651  print "</table>\n";
652  }
653 }
654 
655 // List of Project
656 if ($type == Categorie::TYPE_PROJECT)
657 {
658  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
659 
660  $projects = $object->getObjectsInCateg("project");
661  if ($projects < 0)
662  {
663  dol_print_error($db, $object->error, $object->errors);
664  }
665  else
666  {
667  print "<br>";
668  print "<table class='noborder' width='100%'>\n";
669  print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Project")."</td></tr>\n";
670 
671  if (count($projects) > 0)
672  {
673  foreach ($projects as $key => $project)
674  {
675  print "\t".'<tr class="oddeven">'."\n";
676  print '<td class="nowrap" valign="top">';
677  print $project->getNomUrl(1,0);
678  print "</td>\n";
679  print '<td class="tdtop">'.$project->ref."</td>\n";
680  print '<td class="tdtop">'.$project->title."</td>\n";
681  // Link to delete from category
682  print '<td align="right">';
683  $typeid=$object->type;
684  $permission=0;
685  if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer);
686  if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer;
687  if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer;
688  if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer;
689  if ($typeid == Categorie::TYPE_ACCOUNT) $permission=$user->rights->banque->configurer;
690  if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
691  if ($permission)
692  {
693  print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$project->id."'>";
694  print img_delete($langs->trans("DeleteFromCat")).' ';
695  print $langs->trans("DeleteFromCat")."</a>";
696  }
697  print "</tr>\n";
698  }
699  }
700  else
701  {
702  print '<tr '.$bc[false].'><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoProject").'</td></tr>';
703  }
704  print "</table>\n";
705  }
706 }
707 
708 llxFooter();
709 
710 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
if(!GETPOST('transkey')&&!GETPOST('transphrase')) else
View.
Definition: notice.php:43
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
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...
if(empty($reshook)) $form
View.
Definition: perms.php:103
Class to manage bank accounts.
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
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:46
img_delete($titlealt= 'default', $other= 'class="pictodelete"')
Show delete logo.
print
Draft customers invoices.
Definition: index.php:91
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.
type
Definition: viewcat.php:283
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.