From 23eee1b83add577809c059ad7c5d9b3526fb460f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 13 Sep 2014 17:41:26 +0200 Subject: [PATCH] New: Add hourly and daily amount on user card. Add weekly working hours and salary on user card. --- ChangeLog | 1 + .../install/mysql/migration/3.6.0-3.7.0.sql | 4 + htdocs/install/mysql/tables/llx_user.sql | 3 + htdocs/langs/en_US/salaries.lang | 2 + htdocs/langs/en_US/users.lang | 1 + htdocs/user/class/user.class.php | 20 ++- htdocs/user/fiche.php | 115 +++++++++++++++++- 7 files changed, 142 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7713b6fdccb..fd951104b7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -49,6 +49,7 @@ For users: - New: [ task #1204 ] add a External reference to contract - New: [ task #1218 ] Can drag and drop an event from calendar to change its day. - New: Optimize size of image static resources. +- New: Add hourly and daily amount on user card. Add weekly working hours and salary on user card. - Upgrade phpexcel lib to 1.7.8 - Fix: [ bug #1487 ] PAYMENT_DELETE trigger does not intercept trigger action - Fix: [ bug #1470, #1472, #1473] User trigger problem diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index 70ce60e6a33..e6b8e526bf2 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -84,6 +84,10 @@ ALTER TABLE llx_product MODIFY COLUMN accountancy_code_buy varchar(32); ALTER TABLE llx_user MODIFY COLUMN accountancy_code varchar(32); +ALTER TABLE llx_user ADD COLUMN thm double(24,8); +ALTER TABLE llx_user ADD COLUMN tjm double(24,8); +ALTER TABLE llx_user ADD COLUMN salary double(24,8); +ALTER TABLE llx_user ADD COLUMN salaryextra double(24,8); ALTER TABLE llx_user ADD COLUMN weeklyhours double(16,8); diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index 87e28084ef0..3c084640367 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -71,6 +71,9 @@ create table llx_user fk_barcode_type integer DEFAULT 0, accountancy_code varchar(32) NULL, 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) )ENGINE=innodb; diff --git a/htdocs/langs/en_US/salaries.lang b/htdocs/langs/en_US/salaries.lang index 84eba6fc2bd..0087cbe83e6 100644 --- a/htdocs/langs/en_US/salaries.lang +++ b/htdocs/langs/en_US/salaries.lang @@ -8,3 +8,5 @@ NewSalaryPayment=New salary payment SalaryPayment=Salary payment SalariesPayments=Salaries payments ShowSalaryPayment=Show salary payment +THM=Average hourly price +TJM=Average daily price diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 972b8534213..495cb3981c6 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -119,3 +119,4 @@ HierarchicView=Hierarchical view UseTypeFieldToChange=Use field Type to change OpenIDURL=OpenID URL LoginUsingOpenID=Use OpenID to login +WeeklyHours=Weekly hours \ No newline at end of file diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 1c373b03871..0e4c5596194 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -101,6 +101,10 @@ class User extends CommonObject var $accountancy_code; // Accountancy code in prevision of the complete accountancy module var $thm; // Average cost of employee + var $tjm; // Average cost of employee + var $salary; // Monthly salary + var $salaryextra; // Monthly salary extra + var $weeklyhours; // Weekly hours /** @@ -156,6 +160,10 @@ class User extends CommonObject $sql.= " u.openid as openid,"; $sql.= " u.accountancy_code,"; $sql.= " u.thm,"; + $sql.= " u.tjm,"; + $sql.= " u.salary,"; + $sql.= " u.salaryextra,"; + $sql.= " u.weeklyhours,"; $sql.= " u.ref_int, u.ref_ext"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; @@ -219,6 +227,10 @@ class User extends CommonObject $this->entity = $obj->entity; $this->accountancy_code = $obj->accountancy_code; $this->thm = $obj->thm; + $this->tjm = $obj->tjm; + $this->salary = $obj->salary; + $this->salaryextra = $obj->salaryextra; + $this->weeklyhours = $obj->weeklyhours; $this->datec = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->datem); @@ -1156,11 +1168,15 @@ class User extends CommonObject $sql.= ", job = '".$this->db->escape($this->job)."'"; $sql.= ", signature = '".$this->db->escape($this->signature)."'"; $sql.= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'"; - $sql.= ", thm = ".(isset($this->thm)?$this->thm:"null"); // If not set, we use null $sql.= ", note = '".$this->db->escape($this->note)."'"; $sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null"); $sql.= ", openid = ".($this->openid?"'".$this->db->escape($this->openid)."'":"null"); $sql.= ", fk_user = ".($this->fk_user > 0?"'".$this->db->escape($this->fk_user)."'":"null"); + if (isset($this->thm) || $this->thm != '') $sql.= ", thm= ".($this->thm != ''?"'".$this->db->escape($this->thm)."'":"null"); + if (isset($this->tjm) || $this->tjm != '') $sql.= ", tjm= ".($this->tjm != ''?"'".$this->db->escape($this->tjm)."'":"null"); + if (isset($this->salary) || $this->salary != '') $sql.= ", salary= ".($this->salary != ''?"'".$this->db->escape($this->salary)."'":"null"); + if (isset($this->salaryextra) || $this->salaryextra != '') $sql.= ", salaryextra= ".($this->salaryextra != ''?"'".$this->db->escape($this->salaryextra)."'":"null"); + $sql.= ", weeklyhours= ".($this->weeklyhours != ''?"'".$this->db->escape($this->weeklyhours)."'":"null"); $sql.= ", entity = '".$this->entity."'"; $sql.= " WHERE rowid = ".$this->id; @@ -2217,7 +2233,7 @@ class User extends CommonObject // Init this->parentof that is array(id_son=>id_parent, ...) $this->load_parentof(); - + // Init $this->users array $sql = "SELECT DISTINCT u.rowid, u.firstname, u.lastname, u.fk_user, u.login, u.statut, u.entity"; // Distinct reduce pb with old tables with duplicates $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 5ccd9c68416..d5c5d71e328 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -200,6 +200,12 @@ if ($action == 'add' && $canadduser) $object->ldap_sid = GETPOST("ldap_sid"); $object->fk_user = GETPOST("fk_user")>0?GETPOST("fk_user"):0; + $object->thm = GETPOST("thm")!=''?GETPOST("thm"):''; + $object->tjm = GETPOST("tjm")!=''?GETPOST("tjm"):''; + $object->salary = GETPOST("salary")!=''?GETPOST("salary"):''; + $object->salaryextra = GETPOST("salaryextra")!=''?GETPOST("salaryextra"):''; + $object->weeklyhours = GETPOST("weeklyhours")!=''?GETPOST("weeklyhours"):''; + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -339,6 +345,12 @@ if ($action == 'update' && ! $_POST["cancel"]) $object->openid = GETPOST("openid"); $object->fk_user = GETPOST("fk_user")>0?GETPOST("fk_user"):0; + $object->thm = GETPOST("thm")!=''?GETPOST("thm"):''; + $object->tjm = GETPOST("tjm")!=''?GETPOST("tjm"):''; + $object->salary = GETPOST("salary")!=''?GETPOST("salary"):''; + $object->salaryextra = GETPOST("salaryextra")!=''?GETPOST("salaryextra"):''; + $object->weeklyhours = GETPOST("weeklyhours")!=''?GETPOST("weeklyhours"):''; + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -614,7 +626,7 @@ if (($action == 'create') || ($action == 'adduserldap')) $conf->global->LDAP_FIELD_LOGIN_SAMBA, $conf->global->LDAP_FIELD_PASSWORD, $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, - $conf->global->LDAP_FIELD_PHONE, + $conf->global->LDAP_FIELD_PHONE, $conf->global->LDAP_FIELD_FAX, $conf->global->LDAP_FIELD_MOBILE, $conf->global->LDAP_FIELD_SKYPE, @@ -928,6 +940,39 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; print $form->select_dolusers($object->fk_user,'fk_user',1,array($object->id),0,'',0,$conf->entity); print ''; + print "\n"; + + if ($conf->salaries->enabled) + { + $langs->load("salaries"); + + // THM + print ''.$langs->trans("THM").''; + print ''; + print ''; + print ''; + print "\n"; + + // TJM + print ''.$langs->trans("TJM").''; + print ''; + print ''; + print ''; + print "\n"; + + // Salary + print ''.$langs->trans("Salary").''; + print ''; + print ''; + print ''; + print "\n"; + } + + // Weeklyhours + print ''.$langs->trans("WeeklyHours").''; + print ''; + print ''; + print ''; print "\n"; // Note @@ -1223,6 +1268,39 @@ else print ''; print "\n"; + if ($conf->salaries->enabled) + { + $langs->load("salaries"); + + // THM + print ''.$langs->trans("THM").''; + print ''; + print ($object->thm!=''?price($object->thm,'',$langs,1,-1,-1,$conf->currency):''); + print ''; + print "\n"; + + // TJM + print ''.$langs->trans("TJM").''; + print ''; + print ($object->tjm!=''?price($object->tjm,'',$langs,1,-1,-1,$conf->currency):''); + print ''; + print "\n"; + + // Salary + print ''.$langs->trans("Salary").''; + print ''; + print ($object->salary!=''?price($object->salary,'',$langs,1,-1,-1,$conf->currency):''); + print ''; + print "\n"; + } + + // Weeklyhours + print ''.$langs->trans("WeeklyHours").''; + print ''; + print price2num($object->weeklyhours); + print ''; + print "\n"; + // Accountancy code if (! empty($conf->global->USER_ENABLE_ACCOUNTANCY_CODE)) // For the moment field is not used so must not appeared. { @@ -1879,7 +1957,40 @@ else print ''; print "\n"; - // Accountancy code + $langs->load("salaries"); + + if ($conf->salaries->enabled) + { + // THM + print ''.$langs->trans("THM").''; + print ''; + print ''; + print ''; + print "\n"; + + // TJM + print ''.$langs->trans("TJM").''; + print ''; + print ''; + print ''; + print "\n"; + + // Salary + print ''.$langs->trans("Salary").''; + print ''; + print ''; + print ''; + print "\n"; + } + + // Weeklyhours + print ''.$langs->trans("WeeklyHours").''; + print ''; + print ''; + print ''; + print "\n"; + + // Accountancy code if (! empty($conf->global->USER_ENABLE_ACCOUNTANCY_CODE)) // For the moment field is not used so must not appeared. { print "";