diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index eb6dfaafcc6..23e5e86bedc 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -144,6 +144,26 @@ class Categorie extends CommonObject 'website_page' => 'WebsitePage' ); + /** + * @var array Title Area mapping from type string + * + * @note Move to const array when PHP 5.6 will be our minimum target + */ + public static $MAP_TYPE_TITLE_AREA = array( + 'product' => 'ProductsCategoriesArea', + 'customer' => 'CustomersCategoriesArea', + 'supplier' => 'SuppliersCategoriesArea', + 'member' => 'MembersCategoriesArea', + 'contact' => 'ContactsCategoriesArea', + 'user' => 'UsersCategoriesArea', + 'account' => 'AccountsCategoriesArea', // old for bank account + 'bank_account' => 'AccountsCategoriesArea', + 'project' => 'ProjectsCategoriesArea', + 'warehouse'=> 'StocksCategoriesArea', + 'actioncomm' => 'ActioncommCategoriesArea', + 'website_page' => 'WebsitePageCategoriesArea' + ); + /** * @var array Object table mapping from type string (table llx_...) when value of key does not match table name. * @@ -291,6 +311,7 @@ class Categorie extends CommonObject if (!is_numeric($type)) $type = $this->MAP_ID[$type]; $sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext"; + $sql .= ", date_creation, tms, fk_user_creat, fk_user_modif"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie"; if ($id > 0) { @@ -315,16 +336,20 @@ class Categorie extends CommonObject $res = $this->db->fetch_array($resql); $this->id = $res['rowid']; - //$this->ref = $res['rowid']; + //$this->ref = $res['rowid']; $this->fk_parent = $res['fk_parent']; $this->label = $res['label']; $this->description = $res['description']; $this->color = $res['color']; $this->socid = $res['fk_soc']; $this->visible = $res['visible']; - $this->type = $res['type']; + $this->type = $res['type']; $this->ref_ext = $res['ref_ext']; $this->entity = $res['entity']; + $this->date_creation = $this->db->jdate($$res['date_creation']); + $this->date_modification = $this->db->jdate($res['tms']); + $this->fk_user_create = $res['fk_user_create']; + $this->fk_user_modif = $res['fk_user_modif']; // Retreive all extrafield // fetch optionals attributes and labels diff --git a/htdocs/categories/info.php b/htdocs/categories/info.php new file mode 100644 index 00000000000..efc52aa15cb --- /dev/null +++ b/htdocs/categories/info.php @@ -0,0 +1,96 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2017 Ferran Marcet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/categories/info.php + * \ingroup categories + * \brief Category info page + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; + +if (!$user->rights->categorie->lire) { + accessforbidden(); +} + +// Load translation files required by the page +$langs->loadLangs(array('categories', 'sendings')); + +$socid = 0; +$id = GETPOST('id', 'int'); + +// Security check +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'categorie', $id, '&category'); + +$object = new Categorie($db); +if (!$object->fetch($id) > 0) { + dol_print_error($db); + exit; +} +$type = $object->type; +if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility + +/* + * View + */ + +$form = new Form($db); + +llxHeader('', $langs->trans('Categories'), ''); + +//$object->info($object->id); + +$head = categories_prepare_head($object, $type); + +$title = Categorie::$MAP_TYPE_TITLE_AREA[$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; +$object->ref = $object->label; +$morehtmlref = '
'.$langs->trans("Root").' >> '; +$ways = $object->print_all_ways(" >> ", '', 1); +foreach ($ways as $way) { + $morehtmlref .= $way."
\n"; +} +$morehtmlref .= '
'; + +dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'label', $morehtmlref, '&type='.$type, 0, '', '', 1); + +print '
'; +print '
'; + +print '
'; + +print '
'; +dol_print_object_info($object); +print '
'; + +print '
'; + +dol_fiche_end(); + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 598d060e5f6..07e5d56d268 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -112,20 +112,12 @@ $formother = new FormOther($db); if ($object->id) { - if ($type == Categorie::TYPE_PRODUCT) $title = $langs->trans("ProductsCategoryShort"); - elseif ($type == Categorie::TYPE_SUPPLIER) $title = $langs->trans("SuppliersCategoryShort"); - elseif ($type == Categorie::TYPE_CUSTOMER) $title = $langs->trans("CustomersCategoryShort"); - elseif ($type == Categorie::TYPE_MEMBER) $title = $langs->trans("MembersCategoryShort"); - elseif ($type == Categorie::TYPE_CONTACT) $title = $langs->trans("ContactCategoriesShort"); - elseif ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans("AccountsCategoriesShort"); - elseif ($type == Categorie::TYPE_PROJECT) $title = $langs->trans("ProjectsCategoriesShort"); - elseif ($type == Categorie::TYPE_USER) $title = $langs->trans("UsersCategoriesShort"); - else $title = $langs->trans("Category"); + $title = Categorie::$MAP_TYPE_TITLE_AREA[$type]; $head = categories_prepare_head($object, $type); - dol_fiche_head($head, 'photos', $title, -1, 'category'); + dol_fiche_head($head, 'photos', $langs->trans($title), -1, 'category'); $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter = ' type = '.$object->type; diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index caf79d81e04..c3f87e404b7 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -173,15 +173,7 @@ $form = new Form($db); $formadmin = new FormAdmin($db); $formother = new FormOther($db); -if ($type == Categorie::TYPE_PRODUCT) $title = $langs->trans("ProductsCategoryShort"); -elseif ($type == Categorie::TYPE_SUPPLIER) $title = $langs->trans("SuppliersCategoryShort"); -elseif ($type == Categorie::TYPE_CUSTOMER) $title = $langs->trans("CustomersCategoryShort"); -elseif ($type == Categorie::TYPE_MEMBER) $title = $langs->trans("MembersCategoryShort"); -elseif ($type == Categorie::TYPE_CONTACT) $title = $langs->trans("ContactCategoriesShort"); -elseif ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans("AccountsCategoriesShort"); -elseif ($type == Categorie::TYPE_PROJECT) $title = $langs->trans("ProjectsCategoriesShort"); -elseif ($type == Categorie::TYPE_USER) $title = $langs->trans("UsersCategoriesShort"); -else $title = $langs->trans("Category"); +$title = Categorie::$MAP_TYPE_TITLE_AREA[$type]; $head = categories_prepare_head($object, $type); @@ -195,7 +187,7 @@ if (!empty($object->multilangs)) } } -dol_fiche_head($head, 'translation', $title, -1, 'category'); +dol_fiche_head($head, 'translation', $langs->trans($title), -1, 'category'); $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter = ' type = '.$object->type; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 5b31d2285fc..d259c8ca5a5 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -207,21 +207,12 @@ $arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css $helpurl = ''; llxHeader("", $langs->trans("Categories"), $helpurl, '', 0, 0, $arrayofjs, $arrayofcss); -if ($type == Categorie::TYPE_PRODUCT) { $title = $langs->trans("ProductsCategoriesArea"); $typetext = 'product'; } -elseif ($type == Categorie::TYPE_SUPPLIER) { $title = $langs->trans("SuppliersCategoriesArea"); $typetext = 'supplier'; } -elseif ($type == Categorie::TYPE_CUSTOMER) { $title = $langs->trans("CustomersCategoriesArea"); $typetext = 'customer'; } -elseif ($type == Categorie::TYPE_MEMBER) { $title = $langs->trans("MembersCategoriesArea"); $typetext = 'member'; } -elseif ($type == Categorie::TYPE_CONTACT) { $title = $langs->trans("ContactsCategoriesArea"); $typetext = 'contact'; } -elseif ($type == Categorie::TYPE_ACCOUNT) { $title = $langs->trans("AccountsCategoriesArea"); $typetext = 'bank_account'; } -elseif ($type == Categorie::TYPE_PROJECT) { $title = $langs->trans("ProjectsCategoriesArea"); $typetext = 'project'; } -elseif ($type == Categorie::TYPE_USER) { $title = $langs->trans("UsersCategoriesArea"); $typetext = 'user'; } -elseif ($type == Categorie::TYPE_WAREHOUSE) { $title = $langs->trans("StocksCategoriesArea"); $typetext = 'warehouse'; } -else { $title = $langs->trans("CategoriesArea"); $typetext = 'unknown'; } +$title = Categorie::$MAP_TYPE_TITLE_AREA[$type]; $head = categories_prepare_head($object, $type); -dol_fiche_head($head, 'card', $title, -1, 'category'); +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; @@ -350,7 +341,7 @@ else { $categstatic = new Categorie($db); - $fulltree = $categstatic->get_full_arbo($typetext, $object->id, 1); + $fulltree = $categstatic->get_full_arbo($type, $object->id, 1); // Load possible missing includes if ($conf->global->CATEGORY_SHOW_COUNTS) diff --git a/htdocs/core/lib/categories.lib.php b/htdocs/core/lib/categories.lib.php index 37ff7acad44..e0945f9a029 100644 --- a/htdocs/core/lib/categories.lib.php +++ b/htdocs/core/lib/categories.lib.php @@ -29,7 +29,7 @@ * @param string $type Type of category * @return array Array of tabs to show */ -function categories_prepare_head($object, $type) +function categories_prepare_head(Categorie $object, $type) { global $langs, $conf, $user; @@ -57,6 +57,11 @@ function categories_prepare_head($object, $type) $h++; } + $head[$h][0] = DOL_URL_ROOT.'/categories/info.php?id='.$object->id; + $head[$h][1] = $langs->trans("Info"); + $head[$h][2] = 'info'; + $h++; + // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab