Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into

develop

Conflicts:
	htdocs/install/mysql/tables/llx_user.sql
This commit is contained in:
Laurent Destailleur 2016-09-28 19:49:36 +02:00
commit e99f115a8f
12 changed files with 241 additions and 189 deletions

View File

@ -183,7 +183,7 @@ if (empty($reshook))
// Remove a product line // Remove a product line
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer) else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer)
{ {
$result = $object->deleteline($lineid); $result = $object->deleteline($user, $lineid);
if ($result > 0) if ($result > 0)
{ {
// Define output language // Define output language

View File

@ -401,7 +401,7 @@ class CommandeApi extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$request_data = (object) $request_data; $request_data = (object) $request_data;
$updateRes = $this->commande->deleteline($lineid); $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid);
if ($updateRes == 1) { if ($updateRes == 1) {
return $this->get($id); return $this->get($id);
} }

View File

@ -365,7 +365,7 @@ class Orders extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$request_data = (object) $request_data; $request_data = (object) $request_data;
$updateRes = $this->commande->deleteline($lineid); $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid);
if ($updateRes == 1) { if ($updateRes == 1) {
return $this->get($id); return $this->get($id);
} }

View File

@ -1220,7 +1220,7 @@ class Commande extends CommonOrder
*/ */
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0) function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0)
{ {
global $mysoc, $conf, $langs; global $mysoc, $conf, $langs, $user;
dol_syslog(get_class($this)."::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit", LOG_DEBUG); dol_syslog(get_class($this)."::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit", LOG_DEBUG);
@ -1373,7 +1373,7 @@ class Commande extends CommonOrder
$this->line->array_options=$array_options; $this->line->array_options=$array_options;
} }
$result=$this->line->insert(); $result=$this->line->insert($user);
if ($result > 0) if ($result > 0)
{ {
// Reorder if child line // Reorder if child line
@ -1972,10 +1972,11 @@ class Commande extends CommonOrder
/** /**
* Delete an order line * Delete an order line
* *
* @param User $user User object
* @param int $lineid Id of line to delete * @param int $lineid Id of line to delete
* @return int >0 if OK, 0 if nothing to do, <0 if KO * @return int >0 if OK, 0 if nothing to do, <0 if KO
*/ */
function deleteline($lineid) function deleteline($user=null, $lineid=0)
{ {
if ($this->statut == self::STATUS_DRAFT) if ($this->statut == self::STATUS_DRAFT)
@ -2002,7 +2003,7 @@ class Commande extends CommonOrder
// For triggers // For triggers
$line->fetch($lineid); $line->fetch($lineid);
if ($line->delete() > 0) if ($line->delete($user) > 0)
{ {
$result=$this->update_price(1); $result=$this->update_price(1);
@ -2740,7 +2741,7 @@ class Commande extends CommonOrder
*/ */
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null) function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null)
{ {
global $conf, $mysoc, $langs; global $conf, $mysoc, $langs, $user;
dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code"); dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code");
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@ -2885,7 +2886,7 @@ class Commande extends CommonOrder
$this->line->array_options=$array_options; $this->line->array_options=$array_options;
} }
$result=$this->line->update(); $result=$this->line->update($user);
if ($result > 0) if ($result > 0)
{ {
// Reorder if child line // Reorder if child line
@ -3805,9 +3806,11 @@ class OrderLine extends CommonOrderLine
/** /**
* Delete line in database * Delete line in database
* *
* @param User $user User that modify
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 si ko, >0 si ok * @return int <0 si ko, >0 si ok
*/ */
function delete() function delete($user=null, $notrigger=0)
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
@ -3833,10 +3836,13 @@ class OrderLine extends CommonOrderLine
} }
} }
// Call trigger if (! $error && ! $notrigger)
$result=$this->call_trigger('LINEORDER_DELETE',$user); {
if ($result < 0) $error++; // Call trigger
// End call triggers $result=$this->call_trigger('LINEORDER_DELETE',$user);
if ($result < 0) $error++;
// End call triggers
}
if (!$error) { if (!$error) {
$this->db->commit(); $this->db->commit();
@ -3861,12 +3867,13 @@ class OrderLine extends CommonOrderLine
/** /**
* Insert line into database * Insert line into database
* *
* @param User $user User that modify
* @param int $notrigger 1 = disable triggers * @param int $notrigger 1 = disable triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function insert($notrigger=0) function insert($user=null, $notrigger=0)
{ {
global $langs, $conf, $user; global $langs, $conf;
$error=0; $error=0;
@ -4004,12 +4011,13 @@ class OrderLine extends CommonOrderLine
/** /**
* Update the line object into db * Update the line object into db
* *
* @param User $user User that modify
* @param int $notrigger 1 = disable triggers * @param int $notrigger 1 = disable triggers
* @return int <0 si ko, >0 si ok * @return int <0 si ko, >0 si ok
*/ */
function update($notrigger=0) function update($user=null, $notrigger=0)
{ {
global $conf,$langs,$user; global $conf,$langs;
$error=0; $error=0;

View File

@ -54,7 +54,7 @@ class modSalaries extends DolibarrModules
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this)); $this->name = preg_replace('/^mod/i','',get_class($this));
// Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) // Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
$this->description = "Employees salaries management"; $this->description = "Employees contracts and salaries management";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'dolibarr'; $this->version = 'dolibarr';
@ -97,8 +97,8 @@ class modSalaries extends DolibarrModules
$r=0; $r=0;
$r++; $r++;
$this->rights[$r][0] = 510; $this->rights[$r][0] = 511;
$this->rights[$r][1] = 'Read salaries'; $this->rights[$r][1] = 'Read employee contracts/salaries';
$this->rights[$r][2] = 'r'; $this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'read'; $this->rights[$r][4] = 'read';
@ -106,7 +106,15 @@ class modSalaries extends DolibarrModules
$r++; $r++;
$this->rights[$r][0] = 512; $this->rights[$r][0] = 512;
$this->rights[$r][1] = 'Create/modify salaries'; $this->rights[$r][1] = 'Create/modify employee contracts/salaries';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'write';
$this->rights[$r][5] = '';
$r++;
$this->rights[$r][0] = 513;
$this->rights[$r][1] = 'Create/modify payment of salaries';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'write'; $this->rights[$r][4] = 'write';
@ -114,7 +122,7 @@ class modSalaries extends DolibarrModules
$r++; $r++;
$this->rights[$r][0] = 514; $this->rights[$r][0] = 514;
$this->rights[$r][1] = 'Delete salaries'; $this->rights[$r][1] = 'Delete contracts/salaries';
$this->rights[$r][2] = 'd'; $this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'delete'; $this->rights[$r][4] = 'delete';
@ -122,7 +130,7 @@ class modSalaries extends DolibarrModules
$r++; $r++;
$this->rights[$r][0] = 517; $this->rights[$r][0] = 517;
$this->rights[$r][1] = 'Export salaries'; $this->rights[$r][1] = 'Export employee contracts and salaries payments';
$this->rights[$r][2] = 'r'; $this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'export'; $this->rights[$r][4] = 'export';

View File

@ -33,6 +33,7 @@ DELETE FROM llx_menu where module='expensereport';
ALTER TABLE llx_user DROP COLUMN phenix_login; ALTER TABLE llx_user DROP COLUMN phenix_login;
ALTER TABLE llx_user DROP COLUMN phenix_pass; ALTER TABLE llx_user DROP COLUMN phenix_pass;
ALTER TABLE llx_user ADD COLUMN dateemployment datetime;
ALTER TABLE llx_societe ADD COLUMN fk_account integer; ALTER TABLE llx_societe ADD COLUMN fk_account integer;

View File

@ -78,7 +78,9 @@ create table llx_user
nb_holiday integer DEFAULT 0, nb_holiday integer DEFAULT 0,
thm double(24,8), thm double(24,8),
tjm double(24,8), tjm double(24,8),
salary double(24,8), -- denormalized value coming from llx_user_employment salary double(24,8), -- denormalized value coming from llx_user_employment
salaryextra double(24,8), -- denormalized value coming from llx_user_employment salaryextra double(24,8), -- denormalized value coming from llx_user_employment
dateemployment date, -- denormalized value coming from llx_user_employment
weeklyhours double(16,8) -- denormalized value coming from llx_user_employment weeklyhours double(16,8) -- denormalized value coming from llx_user_employment
)ENGINE=innodb; )ENGINE=innodb;

View File

@ -474,8 +474,8 @@ Module410Name=Webcalendar
Module410Desc=Webcalendar integration Module410Desc=Webcalendar integration
Module500Name=Special expenses Module500Name=Special expenses
Module500Desc=Management of special expenses (taxes, social or fiscal taxes, dividends) Module500Desc=Management of special expenses (taxes, social or fiscal taxes, dividends)
Module510Name=Salaries Module510Name=Employee contracts and salaries
Module510Desc=Management of employees salaries and payments Module510Desc=Management of employees contracts, salaries and payments
Module520Name=Loan Module520Name=Loan
Module520Desc=Management of loans Module520Desc=Management of loans
Module600Name=Notifications Module600Name=Notifications

View File

@ -102,3 +102,4 @@ DisabledInMonoUserMode=Disabled in maintenance mode
UserAccountancyCode=User accountancy code UserAccountancyCode=User accountancy code
UserLogoff=User logout UserLogoff=User logout
UserLogged=User logged UserLogged=User logged
DateEmployment=Date of Employment

View File

@ -100,3 +100,4 @@ WeeklyHours=Heures de travail hebdomadaires
ColorUser=Couleur de l'utilisateur ColorUser=Couleur de l'utilisateur
DisabledInMonoUserMode=Désactivé en mode maintenance DisabledInMonoUserMode=Désactivé en mode maintenance
UserAccountancyCode=Code comptable utilisateur UserAccountancyCode=Code comptable utilisateur
DateEmployment=Date d'embauche

View File

@ -216,6 +216,8 @@ if (empty($reshook)) {
$object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : ''; $object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : '';
$object->color = GETPOST("color") != '' ? GETPOST("color") : ''; $object->color = GETPOST("color") != '' ? GETPOST("color") : '';
$dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth'), GETPOST('dateemploymentday'), GETPOST('dateemploymentyear'));
$object->dateemployment = $dateemployment;
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object); $ret = $extrafields->setOptionalsFromPost($extralabels, $object);
@ -357,6 +359,8 @@ if (empty($reshook)) {
$object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : ''; $object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : '';
$object->color = GETPOST("color") != '' ? GETPOST("color") : ''; $object->color = GETPOST("color") != '' ? GETPOST("color") : '';
$dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth'), GETPOST('dateemploymentday'), GETPOST('dateemploymentyear'));
$object->dateemployment = $dateemployment;
if (! empty($conf->multicompany->enabled)) if (! empty($conf->multicompany->enabled))
{ {
@ -1058,6 +1062,13 @@ if (($action == 'create') || ($action == 'adduserldap'))
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
// Date employment
print '<tr><td>'.$langs->trans("DateEmployment").'</td>';
print '<td>';
echo $form->select_date(GETPOST('dateemployment'),'dateemployment',0,0,1,'form'.'dateemployment',1,0,1);
print '</td>';
print "</tr>\n";
// Accountancy code // Accountancy code
if ($conf->accounting->enabled) if ($conf->accounting->enabled)
{ {
@ -1412,6 +1423,13 @@ else
print '<td>'.$object->accountancy_code.'</td>'; print '<td>'.$object->accountancy_code.'</td>';
} }
// Date employment
print '<tr><td>'.$langs->trans("DateEmployment").'</td>';
print '<td>';
print dol_print_date($object->dateemployment);
print '</td>';
print "</tr>\n";
print '</table>'; print '</table>';
print '</div>'; print '</div>';
@ -2186,6 +2204,13 @@ else
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
// Date employment
print '<tr><td>'.$langs->trans("DateEmployment").'</td>';
print '<td>';
echo $form->select_date(GETPOST('dateemployment')?GETPOST('dateemployment'):$object->dateemployment,'dateemployment',0,0,1,'form'.'dateemployment',1,0,1);
print '</td>';
print "</tr>\n";
// Accountancy code // Accountancy code
if ($conf->accounting->enabled) if ($conf->accounting->enabled)
{ {

View File

@ -125,6 +125,8 @@ class User extends CommonObject
var $color; // Define background color for user in agenda var $color; // Define background color for user in agenda
var $dateemployment; // Define date of employment by company
/** /**
* Constructor de la classe * Constructor de la classe
* *
@ -189,6 +191,7 @@ class User extends CommonObject
$sql.= " u.salaryextra,"; $sql.= " u.salaryextra,";
$sql.= " u.weeklyhours,"; $sql.= " u.weeklyhours,";
$sql.= " u.color,"; $sql.= " u.color,";
$sql.= " u.dateemployment,";
$sql.= " u.ref_int, u.ref_ext,"; $sql.= " u.ref_int, u.ref_ext,";
$sql.= " c.code as country_code, c.label as country,"; $sql.= " c.code as country_code, c.label as country,";
$sql.= " d.code_departement as state_code, d.nom as state"; $sql.= " d.code_departement as state_code, d.nom as state";
@ -288,6 +291,7 @@ class User extends CommonObject
$this->salaryextra = $obj->salaryextra; $this->salaryextra = $obj->salaryextra;
$this->weeklyhours = $obj->weeklyhours; $this->weeklyhours = $obj->weeklyhours;
$this->color = $obj->color; $this->color = $obj->color;
$this->dateemployment = $this->db->jdate($obj->dateemployment);
$this->datec = $this->db->jdate($obj->datec); $this->datec = $this->db->jdate($obj->datec);
$this->datem = $this->db->jdate($obj->datem); $this->datem = $this->db->jdate($obj->datem);
@ -1262,6 +1266,7 @@ class User extends CommonObject
$this->town = empty($this->town)?'':$this->town; $this->town = empty($this->town)?'':$this->town;
$this->accountancy_code = trim($this->accountancy_code); $this->accountancy_code = trim($this->accountancy_code);
$this->color = empty($this->color)?'':$this->color; $this->color = empty($this->color)?'':$this->color;
$this->dateemployment = empty($this->dateemployment)?'':$this->dateemployment;
// Check parameters // Check parameters
if (! empty($conf->global->USER_MAIL_REQUIRED) && ! isValidEMail($this->email)) if (! empty($conf->global->USER_MAIL_REQUIRED) && ! isValidEMail($this->email))
@ -1302,6 +1307,7 @@ class User extends CommonObject
$sql.= ", signature = '".$this->db->escape($this->signature)."'"; $sql.= ", signature = '".$this->db->escape($this->signature)."'";
$sql.= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'"; $sql.= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'";
$sql.= ", color = '".$this->db->escape($this->color)."'"; $sql.= ", color = '".$this->db->escape($this->color)."'";
$sql.= ", dateemployment=".(strval($this->dateemployment)!='' ? "'".$this->db->idate($this->dateemployment)."'" : 'null');
$sql.= ", note = '".$this->db->escape($this->note)."'"; $sql.= ", note = '".$this->db->escape($this->note)."'";
$sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null"); $sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null");
$sql.= ", openid = ".($this->openid?"'".$this->db->escape($this->openid)."'":"null"); $sql.= ", openid = ".($this->openid?"'".$this->db->escape($this->openid)."'":"null");