diff --git a/htdocs/install/mysql/tables/llx_user.key.sql b/htdocs/install/mysql/tables/llx_user.key.sql index 49916b68cb8..82d5f28ef06 100644 --- a/htdocs/install/mysql/tables/llx_user.key.sql +++ b/htdocs/install/mysql/tables/llx_user.key.sql @@ -21,8 +21,8 @@ ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_login (login, entity); -ALTER TABLE llx_user ADD INDEX idx_user_fk_societe (fk_soc); +ALTER TABLE llx_user ADD INDEX idx_user_fk_societe (fk_soc); ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_fk_socpeople (fk_socpeople); ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_fk_member (fk_member); -ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_api_key (api_key); +ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_api_key (api_key); diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index 6b3c5b83f6d..c8d4b78af28 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -78,7 +78,7 @@ create table llx_user nb_holiday integer DEFAULT 0, thm double(24,8), tjm double(24,8), - salary double(24,8), - salaryextra double(24,8), - weeklyhours double(16,8) + salary double(24,8), -- denormalized value coming from llx_user_employment + salaryextra double(24,8), -- denormalized value coming from llx_user_employment + weeklyhours double(16,8) -- denormalized value coming from llx_user_employment )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_user_employment.key.sql b/htdocs/install/mysql/tables/llx_user_employment.key.sql new file mode 100644 index 00000000000..fd0aa62567c --- /dev/null +++ b/htdocs/install/mysql/tables/llx_user_employment.key.sql @@ -0,0 +1,21 @@ +-- ============================================================================ +-- Copyright (C) 2016 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_user_employment ADD UNIQUE INDEX uk_user_employment (ref,entity); + +ALTER TABLE llx_user_employment ADD CONSTRAINT fk_user_employment_fk_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid); diff --git a/htdocs/install/mysql/tables/llx_user_employment.sql b/htdocs/install/mysql/tables/llx_user_employment.sql new file mode 100644 index 00000000000..5c6d65a02c2 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_user_employment.sql @@ -0,0 +1,39 @@ +-- ============================================================================ +-- Copyright (C) 2016 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 . +-- +-- This table can be used to store employee working contracts +-- =========================================================================== + +create table llx_user_employment +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + ref varchar(50), -- reference + ref_ext varchar(50), -- reference into an external system (not used by dolibarr) + fk_user integer, + datec datetime, + tms timestamp, + fk_user_creat integer, + fk_user_modif integer, + job varchar(128), -- job position. may be a dictionnary + status integer NOT NULL, -- draft, active, closed + salary double(24,8), -- last and current value stored into llx_user + salaryextra double(24,8), -- last and current value stored into llx_user + weeklyhours double(16,8) -- last and current value stored into llx_user + dateemployment date, -- last and current value stored into llx_user + dateemploymentend date, -- last and current value stored into llx_user +)ENGINE=innodb; + diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 840d5835fd4..cd96bdd62b0 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -115,11 +115,13 @@ class User extends CommonObject var $parentof; // To store an array of all parents for all ids. var $accountancy_code; // Accountancy code in prevision of the complete accountancy module - var $thm; // Average cost of employee + + var $thm; // Average cost of employee - Used for valuation of time spent var $tjm; // Average cost of employee - var $salary; // Monthly salary - var $salaryextra; // Monthly salary extra - var $weeklyhours; // Weekly hours + + var $salary; // Monthly salary - Denormalized value from llx_user_employment + var $salaryextra; // Monthly salary extra - Denormalized value from llx_user_employment + var $weeklyhours; // Weekly hours - Denormalized value from llx_user_employment var $color; // Define background color for user in agenda