Skip to content

Commit

Permalink
Fix access level for item loans list
Browse files Browse the repository at this point in the history
  • Loading branch information
DidierViret committed Jan 6, 2022
2 parents 1dae73b + 033a1d3 commit db312c7
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions orif/stock/Controllers/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ public function create_inventory_control($id = NULL) {
*/
public function inventory_controls($id = NULL) {
if (!empty($id) && isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true && $_SESSION['user_access'] >= config('\User\Config\UserConfig')->access_lvl_registered) {

helper('MY_date');

// Get item object with related inventory controls
Expand Down 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 All @@ -806,7 +820,7 @@ public function modify_loan($id = NULL) {
* @return void
*/
public function loans($id = NULL) {
if (!empty($id) && isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true && $_SESSION['user_access']>=config('\User\Config\UserConfig')->access_lvl_admin) {
if (!empty($id) && isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true && $_SESSION['user_access']>=config('\User\Config\UserConfig')->access_lvl_registered) {

// Get item object and related loans
$item = $this->item_model->find($id);
Expand Down

0 comments on commit db312c7

Please sign in to comment.