--- /tmp/dsg/dolibarr/htdocs/categories/github_19.0.3_card.php +++ /tmp/dsg/dolibarr/htdocs/categories/client_card.php @@ -3 +3 @@ - * Copyright (C) 2006-2021 Laurent Destailleur + * Copyright (C) 2006-2017 Laurent Destailleur @@ -8 +7,0 @@ - * Copyright (C) 2020 Frédéric France @@ -30 +28,0 @@ -// Load Dolibarr environment @@ -40,6 +38,4 @@ -$socid = (int) GETPOST('socid', 'int'); -if (!$user->hasRight('categorie', 'lire')) { - accessforbidden(); -} - -$action = GETPOST('action', 'alpha'); +$socid = GETPOST('socid', 'int'); +if (!$user->rights->categorie->lire) accessforbidden(); + +$action = GETPOST('action', 'alpha'); @@ -48,3 +44,3 @@ -$catorigin = (int) GETPOST('catorigin', 'int'); -$type = GETPOST('type', 'aZ09'); -$urlfrom = GETPOST('urlfrom', 'alpha'); +$catorigin = GETPOST('catorigin', 'int'); +$type = GETPOST('type', 'alpha'); +$urlfrom = GETPOST('urlfrom', 'alpha'); @@ -53,25 +49,15 @@ -$label = (string) GETPOST('label', 'alphanohtml'); -$description = (string) GETPOST('description', 'restricthtml'); -$color = preg_replace('/[^0-9a-f#]/i', '', (string) GETPOST('color', 'alphanohtml')); -$visible = (int) GETPOST('visible', 'int'); -$parent = (int) GETPOST('parent', 'int'); - -if ($origin) { - if ($type == Categorie::TYPE_PRODUCT) { - $idProdOrigin = $origin; - } - if ($type == Categorie::TYPE_SUPPLIER) { - $idSupplierOrigin = $origin; - } - if ($type == Categorie::TYPE_CUSTOMER) { - $idCompanyOrigin = $origin; - } - if ($type == Categorie::TYPE_MEMBER) { - $idMemberOrigin = $origin; - } - if ($type == Categorie::TYPE_CONTACT) { - $idContactOrigin = $origin; - } - if ($type == Categorie::TYPE_PROJECT) { - $idProjectOrigin = $origin; - } +$socid = GETPOST('socid', 'int'); +$label = GETPOST('label'); +$description = GETPOST('description'); +$color = GETPOST('color'); +$visible = GETPOST('visible'); +$parent = GETPOST('parent'); + +if ($origin) +{ + if ($type == Categorie::TYPE_PRODUCT) $idProdOrigin = $origin; + if ($type == Categorie::TYPE_SUPPLIER) $idSupplierOrigin = $origin; + if ($type == Categorie::TYPE_CUSTOMER) $idCompanyOrigin = $origin; + if ($type == Categorie::TYPE_MEMBER) $idMemberOrigin = $origin; + if ($type == Categorie::TYPE_CONTACT) $idContactOrigin = $origin; + if ($type == Categorie::TYPE_PROJECT) $idProjectOrigin = $origin; @@ -80,3 +66 @@ -if ($catorigin && $type == Categorie::TYPE_PRODUCT) { - $idCatOrigin = $catorigin; -} +if ($catorigin && $type == Categorie::TYPE_PRODUCT) $idCatOrigin = $catorigin; @@ -91,2 +74,0 @@ - -$error = 0; @@ -98,5 +80,84 @@ -$parameters = array('socid' => $socid, 'origin' => $origin, 'catorigin' => $catorigin, 'type' => $type, 'urlfrom' => $urlfrom, 'backtopage' => $backtopage, 'label' => $label, 'description' => $description, 'color' => $color, 'visible' => $visible, 'parent' => $parent); -// Note that $action and $object may be modified by some hooks -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +// Add action +if ($action == 'add' && $user->rights->categorie->creer) +{ + // Action ajout d'une categorie + if ($cancel) + { + if ($urlfrom) + { + header("Location: ".$urlfrom); + exit; + } + elseif ($idProdOrigin) + { + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProdOrigin.'&type='.$type); + exit; + } + elseif ($idCompanyOrigin) + { + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCompanyOrigin.'&type='.$type); + exit; + } + elseif ($idSupplierOrigin) + { + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idSupplierOrigin.'&type='.$type); + exit; + } + elseif ($idMemberOrigin) + { + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idMemberOrigin.'&type='.$type); + exit; + } + elseif ($idContactOrigin) + { + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&type='.$type); + exit; + } + elseif ($idProjectOrigin) + { + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProjectOrigin.'&type='.$type); + exit; + } + else + { + header("Location: ".DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type); + exit; + } + } + + + + $object->label = $label; + $object->color = $color; + $object->description = dol_htmlcleanlastbr($description); + $object->socid = ($socid ? $socid : 'null'); + $object->visible = $visible; + $object->type = $type; + + if ($parent != "-1") $object->fk_parent = $parent; + + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) $error++; + + if (!$object->label) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); + $action = 'create'; + } + + // Create category in database + if (!$error) + { + $result = $object->create($user); + if ($result > 0) + { + $action = 'confirmed'; + $_POST["addcat"] = ''; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } @@ -105,100 +166,49 @@ -if (empty($reshook)) { - // Add action - if ($action == 'add' && $user->hasRight('categorie', 'creer')) { - // Action add a category - if ($cancel) { - if ($urlfrom) { - header("Location: ".$urlfrom); - exit; - } elseif ($backtopage) { - header("Location: ".$backtopage); - exit; - } elseif ($idProdOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProdOrigin.'&type='.$type); - exit; - } elseif ($idCompanyOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCompanyOrigin.'&type='.$type); - exit; - } elseif ($idSupplierOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idSupplierOrigin.'&type='.$type); - exit; - } elseif ($idMemberOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idMemberOrigin.'&type='.$type); - exit; - } elseif ($idContactOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&type='.$type); - exit; - } elseif ($idProjectOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProjectOrigin.'&type='.$type); - exit; - } else { - header("Location: ".DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type); - exit; - } - } - $object->label = $label; - $object->color = $color; - $object->description = dol_htmlcleanlastbr($description); - $object->socid = ($socid > 0 ? $socid : 0); - $object->visible = $visible; - $object->type = $type; - - if ($parent != "-1") { - $object->fk_parent = $parent; - } - - $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) { - $error++; - } - - if (!$object->label) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); - $action = 'create'; - } - - // Create category in database - if (!$error) { - $result = $object->create($user); - if ($result > 0) { - $action = 'confirmed'; - $_POST["addcat"] = ''; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } - // Confirm action - if (($action == 'add' || $action == 'confirmed') && $user->hasRight('categorie', 'creer')) { - // Action confirmation of creation category - if ($action == 'confirmed') { - if ($urlfrom) { - header("Location: ".$urlfrom); - exit; - } elseif ($backtopage) { - header("Location: ".$backtopage); - exit; - } elseif ($idProdOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProdOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); - exit; - } elseif ($idCompanyOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCompanyOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); - exit; - } elseif ($idSupplierOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idSupplierOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); - exit; - } elseif ($idMemberOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idMemberOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); - exit; - } elseif ($idContactOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); - exit; - } elseif ($idProjectOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProjectOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); - exit; - } - - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$result.'&type='.$type); - exit; - } +// Confirm action +if (($action == 'add' || $action == 'confirmed') && $user->rights->categorie->creer) +{ + // Action confirmation de creation categorie + if ($action == 'confirmed') + { + if ($urlfrom) + { + header("Location: ".$urlfrom); + exit; + } + elseif ($backtopage) + { + header("Location: ".$backtopage); + exit; + } + elseif ($idProdOrigin) + { + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProdOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); + exit; + } + elseif ($idCompanyOrigin) + { + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCompanyOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); + exit; + } + elseif ($idSupplierOrigin) + { + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idSupplierOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); + exit; + } + elseif ($idMemberOrigin) + { + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idMemberOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); + exit; + } + elseif ($idContactOrigin) + { + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); + exit; + } + elseif ($idProjectOrigin) + { + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProjectOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); + exit; + } + + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$result.'&type='.$type); + exit; @@ -206,0 +217 @@ + @@ -215,5 +226,5 @@ -$help_url = 'EN:Module_Categories|FR:Module_Catégories|DE:Modul_Kategorien'; - -llxHeader("", $langs->trans("Categories"), $help_url); - -if ($user->hasRight('categorie', 'creer')) { +$helpurl = ''; +llxHeader("", $langs->trans("Categories"), $helpurl); + +if ($user->rights->categorie->creer) +{ @@ -221 +232,2 @@ - if ($action == 'create' || GETPOST("addcat") == 'addcat') { + if ($action == 'create' || $_POST["addcat"] == 'addcat') + { @@ -232,6 +244,2 @@ - if ($origin) { - print ''; - } - if ($catorigin) { - print ''; - } + if ($origin) print ''; + if ($catorigin) print ''; @@ -241 +249 @@ - print dol_get_fiche_head(''); + dol_fiche_head(''); @@ -247 +255 @@ - print ''.$langs->trans("Ref").''; + print ''.$langs->trans("Ref").''; @@ -253 +261 @@ - $doleditor = new DolEditor('description', $description, '', 160, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_5, '90%'); + $doleditor = new DolEditor('description', $description, '', 200, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_6, '90%'); @@ -264 +271,0 @@ - print img_picto($langs->trans("ParentCategory"), 'category', 'class="pictofixedwidth"'); @@ -271,3 +278,4 @@ - print $hookmanager->resPrint; - if (empty($reshook)) { - print $object->showOptionals($extrafields, 'create', $parameters); + print $hookmanager->resPrint; + if (empty($reshook)) + { + print $object->showOptionals($extrafields, 'edit', $parameters); @@ -278 +286 @@ - print dol_get_fiche_end(''); + dol_fiche_end(''); @@ -281 +289 @@ - print ''; + print ''; @@ -283 +291 @@ - print ''; + print ''; --- /tmp/dsg/dolibarr/htdocs/categories/github_19.0.3_edit.php +++ /tmp/dsg/dolibarr/htdocs/categories/client_edit.php @@ -6 +5,0 @@ - * Copyright (C) 2020 Frédéric France @@ -28 +26,0 @@ -// Load Dolibarr environment @@ -38,2 +36,3 @@ -$ref = GETPOST('ref', 'alphanohtml'); -$action = (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'edit'); +$ref = GETPOST('ref'); +$type = GETPOST('type'); +$action = (GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'edit'); @@ -42 +40,0 @@ -$backtopage = GETPOST('backtopage', 'alpha'); @@ -44,6 +42,6 @@ -$socid = (int) GETPOST('socid', 'int'); -$label = (string) GETPOST('label', 'alphanohtml'); -$description = (string) GETPOST('description', 'restricthtml'); -$color = preg_replace('/[^0-9a-f#]/i', '', (string) GETPOST('color', 'alphanohtml')); -$visible = (int) GETPOST('visible', 'int'); -$parent = (int) GETPOST('parent', 'int'); +$socid = GETPOST('socid', 'int'); +$label = GETPOST('label'); +$description = GETPOST('description'); +$color = GETPOST('color', 'alpha'); +$visible = GETPOST('visible'); +$parent = GETPOST('parent'); @@ -51 +49,2 @@ -if ($id == "") { +if ($id == "") +{ @@ -60,9 +59,3 @@ -$result = $object->fetch($id, $label); -if ($result <= 0) { - dol_print_error($db, $object->error); - exit; -} - -$type = $object->type; -if (is_numeric($type)) { - $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility +if ($id > 0) +{ + $result = $object->fetch($id); @@ -77,2 +69,0 @@ -$error = 0; - @@ -83,5 +74,5 @@ -$parameters = array('id' => $id, 'ref' => $ref, 'cancel'=> $cancel, 'backtopage' => $backtopage, 'socid' => $socid, 'label' => $label, 'description' => $description, 'color' => $color, 'visible' => $visible, 'parent' => $parent); -// Note that $action and $object may be modified by some hooks -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if ($cancel) +{ + header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); + exit; @@ -90,6 +81,29 @@ -if (empty($reshook)) { - if ($cancel) { - if ($backtopage) { - header("Location: ".$backtopage); - exit; - } else { +// Action mise a jour d'une categorie +if ($action == 'update' && $user->rights->categorie->creer) +{ + $object->oldcopy = dol_clone($object); + $object->label = $label; + $object->description = dol_htmlcleanlastbr($description); + $object->color = $color; + $object->socid = ($socid ? $socid : 'null'); + $object->visible = $visible; + + if ($parent != "-1") + $object->fk_parent = $parent; + else + $object->fk_parent = ""; + + + if (empty($object->label)) + { + $error++; + $action = 'edit'; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); + } + if (!$error && empty($object->error)) + { + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) $error++; + + if (!$error && $object->update($user) > 0) + { @@ -99,36 +113,2 @@ - } - - // Action mise a jour d'une categorie - if ($action == 'update' && $user->hasRight('categorie', 'creer')) { - $object->oldcopy = dol_clone($object, 2); - - $object->label = $label; - $object->description = dol_htmlcleanlastbr($description); - $object->color = $color; - $object->socid = ($socid > 0 ? $socid : 0); - $object->visible = $visible; - $object->fk_parent = $parent != -1 ? $parent : 0; - - if (empty($object->label)) { - $error++; - $action = 'edit'; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); - } - if (!$error && empty($object->error)) { - $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); - if ($ret < 0) { - $error++; - } - - if (!$error && $object->update($user) > 0) { - if ($backtopage) { - header("Location: ".$backtopage); - exit; - } else { - header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); - exit; - } - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } else { + else + { @@ -137,0 +118,4 @@ + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } @@ -138,0 +123 @@ + @@ -161 +145,0 @@ -print ''; @@ -163 +147 @@ -print dol_get_fiche_head(''); +dol_fiche_head(''); @@ -176 +160 @@ -print ''; +print ''; @@ -178 +162 @@ -$doleditor = new DolEditor('description', $object->description, '', 200, 'dolibarr_notes', '', false, true, isModEnabled('fckeditor'), ROWS_6, '90%'); +$doleditor = new DolEditor('description', $object->description, '', 200, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, ROWS_6, '90%'); @@ -185 +169 @@ -print ''; +print ''; @@ -191 +174,0 @@ -print img_picto('', 'category', 'class="pictofixedwidth"'); @@ -193 +175,0 @@ -print ajax_combobox('parent'); @@ -199 +181,2 @@ -if (empty($reshook)) { +if (empty($reshook)) +{ @@ -206 +189 @@ -print dol_get_fiche_end(); +dol_fiche_end(); @@ -209 +192 @@ -print '
 
