Skip to content

Commit

Permalink
Merge branch 'feature/employee' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Naveenz committed May 5, 2023
2 parents eccbe0c + 4c5d42b commit bf2871b
Show file tree
Hide file tree
Showing 30 changed files with 695 additions and 284 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -103,3 +103,4 @@ fabric.properties
/core/.env
/.idea/inspectionProfiles/Project_Default.xml
/node_modules/
/logs/
31 changes: 0 additions & 31 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

Binary file removed composer.phar
Binary file not shown.
57 changes: 57 additions & 0 deletions controllers/employee/EmployeeReportListController.php
@@ -0,0 +1,57 @@
<?php

namespace app\controllers\employee;

use app\core\Controller;
use app\core\Request;
use app\models\ReportListModel;
use app\stores\EmployeeStore;

class EmployeeReportListController extends Controller
{
const login = 'Location: /login';

private function validate(): void
{
// checking whether the user is logged into the server
if ($_SESSION['userType'] != 'staff') {
header(self::login);
}
}

public function load(Request $request): void
{
$this->validate();

if ($request->isGet()) {
if ($_SESSION['userType'] == 'staff') {
$this -> render("employee/reports.php");
} else {
header(self::login);
}
} else {
header(self::login);
}
}

public function getAllReports(): array
{
$model = new ReportListModel();
// creating an array of all reports
return $model->getAllReports();
}

public function sortBySeen($list): array
{
$seen = array();
$unseen = array();
foreach ($list as $report) {
if ($report->is_employee_noticed) {
$seen[] = $report;
} else {
$unseen[] = $report;
}
}
return array_merge($seen, $unseen);
}
}
12 changes: 0 additions & 12 deletions controllers/employee/EmployeeReports.php

This file was deleted.

177 changes: 117 additions & 60 deletions controllers/employee/EmployeeResController.php
Expand Up @@ -20,22 +20,30 @@ public function loadPharmacy(Request $request): void
$store->flag_aprv_one_usr = $this->getEntityFlag($request);
$store->flag_aprv_one_act = $this->getActionFlag($request);

$obj = HyperPharmacyModel::getByUsername($store->flag_aprv_one_usr);
if ($obj) {
// checking whether there is a direct action to be performed
switch ($store->flag_aprv_one_act) {
case 'delete':
$obj->delete();
header('Location: /employee/res?f=pharmacy');
break;
default:
// loading the approval details page
$store->aprv_one_obj = $obj;
$this -> render("employee/res/pharmacy.php");
break;
}
//identifies the request is NEW or UPDATE
if ($store->flag_aprv_one_usr == '') {
// loading the new pharmacy page
$store->aprv_one_obj = null; // make sure there is no object in the store
$this -> render("employee/res/pharmacy.php");
} else {
header('Location: /employee/res?f=pharmacy');
// loading the update pharmacy page
$obj = HyperPharmacyModel::getByUsername($store->flag_aprv_one_usr);
if ($obj) {
// checking whether there is a direct action to be performed
switch ($store->flag_aprv_one_act) {
case 'delete':
$obj->delete();
header('Location: /employee/res?f=pharmacy');
break;
default:
// loading the approval details page
$store->aprv_one_obj = $obj;
$this -> render("employee/res/pharmacy.php");
break;
}
} else {
header('Location: /employee/res?f=pharmacy');
}
}
}

Expand All @@ -45,6 +53,10 @@ public function pushPharmacy(Request $request): void

// retrieving the employee store
$store = EmployeeStore::getEmployeeStore();

// start output buffering
ob_start();

// retrieving data from the request
if ($request->isPost()) {
$params = $this->getRequestBody($_POST);
Expand Down Expand Up @@ -88,6 +100,8 @@ public function pushPharmacy(Request $request): void
}
}

// flush output buffer and send header
ob_end_flush();
header('Location: /employee/res?f=pharmacy');
}

Expand All @@ -100,22 +114,30 @@ public function loadSupplier(Request $request): void
$store->flag_aprv_one_usr = $this->getEntityFlag($request);
$store->flag_aprv_one_act = $this->getActionFlag($request);

$obj = HyperSupplierModel::getByUsername($store->flag_aprv_one_usr);
if ($obj) {
// checking whether there is a direct action to be performed
switch ($store->flag_aprv_one_act) {
case 'delete':
$obj->delete();
header('Location: /employee/res?f=supplier');
break;
default:
// loading the approval details page
$store->aprv_one_obj = $obj;
$this -> render("employee/res/supplier.php");
break;
}
//identifies the request is NEW or UPDATE
if ($store->flag_aprv_one_usr == '') {
// loading the new supplier page
$store->aprv_one_obj = null; // make sure there is no object in the store
$this -> render("employee/res/supplier.php");
} else {
header('Location: /employee/res?f=supplier');
// loading the update supplier page
$obj = HyperSupplierModel::getByUsername($store->flag_aprv_one_usr);
if ($obj) {
// checking whether there is a direct action to be performed
switch ($store->flag_aprv_one_act) {
case 'delete':
$obj->delete();
header('Location: /employee/res?f=supplier');
break;
default:
// loading the approval details page
$store->aprv_one_obj = $obj;
$this -> render("employee/res/supplier.php");
break;
}
} else {
header('Location: /employee/res?f=supplier');
}
}
}

