Skip to content

Commit

Permalink
New: Add hourly and daily amount on user card. Add weekly working hours
Browse files Browse the repository at this point in the history
and salary on user card.
  • Loading branch information
eldy committed Sep 13, 2014
1 parent 2cfe088 commit 23eee1b
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 4 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions htdocs/install/mysql/migration/3.6.0-3.7.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down
3 changes: 3 additions & 0 deletions htdocs/install/mysql/tables/llx_user.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 2 additions & 0 deletions htdocs/langs/en_US/salaries.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions htdocs/langs/en_US/users.lang
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,4 @@ HierarchicView=Hierarchical view
UseTypeFieldToChange=Use field Type to change
OpenIDURL=OpenID URL
LoginUsingOpenID=Use OpenID to login
WeeklyHours=Weekly hours
20 changes: 18 additions & 2 deletions htdocs/user/class/user.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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


/**
Expand Down Expand Up @@ -156,6 +160,10 @@ function fetch($id='', $login='',$sid='',$loadpersonalconf=1)
$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";

Expand Down Expand Up @@ -219,6 +227,10 @@ function fetch($id='', $login='',$sid='',$loadpersonalconf=1)
$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);
Expand Down Expand Up @@ -1156,11 +1168,15 @@ function update($user,$notrigger=0,$nosyncmember=0,$nosyncmemberpass=0)
$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;

Expand Down Expand Up @@ -2217,7 +2233,7 @@ function get_full_tree($deleteafterid=0)

// 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";
Expand Down
115 changes: 113 additions & 2 deletions htdocs/user/fiche.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@
$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);

Expand Down Expand Up @@ -339,6 +345,12 @@
$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);

Expand Down Expand Up @@ -614,7 +626,7 @@
$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,
Expand Down Expand Up @@ -928,6 +940,39 @@
print '<td>';
print $form->select_dolusers($object->fk_user,'fk_user',1,array($object->id),0,'',0,$conf->entity);
print '</td>';
print "</tr>\n";

if ($conf->salaries->enabled)
{
$langs->load("salaries");

// THM
print '<tr><td valign="top">'.$langs->trans("THM").'</td>';
print '<td>';
print '<input size="8" type="text" name="thm" value="'.GETPOST('thm').'">';
print '</td>';
print "</tr>\n";

// TJM
print '<tr><td valign="top">'.$langs->trans("TJM").'</td>';
print '<td>';
print '<input size="8" type="text" name="tjm" value="'.GETPOST('tjm').'">';
print '</td>';
print "</tr>\n";

// Salary
print '<tr><td valign="top">'.$langs->trans("Salary").'</td>';
print '<td>';
print '<input size="8" type="text" name="salary" value="'.GETPOST('salary').'">';
print '</td>';
print "</tr>\n";
}

// Weeklyhours
print '<tr><td valign="top">'.$langs->trans("WeeklyHours").'</td>';
print '<td>';
print '<input size="8" type="text" name="weeklyhours" value="'.GETPOST('weeklyhours').'">';
print '</td>';
print "</tr>\n";

// Note
Expand Down Expand Up @@ -1223,6 +1268,39 @@
print '</td>';
print "</tr>\n";

if ($conf->salaries->enabled)
{
$langs->load("salaries");

// THM
print '<tr><td valign="top">'.$langs->trans("THM").'</td>';
print '<td>';
print ($object->thm!=''?price($object->thm,'',$langs,1,-1,-1,$conf->currency):'');
print '</td>';
print "</tr>\n";

// TJM
print '<tr><td valign="top">'.$langs->trans("TJM").'</td>';
print '<td>';
print ($object->tjm!=''?price($object->tjm,'',$langs,1,-1,-1,$conf->currency):'');
print '</td>';
print "</tr>\n";

// Salary
print '<tr><td valign="top">'.$langs->trans("Salary").'</td>';
print '<td>';
print ($object->salary!=''?price($object->salary,'',$langs,1,-1,-1,$conf->currency):'');
print '</td>';
print "</tr>\n";
}

// Weeklyhours
print '<tr><td valign="top">'.$langs->trans("WeeklyHours").'</td>';
print '<td>';
print price2num($object->weeklyhours);
print '</td>';
print "</tr>\n";

// Accountancy code
if (! empty($conf->global->USER_ENABLE_ACCOUNTANCY_CODE)) // For the moment field is not used so must not appeared.
{
Expand Down Expand Up @@ -1879,7 +1957,40 @@
print '</td>';
print "</tr>\n";

// Accountancy code
$langs->load("salaries");

if ($conf->salaries->enabled)
{
// THM
print '<tr><td valign="top">'.$langs->trans("THM").'</td>';
print '<td>';
print '<input size="8" type="text" name="thm" value="'.price2num(GETPOST('thm')?GETPOST('thm'):$object->thm).'">';
print '</td>';
print "</tr>\n";

// TJM
print '<tr><td valign="top">'.$langs->trans("TJM").'</td>';
print '<td>';
print '<input size="8" type="text" name="tjm" value="'.price2num(GETPOST('tjm')?GETPOST('tjm'):$object->tjm).'">';
print '</td>';
print "</tr>\n";

// Salary
print '<tr><td valign="top">'.$langs->trans("Salary").'</td>';
print '<td>';
print '<input size="8" type="text" name="salary" value="'.price2num(GETPOST('salary')?GETPOST('salary'):$object->salary).'">';
print '</td>';
print "</tr>\n";
}

// Weeklyhours
print '<tr><td valign="top">'.$langs->trans("WeeklyHours").'</td>';
print '<td>';
print '<input size="8" type="text" name="weeklyhours" value="'.price2num(GETPOST('weeklyhours')?GETPOST('weeklyhours'):$object->weeklyhours).'">';
print '</td>';
print "</tr>\n";

// Accountancy code
if (! empty($conf->global->USER_ENABLE_ACCOUNTANCY_CODE)) // For the moment field is not used so must not appeared.
{
print "<tr>";
Expand Down

0 comments on commit 23eee1b

Please sign in to comment.