'; +print '
 
'; --- /tmp/dsg/dolibarr/htdocs/categories/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/categories/client_index.php @@ -8 +7,0 @@ - * Copyright (C) 2021 Frédéric France @@ -30 +28,0 @@ -// Load Dolibarr environment @@ -38,0 +37,2 @@ +if (!$user->rights->categorie->lire) accessforbidden(); + @@ -42 +41,0 @@ -$nosearch = GETPOST('nosearch', 'int'); @@ -45,10 +44 @@ -if (is_numeric($type)) { - $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility -} - -// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('categoryindex')); - -if (!$user->hasRight('categorie', 'lire')) { - accessforbidden(); -} +if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility @@ -63,2 +52,0 @@ -$moreparam = ($nosearch ? '&nosearch=1' : ''); - @@ -66,11 +54,5 @@ -if ($type == Categorie::TYPE_ACCOUNT) { - $title = $langs->trans('AccountsCategoriesArea'); -} elseif ($type == Categorie::TYPE_WAREHOUSE) { - $title = $langs->trans('StocksCategoriesArea'); -} elseif ($type == Categorie::TYPE_ACTIONCOMM) { - $title = $langs->trans('ActionCommCategoriesArea'); -} elseif ($type == Categorie::TYPE_WEBSITE_PAGE) { - $title = $langs->trans('WebsitePagesCategoriesArea'); -} else { - $title = $langs->trans(ucfirst($type).'sCategoriesArea'); -} +if ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans('AccountsCategoriesArea'); +elseif ($type == Categorie::TYPE_WAREHOUSE) $title = $langs->trans('StocksCategoriesArea'); +elseif ($type == Categorie::TYPE_ACTIONCOMM) $title = $langs->trans('ActionCommCategoriesArea'); +elseif ($type == Categorie::TYPE_WEBSITE_PAGE) $title = $langs->trans('WebsitePagesCategoriesArea'); +else $title = $langs->trans(ucfirst($type).'sCategoriesArea'); @@ -82,0 +65 @@ + @@ -84,2 +67,2 @@ -if ($user->hasRight('categorie', 'creer')) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewCategory'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/categories/card.php?action=create&type='.$type.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam).$moreparam); +if (!empty($user->rights->categorie->creer)) { + $newcardbutton .= dolGetButtonTitle($langs->trans('NewCategory'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/categories/card.php?action=create&type='.$type.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type='.$type)); @@ -90,57 +73,50 @@ -// Search categories -if (empty($nosearch)) { - print '
'; - - - print '
'; - print ''; - print ''; - print ''; - - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans("Search").'
'; - print $langs->trans("Name").':
'; - - - print '
'; - - - /* - * Categories found - */ - if ($catname || $id > 0) { - $cats = $categstatic->rechercher($id, $catname, $typetext); - - print ''; - print ''; - - foreach ($cats as $cat) { - $categstatic->id = $cat->id; - $categstatic->ref = $cat->label; - $categstatic->label = $cat->label; - $categstatic->type = $cat->type; - $categstatic->color = $cat->color; - $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"'; - - print "\t".''."\n"; - print "\t\t\n"; - print "\t\t\n"; - print "\t\n"; - } - print "
'.$langs->trans("FoundCats").'
"; - print ''; - print $categstatic->getNomUrl(1, ''); - print ''; - print ""; - $text = dolGetFirstLineOfText(dol_string_nohtmltag($cat->description, 1)); - $trunclength = 48; - print $form->textwithtooltip(dol_trunc($text, $trunclength), $cat->description); - print "
"; - } else { - print ' '; +print '
'; + + +/* + * Zone recherche produit/service + */ +print '
'; +print ''; +print ''; + + +print ''; +print ''; +print ''; +print ''; +print ''; +print '
'.$langs->trans("Search").'
'; +print $langs->trans("Name").':
'; + + +print '
'; + + +/* + * Categories found + */ +if ($catname || $id > 0) +{ + $cats = $categstatic->rechercher($id, $catname, $typetext); + + print ''; + print ''; + + foreach ($cats as $cat) + { + print "\t".''."\n"; + print "\t\t\n"; + print "\t\t\n"; + print "\t\n"; @@ -148,3 +124,6 @@ - - print ''; -} + print "
'.$langs->trans("FoundCats").'
"; + $categstatic->id = $cat->id; + $categstatic->ref = $cat->label; + $categstatic->label = $cat->label; + $categstatic->type = $cat->type; + $categstatic->color = $cat->color; + print 'color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #aaa"').'>'; + print $categstatic->getNomUrl(1, ''); + print ''; + print ""; + print dolGetFirstLineOfText($cat->description); + print "
"; +} +else print ' '; + + +print '
'; @@ -162,13 +141,6 @@ -if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) { - if ($type == Categorie::TYPE_MEMBER) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - } - if ($type == Categorie::TYPE_ACCOUNT) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - } - if ($type == Categorie::TYPE_PROJECT) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - } - if ($type == Categorie::TYPE_USER) { - require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - } +if ($conf->global->CATEGORY_SHOW_COUNTS) +{ + if ($type == Categorie::TYPE_MEMBER) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + if ($type == Categorie::TYPE_ACCOUNT) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + if ($type == Categorie::TYPE_PROJECT) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + if ($type == Categorie::TYPE_USER) require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -180 +152,2 @@ -foreach ($fulltree as $key => $val) { +foreach ($fulltree as $key => $val) +{ @@ -184,0 +158 @@ + $li = $categstatic->getNomUrl(1, '', 60); @@ -188 +162,3 @@ - if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) { + + if ($conf->global->CATEGORY_SHOW_COUNTS) + { @@ -190,5 +166,2 @@ - $elements = $type == Categorie::TYPE_ACCOUNT - ? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account" - : $categstatic->getObjectsInCateg($type, 1); - - $counter = "".(is_array($elements) ? count($elements) : '0').""; + $elements = $categstatic->getObjectsInCateg($type, 1); + $counter = "".(is_countable($elements) ? count($elements) : '0').""; @@ -197,33 +170,18 @@ - $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"'; - $li = $categstatic->getNomUrl(1, '', 60, '&backtolist='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam)); - - $entry = ''; - $entry .= ''; - - $entry .= ''; - - // Add column counter - $entry .= $counter; - - $entry .= ''; - $entry .= ''; - $entry .= ''; - - $entry .= ''; - $entry .= '
'; - $entry .= ''.$li.''; - $entry .= ''; - $entry .= ''.img_view().''; - $entry .= ''; - if ($user->hasRight('categorie', 'creer')) { - $entry .= '' . img_edit() . ''; - } - $entry .= ''; - if ($user->hasRight('categorie', 'supprimer')) { - $entry .= '' . img_delete() . ''; - } - $entry .= '
'; - - $data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry); -} - + $data[] = array( + 'rowid'=>$val['rowid'], + 'fk_menu'=>$val['fk_parent'], + 'entry'=>''.$counter. + '
color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #aaa"').'>'.$li.''.img_view().'
' + ); +} + + +//print_barre_liste('', 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, 0, '', 0, $newcardbutton, '', 0, 1, 1); + +print ''; +print ''; @@ -233,21 +191,3 @@ -$morethan1level = 0; -foreach ($data as $record) { - if (!empty($record['fk_menu']) && $record['fk_menu'] > 0) { - $morethan1level = 1; - } -} - - -print '
'.$langs->trans("Categories").''; +if (!empty($conf->use_javascript_ajax)) +{ + print ''; +} +print '
'; -print ''; - -if ($nbofentries > 0) { - print ''; +} +else +{ + print ''; @@ -259 +201 @@ - print ''; + print ''; @@ -297,2 +308,3 @@ - if (getDolGlobalString('CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION')) { - print ''; + if (!empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION)) + { + print ''; @@ -303,3 +315 @@ - if (!$cnt_trans && $action != 'add') { - print '
'.$langs->trans('NoTranslation').'
'; - } + if (!$cnt_trans && $action != 'add') print '
'.$langs->trans('NoTranslation').'
'; @@ -313 +323,2 @@ -if ($action == 'add' && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { +if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer)) +{ @@ -322 +333 @@ - print ''; + print ''; @@ -326 +337 @@ - print $formadmin->select_language(GETPOST('forcelangprod', 'alpha'), 'forcelangprod', 0, $object->multilangs); + print $formadmin->select_language(GETPOST('forcelangprod', 'alpha'), 'forcelangprod', 0, $object->multilangs); @@ -331 +342 @@ - $doleditor = new DolEditor('desc', GETPOST('desc', 'restricthtml'), '', 160, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_3, '90%'); + $doleditor = new DolEditor('desc', GETPOST('desc', 'none'), '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); @@ -338 +349,5 @@ - print $form->buttonsSaveCancel(); + print '
'; + print ''; + print '     '; + print ''; + print '
'; --- /tmp/dsg/dolibarr/htdocs/categories/github_19.0.3_viewcat.php +++ /tmp/dsg/dolibarr/htdocs/categories/client_viewcat.php @@ -8 +7,0 @@ - * Copyright (C) 2020 Josep Lluís Amador @@ -30 +28,0 @@ -// Load Dolibarr environment @@ -38 +36 @@ -$langs->loadLangs(array("categories", "compta")); +$langs->load("categories"); @@ -41,0 +40 @@ +$type = GETPOST('type', 'aZ09'); @@ -45 +44 @@ -$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... @@ -51 +50 @@ -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'categorylist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search @@ -53,2 +52 @@ -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') - +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') @@ -57,3 +55,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -61,3 +59 @@ -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { - $page = 0; -} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action @@ -68 +64,2 @@ -if ($id == "" && $label == "") { +if ($id == "" && $label == "") +{ @@ -77 +74 @@ -$result = $object->fetch($id, $label); +$result = $object->fetch($id, $label, $type); @@ -79,8 +76,8 @@ - dol_print_error($db, $object->error); - exit; -} - -$type = $object->type; -if (is_numeric($type)) { - $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility -} + dol_print_error($db, $object->error); exit; +} +$object->fetch_optionals(); +if ($result <= 0) { + dol_print_error($db, $object->error); exit; +} + +if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility @@ -92,0 +90 @@ + @@ -97,8 +94,0 @@ - -if ($confirm == 'no') { - if ($backtopage) { - header("Location: ".$backtopage); - exit; - } -} - @@ -108,2 +98,4 @@ -if ($id > 0 && $removeelem > 0 && $action == 'unlink') { - if ($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { +if ($id > 0 && $removeelem > 0) +{ + if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) + { @@ -114 +106,3 @@ - } elseif ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) { + } + elseif ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) + { @@ -118 +112,3 @@ - } elseif ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) { + } + elseif ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) + { @@ -122 +118,3 @@ - } elseif ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) { + } + elseif ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) + { @@ -127 +125,2 @@ - } elseif ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) { + } + elseif ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) { @@ -132,11 +131,17 @@ - } elseif ($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer')) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $tmpobject = new Account($db); - $result = $tmpobject->fetch($removeelem); - $elementtype = 'account'; - } elseif ($type == Categorie::TYPE_PROJECT && $user->hasRight('projet', 'creer')) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $tmpobject = new Project($db); - $result = $tmpobject->fetch($removeelem); - $elementtype = 'project'; - } elseif ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) { + } + elseif ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) + { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $tmpobject = new Account($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'account'; + } + elseif ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) + { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $tmpobject = new Project($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'project'; + } + elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) + { @@ -147,5 +151,0 @@ - } elseif ($type == Categorie::TYPE_TICKET && $user->hasRight('ticket', 'write')) { - require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; - $tmpobject = new Ticket($db); - $result = $tmpobject->fetch($removeelem); - $elementtype = 'ticket'; @@ -155,15 +155,12 @@ - if ($result < 0) { - dol_print_error('', $object->error); - } -} - -if ($user->hasRight('categorie', 'supprimer') && $action == 'confirm_delete' && $confirm == 'yes') { - if ($object->delete($user) >= 0) { - if ($backtopage) { - header("Location: ".$backtopage); - exit; - } else { - header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type); - exit; - } - } else { + if ($result < 0) dol_print_error('', $object->error); +} + +if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confirm == 'yes') +{ + if ($object->delete($user) >= 0) + { + header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type); + exit; + } + else + { @@ -174,51 +171,4 @@ -if ($elemid && $action == 'addintocategory' && - ( - ($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) || - ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) || - ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) || - ($type == Categorie::TYPE_TICKET && $user->hasRight('ticket', 'write')) || - ($type == Categorie::TYPE_PROJECT && $user->hasRight('projet', 'creer')) || - ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) || - ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) || - ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) || - ($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer')) - )) { - if ($type == Categorie::TYPE_PRODUCT) { - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $newobject = new Product($db); - $elementtype = 'product'; - } elseif ($type == Categorie::TYPE_CUSTOMER) { - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $newobject = new Societe($db); - $elementtype = 'customer'; - } elseif ($type == Categorie::TYPE_SUPPLIER) { - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $newobject = new Societe($db); - $elementtype = 'supplier'; - } elseif ($type == Categorie::TYPE_TICKET) { - require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; - $newobject = new Ticket($db); - $elementtype = 'ticket'; - } elseif ($type == Categorie::TYPE_PROJECT) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $newobject = new Project($db); - $elementtype = 'project'; - } elseif ($type == Categorie::TYPE_MEMBER) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $newobject = new Adherent($db); - $elementtype = 'member'; - } elseif ($type == Categorie::TYPE_CONTACT) { - require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $newobject = new Contact($db); - $elementtype = 'contact'; - } elseif ($type == Categorie::TYPE_USER) { - require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - $newobject = new User($db); - $elementtype = 'user'; - } elseif ($type == Categorie::TYPE_ACCOUNT) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $newobject = new Account($db); - $elementtype = 'bank_account'; - } else { - dol_print_error("Not supported value of type = ".$type); - } +if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory' && ($user->rights->produit->creer || $user->rights->service->creer)) +{ + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + $newobject = new Product($db); @@ -226,2 +176,3 @@ - - // Add into category + $elementtype = 'product'; + + // TODO Add into categ @@ -229 +180,2 @@ - if ($result >= 0) { + if ($result >= 0) + { @@ -231,2 +183,5 @@ - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + } + else + { + if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { @@ -234 +189,3 @@ - } else { + } + else + { @@ -250,4 +207,2 @@ - -$help_url = ''; - -llxHeader("", $langs->trans("Categories"), $help_url, '', 0, 0, $arrayofjs, $arrayofcss); +$helpurl = ''; +llxHeader("", $langs->trans("Categories"), $helpurl, '', 0, 0, $arrayofjs, $arrayofcss); @@ -258,5 +213,6 @@ -print dol_get_fiche_head($head, 'card', $langs->trans($title), -1, 'category'); - -$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.urlencode($type)); -$linkback = ''.$langs->trans("BackToList").''; -$object->next_prev_filter = 'type = '.((int) $object->type); + + +dol_fiche_head($head, 'card', $langs->trans($title), -1, 'category'); +$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type); +$linkback = ''.$langs->trans("BackToList").''; +$object->next_prev_filter = ' type = '.$object->type; @@ -264 +220 @@ -$morehtmlref = '
'.$langs->trans("Root").' >> '; +$morehtmlref = '
'.$langs->trans("Root").' >> '; @@ -266,2 +222,3 @@ -foreach ($ways as $way) { - $morehtmlref .= $way."
\n"; +foreach ($ways as $way) +{ + $morehtmlref .= $way."
\n"; @@ -271 +228 @@ -dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'label', $morehtmlref, '&type='.urlencode($type), 0, '', '', 1); +dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'label', $morehtmlref, '&type='.$type, 0, '', '', 1); @@ -278,6 +235,3 @@ -if ($action == 'delete') { - if ($backtopage) { - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&backtopage='.urlencode($backtopage), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 2); - } else { - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type, $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1); - } +if ($action == 'delete') +{ + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type, $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1); @@ -310 +264 @@ -print dol_get_fiche_end(); +dol_fiche_end(); @@ -318,13 +272,10 @@ -$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} -if (empty($reshook)) { - if ($user->hasRight('categorie', 'creer')) { - $socid = ($object->socid ? "&socid=".$object->socid : ""); - print ''.$langs->trans("Modify").''; - } - - if ($user->hasRight('categorie', 'supprimer')) { - print 'id.'&type='.$type.'&backtolist='.urlencode($backtolist).'">'.$langs->trans("Delete").''; - } + +if ($user->rights->categorie->creer) +{ + $socid = ($object->socid ? "&socid=".$object->socid : ""); + print "".$langs->trans("Modify").""; +} + +if ($user->rights->categorie->supprimer) +{ + print "".$langs->trans("Delete").""; @@ -336 +287,2 @@ -if ($user->hasRight('categorie', 'creer')) { +if (!empty($user->rights->categorie->creer)) +{ @@ -358 +310 @@ -print '
'.$langs->trans("Categories").''; -if ($morethan1level && !empty($conf->use_javascript_ajax)) { - print ''; -} -print '
'; +if ($nbofentries > 0) +{ + print '
'; @@ -256,2 +196,4 @@ -} else { - print '
'; + print ''; --- /tmp/dsg/dolibarr/htdocs/categories/github_19.0.3_info.php +++ /tmp/dsg/dolibarr/htdocs/categories/client_info.php @@ -23 +23 @@ - * \brief Category info page + * \brief Category info page @@ -26 +25,0 @@ -// Load Dolibarr environment @@ -32 +31 @@ -if (!$user->hasRight('categorie', 'lire')) { +if (!$user->rights->categorie->lire) { @@ -41 +39,0 @@ -$label = GETPOST('label', 'alpha'); @@ -44,3 +42 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; @@ -50,4 +46,3 @@ -$result = $object->fetch($id, $label); -if ($result <= 0) { - dol_print_error($db, $object->error); - exit; +if (!$object->fetch($id) > 0) { + dol_print_error($db); + exit; @@ -55 +49,0 @@ - @@ -57,3 +51 @@ -if (is_numeric($type)) { - $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility -} +if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility @@ -74 +65,0 @@ -print dol_get_fiche_head($head, 'info', $langs->trans($title), -1, 'category'); @@ -76,3 +67,4 @@ -$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.urlencode($type)); -$linkback = ''.$langs->trans("BackToList").''; -$object->next_prev_filter = 'type = '.((int) $object->type); +dol_fiche_head($head, 'info', $langs->trans($title), -1, 'category'); +$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type); +$linkback = ''.$langs->trans("BackToList").''; +$object->next_prev_filter = ' type = '.$type; @@ -80 +72 @@ -$morehtmlref = '
'.$langs->trans("Root").' >> '; +$morehtmlref = '
'.$langs->trans("Root").' >> '; @@ -83 +75 @@ - $morehtmlref .= $way."
\n"; + $morehtmlref .= $way."
\n"; @@ -106 +98 @@ -print dol_get_fiche_end(); +dol_fiche_end(); --- /tmp/dsg/dolibarr/htdocs/categories/github_19.0.3_photos.php +++ /tmp/dsg/dolibarr/htdocs/categories/client_photos.php @@ -29 +28,0 @@ -// Load Dolibarr environment @@ -42 +41,2 @@ -$action = GETPOST('action', 'aZ09'); +$type = GETPOST('type'); +$action = GETPOST('action', 'aZ09'); @@ -45,3 +45,4 @@ -if ($id == '' && $label == '') { - dol_print_error('', 'Missing parameter id'); - exit(); +if ($id == '' && $label == '') +{ + dol_print_error('', 'Missing parameter id'); + exit(); @@ -54 +55 @@ -$result = $object->fetch($id, $label); +$result = $object->fetch($id, $label, $type); @@ -56,9 +57,6 @@ - dol_print_error($db, $object->error); - exit; -} - -$type = $object->type; -if (is_numeric($type)) { - $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility -} - + dol_print_error($db, $object->error); exit; +} +$object->fetch_optionals(); +if ($result <= 0) { + dol_print_error($db, $object->error); exit; +} @@ -67 +65 @@ -$hookmanager->initHooks(array('categorycard')); +if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility @@ -72,34 +70,33 @@ -$parameters = array('id' => $id, 'label' => $label, 'confirm' => $confirm, 'type' => $type, 'uploaddir' => $upload_dir, 'sendfile' => (GETPOST("sendit") ? true : false)); -// Note that $action and $object may be modified by some hooks -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && GETPOST("sendit") && getDolGlobalString('MAIN_UPLOAD_DOC')) { - if ($object->id) { - $file = $_FILES['userfile']; - if (is_array($file['name']) && count($file['name']) > 0) { - foreach ($file['name'] as $i => $name) { - if (empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i])) { - setEventMessage($file['name'][$i].' : '.$langs->trans(empty($file['tmp_name'][$i]) ? 'ErrorFailedToSaveFile' : 'MaxSizeForUploadedFiles')); - unset($file['name'][$i], $file['type'][$i], $file['tmp_name'][$i], $file['error'][$i], $file['size'][$i]); - } - } - } - - if (!empty($file['tmp_name'])) { - $object->add_photo($upload_dir, $file); - } - } - } - - if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && $user->hasRight('categorie', 'creer')) { - $object->delete_photo($upload_dir."/".$_GET["file"]); - } - - if ($action == 'addthumb' && $_GET["file"]) { - $object->addThumbs($upload_dir."/".$_GET["file"]); - } -} + +if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) +{ + if ($object->id) { + $file = $_FILES['userfile']; + if (is_array($file['name']) && count($file['name']) > 0) + { + foreach ($file['name'] as $i => $name) + { + if (empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i])) + { + setEventMessage($file['name'][$i].' : '.$langs->trans(empty($file['tmp_name'][$i]) ? 'ErrorFailedToSaveFile' : 'MaxSizeForUploadedFiles')); + unset($file['name'][$i], $file['type'][$i], $file['tmp_name'][$i], $file['error'][$i], $file['size'][$i]); + } + } + } + + if (!empty($file['tmp_name'])) { + $object->add_photo($upload_dir, $file); + } + } +} + +if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && $user->rights->categorie->creer) +{ + $object->delete_photo($upload_dir."/".$_GET["file"]); +} + +if ($action == 'addthumb' && $_GET["file"]) +{ + $object->addThumbs($upload_dir."/".$_GET["file"]); +} + @@ -116 +113,2 @@ -if ($object->id) { +if ($object->id) +{ @@ -120,5 +118,6 @@ - print dol_get_fiche_head($head, 'photos', $langs->trans($title), -1, 'category'); - - $backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.urlencode($type)); - $linkback = ''.$langs->trans("BackToList").''; - $object->next_prev_filter = 'type = '.((int) $object->type); + + + dol_fiche_head($head, 'photos', $langs->trans($title), -1, 'category'); + + $linkback = ''.$langs->trans("BackToList").''; + $object->next_prev_filter = ' type = '.$object->type; @@ -128,2 +127,3 @@ - foreach ($ways as $way) { - $morehtmlref .= $way."
\n"; + foreach ($ways as $way) + { + $morehtmlref .= $way."
\n"; @@ -138,2 +138,3 @@ - if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1); + if ($action == 'delete') + { + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1); @@ -161,9 +162,12 @@ - print '
'; - - print dol_get_fiche_end(); - - - - /* - * Action bar - */ + print '
'; + + dol_fiche_end(); + + + + /* ************************************************************************** */ + /* */ + /* Barre d'action */ + /* */ + /* ************************************************************************** */ + @@ -172,2 +176,4 @@ - if ($action != 'ajout_photo' && $user->hasRight('categorie', 'creer')) { - if (getDolGlobalString('MAIN_UPLOAD_DOC')) { + if ($action != 'ajout_photo' && $user->rights->categorie->creer) + { + if (!empty($conf->global->MAIN_UPLOAD_DOC)) + { @@ -176 +182,3 @@ - } else { + } + else + { @@ -187 +195,2 @@ - if ($action == 'ajout_photo' && $user->hasRight('categorie', 'creer') && getDolGlobalString('MAIN_UPLOAD_DOC')) { + if ($action == 'ajout_photo' && $user->rights->categorie->creer && !empty($conf->global->MAIN_UPLOAD_DOC)) + { @@ -190 +199 @@ - $formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id.'&type='.$type, $langs->trans("AddPhoto"), 1, '', $user->hasRight('categorie', 'creer'), 50, $object, '', false, '', 0); + $formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id.'&type='.$type, $langs->trans("AddPhoto"), 1, '', $user->rights->categorie->creer, 50, $object, '', false, '', 0); @@ -194 +203,2 @@ - if ($action != 'ajout_photo') { + if ($action != 'ajout_photo') + { @@ -206,63 +216,64 @@ - if (is_array($listofphoto) && count($listofphoto)) { - print '
'; - print ''; - - foreach ($listofphoto as $key => $obj) { - $nbphoto++; - - if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) { - print ''; - } - if ($nbbyrow) { - print ''; - } - if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) { - print ''; - } - } - - // Ferme tableau - while ($nbphoto % $nbbyrow) { - print ''; - $nbphoto++; - } - - print '
'; - } - - print ''; - - // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine - if ($obj['photo_vignette']) { - $filename = $obj['photo_vignette']; - } else { - $filename = $obj['photo']; - } - - // Nom affiche - $viewfilename = $obj['photo']; - - // Taille de l'image - $object->get_image_size($dir.$filename); - $imgWidth = ($object->imgWidth < $maxWidth) ? $object->imgWidth : $maxWidth; - $imgHeight = ($object->imgHeight < $maxHeight) ? $object->imgHeight : $maxHeight; - - print ''; - - print ''; - print '
'.$viewfilename; - print '
'; - - // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites - if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight)) { - print ''.img_picto($langs->trans('GenerateThumb'), 'refresh').'  '; - } - if ($user->hasRight('categorie', 'creer')) { - print ''; - print img_delete().''; - } - if ($nbbyrow) { - print '
 
'; - } - - if ($nbphoto < 1) { + if (is_array($listofphoto) && count($listofphoto)) + { + print '
'; + print ''; + + foreach ($listofphoto as $key => $obj) + { + $nbphoto++; + + if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print ''; + if ($nbbyrow) print ''; + if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print ''; + } + + // Ferme tableau + while ($nbphoto % $nbbyrow) + { + print ''; + $nbphoto++; + } + + print '
'; + + print ''; + + // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine + if ($obj['photo_vignette']) + { + $filename = $obj['photo_vignette']; + } + else + { + $filename = $obj['photo']; + } + + // Nom affiche + $viewfilename = $obj['photo']; + + // Taille de l'image + $object->get_image_size($dir.$filename); + $imgWidth = ($object->imgWidth < $maxWidth) ? $object->imgWidth : $maxWidth; + $imgHeight = ($object->imgHeight < $maxHeight) ? $object->imgHeight : $maxHeight; + + print ''; + + print ''; + print '
'.$viewfilename; + print '
'; + + // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites + if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight)) + { + print ''.img_picto($langs->trans('GenerateThumb'), 'refresh').'  '; + } + if ($user->rights->categorie->creer) + { + print ''; + print img_delete().''; + } + if ($nbbyrow) print '
 
'; + } + + if ($nbphoto < 1) + { @@ -272,2 +283,4 @@ -} else { - print $langs->trans("ErrorUnknown"); +} +else +{ + print $langs->trans("ErrorUnknown"); --- /tmp/dsg/dolibarr/htdocs/categories/github_19.0.3_traduction.php +++ /tmp/dsg/dolibarr/htdocs/categories/client_traduction.php @@ -23,6 +23,5 @@ - * \file htdocs/categories/traduction.php - * \ingroup categories - * \brief Page of translation of categories - */ - -// Load Dolibarr environment + * \file htdocs/product/traduction.php + * \ingroup product + * \brief Page of translation of products + */ + @@ -41 +40 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -43,2 +42,4 @@ - -if ($id == '' && $label == '') { +$type = GETPOST('type', 'aZ09'); + +if ($id == '' && $label == '') +{ @@ -53 +54 @@ -$result = $object->fetch($id, $label); +$result = $object->fetch($id, $label, $type); @@ -55,9 +56,8 @@ - dol_print_error($db, $object->error); - exit; -} - -$type = $object->type; -if (is_numeric($type)) { - $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility -} - + dol_print_error($db, $object->error); exit; +} +$object->fetch_optionals(); +if ($result <= 0) { + dol_print_error($db, $object->error); exit; +} + +if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility @@ -68 +67,0 @@ - @@ -71,2 +70,3 @@ -// return to translation view if cancelled -if ($cancel == $langs->trans("Cancel")) { +// retour a l'affichage des traduction si annulation +if ($cancel == $langs->trans("Cancel")) +{ @@ -77 +77 @@ -// validation of addition +// Validation de l'ajout @@ -80 +80,2 @@ -($user->hasRight('categorie', 'creer'))) { +($user->rights->categorie->creer)) +{ @@ -85,42 +86,40 @@ - $forcelangprod = GETPOST('forcelangprod', 'alpha'); - $libelle = GETPOST('libelle', 'alpha'); - $desc = GETPOST('desc', 'restricthtml'); - - if (empty($forcelangprod)) { - $error++; - $object->errors[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Translation')); - } - - if (!$error) { - if (empty($libelle)) { - $error++; - $object->errors[] = $langs->trans('Language_'.$forcelangprod).' : '.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label')); - } - - if (!$error) { - // update the object - if ($forcelangprod == $current_lang) { - $object->label = $libelle; - $object->description = dol_htmlcleanlastbr($desc); - } else { - $object->multilangs[$forcelangprod]["label"] = $libelle; - $object->multilangs[$forcelangprod]["description"] = dol_htmlcleanlastbr($desc); - } - - // save in base / sauvegarde en base - $res = $object->setMultiLangs($user); - if ($res < 0) { - $error++; - } - } - } - - if ($error) { - $action = 'add'; - setEventMessages($object->error, $object->errors, 'errors'); - } else { - $action = ''; - } -} - -// validation of the edition + $forcelangprod = GETPOST('forcelangprod', 'alpha'); + $libelle = GETPOST('libelle', 'alpha'); + $desc = GETPOST('desc', 'none'); + + if (empty($forcelangprod)) { + $error++; + $object->errors[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Translation')); + } + + if (!$error) { + if (empty($libelle)) { + $error++; + $object->errors[] = $langs->trans('Language_'.$forcelangprod).' : '.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label')); + } + + if (!$error) { + // update de l'objet + if ($forcelangprod == $current_lang) { + $object->label = $libelle; + $object->description = dol_htmlcleanlastbr($desc); + } else { + $object->multilangs[$forcelangprod]["label"] = $libelle; + $object->multilangs[$forcelangprod]["description"] = dol_htmlcleanlastbr($desc); + } + + // sauvegarde en base + $res = $object->setMultiLangs($user); + if ($res < 0) $error++; + } + } + + if ($error) { + $action = 'add'; + setEventMessages($object->error, $object->errors, 'errors'); + } else { + $action = ''; + } +} + +// Validation de l'edition @@ -129 +128,2 @@ -($user->hasRight('categorie', 'creer'))) { +($user->rights->categorie->creer)) +{ @@ -133,8 +133,9 @@ - foreach ($object->multilangs as $key => $value) { // recording of new values in the object - $libelle = GETPOST('libelle-'.$key, 'alpha'); - $desc = GETPOST('desc-'.$key, 'restricthtml'); - - if (empty($libelle)) { - $error++; - $object->errors[] = $langs->trans('Language_'.$key).' : '.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label')); - } + foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet + { + $libelle = GETPOST('libelle-'.$key, 'alpha'); + $desc = GETPOST('desc-'.$key); + + if (empty($libelle)) { + $error++; + $object->errors[] = $langs->trans('Language_'.$key).' : '.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label')); + } @@ -151,13 +152,11 @@ - if (!$error) { - $res = $object->setMultiLangs($user); - if ($res < 0) { - $error++; - } - } - - if ($error) { - $action = 'edit'; - setEventMessages($object->error, $object->errors, 'errors'); - } else { - $action = ''; - } + if (!$error) { + $res = $object->setMultiLangs($user); + if ($res < 0) $error++; + } + + if ($error) { + $action = 'edit'; + setEventMessages($object->error, $object->errors, 'errors'); + } else { + $action = ''; + } @@ -171 +170 @@ -$form = new Form($db); +$form = new Form($db); @@ -183,11 +182,12 @@ -if (!empty($object->multilangs)) { - foreach ($object->multilangs as $key => $value) { - $cnt_trans++; - } -} - -print dol_get_fiche_head($head, 'translation', $langs->trans($title), -1, 'category'); - -$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.urlencode($type)); -$linkback = ''.$langs->trans("BackToList").''; -$object->next_prev_filter = 'type = '.((int) $object->type); +if (!empty($object->multilangs)) +{ + foreach ($object->multilangs as $key => $value) + { + $cnt_trans++; + } +} + +dol_fiche_head($head, 'translation', $langs->trans($title), -1, 'category'); + +$linkback = ''.$langs->trans("BackToList").''; +$object->next_prev_filter = ' type = '.$object->type; @@ -198 +198 @@ - $morehtmlref .= $way."
\n"; + $morehtmlref .= $way."
\n"; @@ -226,7 +226,10 @@ -print dol_get_fiche_end(); - - - -/* - * Action bar - */ +dol_fiche_end(); + + + + +/* ************************************************************************** */ +/* */ +/* Barre d'action */ +/* */ +/* ************************************************************************** */ @@ -236,7 +239,7 @@ -if ($action == '') { - if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { - print ''.$langs->trans('Add').''; - if ($cnt_trans > 0) { - print ''.$langs->trans('Update').''; - } - } +if ($action == '') +{ + if ($user->rights->produit->creer || $user->rights->service->creer) + { + print ''.$langs->trans('Add').''; + if ($cnt_trans > 0) print ''.$langs->trans('Update').''; + } @@ -249,2 +252,3 @@ -if ($action == 'edit') { - // WYSIWYG Editor +if ($action == 'edit') +{ + //WYSIWYG Editor @@ -257,5 +261,7 @@ - print ''; - - if (!empty($object->multilangs)) { - foreach ($object->multilangs as $key => $value) { - print "
".$langs->trans('Language_'.$key)." :
"; + print ''; + + if (!empty($object->multilangs)) + { + foreach ($object->multilangs as $key => $value) + { + print "
".$langs->trans('Language_'.$key)." :
"; @@ -265 +271 @@ - $libelle = (GETPOST('libelle-'.$key, 'alpha') ? GETPOST('libelle-'.$key, 'alpha') : $object->multilangs[$key]['label']); + $libelle = (GETPOST('libelle-'.$key, 'alpha') ? GETPOST('libelle-'.$key, 'alpha') : $object->multilangs[$key]['label']); @@ -267 +272,0 @@ - @@ -269 +274 @@ - $desc = (GETPOST('desc-'.$key) ? GETPOST('desc-'.$key) : $object->multilangs[$key]['description']); + $desc = (GETPOST('desc-'.$key) ? GETPOST('desc-'.$key) : $object->multilangs[$key]['description']); @@ -271 +276 @@ - $doleditor = new DolEditor("desc-$key", $desc, '', 160, 'dolibarr_notes', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_3, '90%'); + $doleditor = new DolEditor("desc-$key", $desc, '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); @@ -282 +287,5 @@ - print $form->buttonsSaveCancel(); + print '
'; + print ''; + print '     '; + print ''; + print '
'; @@ -285,8 +294,10 @@ -} elseif ($action != 'add') { - if ($cnt_trans) { - print '
'; - } - - if (!empty($object->multilangs)) { - foreach ($object->multilangs as $key => $value) { - $s = picto_from_langcode($key); +} +elseif ($action != 'add') +{ + if ($cnt_trans) print '
'; + + if (!empty($object->multilangs)) + { + foreach ($object->multilangs as $key => $value) + { + $s = picto_from_langcode($key); @@ -294 +305 @@ - print '
'.($s ? $s.' ' : '')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '').'
'.($s ? $s.' ' : '')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '').'
'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')'.$object->multilangs[$key]["other"].'
'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')'.$object->multilangs[$key]["other"].'
'; +print '
'; @@ -365 +317,2 @@ -if (!empty($conf->use_javascript_ajax)) { +if (!empty($conf->use_javascript_ajax)) +{ @@ -377,5 +330,8 @@ -if ($cats < 0) { - dol_print_error($db, $object->error, $object->errors); -} elseif (count($cats) < 1) { - print ''; - print ''; +if ($cats < 0) +{ + dol_print_error($db, $cats->error, $cats->errors); +} +elseif (count($cats) < 1) +{ + print ''; + print ''; @@ -383 +339,3 @@ -} else { +} +else +{ @@ -389,13 +347,6 @@ - if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) { - if ($type == Categorie::TYPE_MEMBER) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - } - if ($type == Categorie::TYPE_ACCOUNT) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - } - if ($type == Categorie::TYPE_PROJECT) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - } - if ($type == Categorie::TYPE_USER) { - require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - } + if ($conf->global->CATEGORY_SHOW_COUNTS) + { + if ($type == Categorie::TYPE_MEMBER) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + if ($type == Categorie::TYPE_ACCOUNT) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + if ($type == Categorie::TYPE_PROJECT) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + if ($type == Categorie::TYPE_USER) require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -407 +358,2 @@ - foreach ($fulltree as $key => $val) { + foreach ($fulltree as $key => $val) + { @@ -414,2 +366,4 @@ - $counter = ''; - if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) { + $counter = 0; + + if ($conf->global->CATEGORY_SHOW_COUNTS) + { @@ -417,7 +371,8 @@ - $elements = $categstatic->getObjectsInCateg($type, 1); - - $counter = ""; - } - - $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"'; - $li = $categstatic->getNomUrl(1, '', 60, '&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type)); + $elements = $type == Categorie::TYPE_ACCOUNT + ? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account" + : $categstatic->getObjectsInCateg($type, 1); + + $counter = is_countable($elements) ? count($elements) : 0; + } + + $color = $categstatic->color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #aaa"'; @@ -429 +384 @@ - $entry .= ''.$li.''; + $entry .= ''.$categstatic->getNomUrl(1, '', 60).''; @@ -432 +387 @@ - $entry .= $counter; + $entry .= ''; @@ -435,7 +390 @@ - $entry .= ''.img_view().''; - $entry .= ''; - $entry .= ''; - $entry .= ''; + print ''; @@ -494,28 +445,16 @@ -if ($type == Categorie::TYPE_PRODUCT) { - if ($user->hasRight("product", "read") || $user->hasRight("service", "read")) { - $permission = ($user->hasRight('produit', 'creer') || $user->hasRight('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 the category - $showclassifyform = 1; - if ($showclassifyform) { - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans("NoSubCat").'
'.$langs->trans("NoSubCat").'".(is_array($elements) ? count($elements) : '0')."'.$counter.''; - $entry .= ''.img_edit().''; - $entry .= ''; - $entry .= ''.img_delete().''; + $entry .= ''.img_view().''; @@ -450,2 +399,2 @@ - $nbofentries = (count($data) - 1); - if ($nbofentries > 0) { + if ((count($data) - 1)) + { @@ -461 +410,3 @@ - } else { + } + else + { @@ -468 +419 @@ - print ''.$langs->trans("NoCategoryYet").''.$langs->trans("NoCategoryYet").'
'; - print ''; - print ''; - print '
'; - print $langs->trans("AddProductServiceIntoCategory").'  '; - $form->select_produits('', 'elemid', '', 0, 0, -1, 2, '', 1, array(), 0, 1, 0, '', 0, '', null); - print '
'; - print ''; - } - +if ($type == Categorie::TYPE_PRODUCT) +{ + $permission = ($user->rights->produit->creer || $user->rights->service->creer); + + $prods = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($prods < 0) + { + dol_print_error($db, $prods->error, $prods->errors); + } + else + { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) + { + print '
'; @@ -527,37 +466,47 @@ - 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 ''."\n"; - print ''."\n"; - - 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 ''; + 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 ''; + print ''; + print '
'; + print $langs->trans("AddProductServiceIntoCategory").'  '; + $form->select_produits('', 'elemid', '', 0, 0, -1, 2, '', 1); + print '
'; + print ''; + } + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = ''; $newcardbutton = ''; + print_barre_liste($langs->trans("ProductsAndServices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit); + + + print ''."\n"; + print ''."\n"; + + 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 ''; + print "\n"; @@ -568,38 +517,60 @@ - print "
'.$langs->trans("Ref").'
'; + print $prod->getNomUrl(1); + print "'.$prod->label."'; + if ($permission) + { + print ""; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; @@ -565,2 +514,2 @@ - } else { - print '
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; - - print '
'."\n"; - } - } else { - print_barre_liste($langs->trans("ProductsAndServices"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'products'); - accessforbidden("NotEnoughPermissions", 0, 0); - } -} - -// List of customers -if ($type == Categorie::TYPE_CUSTOMER) { - if ($user->hasRight("societe", "read")) { - $permission = $user->hasRight('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").'  '; - $filter = '(s.client:IN:1,3)'; - print $form->select_company('', 'elemid', $filter); - print '
'; - print '
'; + } + else + { + print ''.$langs->trans("ThisCategoryHasNoItems").''; + } + print "\n"; + + print ''."\n"; + } +} + +if ($type == Categorie::TYPE_SUPPLIER) +{ + $permission = $user->rights->societe->creer; + + $socs = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($socs < 0) + { + dol_print_error($db, $socs->error, $socs->errors); + } + else + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($socs); $nbtotalofrecords = ''; $newcardbutton = ''; + print_barre_liste($langs->trans("Suppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit); + + print ''."\n"; + print '\n"; + + 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"; @@ -607,41 +578,56 @@ - - 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 '
'.$langs->trans("Name")."
'; + print $soc->getNomUrl(1); + print "'; + if ($permission) + { + print ""; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print '
'."\n"; - print ''."\n"; - - 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"; + } + 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 '
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + + print '
'."\n"; + } +} + +if ($type == Categorie::TYPE_CUSTOMER) +{ + $permission = $user->rights->societe->creer; + + $socs = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($socs < 0) + { + dol_print_error($db, $socs->error, $socs->errors); + } + else + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($socs); $nbtotalofrecords = ''; $newcardbutton = ''; + print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'companies', 0, $newcardbutton, '', $limit); + + print ''."\n"; + print ''."\n"; + + 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 ''; + print "\n"; @@ -652,38 +638,64 @@ - print "
'.$langs->trans("Name").'
'; + print $soc->getNomUrl(1); + print "'; + if ($permission) + { + print ""; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; @@ -649,2 +635,2 @@ - } else { - print '
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; - - print '
'."\n"; - } - } else { - print_barre_liste($langs->trans("Customers"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'companies'); - accessforbidden("NotEnoughPermissions", 0, 0); - } -} - -// List of suppliers -if ($type == Categorie::TYPE_SUPPLIER) { - if ($user->hasRight("fournisseur", "read")) { - $permission = $user->hasRight('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").'  '; - $filter ='(s.fournisseur:=:1)'; - print $form->select_company('', 'elemid', $filter); - print '
'; - print '
'; + } + else + { + print ''.$langs->trans("ThisCategoryHasNoItems").''; + } + print "\n"; + + print ''."\n"; + } +} + +// List of members +if ($type == Categorie::TYPE_MEMBER) +{ + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + + $permission = $user->rights->adherent->creer; + + $prods = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($prods < 0) + { + dol_print_error($db, $prods->error, $prods->errors); + } + else + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($prods); $nbtotalofrecords = ''; $newcardbutton = ''; + print_barre_liste($langs->trans("Member"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit); + + print "\n"; + print ''."\n"; + + 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"; @@ -691,42 +703,60 @@ - - 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 '
'.$langs->trans("Name").'
'; + $member->ref = $member->login; + print $member->getNomUrl(1, 0); + print "'.$member->lastname."'.$member->firstname."'; + if ($permission) + { + print ""; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print "
'."\n"; - print '\n"; - - 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"; + } + 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 '
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + + print '
'."\n"; + } +} + +// Categorie contact +if ($type == Categorie::TYPE_CONTACT) +{ + $permission = $user->rights->societe->creer; + + $contacts = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($contacts < 0) + { + dol_print_error($db, $contacts->error, $contacts->errors); + } + else + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; + $num = count($contacts); + $nbtotalofrecords = ''; + $newcardbutton = ''; + print_barre_liste($langs->trans("Contact"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contact', 0, $newcardbutton, '', $limit); + + print ''."\n"; + print ''."\n"; + + if (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 ''; + print "\n"; @@ -737,39 +767,128 @@ - print "
'.$langs->trans("Ref").'
'; + print $contact->getNomUrl(1, 'category'); + print "'; + if ($permission) + { + print ""; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; @@ -734,2 +764,2 @@ - } else { - print '
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; - - print '
'."\n"; - } - } else { - print_barre_liste($langs->trans("Suppliers"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'companies'); - accessforbidden("NotEnoughPermissions", 0, 0); - } -} - -// List of members -if ($type == Categorie::TYPE_MEMBER) { - if ($user->hasRight("adherent", "read")) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - - $permission = $user->hasRight('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 '
'; + } + else + { + print ''.$langs->trans("ThisCategoryHasNoItems").''; + } + print "\n"; + + print ''."\n"; + } +} + +// List of bank accounts +if ($type == Categorie::TYPE_ACCOUNT) +{ + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + + $permission = $user->rights->banque->creer; + + $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($accounts < 0) + { + dol_print_error($db, $accounts->error, $accounts->errors); + } + else + { + 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 "\n"; + print ''."\n"; + + 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"; + } + } + else + { + print ''; + } + print "
'.$langs->trans("Ref").'
'; + print $account->getNomUrl(1, 0); + print "'.$account->bank."'.$account->number."'; + if ($permission) + { + print ""; + 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 Project +if ($type == Categorie::TYPE_PROJECT) +{ + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + + $permission = $user->rights->projet->creer; + + $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("Project"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 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"; @@ -777,44 +896,57 @@ - - 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->hasRight('adherent', 'creer')); - - print_barre_liste($langs->trans("Member"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit); - - print '
'.$langs->trans("Ref").'
'; + print $project->getNomUrl(1); + print "'.$project->ref."'.$project->title."'; + if ($permission) + { + print ""; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print "
'."\n"; - print ''."\n"; - - 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 ''; - print "\n"; + } + 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 '
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + + print '
'."\n"; + } +} + +// List of users +if ($type == Categorie::TYPE_USER) +{ + 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 + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = ''; + + print_barre_liste($langs->trans("Users"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'user', 0, $newcardbutton, '', $limit); + + 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 ''; + print "\n"; @@ -825,37 +956,65 @@ - print "
'.$langs->trans("Users").' '.count($users).'
'; + print $userentry->getNomUrl(1); + print "'.$userentry->job."'; + if ($user->rights->user->user->creer) + { + print ""; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; @@ -822,2 +954 @@ - } else { - print '
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; - - print '
'."\n"; - } - } else { - print_barre_liste($langs->trans("Member"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'members'); - accessforbidden("NotEnoughPermissions", 0, 0); - } -} - -// List of contacts -if ($type == Categorie::TYPE_CONTACT) { - if ($user->hasRight("societe", "read")) { - $permission = $user->hasRight('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 '
'; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans("AssignCategoryTo").'  '; - print $form->selectContacts('', '', 'elemid'); - print '
'; - print '
'; + } + else + { + print ''.$langs->trans("ThisCategoryHasNoItems").''; + } + print "\n"; + + print ''."\n"; + } +} + + +// List of Project +if ($type == Categorie::TYPE_WAREHOUSE) +{ + $permission = $user->rights->stock->creer; + + 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"; @@ -863,468 +1022,11 @@ - 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); - - print_barre_liste($langs->trans("Contact"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contact', 0, $newcardbutton, '', $limit); - - $objsoc = new Societe($db); - - print '
'.$langs->trans("Ref").'
'; + print $project->getNomUrl(1); + print "'.$project->ref."'.$project->title."'; + if ($permission) + { + print ""; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print "
'."\n"; - print ''."\n"; - - 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"; - } - } 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 '
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; - - print '
'."\n"; - } - } else { - print_barre_liste($langs->trans("Contact"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'contact'); - accessforbidden("NotEnoughPermissions", 0, 0); - } -} - -// List of bank accounts -if ($type == Categorie::TYPE_ACCOUNT) { - if ($user->hasRight("banque", "read")) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - - $permission = $user->hasRight('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("AddObjectIntoCategory").'  '; - print $form->select_comptes('', 'elemid', 0, '', 0, '', 0, '', 1); - 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 ''."\n"; - print ''."\n"; - - 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 ''; - print "\n"; - } - } 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 '
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; - - print '
'."\n"; - } - } else { - print_barre_liste($langs->trans("Banque"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'bank'); - accessforbidden("NotEnoughPermissions", 0, 0); - } -} - -// List of Project -if ($type == Categorie::TYPE_PROJECT) { - if ($user->hasRight("project", "read")) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - - $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("AddObjectIntoCategory").'  '; - $form->selectProjects('', 'elemid'); - print '
'; - print '
'; - } - - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - - 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 ''."\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 ''; - print "\n"; - } - } 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"; - } - } else { - print_barre_liste($langs->trans("Project"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'project'); - accessforbidden("NotEnoughPermissions", 0, 0); - } -} - -// List of users -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 '
'; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - $force_entity = getEntity($object->element); // So we will get same filter than the getObjectsInCateg() - print img_picto('', $type, 'class="pictofixedwidth"'); - print $form->select_dolusers('', 'elemid', 1, null, 0, '', '', $force_entity); - print '
'; - print '
'; - } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - - print '
'; - - $param = '&limit='.$limit.'&id='.$id.'&type='.$type; - $num = count($users); - $nbtotalofrecords = ''; - $newcardbutton = ''; - - print_barre_liste($langs->trans("Users"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'user', 0, '', '', $limit); - - 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 ''; - print "\n"; - } - } else { - print ''; - } - print "
'.$langs->trans("Users").' '.$num.'
'; - print $userentry->getNomUrl(-1); - print "'.$userentry->job."'; - if ($user->hasRight('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").'
\n"; - - print '
'."\n"; - } - } else { - print_barre_liste($langs->trans("Users"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'user'); - accessforbidden("NotEnoughPermissions", 0, 0); - } -} - - -// List of warehouses -if ($type == Categorie::TYPE_WAREHOUSE) { - if ($user->hasRight("stock", "read")) { - $permission = $user->rights->stock->creer; - - 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 ''; - print "\n"; - } - } 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"; - } - } else { - print_barre_liste($langs->trans("Warehouse"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'stock'); - accessforbidden("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("NotEnoughPermissions", 0, 0); - } -} + } + else + { + print ''.$langs->trans("ThisCategoryHasNoItems").''; + } + print "\n"; + + print ''."\n"; + } +} +