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,),
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';
250 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
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';
347 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
349 global
$conf, $langs, $hookmanager;
351 if (!empty(
$conf->dol_no_mouse_hover)) {
357 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Evaluationdet").
'</u>';
358 if (isset($this->
status)) {
359 $label .=
' '.$this->getLibStatut(5);
362 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
364 $url =
dol_buildpath(
'/hrm/evaluationdet_card.php', 1).
'?id='.$this->id;
366 if ($option !=
'nolink') {
368 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
369 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
370 $add_save_lastsearch_values = 1;
372 if ($add_save_lastsearch_values) {
373 $url .=
'&save_lastsearch_values=1';
378 if (empty($notooltip)) {
380 $label = $langs->trans(
"ShowEvaluationdet");
381 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
383 $linkclose .=
' title="'.dolPrintHTMLForAttribute($label).
'"';
384 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
386 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
389 if ($option ==
'nolink') {
390 $linkstart =
'<span';
392 $linkstart =
'<a href="'.$url.
'"';
394 $linkstart .= $linkclose.
'>';
395 if ($option ==
'nolink') {
396 $linkend =
'</span>';
401 $result .= $linkstart;
403 if (empty($this->showphoto_on_popup)) {
405 $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);
409 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
411 list($class, $module) = explode(
'@', $this->picto);
414 $filename = $filearray[0][
'name'];
415 if (!empty($filename)) {
416 $pospoint = strpos($filearray[0][
'name'],
'.');
418 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
420 $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>';
422 $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>';
427 $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);
432 if ($withpicto != 2) {
433 $result .= $this->ref;
439 global $action, $hookmanager;
440 $hookmanager->initHooks(array(
'evaluationlinedao'));
441 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
442 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
444 $result = $hookmanager->resPrint;
446 $result .= $hookmanager->resPrint;
460 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
461 $sql .=
' fk_user_creat, fk_user_modif';
462 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
463 $sql .=
' WHERE t.rowid = '.((int) $id);
464 $result = $this->db->query($sql);
466 if ($this->db->num_rows($result)) {
467 $obj = $this->db->fetch_object($result);
469 $this->
id = $obj->rowid;
471 $this->user_creation_id = $obj->fk_user_creat;
472 $this->user_modification_id = $obj->fk_user_modif;
473 $this->date_creation = $this->db->jdate($obj->datec);
474 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
477 $this->db->free($result);
503 public function getNextNumRef()
505 global $langs,
$conf;
509 $conf->global->hrm_EVALUATIONLINE_ADDON =
'mod_evaluationdet_standard';
519 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
520 foreach ($dirmodels as $reldir) {
524 $mybool = ((bool) @include_once $dir.$file) || $mybool;
532 if (class_exists($classname)) {
533 $obj =
new $classname();
534 '@phan-var-force ModeleNumRefEvaluation $obj';
536 $numref = $obj->getNextValue($this);
538 if ($numref !=
'' && $numref !=
'-1') {
541 $this->error = $obj->error;
546 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
550 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
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.
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.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.