Close #35754 - Better fix in 1 POST.
This commit is contained in:
parent
c1a8172347
commit
51c2103c3e
2 changed files with 33 additions and 26 deletions
|
|
@ -110,7 +110,6 @@ if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) {
|
|||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
|
@ -136,6 +135,34 @@ if (empty($reshook)) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($action == 'saveSkill' && $permissiontoadd) {
|
||||
$TNote = GETPOST('TNote', 'array');
|
||||
if (!empty($TNote)) {
|
||||
foreach ($object->lines as $line) {
|
||||
$line->rankorder = ($TNote[$line->fk_skill] == "NA" ? -1 : $TNote[$line->fk_skill]);
|
||||
$line->update($user);
|
||||
}
|
||||
//setEventMessage($langs->trans("SaveLevelSkill"));
|
||||
}
|
||||
|
||||
$action = 'validate';
|
||||
}
|
||||
|
||||
if ($action == "validate" && $permissiontoadd) {
|
||||
$TNote = GETPOST('TNote', 'array');
|
||||
$emptyTNote = true;
|
||||
foreach ($object->lines as $line) {
|
||||
if (!in_array($TNote[$line->fk_skill], array("0", ""))) {
|
||||
$emptyTNote = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($emptyTNote) {
|
||||
setEventMessage($langs->trans("WarningEvaluationEmptyValidate"), 'errors');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
|
||||
$triggermodname = 'HRM_EVALUATION_MODIFY'; // Name of trigger action code to execute when we modify record
|
||||
|
||||
// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
|
||||
|
|
@ -164,17 +191,6 @@ if (empty($reshook)) {
|
|||
$trackid = 'evaluation'.$object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
|
||||
|
||||
if ($action == 'saveSkill' && $permissiontoadd) {
|
||||
$TNote = GETPOST('TNote', 'array');
|
||||
if (!empty($TNote)) {
|
||||
foreach ($object->lines as $line) {
|
||||
$line->rankorder = ($TNote[$line->fk_skill] == "NA" ? -1 : $TNote[$line->fk_skill]);
|
||||
$line->update($user);
|
||||
}
|
||||
setEventMessage($langs->trans("SaveLevelSkill"));
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'close' && $permissiontoadd) {
|
||||
// save evaldet lines to user;
|
||||
$sk = new SkillRank($db);
|
||||
|
|
@ -253,7 +269,6 @@ if (empty($reshook)) {
|
|||
|
||||
$form = new Form($db);
|
||||
$formfile = new FormFile($db);
|
||||
$formproject = new FormProjets($db);
|
||||
|
||||
$title = $langs->trans("Evaluation");
|
||||
$help_url = '';
|
||||
|
|
@ -263,20 +278,11 @@ llxHeader('', $title, $help_url, '', 0, 0, '', $css);
|
|||
|
||||
print '<script type="text/javascript" language="javascript">
|
||||
$(document).ready(function() {
|
||||
$("#btn_valid").click(function(){
|
||||
$("#btn_valid").click(function() {
|
||||
console.log("Click on btn_valid");
|
||||
var form = $("#form_save_rank");
|
||||
|
||||
$.ajax({
|
||||
|
||||
type: "POST",
|
||||
url: form.attr("action"),
|
||||
data: form.serialize(),
|
||||
dataType: "json"
|
||||
}).always(function() {
|
||||
window.location.href = "'.dol_buildpath('/hrm/evaluation_card.php', 1).'?id='.$id.'&action=validate&token='.newToken().'";
|
||||
return false;
|
||||
});
|
||||
|
||||
form.submit();
|
||||
return true;
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
|
|
|||
|
|
@ -451,3 +451,4 @@ ThisIdNotDefined=Id not defined
|
|||
OperNotDefined=Payment method not defined
|
||||
EmptyMessageNotAllowedError=Empty message is not allowed
|
||||
SomeShipmentExists=Error, there is some shipment linked to the order. Deletion refused.
|
||||
WarningEvaluationEmptyValidate=Can't validate evaluation, levels on skills not defined
|
||||
|
|
|
|||
Loading…
Reference in a new issue