diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 51d9ca2bced..16f9aed618f 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -70,7 +70,7 @@ $hookmanager->initHooks(array('admin'));
// Put here declaration of dictionaries properties
// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
-$taborder=array(9,0,4,3,2,0,1,8,19,16,0,5,11,0,6,0,10,25,12,13,0,14,0,7,17,0,22,20,18,21,0,15,0,24,23);
+$taborder=array(9,0,4,3,2,0,1,8,19,16,0,5,11,0,6,0,10,25,12,13,0,14,0,7,17,0,22,20,18,21,0,15,0,24,23,0,26);
// Name of SQL tables of dictionaries
$tabname=array();
@@ -99,6 +99,7 @@ $tabname[22]= MAIN_DB_PREFIX."c_input_reason";
$tabname[23]= MAIN_DB_PREFIX."accountingaccount";
$tabname[24]= MAIN_DB_PREFIX."accounting_system";
$tabname[25]= MAIN_DB_PREFIX."c_revenuestamp";
+$tabname[26]= MAIN_DB_PREFIX."c_type_resource";
// Dictionary labels
$tablib=array();
@@ -127,6 +128,7 @@ $tablib[22]= "DictionarySource";
$tablib[23]= "DictionaryAccountancyplan";
$tablib[24]= "DictionaryAccountancysystem";
$tablib[25]= "DictionaryRevenueStamp";
+$tablib[26]= "DictionaryResourceType";
// Requete pour extraction des donnees des dictionnaires
$tabsql=array();
@@ -155,6 +157,7 @@ $tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX
$tabsql[23]= "SELECT rowid as rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number as accountancy_code, account_parent, label, active FROM ".MAIN_DB_PREFIX."accountingaccount";
$tabsql[24]= "SELECT s.rowid as rowid, pcg_version, s.fk_pays as country_id, p.code as country_code, p.libelle as pays, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_pays as p WHERE s.fk_pays=p.rowid and p.active=1";
$tabsql[25]= "SELECT t.rowid, t.taux, p.libelle as country, p.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_pays as p WHERE t.fk_pays=p.rowid";
+$tabsql[26]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
// Critere de tri du dictionnaire
$tabsqlsort=array();
@@ -183,6 +186,7 @@ $tabsqlsort[22]="code ASC, label ASC";
$tabsqlsort[23]="fk_pcg_version ASC, accountancy_code ASC";
$tabsqlsort[24]="pcg_version ASC";
$tabsqlsort[25]="country ASC, taux ASC";
+$tabsqlsort[26]="code ASC,label ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
@@ -211,6 +215,7 @@ $tabfield[22]= "code,label";
$tabfield[23]= "fk_pcg_version,accountancy_code,account_parent,pcg_type,pcg_subtype,label";
$tabfield[24]= "pcg_version,country_id,country,label";
$tabfield[25]= "country_id,country,taux,accountancy_code_sell,accountancy_code_buy,note";
+$tabfield[26]= "code,label";
// Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array();
@@ -239,6 +244,7 @@ $tabfieldvalue[22]= "code,label";
$tabfieldvalue[23]= "fk_pcg_version,accountancy_code,account_parent,pcg_type,pcg_subtype,label";
$tabfieldvalue[24]= "pcg_version,country,label";
$tabfieldvalue[25]= "country,taux,accountancy_code_sell,accountancy_code_buy,note";
+$tabfieldvalue[26]= "code,label";
// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array();
@@ -267,6 +273,7 @@ $tabfieldinsert[22]= "code,label";
$tabfieldinsert[23]= "fk_pcg_version,account_number,account_parent,pcg_type,pcg_subtype,label";
$tabfieldinsert[24]= "pcg_version,fk_pays,label";
$tabfieldinsert[25]= "fk_pays,taux,accountancy_code_sell,accountancy_code_buy,note";
+$tabfieldinsert[26]= "code,label";
// Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on
@@ -297,6 +304,7 @@ $tabrowid[22]= "rowid";
$tabrowid[23]= "";
$tabrowid[24]= "";
$tabrowid[25]= "";
+$tabrowid[25]= "";
// Condition to show dictionary in setup page
$tabcond=array();
@@ -325,6 +333,7 @@ $tabcond[22]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabl
$tabcond[23]= (! empty($conf->global->ACCOUNTING_USEDICTTOEDIT) && ! empty($conf->accounting->enabled)); // The accountancy plan should be edited with specific pages. You can set ACCOUNTING_USEDICTTOEDIT to 1 if you want to use dictionary editor.
$tabcond[24]= (! empty($conf->global->ACCOUNTING_USEDICTTOEDIT) && ! empty($conf->accounting->enabled)); // The accountancy system should be edited with specific pages. You can set ACCOUNTING_USEDICTTOEDIT to 1 if you want to use dictionary editor.
$tabcond[25]= true;
+$tabcond[26]= ! empty($conf->resource->enabled);
// List of help for fields
$tabhelp=array();
@@ -353,6 +362,7 @@ $tabhelp[22] = array();
$tabhelp[23] = array();
$tabhelp[24] = array();
$tabhelp[25] = array();
+$tabhelp[26] = array();
// Complete all arrays with entries found into modules
complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp);
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 5bb313ab6f7..7f13f128541 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -3285,6 +3285,92 @@ abstract class CommonObject
print '';
}
+
+ /**
+ * Add resources to the current object : add entry into llx_element_resources
+ *Need $this->element & $this->id
+ *
+ * @param int $resource_id Resource id
+ * @param string $resource_element Resource element
+ * @return int <=0 if KO, >0 if OK
+ */
+ function add_element_resource($resource_id,$resource_element,$busy=0,$mandatory=0)
+ {
+ $this->db->begin();
+
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_resources (";
+ $sql.= "resource_id";
+ $sql.= ", resource_type";
+ $sql.= ", element_id";
+ $sql.= ", element_type";
+ $sql.= ", busy";
+ $sql.= ", mandatory";
+ $sql.= ") VALUES (";
+ $sql.= $resource_id;
+ $sql.= ", '".$resource_element."'";
+ $sql.= ", '".$this->id."'";
+ $sql.= ", '".$this->element."'";
+ $sql.= ", '".$busy."'";
+ $sql.= ", '".$mandatory."'";
+ $sql.= ")";
+
+ dol_syslog(get_class($this)."::add_element_resource sql=".$sql, LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
+ $this->db->rollback();
+ return 0;
+ }
+ }
+
+ /**
+ * Delete a link to resource line
+ *
+ * @param int $rowid Id of resource line to delete
+ * @param int $element element name (for trigger) TODO: use $this->element into commonobject class
+ * @param int $notrigger Disable all triggers
+ * @return int >0 if OK, <0 if KO
+ */
+ function delete_resource($rowid, $element, $notrigger=0)
+ {
+ global $user,$langs,$conf;
+
+ $error=0;
+
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources";
+ $sql.= " WHERE rowid =".$rowid;
+
+ dol_syslog(get_class($this)."::delete_resource sql=".$sql);
+ if ($this->db->query($sql))
+ {
+ if (! $notrigger)
+ {
+ // Call triggers
+ include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ $interface=new Interfaces($this->db);
+ $result=$interface->run_triggers(strtoupper($element).'_DELETE_RESOURCE',$this,$user,$langs,$conf);
+ if ($result < 0) {
+ $error++; $this->errors=$interface->errors;
+ }
+ // End call triggers
+ }
+
+ return 1;
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
+ dol_syslog(get_class($this)."::delete_resource error=".$this->error, LOG_ERR);
+ return -1;
+ }
+ }
+
+
/**
* Overwrite magic function to solve problem of cloning object that are kept as references
*
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index efa0af07843..cc84823c276 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -1656,3 +1656,125 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent)
return $totalnb;
}
}
+
+/**
+ * Get an array with properties of an element
+*
+* @param string $element_type Element type. ex : project_task or object@modulext or object_under@module
+* @return array (module, classpath, element, subelement, classfile, classname)
+*/
+function getElementProperties($element_type)
+{
+ // Parse element/subelement (ex: project_task)
+ $module = $element = $subelement = $element_type;
+
+ // If we ask an resource form external module (instead of default path)
+ if (preg_match('/^([^@]+)@([^@]+)$/i',$element_type,$regs))
+ {
+ $element = $subelement = $regs[1];
+ $module = $regs[2];
+ }
+
+ //print ' 1. element : '.$element.' - module : '.$module .' ';
+ if ( preg_match('/^([^_]+)_([^_]+)/i',$element,$regs))
+ {
+ $module = $element = $regs[1];
+ $subelement = $regs[2];
+ }
+
+ $classfile = strtolower($subelement);
+ $classname = ucfirst($subelement);
+ $classpath = $module.'/class';
+
+ // For compat
+ if($element_type == "action") {
+ $classpath = 'comm/action/class';
+ $subelement = 'Actioncomm';
+ $module = 'agenda';
+ }
+
+ // To work with non standard path
+ if ($element_type == 'facture' || $element_type == 'invoice') {
+ $classpath = 'compta/facture/class';
+ $module='facture';
+ $subelement='facture';
+ }
+ if ($element_type == 'commande' || $element_type == 'order') {
+ $classpath = 'commande/class';
+ $module='commande';
+ $subelement='commande';
+ }
+ if ($element_type == 'propal') {
+ $classpath = 'comm/propal/class';
+ }
+ if ($element_type == 'shipping') {
+ $classpath = 'expedition/class';
+ $subelement = 'expedition';
+ $module = 'expedition_bon';
+ }
+ if ($element_type == 'delivery') {
+ $classpath = 'livraison/class';
+ $subelement = 'livraison';
+ $module = 'livraison_bon';
+ }
+ if ($element_type == 'contract') {
+ $classpath = 'contrat/class';
+ $module='contrat';
+ $subelement='contrat';
+ }
+ if ($element_type == 'member') {
+ $classpath = 'adherents/class';
+ $module='adherent';
+ $subelement='adherent';
+ }
+ if ($element_type == 'cabinetmed_cons') {
+ $classpath = 'cabinetmed/class';
+ $module='cabinetmed';
+ $subelement='cabinetmedcons';
+ }
+ if ($element_type == 'fichinter') {
+ $classpath = 'fichinter/class';
+ $module='ficheinter';
+ $subelement='fichinter';
+ }
+ $classfile = strtolower($subelement);
+ $classname = ucfirst($subelement);
+
+ $element_properties = array(
+ 'module' => $module,
+ 'classpath' => $classpath,
+ 'element' => $element,
+ 'subelement' => $subelement,
+ 'classfile' => $classfile,
+ 'classname' => $classname
+ );
+ return $element_properties;
+}
+
+/**
+ * Fetch an object with element_type and its id
+ * Inclusion classes is automatic
+ *
+ * @param int $element_id Element id
+ * @param string $element_type Element type
+ * @return object || 0 || -1 if error
+ */
+function fetchObjectByElement($element_id,$element_type) {
+
+ global $conf;
+ global $db,$conf;
+
+ $element_prop = getElementProperties($element_type);
+ if (is_array($element_prop) && $conf->$element_prop['module']->enabled)
+ {
+ dol_include_once('/'.$element_prop['classpath'].'/'.$element_prop['classfile'].'.class.php');
+
+ $objectstat = new $element_prop['classname']($db);
+ $ret = $objectstat->fetch($element_id);
+ if ($ret >= 0)
+ {
+ return $objectstat;
+ }
+ }
+ return 0;
+}
diff --git a/htdocs/core/lib/resource.lib.php b/htdocs/core/lib/resource.lib.php
new file mode 100644
index 00000000000..c516485ed9d
--- /dev/null
+++ b/htdocs/core/lib/resource.lib.php
@@ -0,0 +1,44 @@
+
+ *
+ * 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 lib/resource.lib.php
+ * \ingroup resource
+ * \brief This file is library for resource module
+ */
+
+function resourcePrepareHead($object)
+{
+ global $langs, $conf, $user;
+ $h = 0;
+ $head = array();
+
+ $head[$h][0] = dol_buildpath('/resource/card.php',1).'?id='.$object->id;
+ $head[$h][1] = $langs->trans("ResourceCard");
+ $head[$h][2] = 'resource';
+ $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
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
+ complete_head_from_modules($conf,$langs,$object,$head,$h,'resource');
+
+
+ return $head;
+}
diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php
new file mode 100644
index 00000000000..b391c6bb4af
--- /dev/null
+++ b/htdocs/core/modules/modResource.class.php
@@ -0,0 +1,391 @@
+
+ *
+ * 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 .
+ */
+
+/**
+ * \defgroup resource Resource module
+ * \brief Resource module descriptor.
+ * \file core/modules/modResource.class.php
+ * \ingroup resource
+ * \brief Description and activation file for module Resource
+ */
+include_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php";
+
+/**
+ * Description and activation class for module Resource
+ */
+class modResource extends DolibarrModules
+{
+
+ /**
+ * Constructor. Define names, constants, directories, boxes, permissions
+ *
+ * @param DoliDB $db Database handler
+ */
+ public function __construct($db)
+ {
+ global $langs, $conf;
+
+ $this->db = $db;
+
+ // Id for module (must be unique).
+ // Use a free id here
+ // (See in Home -> System information -> Dolibarr for list of used modules id).
+ $this->numero = 110111;
+ // Key text used to identify module (for permissions, menus, etc...)
+ $this->rights_class = 'resource';
+
+ // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
+ // It is used to group modules in module setup page
+ $this->family = "hr";
+ // Module label (no space allowed)
+ // used if translation string 'ModuleXXXName' not found
+ // (where XXX is value of numeric property 'numero' of module)
+ $this->name = preg_replace('/^mod/i', '', get_class($this));
+ // Module description
+ // used if translation string 'ModuleXXXDesc' not found
+ // (where XXX is value of numeric property 'numero' of module)
+ $this->description = "Description of module Resource";
+ // Possible values for version are: 'development', 'experimental' or version
+ $this->version = 'experimental';
+ // Key used in llx_const table to save module status enabled/disabled
+ // (where MYMODULE is value of property name of module in uppercase)
+ $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
+ // Where to store the module in setup page
+ // (0=common,1=interface,2=others,3=very specific)
+ $this->special = 0;
+ // Name of image file used for this module.
+ // If file is in theme/yourtheme/img directory under name object_pictovalue.png
+ // use this->picto='pictovalue'
+ // If file is in module/img directory under name object_pictovalue.png
+ // use this->picto='pictovalue@module'
+ $this->picto = 'resource'; // mypicto@resource
+ // Defined all module parts (triggers, login, substitutions, menus, css, etc...)
+ // for default path (eg: /resource/core/xxxxx) (0=disable, 1=enable)
+ // for specific path of parts (eg: /resource/core/modules/barcode)
+ // for specific css file (eg: /resource/css/resource.css.php)
+ $this->module_parts = array(
+ // Set this to 1 if module has its own trigger directory
+ //'triggers' => 1,
+ // Set this to 1 if module has its own login method directory
+ //'login' => 0,
+ // Set this to 1 if module has its own substitution function file
+ //'substitutions' => 0,
+ // Set this to 1 if module has its own menus handler directory
+ //'menus' => 0,
+ // Set this to 1 if module has its own barcode directory
+ //'barcode' => 0,
+ // Set this to 1 if module has its own models directory
+ //'models' => 0,
+ // Set this to relative path of css if module has its own css file
+ //'css' => '/resource/css/resource.css.php',
+ // Set here all hooks context managed by module
+ 'hooks' => array('actioncard','actioncommdao','resource_card','element_resource')
+ // Set here all workflow context managed by module
+ //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE'))
+ );
+
+ // Data directories to create when module is enabled.
+ // Example: this->dirs = array("/resource/temp");
+ //$this->dirs = array("/resource");
+
+ // Config pages. Put here list of php pages
+ // stored into resource/admin directory, used to setup module.
+ //$this->config_page_url = array("admin_resource.php@resource");
+
+ // Dependencies
+ // List of modules id that must be enabled if this module is enabled
+ $this->depends = array();
+ // List of modules id to disable if this one is disabled
+ $this->requiredby = array('modPlace');
+ // Minimum version of PHP required by module
+ $this->phpmin = array(5, 3);
+ // Minimum version of Dolibarr required by module
+ $this->need_dolibarr_version = array(3, 5);
+ $this->langfiles = array("resource@resource"); // langfiles@resource
+ // Constants
+ // List of particular constants to add when module is enabled
+ // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
+ // Example:
+ $this->const = array();
+
+ // Array to add new pages in new tabs
+ // Example:
+ $this->tabs = array(
+ // // To add a new tab identified by code tabname1
+ // 'objecttype:+tabname1:Title1:langfile@resource:$user->rights->resource->read:/resource/mynewtab1.php?id=__ID__',
+ // // To add another new tab identified by code tabname2
+ // 'objecttype:+tabname2:Title2:langfile@resource:$user->rights->othermodule->read:/resource/mynewtab2.php?id=__ID__',
+ // // To remove an existing tab identified by code tabname
+ // 'objecttype:-tabname'
+ );
+ // where objecttype can be
+ // 'thirdparty' to add a tab in third party view
+ // 'intervention' to add a tab in intervention view
+ // 'order_supplier' to add a tab in supplier order view
+ // 'invoice_supplier' to add a tab in supplier invoice view
+ // 'invoice' to add a tab in customer invoice view
+ // 'order' to add a tab in customer order view
+ // 'product' to add a tab in product view
+ // 'stock' to add a tab in stock view
+ // 'propal' to add a tab in propal view
+ // 'member' to add a tab in fundation member view
+ // 'contract' to add a tab in contract view
+ // 'user' to add a tab in user view
+ // 'group' to add a tab in group view
+ // 'contact' to add a tab in contact view
+ // 'categories_x' to add a tab in category view
+ // (reresource 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
+
+ $this->tabs = array(
+ 'action:+resources:Resources:resource:$user->rights->resource->read:/resource/element_resource.php?element=action&element_id=__ID__',
+ 'thirdparty:+resources:Resources:resource:$user->rights->resource->read:/resource/element_resource.php?element=societe&element_id=__ID__'
+ );
+
+ // Boxes
+ // Add here list of php file(s) stored in core/boxes that contains class to show a box.
+ $this->boxes = array(); // Boxes list
+ $r = 0;
+ // Example:
+
+ //$this->boxes[$r][1] = "MyBox@resource";
+ //$r ++;
+ /*
+ $this->boxes[$r][1] = "myboxb.php";
+ $r++;
+ */
+
+ // Permissions
+ $this->rights = array(); // Permission array used by this module
+ $r = 0;
+
+ $this->rights[$r][0] = 1101201;
+ $this->rights[$r][1] = 'See resources';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'read';
+ $r++;
+
+ $this->rights[$r][0] = 1101202;
+ $this->rights[$r][1] = 'Modify resources';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'write';
+ $r++;
+
+ $this->rights[$r][0] = 1101203;
+ $this->rights[$r][1] = 'Delete resources';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'delete';
+ $r++;
+
+ $this->rights[$r][0] = 1101204;
+ $this->rights[$r][1] = 'Link resources';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'link';
+ $r++;
+
+
+ // Add here list of permission defined by
+ // an id, a label, a boolean and two constant strings.
+ // Example:
+ //// Permission id (must not be already used)
+ //$this->rights[$r][0] = 2000;
+ //// Permission label
+ //$this->rights[$r][1] = 'Permision label';
+ //// Permission by default for new user (0/1)
+ //$this->rights[$r][3] = 1;
+ //// In php code, permission will be checked by test
+ //// if ($user->rights->permkey->level1->level2)
+ //$this->rights[$r][4] = 'level1';
+ //// In php code, permission will be checked by test
+ //// if ($user->rights->permkey->level1->level2)
+ //$this->rights[$r][5] = 'level2';
+ //$r++;
+ // Main menu entries
+ $this->menu = array(); // List of menus to add
+ $r = 0;
+
+ // Menus declaration
+ $this->menu[$r]=array(
+ 'fk_menu'=>'fk_mainmenu=tools',
+ 'type'=>'left',
+ 'titre'=> 'MenuResourceIndex',
+ 'mainmenu'=>'tools',
+ 'leftmenu'=> 'resource',
+ 'url'=> '/resource/list.php',
+ 'langs'=> 'resource',
+ 'position'=> 100,
+ 'enabled'=> '1',
+ 'perms'=> '$user->rights->resource->read',
+ 'user'=> 0
+ );
+ $r++;
+
+ $this->menu[$r++]=array(
+ 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=resource', //On utilise les ancres définis dans le menu parent déclaré au dessus
+ 'type'=> 'left', // Toujours un menu gauche
+ 'titre'=> 'MenuResourceAdd',
+ 'mainmenu'=> 'tools',
+ 'leftmenu'=> '', // On n'indique rien ici car on ne souhaite pas intégrer de sous-menus à ce menu
+ 'url'=> '/resource/add.php',
+ 'langs'=> 'resource',
+ 'position'=> 101,
+ 'enabled'=> '1',
+ 'perms'=> '$user->rights->resource->read',
+ 'target'=> '',
+ 'user'=> 0
+ );
+
+ // Exports
+ $r = 1;
+
+ // Example:
+ //$this->export_code[$r]=$this->rights_class.'_'.$r;
+ //// Translation key (used only if key ExportDataset_xxx_z not found)
+ //$this->export_label[$r]='CustomersInvoicesAndInvoiceLines';
+ //// Condition to show export in list (ie: '$user->id==3').
+ //// Set to 1 to always show when module is enabled.
+ //$this->export_enabled[$r]='1';
+ //$this->export_permission[$r]=array(array("facture","facture","export"));
+ //$this->export_fields_array[$r]=array(
+ // 's.rowid'=>"IdCompany",
+ // 's.nom'=>'CompanyName',
+ // 's.address'=>'Address',
+ // 's.cp'=>'Zip',
+ // 's.ville'=>'Town',
+ // 's.fk_pays'=>'Country',
+ // 's.tel'=>'Phone',
+ // 's.siren'=>'ProfId1',
+ // 's.siret'=>'ProfId2',
+ // 's.ape'=>'ProfId3',
+ // 's.idprof4'=>'ProfId4',
+ // 's.code_compta'=>'CustomerAccountancyCode',
+ // 's.code_compta_fournisseur'=>'SupplierAccountancyCode',
+ // 'f.rowid'=>"InvoiceId",
+ // 'f.facnumber'=>"InvoiceRef",
+ // 'f.datec'=>"InvoiceDateCreation",
+ // 'f.datef'=>"DateInvoice",
+ // 'f.total'=>"TotalHT",
+ // 'f.total_ttc'=>"TotalTTC",
+ // 'f.tva'=>"TotalVAT",
+ // 'f.paye'=>"InvoicePaid",
+ // 'f.fk_statut'=>'InvoiceStatus',
+ // 'f.note'=>"InvoiceNote",
+ // 'fd.rowid'=>'LineId',
+ // 'fd.description'=>"LineDescription",
+ // 'fd.price'=>"LineUnitPrice",
+ // 'fd.tva_tx'=>"LineVATRate",
+ // 'fd.qty'=>"LineQty",
+ // 'fd.total_ht'=>"LineTotalHT",
+ // 'fd.total_tva'=>"LineTotalTVA",
+ // 'fd.total_ttc'=>"LineTotalTTC",
+ // 'fd.date_start'=>"DateStart",
+ // 'fd.date_end'=>"DateEnd",
+ // 'fd.fk_product'=>'ProductId',
+ // 'p.ref'=>'ProductRef'
+ //);
+ //$this->export_entities_array[$r]=array('s.rowid'=>"company",
+ // 's.nom'=>'company',
+ // 's.address'=>'company',
+ // 's.cp'=>'company',
+ // 's.ville'=>'company',
+ // 's.fk_pays'=>'company',
+ // 's.tel'=>'company',
+ // 's.siren'=>'company',
+ // 's.siret'=>'company',
+ // 's.ape'=>'company',
+ // 's.idprof4'=>'company',
+ // 's.code_compta'=>'company',
+ // 's.code_compta_fournisseur'=>'company',
+ // 'f.rowid'=>"invoice",
+ // 'f.facnumber'=>"invoice",
+ // 'f.datec'=>"invoice",
+ // 'f.datef'=>"invoice",
+ // 'f.total'=>"invoice",
+ // 'f.total_ttc'=>"invoice",
+ // 'f.tva'=>"invoice",
+ // 'f.paye'=>"invoice",
+ // 'f.fk_statut'=>'invoice',
+ // 'f.note'=>"invoice",
+ // 'fd.rowid'=>'invoice_line',
+ // 'fd.description'=>"invoice_line",
+ // 'fd.price'=>"invoice_line",
+ // 'fd.total_ht'=>"invoice_line",
+ // 'fd.total_tva'=>"invoice_line",
+ // 'fd.total_ttc'=>"invoice_line",
+ // 'fd.tva_tx'=>"invoice_line",
+ // 'fd.qty'=>"invoice_line",
+ // 'fd.date_start'=>"invoice_line",
+ // 'fd.date_end'=>"invoice_line",
+ // 'fd.fk_product'=>'product',
+ // 'p.ref'=>'product'
+ //);
+ //$this->export_sql_start[$r] = 'SELECT DISTINCT ';
+ //$this->export_sql_end[$r] = ' FROM (' . MAIN_DB_PREFIX . 'facture as f, '
+ // . MAIN_DB_PREFIX . 'facturedet as fd, ' . MAIN_DB_PREFIX . 'societe as s)';
+ //$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX
+ // . 'product as p on (fd.fk_product = p.rowid)';
+ //$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid '
+ // . 'AND f.rowid = fd.fk_facture';
+ //$r++;
+ }
+
+ /**
+ * Function called when module is enabled.
+ * The init function add constants, boxes, permissions and menus
+ * (defined in constructor) into Dolibarr database.
+ * It also creates data directories
+ *
+ * @param string $options Options when enabling module ('', 'noboxes')
+ * @return int 1 if OK, 0 if KO
+ */
+ public function init($options = '')
+ {
+ $sql = array();
+
+ $result = $this->loadTables();
+
+ return $this->_init($sql, $options);
+ }
+
+ /**
+ * Function called when module is disabled.
+ * Remove from database constants, boxes and permissions from Dolibarr database.
+ * Data directories are not deleted
+ *
+ * @param string $options Options when enabling module ('', 'noboxes')
+ * @return int 1 if OK, 0 if KO
+ */
+ public function remove($options = '')
+ {
+ $sql = array();
+
+ return $this->_remove($sql, $options);
+ }
+
+ /**
+ * Create tables, keys and data required by module
+ * Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys
+ * and create data commands must be stored in directory /resource/sql/
+ * This function is called by this->init
+ *
+ * @return int <=0 if KO, >0 if OK
+ */
+ private function loadTables()
+ {
+ return $this->_load_tables('/resource/sql/');
+ }
+}
diff --git a/htdocs/core/tpl/resource_add.tpl.php b/htdocs/core/tpl/resource_add.tpl.php
new file mode 100644
index 00000000000..f9cd20b5dc3
--- /dev/null
+++ b/htdocs/core/tpl/resource_add.tpl.php
@@ -0,0 +1,45 @@
+load($resource_type);
+
+$form = new Form($db);
+if(!class_exists('FormResource'))
+ require_once(DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php');
+$formresources = new FormResource($db);
+
+$out .= '
';
+
+}
+// FIN DU TPL
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 35b8571813a..f4945b0c30f 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
@@ -1003,7 +1003,7 @@ create table llx_product_customer_price
datec datetime,
tms timestamp,
fk_product integer NOT NULL,
- fk_soc integer NOT NULL,
+ fk_soc integer NOT NULL,
price double(24,8) DEFAULT 0,
price_ttc double(24,8) DEFAULT 0,
price_min double(24,8) DEFAULT 0,
@@ -1011,7 +1011,7 @@ create table llx_product_customer_price
price_base_type varchar(3) DEFAULT 'HT',
tva_tx double(6,3),
recuperableonly integer NOT NULL DEFAULT '0', -- Other NPR VAT
- localtax1_tx double(6,3) DEFAULT 0, -- Other local VAT 1
+ localtax1_tx double(6,3) DEFAULT 0, -- Other local VAT 1
localtax2_tx double(6,3) DEFAULT 0, -- Other local VAT 2
fk_user integer,
import_key varchar(14) -- Import key
@@ -1038,7 +1038,7 @@ create table llx_product_customer_price_log
entity integer DEFAULT 1 NOT NULL, -- multi company id
datec datetime,
fk_product integer NOT NULL,
- fk_soc integer NOT NULL,
+ fk_soc integer NOT NULL,
price double(24,8) DEFAULT 0,
price_ttc double(24,8) DEFAULT 0,
price_min double(24,8) DEFAULT 0,
@@ -1046,7 +1046,7 @@ create table llx_product_customer_price_log
price_base_type varchar(3) DEFAULT 'HT',
tva_tx double(6,3),
recuperableonly integer NOT NULL DEFAULT 0, -- Other NPR VAT
- localtax1_tx double(6,3) DEFAULT 0, -- Other local VAT 1
+ localtax1_tx double(6,3) DEFAULT 0, -- Other local VAT 1
localtax2_tx double(6,3) DEFAULT 0, -- Other local VAT 2
fk_user integer,
import_key varchar(14) -- Import key
@@ -1091,10 +1091,10 @@ CREATE TABLE llx_payment_salary (
num_payment varchar(50),
label varchar(255),
datesp date, -- date de début de la période
- dateep date, -- date de fin de la période
+ dateep date, -- date de fin de la période
entity integer DEFAULT 1 NOT NULL, -- multi company id
note text,
- fk_bank integer,
+ fk_bank integer,
fk_user_creat integer,
fk_user_modif integer
)ENGINE=innodb;
@@ -1155,3 +1155,45 @@ create table llx_categorie_lang
ALTER TABLE llx_categorie_lang ADD UNIQUE INDEX uk_category_lang (fk_category, lang);
ALTER TABLE llx_categorie_lang ADD CONSTRAINT fk_category_lang_fk_category FOREIGN KEY (fk_category) REFERENCES llx_categorie (rowid);
+
+-- Resource module
+CREATE TABLE llx_resource
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ entity integer,
+ ref varchar(255),
+ description text,
+ fk_code_type_resource varchar(32),
+ note_public text,
+ note_private text,
+ tms timestamp
+)ENGINE=innodb;
+
+ALTER TABLE llx_resource ADD INDEX fk_code_type_resource_idx (fk_code_type_resource);
+
+CREATE TABLE llx_element_resources
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ resource_id integer,
+ resource_type varchar(64),
+ element_id integer,
+ element_type varchar(64),
+ busy integer,
+ mandatory integer,
+ fk_user_create integer,
+ tms timestamp
+)ENGINE=innodb;
+
+ALTER TABLE llx_element_resources ADD UNIQUE INDEX idx_element_resources_idx1 (resource_id, resource_type, element_id, element_type);
+ALTER TABLE llx_element_resources ADD INDEX idx_element_element_element_id (element_id);
+-- Pas de contraite sur resource_id et element_id car pointe sur differentes tables
+
+create table llx_c_type_resource
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ code varchar(32) NOT NULL,
+ label varchar(64) NOT NULL,
+ active tinyint DEFAULT 1 NOT NULL
+)ENGINE=innodb;
+
+ALTER TABLE llx_c_type_resource ADD UNIQUE INDEX uk_c_type_resource_id (label, code);
diff --git a/htdocs/install/mysql/tables/llx_c_type_resource.key.sql b/htdocs/install/mysql/tables/llx_c_type_resource.key.sql
new file mode 100644
index 00000000000..5a76ff0cfa6
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_c_type_resource.key.sql
@@ -0,0 +1,21 @@
+-- ========================================================================
+-- Copyright (C) 2014 Laurent Destailleur
+--
+-- 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_c_type_contact ADD UNIQUE INDEX uk_c_type_contact_id (element, source, code);
+
diff --git a/htdocs/install/mysql/tables/llx_c_type_resource.sql b/htdocs/install/mysql/tables/llx_c_type_resource.sql
new file mode 100644
index 00000000000..efb505ba574
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_c_type_resource.sql
@@ -0,0 +1,34 @@
+-- ========================================================================
+-- 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 .
+--
+-- Defini les types de contact d'un element sert de reference pour
+-- la table llx_element_contact
+--
+-- element est le nom de la table utilisant le type de contact.
+-- i.e. contact, facture, projet, societe (sans le llx_ devant).
+-- Libelle est un texte decrivant le type de contact.
+-- active precise si cette valeur est 'active' ou 'archive'.
+--
+-- ========================================================================
+
+create table llx_c_type_resource
+(
+ rowid integer PRIMARY KEY,
+ code varchar(32) NOT NULL,
+ libelle varchar(64) NOT NULL,
+ active tinyint DEFAULT 1 NOT NULL
+)ENGINE=innodb;
diff --git a/htdocs/install/mysql/tables/llx_element_resources.key.sql b/htdocs/install/mysql/tables/llx_element_resources.key.sql
new file mode 100644
index 00000000000..72dd5f3d850
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_element_resources.key.sql
@@ -0,0 +1,23 @@
+-- ============================================================================
+-- 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_element_resources ADD UNIQUE INDEX idx_element_resources_idx1 (resource_id, resource_type, element_id, element_type);
+ALTER TABLE llx_element_resources ADD INDEX idx_element_element_element_id (element_id);
+-- Pas de contraite sur resource_id et element_id car pointe sur differentes tables
+
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_element_resources.sql b/htdocs/install/mysql/tables/llx_element_resources.sql
new file mode 100644
index 00000000000..3cc636ceab4
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_element_resources.sql
@@ -0,0 +1,28 @@
+--
+-- Copyright (C) 2013 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_element_resources
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ resource_id integer,
+ resource_type varchar(64),
+ element_id integer,
+ element_type varchar(64),
+ busy integer,
+ mandatory integer,
+ fk_user_create integer,
+ tms timestamp
+)ENGINE=innodb;
diff --git a/htdocs/install/mysql/tables/llx_resource.key.sql b/htdocs/install/mysql/tables/llx_resource.key.sql
new file mode 100755
index 00000000000..62eb21056c4
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_resource.key.sql
@@ -0,0 +1,18 @@
+-- Module to manage resources into Dolibarr ERP/CRM
+-- Copyright (C) 2013 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_resource ADD INDEX fk_code_type_resource_idx (fk_code_type_resource);
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_resource.sql b/htdocs/install/mysql/tables/llx_resource.sql
new file mode 100755
index 00000000000..91ebbe8b75d
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_resource.sql
@@ -0,0 +1,27 @@
+-- Module to manage resources into Dolibarr ERP/CRM
+-- Copyright (C) 2013 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_resource
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ entity integer,
+ ref varchar(255),
+ description text,
+ fk_code_type_resource varchar(32),
+ note_public text,
+ note_private text,
+ tms timestamp
+)ENGINE=innodb;
\ No newline at end of file
diff --git a/htdocs/langs/en_US/resource.lang b/htdocs/langs/en_US/resource.lang
new file mode 100755
index 00000000000..f5927388193
--- /dev/null
+++ b/htdocs/langs/en_US/resource.lang
@@ -0,0 +1,33 @@
+
+MenuResourceIndex=Resources
+MenuResourceAdd=New resource
+MenuResourcePlanning=Resource planning
+DeleteResource=Delete resource
+ConfirmDeleteResourceElement=Confirm delete the resource for this element
+NoResourceInDatabase=No resource in database.
+NoResourceLinked=No resource linked
+
+ResourcePageIndex=Resources list
+ResourceSingular=Resource
+ResourceCard=Resource card
+AddResource=Add a resource
+ResourceFormLabel_ref=Resource name
+ResourceType=Resource type
+ResourceFormLabel_description=Resource description
+
+ResourcesLinkedToElement=Resources linked to element
+RessourceLineSuccessfullyUpdated=Resource successfully updated
+RessourceLineSuccessfullyDeleted=Resource successfully deleted
+
+ShowResourcePlanning=Show resource planning
+NoResourceInDatabase=No resource in database
+GotoDate=Go to date
+
+ResourceCreatedWithSuccess=Resource successfully created
+RessourceLineSuccessfullyDeleted=Resource line successfully deleted
+RessourceLineSuccessfullyUpdated=Resource line successfully updated
+
+TitleResourceCard=Resource card
+ConfirmDeleteResource=Confirm to delete this resource
+RessourceSuccessfullyDeleted=Resource successfully deleted
+DictionaryResourceType=Type of resources
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/resource.lang b/htdocs/langs/fr_FR/resource.lang
new file mode 100755
index 00000000000..7d896e27f5f
--- /dev/null
+++ b/htdocs/langs/fr_FR/resource.lang
@@ -0,0 +1,33 @@
+
+MenuResourceIndex=Ressources
+MenuResourceAdd=Nouvelle ressource
+MenuResourcePlanning=Planning des Ressources
+DeleteResource=Effacer resource
+ConfirmDeleteResourceElement=Confirmer la suppression de la ressource pour cet élément
+NoResourceInDatabase=Aucune ressource en base de données.
+NoResourceLinked=Aucune ressource liée
+
+ResourcePageIndex=Liste des Ressources
+ResourceSingular=Ressource
+ResourceCard=Fiche ressource
+AddResource=Ajouter une ressource
+ResourceFormLabel_ref=Nom de la ressource
+ResourceType=Type de la ressource
+ResourceFormLabel_description=Description de la ressource
+
+ResourcesLinkedToElement=Ressources liées à l'élément
+RessourceLineSuccessfullyUpdated=Ressource mise à jour
+RessourceLineSuccessfullyDeleted=Resource supprimée
+
+ShowResourcePlanning=Montrer le planning des ressources
+PlanningOfAffectedResources=Planning des ressources affectées aux évènements
+GotoDate=Afficher la date
+
+ResourceCreatedWithSuccess=Ressource créee avec succès
+RessourceLineSuccessfullyDeleted=Ressource supprimée avec succès
+RessourceLineSuccessfullyUpdated=Ressource mise à jour
+
+TitleResourceCard=Fiche resource
+ConfirmDeleteResource=Confirmer la suppression de cette ressource?
+RessourceSuccessfullyDeleted=Ressource effacée avec succès
+DictionaryResourceType=Type de ressources
\ No newline at end of file
diff --git a/htdocs/resource/add.php b/htdocs/resource/add.php
new file mode 100755
index 00000000000..5b127204185
--- /dev/null
+++ b/htdocs/resource/add.php
@@ -0,0 +1,175 @@
+
+ *
+ * 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 resource/add.php
+ * \ingroup resource
+ * \brief Page to manage resource object
+ * Initialy built by build_class_from_table on 2013-07-24 16:03
+ */
+
+
+// Change this following line to use the correct relative path (../, ../../, etc)
+$res=0;
+$res=@include("../main.inc.php"); // For root directory
+if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory
+if (! $res) die("Include of main fails");
+
+require_once 'class/resource.class.php';
+require_once 'class/html.formresource.class.php';
+
+// Load traductions files requiredby by page
+$langs->load("resource");
+$langs->load("companies");
+$langs->load("other");
+$langs->load("resource@resource");
+
+// Get parameters
+$id = GETPOST('id','int');
+$action = GETPOST('action','alpha');
+if (empty($sortorder)) $sortorder="DESC";
+if (empty($sortfield)) $sortfield="t.rowid";
+if (empty($arch)) $arch = 0;
+
+if ($page == -1) {
+ $page = 0 ;
+}
+
+$limit = $conf->global->limit;
+$offset = $limit * $page ;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+
+
+// Protection if external user
+if ($user->societe_id > 0)
+{
+ accessforbidden();
+}
+
+$object = new Resource($db);
+
+if ($action == 'confirm_add_resource')
+{
+ $error='';
+
+ $ref=GETPOST('ref','alpha');
+ $description=GETPOST('description','alpha');
+ $fk_code_type_resource=GETPOST('fk_code_type_resource','alpha');
+
+ if (empty($ref))
+ {
+ $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
+ setEventMessage($mesg, 'errors');
+ $error++;
+ }
+
+ if (! $error)
+ {
+ $object=new Resource($db);
+ $object->ref=$ref;
+ $object->description=$description;
+ $object->fk_code_type_resource=$fk_code_type_resource;
+
+ $result=$object->create($user);
+ if ($result > 0)
+ {
+ // Creation OK
+ $db->commit();
+ setEventMessage($langs->trans('ResourceCreatedWithSuccess'));
+ Header("Location: card.php?id=" . $object->id);
+ return;
+ }
+ else
+ {
+ // Creation KO
+ setEventMessage($object->error, 'errors');
+ $action = '';
+ }
+ }
+ else
+ {
+ $action = '';
+ }
+}
+
+/***************************************************
+* VIEW
+*
+****************************************************/
+
+$form=new Form($db);
+$formresource = new FormResource($db);
+
+if ( !$action )
+{
+ $pagetitle=$langs->trans('AddResource');
+ llxHeader('',$pagetitle,'');
+ print_fiche_titre($pagetitle,'','resource.png@resource');
+
+ print '';
+}
+
+
+// End of page
+llxFooter();
+$db->close();
+?>
diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php
new file mode 100755
index 00000000000..1ecf827fe39
--- /dev/null
+++ b/htdocs/resource/card.php
@@ -0,0 +1,252 @@
+
+ *
+ * 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 resource/card.php
+ * \ingroup resource
+ * \brief Page to manage resource object
+ */
+
+
+// Change this following line to use the correct relative path (../, ../../, etc)
+$res=0;
+$res=@include("../main.inc.php"); // For root directory
+if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory
+if (! $res) die("Include of main fails");
+
+require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
+require_once 'class/resource.class.php';
+require_once 'class/html.formresource.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
+
+// Load traductions files requiredby by page
+$langs->load("resource");
+$langs->load("companies");
+$langs->load("other");
+$langs->load("main");
+
+// Get parameters
+$id = GETPOST('id','int');
+$action = GETPOST('action','alpha');
+$ref = GETPOST('ref');
+$description = GETPOST('description');
+$fk_code_type_resource = GETPOST('fk_code_type_resource','alpha');
+
+// Protection if external user
+if ($user->societe_id > 0)
+{
+ accessforbidden();
+}
+
+if( ! $user->rights->resource->read)
+ accessforbidden();
+
+$object = new Resource($db);
+
+$hookmanager->initHooks(array('resource_card'));
+$parameters=array('resource_id'=>$id);
+$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+
+
+/*******************************************************************
+* ACTIONS
+*
+* Put here all code to do according to value of "action" parameter
+********************************************************************/
+
+if ($action == 'update' && ! $_POST["cancel"] && $user->rights->resource->write )
+{
+ $error=0;
+
+ if (empty($ref))
+ {
+ $error++;
+ $mesg='
';
+ }
+ }
+ }
+}
+
+llxFooter();
+
+$db->close();
diff --git a/htdocs/resource/img/object_resource.png b/htdocs/resource/img/object_resource.png
new file mode 100644
index 00000000000..55f2e1bf937
Binary files /dev/null and b/htdocs/resource/img/object_resource.png differ
diff --git a/htdocs/resource/img/resource.png b/htdocs/resource/img/resource.png
new file mode 100644
index 00000000000..7d5bbfa5a3d
Binary files /dev/null and b/htdocs/resource/img/resource.png differ
diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php
new file mode 100644
index 00000000000..3fde7b52999
--- /dev/null
+++ b/htdocs/resource/list.php
@@ -0,0 +1,175 @@
+
+ *
+ * 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 resource/index.php
+ * \ingroup resource
+ * \brief Page to manage resource objects
+ */
+
+
+// Change this following line to use the correct relative path (../, ../../, etc)
+$res=0;
+$res=@include("../main.inc.php"); // For root directory
+if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory
+if (! $res) die("Include of main fails");
+
+require 'class/resource.class.php';
+
+// Load traductions files requiredby by page
+$langs->load("resource");
+$langs->load("companies");
+$langs->load("other");
+
+// Get parameters
+$id = GETPOST('id','int');
+$action = GETPOST('action','alpha');
+
+$lineid = GETPOST('lineid','int');
+$element = GETPOST('element','alpha');
+$element_id = GETPOST('element_id','int');
+$resource_id = GETPOST('resource_id','int');
+
+$sortorder = GETPOST('sortorder','alpha');
+$sortfield = GETPOST('sortfield','alpha');
+$page = GETPOST('page','int');
+
+$object = new Resource($db);
+
+$hookmanager->initHooks(array('resource_list'));
+
+$parameters=array();
+$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+
+if (empty($sortorder)) $sortorder="DESC";
+if (empty($sortfield)) $sortfield="t.rowid";
+if (empty($arch)) $arch = 0;
+
+if ($page == -1) {
+ $page = 0 ;
+}
+
+$limit = $conf->liste_limit;
+$offset = $limit * $page ;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+
+if( ! $user->rights->resource->read)
+ accessforbidden();
+
+/***************************************************
+ * VIEW
+*
+* Put here all code to build page
+****************************************************/
+
+$pagetitle=$langs->trans('ResourcePageIndex');
+llxHeader('',$pagetitle,'');
+
+
+
+$form=new Form($db);
+
+print_fiche_titre($pagetitle,'','resource.png@resource');
+
+// Confirmation suppression resource line
+if ($action == 'delete_resource')
+{
+ print $form->formconfirm($_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id."&lineid=".$lineid,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResourceElement"),"confirm_delete_resource",'','',1);
+}
+
+// Load object list
+$ret = $object->fetch_all($sortorder, $sortfield, $limit, $offset);
+if($ret == -1) {
+ dol_print_error($db,$object->error);
+ exit;
+}
+if(!$ret) {
+ print '