mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 01:28:19 +01:00
info categorie
This commit is contained in:
@@ -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)
|
||||
{
|
||||
@@ -325,6 +346,10 @@ class Categorie extends CommonObject
|
||||
$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
|
||||
|
||||
96
htdocs/categories/info.php
Normal file
96
htdocs/categories/info.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \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 = '<a href="'.$backtolist.'">'.$langs->trans("BackToList").'</a>';
|
||||
$object->next_prev_filter = ' type = '.$type;
|
||||
$object->ref = $object->label;
|
||||
$morehtmlref = '<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
|
||||
$ways = $object->print_all_ways(" >> ", '', 1);
|
||||
foreach ($ways as $way) {
|
||||
$morehtmlref .= $way."<br>\n";
|
||||
}
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'label', $morehtmlref, '&type='.$type, 0, '', '', 1);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<table width="100%"><tr><td>';
|
||||
dol_print_object_info($object);
|
||||
print '</td></tr></table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@@ -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 = '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("BackToList").'</a>';
|
||||
$object->next_prev_filter = ' type = '.$object->type;
|
||||
|
||||
@@ -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 = '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("BackToList").'</a>';
|
||||
$object->next_prev_filter = ' type = '.$object->type;
|
||||
|
||||
@@ -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 = '<a href="'.$backtolist.'">'.$langs->trans("BackToList").'</a>';
|
||||
$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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user