From b571cc86ff91511b8019fa21b831b481000f9afd Mon Sep 17 00:00:00 2001 From: aspangaro Date: Fri, 9 Oct 2015 07:30:48 +0200 Subject: [PATCH] Add a yn form in user card to know if the user is also an employee --- .../install/mysql/migration/3.9.0-4.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_user.sql | 2 ++ htdocs/user/card.php | 19 +++++++++++++++++++ htdocs/user/class/user.class.php | 9 +++++++-- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index bea4065fab8..6120a946ec3 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -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; + diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index a11b0ec6b50..f95def7e503 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -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, diff --git a/htdocs/user/card.php b/htdocs/user/card.php index b74b921c735..9744aebfbbe 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -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 ''; } + print ''; + + // Employee + print ''; + print ''.fieldLabel('Employee','employee',0).''; + print $form->selectyesno("employee",(isset($_POST['employee'])?GETPOST('employee'):0),1); print ''; // Position/Job @@ -1224,6 +1232,11 @@ else print ''.$object->firstname.''; print ''."\n"; + // Employee + print ''.$langs->trans("Employee").''; + print yn($object->employee); + print ''."\n"; + // Position/Job print ''.$langs->trans("PostOrFunction").''; print ''.$object->job.''; @@ -1803,6 +1816,12 @@ else } print ''; + // Employee + print ''; + print ''.fieldLabel('Employee','employee',0).''; + print $form->selectyesno("employee",$object->employee,1); + print ''; + // Position/Job print ''.$langs->trans("PostOrFunction").''; print ''; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 6dc8de8db8e..d4317a0d919 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -8,7 +8,7 @@ * Copyright (C) 2005 Lionel Cousteix * Copyright (C) 2011 Herve Prot * Copyright (C) 2013-2014 Philippe Grand - * Copyright (C) 2013 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2015 Marcos GarcĂ­a * * 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'