diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php new file mode 100644 index 00000000000..7ff0c854dcf --- /dev/null +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -0,0 +1,151 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * + * 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/admin/categorie_extrafields.php + * \ingroup societe + * \brief Page to setup extra fields of category + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +$langs->load("categories"); +$langs->load("admin"); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=getStaticMember(get_class($extrafields),'type2label'); +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='categories'; //Must be the $element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + +/* + * View + */ + +$textobject=$langs->transnoentitiesnoconv("Categories"); + +$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'; +llxHeader('',$langs->trans("CompanySetup"),$help_url); + + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("CategoriesSetup"),$linkback,'setup'); + +$head = categoriesadmin_prepare_head(null); + +dol_fiche_head($head, 'attributes_categories', $langs->trans("Categories"), 0, 'categoriesadmin'); + +print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; +print '
'; + +// Load attribute_label +$extrafields->fetch_name_optionals_label($elementtype); + +print ""; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +$var=True; +foreach($extrafields->attribute_type as $key => $value) +{ + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + print '\n"; + print '\n"; + print '\n"; + print '\n"; + print ""; + // $i++; +} + +print "
'.$langs->trans("Label").''.$langs->trans("AttributeCode").''.$langs->trans("Type").''.$langs->trans("Size").''.$langs->trans("Unique").''.$langs->trans("Required").' 
".$extrafields->attribute_label[$key]."".$key."".$type2label[$extrafields->attribute_type[$key]]."'.$extrafields->attribute_size[$key]."'.yn($extrafields->attribute_unique[$key])."'.yn($extrafields->attribute_required[$key])."'.img_edit().''; + print "  ".img_delete()."
"; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation d'un champ optionnel + /* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
"; + print_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition d'un champ optionnel */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); +?> diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 244b1987448..9aec1a23319 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; class Categorie { public $element='category'; - public $table_element='category'; + public $table_element='categories'; var $id; var $fk_parent; diff --git a/htdocs/core/lib/categories.lib.php b/htdocs/core/lib/categories.lib.php index dc4b5aaac20..179ff317294 100644 --- a/htdocs/core/lib/categories.lib.php +++ b/htdocs/core/lib/categories.lib.php @@ -78,6 +78,11 @@ function categoriesadmin_prepare_head() $head[$h][1] = $langs->trans("Setup"); $head[$h][2] = 'setup'; $h++; + + $head[$h][0] = DOL_URL_ROOT.'/categories/admin/categorie_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsCategories"); + $head[$h][2] = 'attributes_categories'; + $h++; // Show more tabs from modules // Entries must be declared in modules descriptor with line diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 2eccc4701b3..030b40a09f4 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -63,7 +63,7 @@ class modCategorie extends DolibarrModules $this->depends = array(); // Config pages - $this->config_page_url = array(); + $this->config_page_url = array('categorie_extrafields.php@categories'); $this->langfiles = array("products","companies","categories"); // Constantes diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql index 0fb148e0f40..ff795a7ab79 100644 --- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql +++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql @@ -1064,4 +1064,17 @@ CREATE TABLE llx_payment_salary ( --New 1074 : Stock mouvement link to origin ALTER TABLE llx_stock_mouvement ADD fk_origin INT NOT NULL ; -ALTER TABLE llx_stock_mouvement ADD origintype VARCHAR( 32 ) NOT NULL ; \ No newline at end of file +ALTER TABLE llx_stock_mouvement ADD origintype VARCHAR( 32 ) NOT NULL ; + + +-- New : extrafield on categories +create table llx_categories_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_categories_extrafields ADD INDEX idx_categories_extrafields (fk_object); + diff --git a/htdocs/install/mysql/tables/llx_categories_extrafields.key.sql b/htdocs/install/mysql/tables/llx_categories_extrafields.key.sql new file mode 100644 index 00000000000..6089f886028 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_categories_extrafields.key.sql @@ -0,0 +1,20 @@ +-- =================================================================== +-- Copyright (C) 2014 Jean-François Ferry +-- +-- 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 . +-- +-- =================================================================== + + +ALTER TABLE llx_categories_extrafields ADD INDEX idx_categories_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_categories_extrafields.sql b/htdocs/install/mysql/tables/llx_categories_extrafields.sql new file mode 100644 index 00000000000..ff91cc34b2b --- /dev/null +++ b/htdocs/install/mysql/tables/llx_categories_extrafields.sql @@ -0,0 +1,26 @@ +-- ======================================================================== +-- Copyright (C) 2014 Jean-François Ferry +-- +-- 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 . +-- +-- ======================================================================== + +create table llx_categories_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 1740288683d..85d445dfc19 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -66,7 +66,7 @@ ReturnInCompany=Back to customer/prospect card ContentsVisibleByAll=The contents will be visible by all ContentsVisibleByAllShort=Contents visible by all ContentsNotVisibleByAllShort=Contents not visible by all -CategoriesTree=Categories tree +CategoriesTree=Categories tree² DeleteCategory=Delete category ConfirmDeleteCategory=Are you sure you want to delete this category ? RemoveFromCategory=Remove link with categorie @@ -106,4 +106,6 @@ CatCusLinks=Customer/Prospects CatSupLinks=Suppliers DeleteFromCat=Remove from category DeletePicture=Picture delete -ConfirmDeletePicture=Confirm picture deletion? \ No newline at end of file +ConfirmDeletePicture=Confirm picture deletion? +ExtraFieldsCategories=Complementary attributes +CategoriesSetup=Categories setup \ No newline at end of file