Skip to content

Commit

Permalink
Remove need to redo everything on loan submit error
Browse files Browse the repository at this point in the history
  • Loading branch information
MestourBS committed Jan 6, 2022
1 parent 3fb4230 commit 033a1d3
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions orif/stock/Controllers/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,15 @@ public function create_loan($id = NULL) {
$this->loan_model->insert($loanArray);

return redirect()->to("/item/loans/".$id);
} else {
$data['errors'] = $validation->getErrors();

// List of data inputs from the user
$inputs = ['date', 'planned_return_date', 'real_return_date', 'loan_to_user_id', 'borrower_email', 'item_localisation'];
foreach ($inputs as $input) {
if (isset($_POST[$input])) $data[$input] = $_POST[$input];
}
}
$data['errors'] = $validation->getErrors();
}
$this->display_view('Stock\Views\loan\form', $data);
} else {
Expand Down Expand Up @@ -788,8 +795,15 @@ public function modify_loan($id = NULL) {
$this->loan_model->update($id, $loanArray);

return redirect()->to("/item/loans/".$data["item_id"]);
} else {
$data['errors'] = $validation->getErrors();

// List of data inputs from the user
$inputs = ['date', 'planned_return_date', 'real_return_date', 'loan_to_user_id', 'borrower_email', 'item_localisation'];
foreach ($inputs as $input) {
if (isset($_POST[$input])) $data[$input] = $_POST[$input];
}
}
$data['errors'] = $validation->getErrors();
}
$this->display_view('Stock\Views\loan\form', $data);
} else {
Expand Down

0 comments on commit 033a1d3

Please sign in to comment.