Add a yn form in user card to know if the user is also an employee

This commit is contained in:
aspangaro 2015-10-09 07:30:48 +02:00
parent 6a7892ca52
commit b571cc86ff
4 changed files with 30 additions and 2 deletions

View File

@ -86,3 +86,5 @@ CREATE TABLE IF NOT EXISTS llx_establishment (
statut tinyint DEFAULT 1,
) ENGINE=InnoDB;
ALTER TABLE llx_user ADD COLUMN employee tinyint DEFAULT 0 AFTER ref_int;

View File

@ -25,6 +25,8 @@ create table llx_user
ref_ext varchar(50), -- reference into an external system (not used by dolibarr)
ref_int varchar(50), -- reference into an internal system (deprecated)
employee tinyint DEFAULT 0, -- employee 0/1
datec datetime,
tms timestamp,

View File

@ -191,6 +191,7 @@ if ($action == 'add' && $canadduser)
{
$object->lastname = GETPOST("lastname",'alpha');
$object->firstname = GETPOST("firstname",'alpha');
$object->employee = GETPOST("employee",'int');
$object->login = GETPOST("login",'alpha');
$object->api_key = GETPOST("api_key",'alpha');
$object->gender = GETPOST("gender",'alpha');
@ -344,6 +345,7 @@ if ($action == 'update' && ! $_POST["cancel"])
$object->lastname = GETPOST("lastname",'alpha');
$object->firstname = GETPOST("firstname",'alpha');
$object->employee = GETPOST("employee",'int');
$object->login = GETPOST("login",'alpha');
$object->gender = GETPOST("gender",'alpha');
$object->pass = GETPOST("password");
@ -762,6 +764,12 @@ if (($action == 'create') || ($action == 'adduserldap'))
{
print '<input size="30" type="text" name="firstname" value="'.GETPOST('firstname').'">';
}
print '</td></tr>';
// Employee
print '<tr>';
print '<td>'.fieldLabel('Employee','employee',0).'</td><td>';
print $form->selectyesno("employee",(isset($_POST['employee'])?GETPOST('employee'):0),1);
print '</td></tr>';
// Position/Job
@ -1224,6 +1232,11 @@ else
print '<td colspan="2">'.$object->firstname.'</td>';
print '</tr>'."\n";
// Employee
print '<tr><td>'.$langs->trans("Employee").'</td><td colspan="2">';
print yn($object->employee);
print '</td></tr>'."\n";
// Position/Job
print '<tr><td>'.$langs->trans("PostOrFunction").'</td>';
print '<td colspan="2">'.$object->job.'</td>';
@ -1803,6 +1816,12 @@ else
}
print '</td></tr>';
// Employee
print '<tr>';
print '<td>'.fieldLabel('Employee','employee',0).'</td><td>';
print $form->selectyesno("employee",$object->employee,1);
print '</td></tr>';
// Position/Job
print '<tr><td>'.$langs->trans("PostOrFunction").'</td>';
print '<td>';

View File

@ -8,7 +8,7 @@
* Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk>
* Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
* Copyright (C) 2013-2014 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2013 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
@ -46,6 +46,7 @@ class User extends CommonObject
var $id=0;
var $ldap_sid;
var $search_sid;
var $employee;
var $gender;
var $email;
var $skype;
@ -156,7 +157,7 @@ class User extends CommonObject
$login=trim($login);
// Get user
$sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.email, u.job, u.skype, u.signature, u.office_phone, u.office_fax, u.user_mobile,";
$sql = "SELECT u.rowid, u.lastname, u.firstname, u.employee, u.gender, u.email, u.job, u.skype, u.signature, u.office_phone, u.office_fax, u.user_mobile,";
$sql.= " u.admin, u.login, u.note,";
$sql.= " u.pass, u.pass_crypted, u.pass_temp, u.api_key,";
$sql.= " u.fk_soc, u.fk_socpeople, u.fk_member, u.fk_user, u.ldap_sid,";
@ -215,6 +216,8 @@ class User extends CommonObject
$this->ldap_sid = $obj->ldap_sid;
$this->lastname = $obj->lastname;
$this->firstname = $obj->firstname;
$this->employee = $obj->employee;
$this->login = $obj->login;
$this->gender = $obj->gender;
@ -1145,6 +1148,7 @@ class User extends CommonObject
// Clean parameters
$this->lastname = trim($this->lastname);
$this->firstname = trim($this->firstname);
$this->employee = trim($this->employee);
$this->login = trim($this->login);
$this->gender = trim($this->gender);
$this->pass = trim($this->pass);
@ -1185,6 +1189,7 @@ class User extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET";
$sql.= " lastname = '".$this->db->escape($this->lastname)."'";
$sql.= ", firstname = '".$this->db->escape($this->firstname)."'";
$sql.= ", employee = ".$this->employee;
$sql.= ", login = '".$this->db->escape($this->login)."'";
$sql.= ", api_key = ".($this->api_key ? "'".$this->db->escape($this->api_key)."'" : "null");
$sql.= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman'