2
0
forked from Wavyzz/dolibarr

Clean/Debug module hrm.

This commit is contained in:
Laurent Destailleur
2021-11-27 14:46:47 +01:00
parent f3f91512ae
commit 7b68ef1fb8
39 changed files with 72 additions and 158 deletions

View File

@@ -469,13 +469,17 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
print load_fiche_titre($langs->trans('OtherOptions'), '', '');
if (empty($conf->global->HRM_MAXRANK)) {
$conf->global->HRM_MAXRANK = Skill::DEFAULT_MAX_RANK_PER_SKILL;
}
if ($action == 'edit') {
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach ($arrayofparameters as $constname => $val) {
if ($val['enabled']==1) {

View File

@@ -241,29 +241,46 @@ class Skill extends CommonObject
}
/**
* @param int $i rank from which we want to create skilldets
* createSkills
*
* @param int $i Rank from which we want to create skilldets (level $i to HRM_MAXRANK wil be created)
* @return null
*/
public function createSkills($i = 1)
{
global $conf, $user, $langs;
$MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : self::DEFAULT_MAX_RANK_PER_SKILL;
$defaultSkillDesc = !empty($conf->global->HRM_DEFAULT_SKILL_DESCRIPTION) ? $conf->global->HRM_DEFAULT_SKILL_DESCRIPTION : 'no Description';
$error = 0;
require_once __DIR__ . '/skilldet.class.php';
$this->db->begin();
// Create level of skills
for ($i; $i <= $MaxNumberSkill ; $i++) {
$skilldet = new Skilldet($this->db);
$skilldet->description = $defaultSkillDesc . " " . $i ;
$skilldet->rank = $i;
$skilldet->description = $defaultSkillDesc . " " . $i;
$skilldet->rankorder = $i;
$skilldet->fk_skill = $this->id;
$result = $skilldet->create($user);
if ($result > 0) {
setEventMessage($langs->trans('TraductionCreadted'), $i);
if ($result <= 0) {
$error++;
}
}
if (! $error) {
$this->db->commit();
setEventMessage($langs->trans('SkillCreated'), $i);
return 1;
} else {
$this->db->rollback();
return -1;
}
}
/**
@@ -384,7 +401,7 @@ class Skill extends CommonObject
/**
* Load object lines in memory from the database
*
* @return array|int <0 if KO, 0 if not found, array if OK
* @return array <0 if KO, array of skill level found
*/
public function fetchLines()
{
@@ -393,7 +410,7 @@ class Skill extends CommonObject
$skilldet = new Skilldet($this->db);
$this->lines = $skilldet->fetchAll('ASC', '', '', '', array('fk_skill' => $this->id), '');
return (count($this->lines) > 0 ) ? $this->lines : 0;
return (count($this->lines) > 0 ) ? $this->lines : array();
}

View File

@@ -104,18 +104,18 @@ class Skilldet extends CommonObject
*/
public $fields=array(
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
'rankorder' => array('type'=>'integer', 'label'=>'rank', 'enabled'=>'1', 'position'=>2, 'notnull'=>0, 'visible'=>2,),
'fk_skill' => array('type'=>'integer:Skill:/hrm/class/skill.class.php', 'label'=>'fk_skill', 'enabled'=>'1', 'position'=>5, 'notnull'=>1, 'visible'=>0,),
'rankorder' => array('type'=>'integer', 'label'=>'rank', 'enabled'=>'1', 'position'=>10, 'notnull'=>0, 'visible'=>2,),
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1,),
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',),
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>0,),
'fk_skill' => array('type'=>'integer:Skill:/hrm/class/skill.class.php', 'label'=>'fk_skill', 'enabled'=>'1', 'position'=>513, 'notnull'=>1, 'visible'=>0,),
);
public $rowid;
public $fk_skill;
public $rankorder;
public $description;
public $fk_user_creat;
public $fk_user_modif;
public $fk_skill;
public $rank;
// END MODULEBUILDER PROPERTIES

View File

@@ -147,7 +147,7 @@ if ($object->id > 0) {
// Object card
// ------------------------------------------------------------
$linkback = '<a href="'.dol_buildpath('/hrm/skill_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/hrm/skill_list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refid">';
$morehtmlref.= $object->label;

View File

@@ -84,6 +84,8 @@ $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->enti
if (empty($conf->hrm->enabled)) accessforbidden();
if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) accessforbidden();
$MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL;
/*
* Actions
@@ -98,14 +100,14 @@ if ($reshook < 0) {
if (empty($reshook)) {
$error = 0;
$backurlforlist = dol_buildpath('/hrm/skill_list.php', 1);
$backurlforlist = DOL_URL_ROOT.'/hrm/skill_list.php';
if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
$backtopage = $backurlforlist;
} else {
$backtopage = dol_buildpath('/hrm/skill_card.php', 1) . '?id=' . ($id > 0 ? $id : '__ID__');
$backtopage = DOL_URL_ROOT.'/hrm/skill_card.php?id=' . ($id > 0 ? $id : '__ID__');
}
}
}
@@ -166,8 +168,6 @@ if (empty($reshook)) {
/*
* View
*
* Put here all code to build page
*/
$form = new Form($db);
@@ -186,9 +186,9 @@ if ($action == 'create') {
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
print '<input type="hidden" name="token" value="' . newToken() . '">';
print '<input type="hidden" name="action" value="add">';
$backtopage .= "&objecttype=job";
$backtopage .= (strpos($backtopage, '?') > 0 ? '&' : '?' ) ."objecttype=job";
if ($backtopage) {
print '<input type="hidden" name="backtopage" value="' . $backtopage . ' &objecttype=job ">';
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
}
if ($backtopageforcancel) {
print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
@@ -254,11 +254,16 @@ if (($id || $ref) && $action == 'edit') {
// SKILLDET
print dol_get_fiche_head(array(), '');
$SkilldetRecords = $object->fetchLines();
if (is_array($SkilldetRecords) && count($SkilldetRecords) == 0) {
$object->createSkills(1);
}
if (is_array($SkilldetRecords) && count($SkilldetRecords) > 0) {
print '<table>';
foreach ($SkilldetRecords as $sk) {
$MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL;
if ($sk->rank > $MaxNumberSkill) {
continue;
}
@@ -397,7 +402,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Object card
// ------------------------------------------------------------
$linkback = '<a href="' . dol_buildpath('/hrm/skill_list.php', 1) . '?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$linkback = '<a href="' . DOL_URL_ROOT.'/hrm/skill_list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref = '<div class="refid">';
@@ -691,7 +696,6 @@ if ($action != "create" && $action != "edit") {
break; // Should not happen
}
$MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL;
if ($obj->rank > $MaxNumberSkill) {
continue;
}

View File

@@ -129,7 +129,7 @@ if ($object->id) {
print dol_get_fiche_head($head, 'contact', '', -1, $object->picto);
$linkback = '<a href="'.dol_buildpath('/hrm/skill_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/hrm/skill_list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refidno">';
/*

View File

@@ -127,7 +127,7 @@ if ($object->id) {
// Object card
// ------------------------------------------------------------
$linkback = '<a href="'.dol_buildpath('/hrm/skill_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/hrm/skill_list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refid">';
$morehtmlref.= $object->label;

View File

@@ -100,7 +100,7 @@ if ($id > 0 || !empty($ref)) {
// Object card
// ------------------------------------------------------------
$linkback = '<a href="'.dol_buildpath('/hrm/skill_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/hrm/skill_list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refid">';
$morehtmlref.= $object->label;

View File

@@ -93,14 +93,14 @@ if ($reshook < 0) {
if (empty($reshook)) {
$error = 0;
$backurlforlist = dol_buildpath('/hrm/skill_list.php', 1);
$backurlforlist = DOL_URL_ROOT.'/hrm/skill_list.php';
if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
$backtopage = $backurlforlist;
} else {
$backtopage = dol_buildpath('/hrm/skill_list.php', 1) . '?id=' . ($id > 0 ? $id : '__ID__');
$backtopage = DOL_URL_ROOT.'/hrm/skill_list.php?id=' . ($id > 0 ? $id : '__ID__');
}
}
}

View File

@@ -306,17 +306,6 @@ ALTER TABLE llx_hrm_job_user ADD INDEX idx_hrm_job_user_rowid (rowid);
-- ALTER TABLE llx_hrm_job_user ADD INDEX idx_hrm_job_user_ref (ref);
create table llx_hrm_job_user_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;
ALTER TABLE llx_hrm_job_user_extrafields ADD INDEX idx_position_fk_object(fk_object);
CREATE TABLE llx_hrm_skill
(
@@ -360,20 +349,11 @@ CREATE TABLE llx_hrm_skilldet
rankorder integer
) ENGINE=innodb;
ALTER TABLE llx_hrm_skilldet ADD COLUMN rankorder integer NOT NULL DEFAULT '1';
ALTER TABLE llx_hrm_skilldet ADD INDEX idx_hrm_skilldet_rowid (rowid);
ALTER TABLE llx_hrm_skilldet ADD CONSTRAINT llx_hrm_skilldet_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid);
create table llx_hrm_skilldet_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;
ALTER TABLE llx_hrm_skilldet_extrafields ADD INDEX idx_skilldet_fk_object(fk_object);
CREATE TABLE llx_hrm_skillrank
(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,

View File

@@ -1,21 +0,0 @@
-- Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
-- Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
-- Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/.
-- BEGIN MODULEBUILDER INDEXES
ALTER TABLE llx_hrm_job_user_extrafields ADD INDEX idx_position_fk_object(fk_object);
-- END MODULEBUILDER INDEXES

View File

@@ -1,25 +0,0 @@
-- Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
-- Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
-- Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/.
create table llx_hrm_job_user_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;

View File

@@ -18,9 +18,9 @@
CREATE TABLE llx_hrm_skilldet(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
fk_skill integer NOT NULL,
rankorder integer NOT NULL DEFAULT '1',
description text,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
fk_skill integer NOT NULL,
rankorder integer
fk_user_modif integer
) ENGINE=innodb;

View File

@@ -1,21 +0,0 @@
-- Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
-- Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
-- Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/.
-- BEGIN MODULEBUILDER INDEXES
ALTER TABLE llx_hrm_skilldet_extrafields ADD INDEX idx_skilldet_fk_object(fk_object);
-- END MODULEBUILDER INDEXES

View File

@@ -1,24 +0,0 @@
-- Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
-- Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
-- Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/.
create table llx_hrm_skilldet_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;

View File

@@ -154,8 +154,8 @@ if ($action == "set") {
/**************************************************************************************
*
* Chargement fichiers tables/*.sql (non *.key.sql)
* A faire avant les fichiers *.key.sql
* Load files tables/*.sql (not the *.key.sql). Files with '-xxx' in name are excluded (they will be loaded during activation o fmodule 'xxx').
* To do before the files *.key.sql
*
***************************************************************************************/
if ($ok && $createtables) {
@@ -169,7 +169,7 @@ if ($action == "set") {
$tabledata = array();
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && !preg_match('/\.key\.sql$/i', $file)) {
if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && !preg_match('/\.key\.sql$/i', $file) && !preg_match('/\-/', $file)) {
$tablefound++;
$tabledata[] = $file;
}
@@ -252,8 +252,8 @@ if ($action == "set") {
/***************************************************************************************
*
* Chargement fichiers tables/*.key.sql
* A faire apres les fichiers *.sql
* Load files tables/*.key.sql. Files with '-xxx' in name are excluded (they will be loaded during activation o fmodule 'xxx').
* To do after the files *.sql
*
***************************************************************************************/
if ($ok && $createkeys) {
@@ -267,7 +267,7 @@ if ($action == "set") {
$tabledata = array();
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && preg_match('/\.key\.sql$/i', $file)) {
if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && preg_match('/\.key\.sql$/i', $file) && !preg_match('/\-/', $file)) {
$tablefound++;
$tabledata[] = $file;
}
@@ -372,7 +372,7 @@ if ($action == "set") {
/***************************************************************************************
*
* Chargement fichier functions.sql
* Lod the file 'functions.sql'
*
***************************************************************************************/
if ($ok && $createfunctions) {
@@ -449,7 +449,7 @@ if ($action == "set") {
/***************************************************************************************
*
* Load files data/*.sql
* Load files data/*.sql. Files with '-xxx' in name are excluded (they will be loaded during activation o fmodule 'xxx').
*
***************************************************************************************/
if ($ok && $createdata) {
@@ -463,7 +463,7 @@ if ($action == "set") {
$tabledata = array();
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file)) {
if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && !preg_match('/\-/', $file)) {
if (preg_match('/^llx_accounting_account_/', $file)) {
continue; // We discard data file of chart of account. Will be loaded when a chart is selected.
}

View File

@@ -404,7 +404,7 @@ if ($action == "set" && $success) {
// If upgrade
if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) {
// Upgrade is finished
print '<img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/checklist.svg" width="20" alt="Configuration"> '.$langs->trans("SystemIsUpgraded")."<br>";
print '<img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/checklist.svg" width="20" alt="Configuration"> <span class="valignmiddle">'.$langs->trans("SystemIsUpgraded")."</span><br>";
$createlock = 0;

View File

@@ -21,7 +21,7 @@ NewEmployee=New employee
ListOfEmployees=List of employees
HrmSetup=HRM module setup
SkillsManagement=Skills management
HRM_MAXRANK=Maximum rank for a skill
HRM_MAXRANK=Maximum number of levels to rank a skill
HRM_DEFAULT_SKILL_DESCRIPTION=Default description of ranks when skill is created
deplacement=Shift
DateEval=Evaluation date