31require_once DOL_DOCUMENT_ROOT .
'/core/class/commonobjectline.class.php';
32require_once DOL_DOCUMENT_ROOT .
'/hrm/class/skillrank.class.php';
43 public $module =
'hrm';
48 public $element =
'evaluationdet';
53 public $table_element =
'hrm_evaluationdet';
68 public $picto =
'evaluationdet@hrm';
101 public $fields = array(
102 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'position' => 1,
'notnull' => 1,
'visible' => 0,
'noteditable' => 1,
'index' => 1,
'css' =>
'left',
'comment' =>
"Id"),
103 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'position' => 500,
'notnull' => 1,
'visible' => -2,),
104 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'position' => 501,
'notnull' => 0,
'visible' => -2,),
105 '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',),
106 'fk_user_modif' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserModif',
'enabled' => 1,
'position' => 511,
'notnull' => -1,
'visible' => -2,),
107 'fk_skill' => array(
'type' =>
'integer:Skill:hrm/class/skill.class.php:1',
'label' =>
'Skill',
'enabled' => 1,
'position' => 3,
'notnull' => 1,
'visible' => 1,
'index' => 1,),
108 'fk_evaluation' => array(
'type' =>
'integer:Evaluation:hrm/class/evaluation.class.php:1',
'label' =>
'Evaluation',
'enabled' => 1,
'position' => 3,
'notnull' => 1,
'visible' => 1,
'index' => 1,),
109 'rankorder' => array(
'type' =>
'integer',
'label' =>
'Rank',
'enabled' => 1,
'position' => 4,
'notnull' => 1,
'visible' => 1,
'uieditable' => 1,),
110 'required_rank' => array(
'type' =>
'integer',
'label' =>
'requiredRank',
'enabled' => 1,
'position' => 5,
'notnull' => 1,
'visible' => 1,),
111 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'position' => 1000,
'notnull' => -1,
'visible' => -2,),
120 public $fk_user_creat;
124 public $fk_user_modif;
132 public $fk_evaluation;
144 public $required_rank;
158 global
$conf, $langs;
162 $this->ismultientitymanaged = 0;
163 $this->isextrafieldmanaged = 1;
166 $this->fields[
'rowid'][
'visible'] = 0;
168 if (!
isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
169 $this->fields[
'entity'][
'enabled'] = 0;
173 foreach ($this->fields as $key => $val) {
174 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
175 unset($this->fields[$key]);
180 if (is_object($langs)) {
181 foreach ($this->fields as $key => $val) {
182 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
183 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
184 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
202 return $resultcreate;
212 public function fetch($id, $ref =
null)
231 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
241 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
242 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
243 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
245 $sql .=
' WHERE 1 = 1';
252 $this->errors[] = $errormessage;
253 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
257 if (!empty($sortfield)) {
258 $sql .= $this->db->order($sortfield, $sortorder);
260 if (!empty($limit)) {
261 $sql .=
' '.$this->db->plimit($limit, $offset);
264 $resql = $this->db->query($sql);
266 $num = $this->db->num_rows($resql);
268 while ($i < ($limit ? min($limit, $num) : $num)) {
269 $obj = $this->db->fetch_object($resql);
271 $record =
new self($this->db);
272 $record->setVarsFromFetchObj($obj);
274 $records[$record->id] = $record;
278 $this->db->free($resql);
282 $this->errors[] =
'Error '.$this->db->lasterror();
283 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
308 public function delete(
User $user, $notrigger = 0)
310 if ($this->fk_rank) {
312 $skillRank->fetch($this->fk_rank);
313 $skillRank->delete($user, $notrigger);
330 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
346 if ($mode ==
'create') {
350 return in_array($mode, array(
'read',
'write',
'delete')) && $user->hasRight(
'hrm',
'evaluation', $mode);
361 require_once DOL_DOCUMENT_ROOT.
'/hrm/class/evaluation.class.php';
363 if ($evaluation->fetch($this->fk_evaluation) <= 0) {
367 return (
int) $evaluation->status !== Evaluation::STATUS_DRAFT;
379 $value = parent::getFieldValueFromAjaxPost($field);
381 if ($field ==
'rankorder' && !is_null($value)) {
382 require_once DOL_DOCUMENT_ROOT.
'/hrm/class/skill.class.php';
383 if ($value < -1 || $value >
getDolGlobalInt(
'HRM_MAXRANK', Skill::DEFAULT_MAX_RANK_PER_SKILL)) {
401 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
403 global
$conf, $langs, $hookmanager;
405 if (!empty(
$conf->dol_no_mouse_hover)) {
411 $label = img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Evaluationdet").
'</u>';
412 if (isset($this->
status)) {
413 $label .=
' '.$this->getLibStatut(5);
416 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
418 $url =
dol_buildpath(
'/hrm/evaluationdet_card.php', 1).
'?id='.$this->id;
420 if ($option !=
'nolink') {
422 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
423 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
424 $add_save_lastsearch_values = 1;
426 if ($add_save_lastsearch_values) {
427 $url .=
'&save_lastsearch_values=1';
432 if (empty($notooltip)) {
434 $label = $langs->trans(
"ShowEvaluationdet");
435 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
437 $linkclose .=
' title="'.dolPrintHTMLForAttribute($label).
'"';
438 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
440 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
443 if ($option ==
'nolink') {
444 $linkstart =
'<span';
446 $linkstart =
'<a href="'.$url.
'"';
448 $linkstart .= $linkclose.
'>';
449 if ($option ==
'nolink') {
450 $linkend =
'</span>';
455 $result .= $linkstart;
457 if (empty($this->showphoto_on_popup)) {
459 $result .= img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
463 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
465 list($class, $module) = explode(
'@', $this->picto);
468 $filename = $filearray[0][
'name'];
469 if (!empty($filename)) {
470 $pospoint = strpos($filearray[0][
'name'],
'.');
472 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.
dol_substr($filename, 0, $pospoint).
'_mini'.
dol_substr($filename, $pospoint);
474 $result .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.
'" alt="No photo" border="0" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$module.
'&entity='.
$conf->entity.
'&file='.urlencode($pathtophoto).
'"></div></div>';
476 $result .=
'<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$module.
'&entity='.
$conf->entity.
'&file='.urlencode($pathtophoto).
'"></div>';
481 $result .= img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
486 if ($withpicto != 2) {
487 $result .= $this->ref;
493 global $action, $hookmanager;
494 $hookmanager->initHooks(array(
'evaluationlinedao'));
495 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
496 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
498 $result = $hookmanager->resPrint;
500 $result .= $hookmanager->resPrint;
514 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
515 $sql .=
' fk_user_creat, fk_user_modif';
516 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
517 $sql .=
' WHERE t.rowid = '.((int) $id);
518 $result = $this->db->query($sql);
520 if ($this->db->num_rows($result)) {
521 $obj = $this->db->fetch_object($result);
523 $this->
id = $obj->rowid;
525 $this->user_creation_id = $obj->fk_user_creat;
526 $this->user_modification_id = $obj->fk_user_modif;
527 $this->date_creation = $this->db->jdate($obj->datec);
528 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
531 $this->db->free($result);
533 dol_print_error($this->db);
557 public function getNextNumRef()
559 global $langs,
$conf;
563 $conf->global->hrm_EVALUATIONLINE_ADDON =
'mod_evaluationdet_standard';
573 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
574 foreach ($dirmodels as $reldir) {
578 $mybool = ((bool) @include_once $dir.$file) || $mybool;
582 dol_print_error(
null,
"Failed to include file ".$file);
586 if (class_exists($classname)) {
587 $obj =
new $classname();
588 '@phan-var-force ModeleNumRefEvaluation $obj';
590 $numref = $obj->getNextValue($this);
592 if ($numref !=
'' && $numref !=
'-1') {
595 $this->error = $obj->error;
600 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
604 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
deleteLineCommon(User $user, $idline, $notrigger=0)
Delete a line of object in database.
createCommon(User $user, $notrigger=0)
Create object in the database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
updateCommon(User $user, $notrigger=0)
Update object into database.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
Class for EvaluationLine.
update(User $user, $notrigger=0)
Update object into database.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
fetch($id, $ref=null)
Load object in memory from the database.
hasUserPermission(User $user, $mode='write')
Check if user has a permission on evaluations, the lines of an evaluation have no permission of their...
isFieldBlockedByObjectState($field)
A line can be changed only while its evaluation is a draft.
info($id)
Load the info information in the object.
create(User $user, $notrigger=0)
Create object into database.
__construct(DoliDB $db)
Constructor.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load list of objects in memory from the database.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
deleteLine(User $user, $idline, $notrigger=0)
Delete a line of object in database.
getFieldValueFromAjaxPost($field)
Return the value of a field posted by the user interface (core/ajax/objectfield.php).
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0, $forbiddenfields=array())
forgeSQLFromUniversalSearchCriteria
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.