Skip to content

Commit

Permalink
[PreventionPlan] fix: redirect after cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-theo committed Jun 18, 2021
1 parent 8b5178c commit c0dd580
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions digiriskelement_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@
print '<div class="center">';
print '<input type="submit" class="button" id ="actionButtonCreate" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">';
print '&nbsp; ';
print ' &nbsp; <input type="submit" id ="actionButtonCancelCreate" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print ' &nbsp; <input type="submit" id ="actionButtonCancelCreate" class="button" name="cancel" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">';
print '</div>';

print '</form>';
Expand Down Expand Up @@ -329,7 +329,7 @@
dol_fiche_end();

print '<div class="center"><input type="submit" id ="actionButtonSave" class="button" name="save" value="'.$langs->trans("Save").'">';
print ' &nbsp; <input type="submit" id ="actionButtonCancelEdit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print ' &nbsp; <input type="submit" id ="actionButtonCancelEdit" class="button" name="cancel" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">';
print '</div>';

print '</form>';
Expand Down
29 changes: 14 additions & 15 deletions preventionplan_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,22 @@
$digiriskresources->digirisk_dolibarr_set_resources($db, $user->id, 'PP_LABOUR_INSPECTOR_ASSIGNED', 'societe', array($labour_inspector_id), $conf->entity, 'preventionplan', $object->id, 1);
$digiriskresources->digirisk_dolibarr_set_resources($db, $user->id, 'PP_EXT_SOCIETY_INTERVENANTS', 'socpeople', $extintervenant_ids, $conf->entity, 'preventionplan', $object->id, 1);

// Creation risk + evaluation + task OK
// Creation prevention plan OK
$urltogo = str_replace('__ID__', $result, $backtopage);
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation
header("Location: " . $urltogo);
exit;
}
else
{
// Creation risk KO
// Creation prevention plan KO
if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
}
}
}

// Action to add record
// Action to update record
if ($action == 'update' && $permissiontoadd) {

$maitre_oeuvre_id = GETPOST('maitre_oeuvre');
Expand Down Expand Up @@ -220,22 +220,22 @@
$digiriskresources->digirisk_dolibarr_set_resources($db, $user->id, 'PP_LABOUR_DOCTOR_ASSIGNED', 'societe', array($labour_inspector_id), $conf->entity, 'preventionplan', $object->id, 0);
$digiriskresources->digirisk_dolibarr_set_resources($db, $user->id, 'PP_EXT_SOCIETY_INTERVENANTS', 'socpeople', $extintervenant_ids, $conf->entity, 'preventionplan', $object->id, 0);

// Creation risk + evaluation + task OK
// Creation prevention plan OK
$urltogo = str_replace('__ID__', $result, $backtopage);
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation
header("Location: " . $urltogo);
exit;
}
else
{
// Creation risk KO
// Creation prevention plan KO
if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
}
}
}

// Action to add record
// Action to delete record
if ($action == 'delete' && $permissiontoadd) {

}
Expand Down Expand Up @@ -286,7 +286,7 @@
}
}

// Action to add record
// Action to update line
if ($action == 'updateLine' && $permissiontoadd) {

$actions_description = GETPOST('actionsdescription');
Expand Down Expand Up @@ -318,36 +318,36 @@

if ($result > 0) {

// Creation risk + evaluation + task OK
// Creation prevention plan OK
$urltogo = str_replace('__ID__', $result, $backtopage);
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $parent_id, $urltogo); // New method to autoselect project after a New on another form object creation
header("Location: " . $urltogo);
exit;
}
else
{
// Creation risk KO
// Creation prevention plan KO
if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
}
}
}

// Action to add record
// Action to delete line
if ($action == 'deleteline' && $permissiontodelete) {

$objectline = new PreventionPlanLine($db);
$result = $objectline->fetch($lineid);

if ($result > 0) {
$objectline->delete();
// Creation risk + evaluation + task OK
// Creation prevention plan OK
$urltogo = str_replace('__ID__', $result, $backtopage);
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $parent_id, $urltogo); // New method to autoselect project after a New on another form object creation
header("Location: " . $urltogo);
exit;
} else {
// Creation risk KO
// Creation prevention plan KO
if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
}
Expand Down Expand Up @@ -549,8 +549,7 @@

print '<div class="center">';
print '<input type="submit" class="button" id ="actionButtonCreate" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">';
print '&nbsp; ';
print ' &nbsp; <input type="submit" id ="actionButtonCancelCreate" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print ' &nbsp; <input type="submit" id ="actionButtonCancelCreate" class="button" name="cancel" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">';
print '</div>';

print '</form>';
Expand Down Expand Up @@ -701,7 +700,7 @@
dol_fiche_end();

print '<div class="center"><input type="submit" id ="actionButtonSave" class="button" name="save" value="'.$langs->trans("Save").'">';
print ' &nbsp; <input type="submit" id ="actionButtonCancelEdit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print ' &nbsp; <input type="submit" id ="actionButtonCancelEdit" class="button" name="cancel" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">';
print '</div>';

print '</form>';
Expand Down

0 comments on commit c0dd580

Please sign in to comment.