From a955f88bb6b89f50620a0aa174850175761fdf01 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 29 Aug 2022 11:22:27 +0200 Subject: [PATCH] Fix : categhory view permission --- htdocs/categories/viewcat.php | 1211 +++++++++++++++++---------------- 1 file changed, 629 insertions(+), 582 deletions(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 5405b33d994..0e5da0735ce 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -487,753 +487,800 @@ $typeid = $type; // List of products or services (type is type of category) if ($type == Categorie::TYPE_PRODUCT) { - $permission = ($user->rights->produit->creer || $user->rights->service->creer); + if ($user->hasRight("product", "read")) { + $permission = ($user->rights->produit->creer || $user->rights->service->creer); + + $prods = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($prods < 0) { + dol_print_error($db, $object->error, $object->errors); + } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AddProductServiceIntoCategory").'  '; + $form->select_produits('', 'elemid', '', 0, 0, -1, 2, '', 1); + print '
'; + print '
'; + } - $prods = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($prods < 0) { - dol_print_error($db, $object->error, $object->errors); - } else { - // Form to add record into a category - $showclassifyform = 1; - if ($showclassifyform) { - print '
'; print '
'; print ''; print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans("AddProductServiceIntoCategory").'  '; - $form->select_produits('', 'elemid', '', 0, 0, -1, 2, '', 1); - print '
'; - print '
'; - } + print ''; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - - print '
'; - $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = ''; - $newcardbutton = dolGetButtonTitle($langs->trans("AddProduct"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&categories[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->societe->creer); - print_barre_liste($langs->trans("ProductsAndServices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit); + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = ''; + $newcardbutton = dolGetButtonTitle($langs->trans("AddProduct"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&categories[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->societe->creer); + print_barre_liste($langs->trans("ProductsAndServices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit); - print ''."\n"; - print ''."\n"; + print '
'.$langs->trans("Ref").'
'."\n"; + print ''."\n"; - if (count($prods) > 0) { - $i = 0; - foreach ($prods as $prod) { - $i++; - if ($i > $limit) { - break; + if (count($prods) > 0) { + $i = 0; + foreach ($prods as $prod) { + $i++; + if ($i > $limit) { + break; + } + + print "\t".''."\n"; + print '\n"; + print '\n"; + // Link to delete from category + print ''; + print "\n"; } - - print "\t".''."\n"; - print '\n"; - print '\n"; - // Link to delete from category - print ''; - print "\n"; + } else { + print ''; } - } else { - print ''; - } - print "
'.$langs->trans("Ref").'
'; + print $prod->getNomUrl(1); + print "'.$prod->label."'; + if ($permission) { + print "id."'>"; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print '
'; - print $prod->getNomUrl(1); - print "'.$prod->label."'; - if ($permission) { - print "id."'>"; - print $langs->trans("DeleteFromCat"); - print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); - print ""; - } - print '
'.$langs->trans("ThisCategoryHasNoItems").'
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + print "\n"; - print '
'."\n"; + print ''."\n"; + } + } else { + print_barre_liste($langs->trans("ProductsAndServices"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'products'); + accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); } } // List of customers if ($type == Categorie::TYPE_CUSTOMER) { - $permission = $user->rights->societe->creer; + if ($user->hasRight("societe", "read")) { + $permission = $user->rights->societe->creer; + + $socs = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($socs < 0) { + dol_print_error($db, $object->error, $object->errors); + } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AddCustomerIntoCategory").'  '; + print $form->select_company('', 'elemid', 's.client IN (1,3)'); + print '
'; + print '
'; + } - $socs = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($socs < 0) { - dol_print_error($db, $object->error, $object->errors); - } else { - // Form to add record into a category - $showclassifyform = 1; - if ($showclassifyform) { - print '
'; print '
'; print ''; print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans("AddCustomerIntoCategory").'  '; - print $form->select_company('', 'elemid', 's.client IN (1,3)'); - print '
'; - print '
'; - } + print ''; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($socs); $nbtotalofrecords = ''; + $newcardbutton = dolGetButtonTitle($langs->trans("AddThirdParty"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&client=3&custcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->societe->creer); + print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit); - print '
'; - $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($socs); $nbtotalofrecords = ''; - $newcardbutton = dolGetButtonTitle($langs->trans("AddThirdParty"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&client=3&custcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->societe->creer); - print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit); + print ''."\n"; + print ''."\n"; - print '
'.$langs->trans("Name").'
'."\n"; - print ''."\n"; + if (count($socs) > 0) { + $i = 0; + foreach ($socs as $key => $soc) { + $i++; + if ($i > $limit) { + break; + } - if (count($socs) > 0) { - $i = 0; - foreach ($socs as $key => $soc) { - $i++; - if ($i > $limit) { - break; + print "\t".''."\n"; + print '\n"; + // Link to delete from category + print ''; + print "\n"; } - - print "\t".''."\n"; - print '\n"; - // Link to delete from category - print ''; - print "\n"; + } else { + print ''; } - } else { - print ''; - } - print "
'.$langs->trans("Name").'
'; + print $soc->getNomUrl(1); + print "'; + if ($permission) { + print "id."'>"; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print '
'; - print $soc->getNomUrl(1); - print "'; - if ($permission) { - print "id."'>"; - print $langs->trans("DeleteFromCat"); - print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); - print ""; - } - print '
'.$langs->trans("ThisCategoryHasNoItems").'
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + print "\n"; - print '
'."\n"; + print ''."\n"; + } + } else { + print_barre_liste($langs->trans("Customers"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'companies'); + accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); } } // List of suppliers if ($type == Categorie::TYPE_SUPPLIER) { - $permission = $user->rights->societe->creer; + if ($user->hasRight("fournisseur", "read")) { + $permission = $user->rights->societe->creer; + + $socs = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($socs < 0) { + dol_print_error($db, $object->error, $object->errors); + } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AddSupplierIntoCategory").'  '; + print $form->select_company('', 'elemid', 's.fournisseur = 1'); + print '
'; + print '
'; + } - $socs = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($socs < 0) { - dol_print_error($db, $object->error, $object->errors); - } else { - // Form to add record into a category - $showclassifyform = 1; - if ($showclassifyform) { - print '
'; print '
'; print ''; print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans("AddSupplierIntoCategory").'  '; - print $form->select_company('', 'elemid', 's.fournisseur = 1'); - print '
'; - print '
'; - } + print ''; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($socs); $nbtotalofrecords = ''; + $newcardbutton = dolGetButtonTitle($langs->trans("AddSupplier"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&fournisseur=1&suppcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->societe->creer); + print_barre_liste($langs->trans("Suppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit); - print '
'; - $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($socs); $nbtotalofrecords = ''; - $newcardbutton = dolGetButtonTitle($langs->trans("AddSupplier"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create&fournisseur=1&suppcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->societe->creer); - print_barre_liste($langs->trans("Suppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit); + print ''."\n"; + print '\n"; - print '
'.$langs->trans("Name")."
'."\n"; - print '\n"; + if (count($socs) > 0) { + $i = 0; + foreach ($socs as $soc) { + $i++; + if ($i > $limit) { + break; + } - if (count($socs) > 0) { - $i = 0; - foreach ($socs as $soc) { - $i++; - if ($i > $limit) { - break; + print "\t".''."\n"; + print '\n"; + // Link to delete from category + print ''; + + print "\n"; } - - print "\t".''."\n"; - print '\n"; - // Link to delete from category - print ''; - - print "\n"; + } else { + print ''; } - } else { - print ''; - } - print "
'.$langs->trans("Name")."
'; + print $soc->getNomUrl(1); + print "'; + if ($permission) { + print "id."'>"; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print '
'; - print $soc->getNomUrl(1); - print "'; - if ($permission) { - print "id."'>"; - print $langs->trans("DeleteFromCat"); - print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); - print ""; - } - print '
'.$langs->trans("ThisCategoryHasNoItems").'
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + print "\n"; - print '
'."\n"; + print ''."\n"; + } + } else { + print_barre_liste($langs->trans("Suppliers"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'companies'); + accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); } } // List of members if ($type == Categorie::TYPE_MEMBER) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + if ($user->hasRight("adherent", "read")) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $permission = $user->rights->adherent->creer; + $permission = $user->rights->adherent->creer; + + $prods = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($prods < 0) { + dol_print_error($db, $object->error, $object->errors); + } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AssignCategoryTo").'  '; + print $form->selectMembers('', 'elemid'); + print '
'; + print '
'; + } - $prods = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($prods < 0) { - dol_print_error($db, $object->error, $object->errors); - } else { - // Form to add record into a category - $showclassifyform = 1; - if ($showclassifyform) { - print '
'; print '
'; print ''; print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans("AssignCategoryTo").'  '; - print $form->selectMembers('', 'elemid'); - print '
'; - print '
'; - } + print ''; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = ''; + $newcardbutton = dolGetButtonTitle($langs->trans("AddMember"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create&memcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->adherent->creer); + print_barre_liste($langs->trans("Member"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit); - print '
'; - $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = ''; - $newcardbutton = dolGetButtonTitle($langs->trans("AddMember"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create&memcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->adherent->creer); - print_barre_liste($langs->trans("Member"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit); + print "\n"; + print ''."\n"; - print "
'.$langs->trans("Name").'
\n"; - print ''."\n"; + if (count($prods) > 0) { + $i = 0; + foreach ($prods as $key => $member) { + $i++; + if ($i > $limit) { + break; + } - if (count($prods) > 0) { - $i = 0; - foreach ($prods as $key => $member) { - $i++; - if ($i > $limit) { - break; + print "\t".''."\n"; + print '\n"; + print '\n"; + print '\n"; + // Link to delete from category + print '\n"; } - - print "\t".''."\n"; - print '\n"; - print '\n"; - print '\n"; - // Link to delete from category - print '\n"; + } else { + print ''; } - } else { - print ''; - } - print "
'.$langs->trans("Name").'
'; + $member->ref = $member->login; + print $member->getNomUrl(1, 0); + print "'.$member->lastname."'.$member->firstname."'; + if ($permission) { + print "id."'>"; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print "
'; - $member->ref = $member->login; - print $member->getNomUrl(1, 0); - print "'.$member->lastname."'.$member->firstname."'; - if ($permission) { - print "id."'>"; - print $langs->trans("DeleteFromCat"); - print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); - print ""; - } - print "
'.$langs->trans("ThisCategoryHasNoItems").'
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + print "\n"; - print '
'."\n"; + print ''."\n"; + } + } else { + print_barre_liste($langs->trans("Member"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'members'); + accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); } } // List of contacts if ($type == Categorie::TYPE_CONTACT) { - $permission = $user->rights->societe->creer; + if ($user->hasRight("societe", "read")) { + $permission = $user->rights->societe->creer; - $contacts = $object->getObjectsInCateg($type, 0, $limit, $offset); - if (is_numeric($contacts) && $contacts < 0) { - dol_print_error($db, $object->error, $object->errors); - } else { - // Form to add record into a category - $showclassifyform = 1; - if ($showclassifyform) { - print '
'; + $contacts = $object->getObjectsInCateg($type, 0, $limit, $offset); + if (is_numeric($contacts) && $contacts < 0) { + dol_print_error($db, $object->error, $object->errors); + } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AssignCategoryTo").'  '; + print $form->selectContacts('', '', 'elemid'); + print '
'; + print '
'; + } print '
'; print ''; print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans("AssignCategoryTo").'  '; - print $form->selectContacts('', '', 'elemid'); - print '
'; - print '
'; - } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; - print '
'; - $param = '&limit='.$limit.'&id='.$id.'&type='.$type; - $num = count($contacts); - $nbtotalofrecords = ''; - $newcardbutton = dolGetButtonTitle($langs->trans("AddContact"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create&contcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->societe->creer); - $objsoc = new Societe($db); - print_barre_liste($langs->trans("Contact"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contact', 0, $newcardbutton, '', $limit); + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; + $num = count($contacts); + $nbtotalofrecords = ''; + $newcardbutton = dolGetButtonTitle($langs->trans("AddContact"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create&contcats[]='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $user->rights->societe->creer); + $objsoc = new Societe($db); + print_barre_liste($langs->trans("Contact"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contact', 0, $newcardbutton, '', $limit); - print ''."\n"; - print ''."\n"; + print '
'.$langs->trans("Ref").'
'."\n"; + print ''."\n"; - if (is_array($contacts) && count($contacts) > 0) { - $i = 0; - foreach ($contacts as $key => $contact) { - $i++; - if ($i > $limit) { - break; + if (is_array($contacts) && count($contacts) > 0) { + $i = 0; + foreach ($contacts as $key => $contact) { + $i++; + if ($i > $limit) { + break; + } + + print "\t".''."\n"; + print '\n"; + // Link to delete from category + print ''; + print "\n"; } - - print "\t".''."\n"; - print '\n"; - // Link to delete from category - print ''; - print "\n"; + } else { + print ''; } - } else { - print ''; - } - print "
'.$langs->trans("Ref").'
'; + print $contact->getNomUrl(1, 'category'); + if ($contact->socid > 0) { + $objsoc->fetch($contact->socid); + print ' - '; + print $objsoc->getNomUrl(1, 'contact'); + } + print "'; + if ($permission) { + print "id."'>"; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print '
'; - print $contact->getNomUrl(1, 'category'); - if ($contact->socid > 0) { - $objsoc->fetch($contact->socid); - print ' - '; - print $objsoc->getNomUrl(1, 'contact'); - } - print "'; - if ($permission) { - print "id."'>"; - print $langs->trans("DeleteFromCat"); - print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); - print ""; - } - print '
'.$langs->trans("ThisCategoryHasNoItems").'
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + print "\n"; - print '
'."\n"; + print ''."\n"; + } + } else { + print_barre_liste($langs->trans("Contact"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'contact'); + accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); } } // List of bank accounts if ($type == Categorie::TYPE_ACCOUNT) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + if ($user->hasRight("banque", "read")) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $permission = $user->rights->banque->creer; + $permission = $user->rights->banque->creer; + + $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($accounts < 0) { + dol_print_error($db, $object->error, $object->errors); + } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AddAccountIntoCategory").'  '; + $form->select_comptes('', 'elemid'); + print '
'; + print '
'; + } - $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($accounts < 0) { - dol_print_error($db, $object->error, $object->errors); - } else { - // Form to add record into a category - $showclassifyform = 1; - if ($showclassifyform) { - print '
'; print '
'; print ''; print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans("AddAccountIntoCategory").'  '; - $form->select_comptes('', 'elemid'); - print '
'; - print '
'; - } + print ''; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($accounts); $nbtotalofrecords = ''; $newcardbutton = ''; + print_barre_liste($langs->trans("Account"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit); - print '
'; - $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($accounts); $nbtotalofrecords = ''; $newcardbutton = ''; - print_barre_liste($langs->trans("Account"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit); + print "\n"; + print ''."\n"; - print "
'.$langs->trans("Ref").'
\n"; - print ''."\n"; + if (count($accounts) > 0) { + $i = 0; + foreach ($accounts as $key => $account) { + $i++; + if ($i > $limit) { + break; + } - if (count($accounts) > 0) { - $i = 0; - foreach ($accounts as $key => $account) { - $i++; - if ($i > $limit) { - break; + print "\t".''."\n"; + print '\n"; + print '\n"; + print '\n"; + // Link to delete from category + print '\n"; } - - print "\t".''."\n"; - print '\n"; - print '\n"; - print '\n"; - // Link to delete from category - print '\n"; + } else { + print ''; } - } else { - print ''; - } - print "
'.$langs->trans("Ref").'
'; + print $account->getNomUrl(1, 0); + print "'.$account->bank."'.$account->number."'; + if ($permission) { + print "id."'>"; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print "
'; - print $account->getNomUrl(1, 0); - print "'.$account->bank."'.$account->number."'; - if ($permission) { - print "id."'>"; - print $langs->trans("DeleteFromCat"); - print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); - print ""; - } - print "
'.$langs->trans("ThisCategoryHasNoItems").'
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + print "\n"; - print '
'."\n"; + print ''."\n"; + } + } else { + print_barre_liste($langs->trans("Banque"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'bank'); + accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); } } // List of Project if ($type == Categorie::TYPE_PROJECT) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + if ($user->hasRight("project", "read")) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $permission = $user->rights->projet->creer; + $permission = $user->rights->projet->creer; + + $objects = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($objects < 0) { + dol_print_error($db, $object->error, $object->errors); + } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AddProjectIntoCategory").'  '; + $form->selectProjects('', 'elemid'); + print '
'; + print '
'; + } - $objects = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($objects < 0) { - dol_print_error($db, $object->error, $object->errors); - } else { - // Form to add record into a category - $showclassifyform = 1; - if ($showclassifyform) { - print '
'; print '
'; print ''; print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans("AddProjectIntoCategory").'  '; - $form->selectProjects('', 'elemid'); - print '
'; - print '
'; - } + print ''; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = ''; - print '
'; - $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = ''; + print_barre_liste($langs->trans("Project"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit); - print_barre_liste($langs->trans("Project"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit); + print "\n"; + print ''."\n"; - print "
'.$langs->trans("Ref").'
\n"; - print ''."\n"; + if (count($objects) > 0) { + $i = 0; + foreach ($objects as $key => $project) { + $i++; + if ($i > $limit) { + break; + } - if (count($objects) > 0) { - $i = 0; - foreach ($objects as $key => $project) { - $i++; - if ($i > $limit) { - break; + print "\t".''."\n"; + print '\n"; + print '\n"; + print '\n"; + // Link to delete from category + print '\n"; } - - print "\t".''."\n"; - print '\n"; - print '\n"; - print '\n"; - // Link to delete from category - print '\n"; + } else { + print ''; } - } else { - print ''; - } - print "
'.$langs->trans("Ref").'
'; + print $project->getNomUrl(1); + print "'.$project->ref."'.$project->title."'; + if ($permission) { + print "id."'>"; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print "
'; - print $project->getNomUrl(1); - print "'.$project->ref."'.$project->title."'; - if ($permission) { - print "id."'>"; - print $langs->trans("DeleteFromCat"); - print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); - print ""; - } - print "
'.$langs->trans("ThisCategoryHasNoItems").'
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + print "\n"; - print '
'."\n"; + print ''."\n"; + } + } else { + print_barre_liste($langs->trans("Project"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'project'); + accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); } } // List of users -if ($type == Categorie::TYPE_USER && $user->hasRight("user", "user", "read")) { - require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +if ($type == Categorie::TYPE_USER) { + if ($user->hasRight("user", "user", "read")) { + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - $users = $object->getObjectsInCateg($type); - if ($users < 0) { - dol_print_error($db, $object->error, $object->errors); - } else { - // Form to add record into a category - $showclassifyform = 1; - if ($showclassifyform) { - print '
'; + $users = $object->getObjectsInCateg($type); + if ($users < 0) { + dol_print_error($db, $object->error, $object->errors); + } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AddObjectIntoCategory").'  '; + print $form->select_dolusers('', 'elemid'); + print '
'; + print '
'; + } print '
'; print ''; print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans("AddObjectIntoCategory").'  '; - print $form->select_dolusers('', 'elemid'); - print '
'; - print '
'; - } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; - print '
'; + print '
'; - $param = '&limit='.$limit.'&id='.$id.'&type='.$type; - $num = count($users); + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; + $num = count($users); - print_barre_liste($langs->trans("Users"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, '', 'user', 0, '', '', $limit); + print_barre_liste($langs->trans("Users"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, '', 'user', 0, '', '', $limit); - print "\n"; - print ''."\n"; + print "
'.$langs->trans("Users").' '.$num.'
\n"; + print ''."\n"; - if (count($users) > 0) { - // Use "$userentry" here, because "$user" is the current user - foreach ($users as $key => $userentry) { - print "\t".''."\n"; - print '\n"; - print '\n"; + if (count($users) > 0) { + // Use "$userentry" here, because "$user" is the current user + foreach ($users as $key => $userentry) { + print "\t".''."\n"; + print '\n"; + print '\n"; - // Link to delete from category - print '\n"; } - print "\n"; + } else { + print ''; } - } else { - print ''; - } - print "
'.$langs->trans("Users").' '.$num.'
'; - print $userentry->getNomUrl(1); - print "'.$userentry->job."
'; + print $userentry->getNomUrl(1); + print "'.$userentry->job."'; - if ($user->rights->user->user->creer) { - print "id."'>"; - print $langs->trans("DeleteFromCat"); - print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); - print ""; + // Link to delete from category + print ''; + if ($user->rights->user->user->creer) { + print "id."'>"; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print "
'.$langs->trans("ThisCategoryHasNoItems").'
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + print "\n"; - print '
'."\n"; + print ''."\n"; + } + } else { + print_barre_liste($langs->trans("Users"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'user'); + accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); } -} else { - print_barre_liste($langs->trans("Users"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'user'); - accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); } // List of warehouses if ($type == Categorie::TYPE_WAREHOUSE) { - $permission = $user->rights->stock->creer; + if ($user->hasRight("warehouse", "read")) { + $permission = $user->rights->stock->creer; - require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; - $objects = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($objects < 0) { - dol_print_error($db, $object->error, $object->errors); - } else { - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - - print '
'; - $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = ''; - - print_barre_liste($langs->trans("Warehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, $newcardbutton, '', $limit); - - print "\n"; - print ''."\n"; - - if (count($objects) > 0) { - $i = 0; - foreach ($objects as $key => $project) { - $i++; - if ($i > $limit) { - break; - } - - print "\t".''."\n"; - print '\n"; - print '\n"; - print '\n"; - // Link to delete from category - print '\n"; - } + $objects = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($objects < 0) { + dol_print_error($db, $object->error, $object->errors); } else { - print ''; - } - print "
'.$langs->trans("Ref").'
'; - print $project->getNomUrl(1); - print "'.$project->ref."'.$project->title."'; - if ($permission) { - print "id."'>"; - print $langs->trans("DeleteFromCat"); - print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); - print ""; - } - print "
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; - - print '
'."\n"; - } -} - -// List of tickets -if ($type == Categorie::TYPE_TICKET) { - $permission = ($user->rights->categorie->creer || $user->rights->categorie->creer); - - $tickets = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($tickets < 0) { - dol_print_error($db, $object->error, $object->errors); - } else { - // Form to add record into a category - $showclassifyform = 1; - if ($showclassifyform) { - print '
'; print '
'; print ''; print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans("AddTicketIntoCategory").'  '; - $form->selectTickets('', 'elemid'); - print '
'; - print '
'; - } + print ''; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = ''; - print '
'; - $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($tickets); $nbtotalofrecords = ''; $newcardbutton = ''; - print_barre_liste($langs->trans("Ticket"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'ticket', 0, $newcardbutton, '', $limit); + print_barre_liste($langs->trans("Warehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, $newcardbutton, '', $limit); + print "\n"; + print ''."\n"; - print '
'.$langs->trans("Ref").'
'."\n"; - print ''."\n"; + if (count($objects) > 0) { + $i = 0; + foreach ($objects as $key => $project) { + $i++; + if ($i > $limit) { + break; + } - if (count($tickets) > 0) { - $i = 0; - foreach ($tickets as $ticket) { - $i++; - if ($i > $limit) break; - - print "\t".''."\n"; - print '\n"; - print '\n"; - // Link to delete from category - print ''."\n"; + print '\n"; + print '\n"; + print '\n"; + // Link to delete from category + print '\n"; } - print ''; - print "\n"; + } else { + print ''; } - } else { - print ''; - } - print "
'.$langs->trans("Ref").'
'; - print $ticket->getNomUrl(1); - print "'.$ticket->label."'; - if ($permission) { - print "id."'>"; - print $langs->trans("DeleteFromCat"); - print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); - print ""; + print "\t".'
'; + print $project->getNomUrl(1); + print "'.$project->ref."'.$project->title."'; + if ($permission) { + print "id."'>"; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print "
'.$langs->trans("ThisCategoryHasNoItems").'
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + print "\n"; - print '
'."\n"; + print ''."\n"; + } + } else { + print_barre_liste($langs->trans("Warehouse"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'stock'); + accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); + } +} + +// List of tickets +if ($type == Categorie::TYPE_TICKET) { + if ($user->hasRight("ticket", "read")) { + $permission = ($user->rights->categorie->creer || $user->rights->categorie->creer); + + $tickets = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($tickets < 0) { + dol_print_error($db, $object->error, $object->errors); + } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AddTicketIntoCategory").'  '; + $form->selectTickets('', 'elemid'); + print '
'; + print '
'; + } + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($tickets); $nbtotalofrecords = ''; $newcardbutton = ''; + print_barre_liste($langs->trans("Ticket"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'ticket', 0, $newcardbutton, '', $limit); + + + print ''."\n"; + print ''."\n"; + + if (count($tickets) > 0) { + $i = 0; + foreach ($tickets as $ticket) { + $i++; + if ($i > $limit) break; + + print "\t".''."\n"; + print '\n"; + print '\n"; + // Link to delete from category + print ''; + print "\n"; + } + } else { + print ''; + } + print "
'.$langs->trans("Ref").'
'; + print $ticket->getNomUrl(1); + print "'.$ticket->label."'; + if ($permission) { + print "id."'>"; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print '
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + + print '
'."\n"; + } + } else { + print_barre_liste($langs->trans("Ticket"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'ticket'); + accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0); } }