| Current Path : /var/www/html/mmishra/erp/controllers/ |
| Current File : /var/www/html/mmishra/erp/controllers/ihc_controller.php |
<?php
//if (!class_exists($erpController)) {
require_once __DIR__."/erp_controller.php";
//}
class ihcController extends erpController {
var $model;
public function __construct($model) {
// call parent constructor
// parent::__construct();
// initialize variables
$this->model = $model;
$this->appURL = $_SERVER["REQUEST_URI"]; // this is Request URI for log entry
$this->referer = $_SERVER["HTTP_REFERER"]; // requires for log entry, not mandatory
$this->instituteID = $_SESSION["instituteID"]; // current user id
$this->loginID = $_SESSION["loginID"]; // current user id
$this->sessionID = $_SESSION["sessionID"]; // current session id
$this->moduleID = isset($_SESSION["moduleID"]) ? $_SESSION["moduleID"] : 1;
$this->appID = $_SESSION["appID"]; // current application id
$this->userIP = $this->getIP();
$this->filterText = $_POST['filterText'];
// maintain erp activity log for inner contents
if ($this->loginID && strpos($this->appURL, 'inner')) {
$this->model->erpLog($this->loginID, $this->userIP, $this->appURL, $this->referer);
} else if (!$this->sessionID) {
header("Location: /");
}
}
public function __destruct() {
// echo $erpModel->sqlCommand;//'Destroying: ', $this->moduleID, PHP_EOL;
// log sql operation on corresponding table
// call $erpModel->erpSql($sql);
// print("Thanks.");
}
public function ihcDashboard($action, $tupleID) {
}
public function manageDoctor($action, $doctorID) {
$this->model->tableID = 'ihc_doctors';
$this->model->tupleID = $doctorID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
$doctorName = $_POST['doctorName'];
$designation = $_POST['designation'];
$specialization = $_POST['specialization'];
$contactNo = $_POST['contactNo'];
$email = $_POST['email'];
if ($doctorName) {
$this->model->saveDoctor($doctorName,$designation,$specialization,$contactNo,$email);
$this->model->sqlLog();
$this->errorText = 'Doctor record saved successfully.';
}
break;
case 'delete':
$this->model->deleteDoctor();
$this->errorText = 'Doctor test record deleted successfully.';
break;
case 'email':
$msg = "Dear Doctor!
You have been enrolled in the ERP database as a Medical Officer.
This is for your information.";
//automailer($email, "Acknowledgement", $msg);
break;
}
return $this->model->tupleID;
}
public function manageStaff($action, $staffID) {
$this->model->tableID = 'ihc_staffs';
$this->model->tupleID = $staffID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
$staffName = $_POST['staffName'];
$designation = $_POST['designation'];
$specialization = $_POST['specialization'];
$contactNo = $_POST['contactNo'];
$email = $_POST['email'];
if ($staffName) {
$this->model->saveStaff($staffName,$designation,$specialization,$contactNo,$email);
$this->model->sqlLog();
$this->errorText = 'Staff record saved successfully.';
}
break;
case 'delete':
$this->model->deleteStaff();
$this->errorText = 'Staff record deleted successfully.';
break;
case 'email':
$msg = "Dear Staff!
You have been enrolled in the ERP database as a Pharmacy Staff.
This is for your information.";
//automailer($email, "Acknowledgement", $msg);
break;
}
return $this->model->tupleID;
}
public function manageMedicine($action, $medicineID) {
$this->model->tableID = 'ihc_medicines';
$this->model->tupleID = $medicineID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
$patientID = $_POST["patientID"];
$dependent = $_POST["dependent"];
$doctorID = $_POST["doctorID"];
if ($patientID) {
$this->model->saveRegistration($patientID,$dependent,$doctorID);
$this->model->sqlLog();
$this->errorText = 'Registration record saved successfully.';
}
break;
case 'delete':
$this->model->deleteRegistration();
$this->errorText = 'Medicine record deleted successfully.';
break;
}
return $this->model->tupleID;
}
public function manageLabtest($action, $testID) {
$this->model->tableID = 'ihc_labtests';
$this->model->tupleID = $testID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
$testGroup = $_POST["testGroup"];
$testName = $_POST["testName"];
$normalValue = $_POST["normalValue"];
if ($testID) {
$this->model->saveLabtest($testGroup,$testName,$normalValue);
$this->model->sqlLog();
$this->errorText = 'Lab test record saved successfully.';
}
break;
case 'delete':
$this->model->deleteLabtest();
$this->errorText = 'Lab test record deleted successfully.';
break;
}
return $this->model->tupleID;
}
public function manageRegistration($action, $opdID) {
$this->model->tableID = 'ihc_registrations';
$this->model->tupleID = $opdID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
$patientID = $_POST["patientID"];
$dependent = $_POST["dependent"];
$doctorID = $_POST["doctorID"];
if ($patientID) {
$this->model->saveRegistration($patientID,$dependent,$doctorID);
$this->model->sqlLog();
$this->errorText = 'Registration record saved successfully.';
}
break;
case 'delete':
$this->model->deleteRegistration();
$this->errorText = 'Registration record deleted successfully.';
break;
}
return $this->model->tupleID;
}
public function manageMedication($action, $medicationID) {
$this->model->tableID = 'ihc_medications';
$this->model->tupleID = $medicationID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
$opdID = $_POST["opdID"];
$medicineID = $_POST["medicineID"];
$qtyOut = $_POST["qtyOut"];
$this->model->saveMedication($opdID,$medicineID,$qtyOut);
$this->model->sqlLog();
$this->errorText = 'Medication record saved successfully.';
break;
case 'delete':
$this->model->deleteRegistration();
$this->errorText = 'Registration record deleted successfully.';
break;
}
return $this->model->tupleID;
}
public function manageLabreport($action, $opdID) {
$this->model->tableID = 'ihc_labreports';
$this->model->tupleID = $opdID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
$testIDs = $_POST["testID"];
$testValues = $_POST["testValue"];
$i = 0;
foreach ($testIDs as $testID) {
if ($testValues[$i]) $this->model->saveLabreport($opdID,$testID,$testValues[$i]);
$i++;
}
//$this->model->sqlLog();
$this->model->tupleID = $opdID;
$this->errorText = 'Lab report record saved successfully.';
break;
case 'delete':
$this->model->deleteLabreport();
$this->errorText = 'Lab report record deleted successfully.';
break;
}
return $this->model->tupleID;
}
}
?>