Expand All @@ -125,9 +147,14 @@ public function pushSupplier(Request $request): void

// retrieving the employee store
$store = EmployeeStore::getEmployeeStore();

// start output buffering
ob_start();

// retrieving data from the request
if ($request->isPost()) {
$params = $this->getRequestBody($_POST);
//$params = $request->getBody();
// checking whether the supplier exists in the store.
//If not, it means this is s insert request
if ($store->aprv_one_obj) {
Expand Down Expand Up @@ -162,6 +189,8 @@ public function pushSupplier(Request $request): void
}
}

// flush output buffer and send header
ob_end_flush();
header('Location: /employee/res?f=supplier');
}

Expand All @@ -174,22 +203,30 @@ public function loadDelivery(Request $request): void
$store->flag_aprv_one_usr = $this->getEntityFlag($request);
$store->flag_aprv_one_act = $this->getActionFlag($request);

$obj = HyperDeliveryModel::getByUsername($store->flag_aprv_one_usr);
if ($obj) {
// checking whether there is a direct action to be performed
switch ($store->flag_aprv_one_act) {
case 'delete':
$obj->delete();
header('Location: /employee/res?f=delivery');
break;
default:
// loading the approval details page
$store->aprv_one_obj = $obj;
$this -> render("employee/res/delivery.php");
break;
}
//identifies the request is NEW or UPDATE
if ($store->flag_aprv_one_usr == '') {
// loading the new delivery page
$store->aprv_one_obj = null; // make sure there is no object in the store
$this -> render("employee/res/delivery.php");
} else {
header('Location: /employee/res?f=delivery');
// loading the update delivery page
$obj = HyperDeliveryModel::getByUsername($store->flag_aprv_one_usr);
if ($obj) {
// checking whether there is a direct action to be performed
switch ($store->flag_aprv_one_act) {
case 'delete':
$obj->delete();
header('Location: /employee/res?f=delivery');
break;
default:
// loading the approval details page
$store->aprv_one_obj = $obj;
$this -> render("employee/res/delivery.php");
break;
}
} else {
header('Location: /employee/res?f=delivery');
}
}
}

Expand All @@ -199,6 +236,10 @@ public function pushDelivery(Request $request): void

// retrieving the employee store
$store = EmployeeStore::getEmployeeStore();

// start output buffering
ob_start();

// retrieving data from the request
if ($request->isPost()) {
$params = $this->getRequestBody($_POST);
Expand Down Expand Up @@ -250,6 +291,8 @@ public function pushDelivery(Request $request): void
}
}

// flush output buffer and send header
ob_end_flush();
header('Location: /employee/res?f=delivery');
}

Expand All @@ -262,22 +305,30 @@ public function loadLab(Request $request): void
$store->flag_aprv_one_usr = $this->getEntityFlag($request);
$store->flag_aprv_one_act = $this->getActionFlag($request);

$obj = HyperLabModel::getByUsername($store->flag_aprv_one_usr);
if ($obj) {
// checking whether there is a direct action to be performed
switch ($store->flag_aprv_one_act) {
case 'delete':
$obj->delete();
header('Location: /employee/res?f=lab');
break;
default:
// loading the approval details page
$store->aprv_one_obj = $obj;
$this -> render("employee/res/lab.php");
break;
}
//identifies the request is NEW or UPDATE
if ($store->flag_aprv_one_usr == '') {
// loading the new lab page
$store->aprv_one_obj = null; // make sure there is no object in the store
$this -> render("employee/res/lab.php");
} else {
header('Location: /employee/res?f=lab');
// loading the update lab page
$obj = HyperLabModel::getByUsername($store->flag_aprv_one_usr);
if ($obj) {
// checking whether there is a direct action to be performed
switch ($store->flag_aprv_one_act) {
case 'delete':
$obj->delete();
header('Location: /employee/res?f=lab');
break;
default:
// loading the approval details page
$store->aprv_one_obj = $obj;
$this -> render("employee/res/lab.php");
break;
}
} else {
header('Location: /employee/res?f=lab');
}
}
}

Expand All @@ -287,6 +338,10 @@ public function pushLab(Request $request): void

// retrieving the employee store
$store = EmployeeStore::getEmployeeStore();

// start output buffering
ob_start();

// retrieving data from the request
if ($request->isPost()) {
$params = $this->getRequestBody($_POST);
Expand Down Expand Up @@ -322,6 +377,8 @@ public function pushLab(Request $request): void
}
}

// flush output buffer and send header
ob_end_flush();
header('Location: /employee/res?f=lab');
}
}
7 changes: 0 additions & 7 deletions core/.env

This file was deleted.

Empty file removed logs/debug.log
Empty file.
Empty file removed logs/error.log
Empty file.

0 comments on commit bf2871b

Please sign in to comment.