| Current Path : /var/www/html/mmishra/erp/controllers/ |
| Current File : /var/www/html/mmishra/erp/controllers/hms_controller.php |
<?php
//if (!class_exists($erpController)) {
require_once __DIR__."/erp_controller.php";
//}
class hmsController extends erpController {
var $model;
public function __construct($model) {
// call parent constructor
// parent::__construct();
// initialize variables
$this->model = $model;
$this->model->tupleID = $this->tuple;
$this->userIP = $this->getIP(); // requires in log entry
$this->appURL = $_SERVER["REQUEST_URI"]; // this is Request URI for log entry
$this->referer = $_SERVER["HTTP_REFERER"]; // requires for log entry, not mandatory
// maintain erp activity log for inner contents
if ($_SESSION["loginID"] && strpos($this->appURL, 'inner')) {
$this->model->erpLog($this->userIP, $this->appURL, $this->referer);
} else if ($this->model->getMenuProtection($this->menu)) {
print("<h1>Session expired. Please sign-in again.</h1>");
exit;
}
}
public function __destruct() {
//'Destroying: ', $this->moduleID, PHP_EOL;
// log sql operation on corresponding table
// call $erpModel->erpSql($sql);
// print("Thanks.");
}
public function manageHostel($action, $hostelID) {
$this->model->tableID = 'hms_hostels';
$this->model->tupleID = $hostelID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'refresh':
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save record
$hostelCode = $_POST['hostelCode'];
$hostelName = $_POST['hostelName'];
$hostelType = $_POST['hostelType'];
$totalFloors = $_POST['totalFloors'];
$totalCapacity = $_POST['totalCapacity'];
$singleBedded = $_POST['singleBedded'];
$doubleBedded = $_POST['doubleBedded'];
$tripleBedded = $_POST['tripleBedded'];
$apartment = $_POST['apartment'];
$suite = $_POST['suite'];
$receptionNo = $_POST['receptionNo'];
$this->model->saveHostel($hostelCode,$hostelName,$hostelType,$totalFloors,$totalCapacity,$singleBedded,$doubleBedded,$tripleBedded,$apartment,$suite,$receptionNo);
$this->model->sqlLog();
$this->errorText = 'Hostel record saved successfully.';
break;
case 'enable':
// enable record
$this->model->enableHostel();
$this->model->sqlLog();
$this->errorText = 'Hostel record enabled successfully.';
break;
case 'disable':
// disable record
$this->model->disableHostel();
$this->model->sqlLog();
$this->errorText = 'Hostel record disabled successfully.';
break;
case 'delete':
// delete record
$this->model->deleteHostel();
$this->model->sqlLog();
$this->errorText = 'Hostel record deleted successfully.';
break;
case 'mail':
$hostel = $this->model->gethostel($hostelID); // fetch hostel record
$subject = $this->reminders[$hostel['subjectID']]; // get subject text
$message = $hostel['message'];
$emailsTo = $hostel['emailsTo'];
$emailsCC = $hostel['emailsCC'];
$emailsBCC = $hostel['emailsBCC'];
$targetGroups = $hostel['targetGroups'];
$attachments = $hostel['attachments'];
$schedule = $hostel['schedule'];
break;
}
return $this->model->tupleID;
}
public function manageRoom($action, $roomID) {
$this->model->tableID = 'hms_rooms';
$this->model->tupleID = $roomID;
$hostelID = $this->params[0];
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'refresh':
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save record
$floorNo = $_POST["floorNo"];
foreach ($this->roomTypes as $key => $value) {
$roomIDs = $_POST["roomID{$key}"];
$roomNo[$key] = $_POST["roomNo{$key}"];
$i = 0;
foreach ($roomNo[$key] as $roomNo) {
$roomID = $roomIDs[$i];
$this->model->tupleID = $roomID;
if ($roomNo) $this->model->saveRoom($hostelID,$floorNo,$roomNo,$key);
else $this->model->deleteRoom();
$i++;
}
}
$this->model->sqlLog();
$this->errorText = 'Room record saved successfully.';
break;
case 'enable':
// enable record
$this->model->enableRoom();
$this->model->sqlLog();
$this->errorText = 'Room record enabled successfully.';
break;
case 'disable':
// disable record
$this->model->disableRoom();
$this->model->sqlLog();
$this->errorText = 'Room record disabled successfully.';
break;
case 'delete':
// delete record
$this->model->deleteRoom();
$this->model->sqlLog();
$this->errorText = 'Room record deleted successfully.';
break;
}
return $this->model->tupleID;
}
public function manageWarden($action, $wardenID) {
$this->model->tableID = 'hms_wardens';
$this->model->tupleID = $wardenID;
$hostelID = $this->params[0];
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'refresh':
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save record
$wardenName = $_POST['wardenName'];
$wardenEmail = $_POST['wardenEmail'];
$wardenMobile = $_POST['wardenMobile'];
$this->model->saveWarden($hostelID,$wardenName,$wardenEmail,$wardenMobile);
$this->model->sqlLog();
$this->errorText = 'Warden record saved successfully.';
break;
case 'enable':
// enable record
$this->model->enableWarden();
$this->model->sqlLog();
$this->errorText = 'Warden record enabled successfully.';
break;
case 'disable':
// disable record
$this->model->disableWarden();
$this->model->sqlLog();
$this->errorText = 'Warden record disabled successfully.';
break;
case 'delete':
// delete record
$this->model->deleteWarden();
$this->model->sqlLog();
$this->errorText = 'Warden record deleted successfully.';
break;
}
return $this->model->tupleID;
}
public function manageAsstt($action, $assttID) {
$this->model->tableID = 'hms_assistants';
$this->model->tupleID = $assttID;
$hostelID = $this->params[0];
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'refresh':
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save record
$assttName = $_POST['assttName'];
$assttEmail = $_POST['assttEmail'];
$assttMobile = $_POST['assttMobile'];
$this->model->saveAsstt($hostelID,$assttName,$assttEmail,$assttMobile);
$this->model->sqlLog();
$this->errorText = 'Assistant record saved successfully.';
break;
case 'enable':
// enable record
$this->model->enableAsstt();
$this->model->sqlLog();
$this->errorText = 'Assistant record enabled successfully.';
break;
case 'disable':
// disable record
$this->model->disableAsstt();
$this->model->sqlLog();
$this->errorText = 'Assistant record disabled successfully.';
break;
case 'delete':
// delete record
$this->model->deleteAsstt();
$this->model->sqlLog();
$this->errorText = 'Assistant record deleted successfully.';
break;
}
return $this->model->tupleID;
}
public function manageAllocation($action, $programID) {
$this->model->tableID = 'hms_allocations';
$this->model->tupleID = $programID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'refresh':
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save record
$hostelIDs = $_POST['hostelID'];
$floorNos = $_POST['floorNo'];
$this->model->deleteAllocation();
foreach ($hostelIDs as $hostelID) {
foreach ($floorNos as $floorNo) {
$this->model->saveAllocation($hostelID,$floorNo,$programID);
}
}
$this->model->sqlLog();
$this->errorText = 'Allocation record saved successfully.';
break;
case 'delete':
// delete record
$this->model->deleteAllocation();
$this->model->sqlLog();
$this->errorText = 'Allocation record deleted successfully.';
break;
}
return $this->model->tupleID;
}
public function manageBooking($action, $allotmentID) {
$this->model->tableID = 'hms_allotments';
$this->model->tupleID = $allotmentID;
switch ($action) {
case 'open':
break;
case 'save':
$allotteeNo = $this->params[0];
$hostelID = $this->params[1];
$roomID = $this->params[2];
$acCooler = 'N'; // for freshers, it is assumed
$this->model->saveAllotment($hostelID,$allotteeNo,$roomID,$acCooler);
$this->model->sqlLog();
break;
case 'change':
$allotteeNo = $this->params[1];
$this->model->changeAllotment($allotteeNo);
$this->model->sqlLog();
break;
}
return $this->model->tupleID;
}
public function manageAllotment($action, $allotmentID) {
$this->model->tableID = 'hms_allotments';
$this->model->tupleID = $allotmentID;
$hostelID = $this->params[0];
$floorNo = $this->params[1];
$roomID = $this->params[2];
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'refresh':
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save record
$allotteeNo = $_POST["allotteeNo"];
$acCooler = $_POST["acCooler"];
if (!$acCooler) $acCooler = 'N';
if ($allotteeNo) $this->model->saveAllotment($hostelID,$allotteeNo,$roomID,$acCooler);
else $this->model->deleteAllotment();
$this->model->sqlLog();
$this->errorText = 'Allotment record saved successfully.';
break;
case 'delete':
// delete record
$this->model->deleteAllotment();
$this->model->sqlLog();
$this->errorText = 'Allotment record deleted successfully.';
break;
}
return $this->model->tupleID;
}
public function manageAsset($action, $assetID) {
$this->model->tableID = 'hms_assets';
$this->model->tupleID = $assetID;
$hostelID = $this->params[0];
$allotmentID = $this->params[1];
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'refresh':
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save record
$assetName = $_POST["assetName"];
$description = $_POST["description"];
$approxCost = $_POST["approxCost"];
$this->model->saveAsset($allotmentID,$assetName,$description,$approxCost);
$this->model->sqlLog();
$this->errorText = 'Asset record saved successfully.';
break;
case 'delete':
// delete record
$this->model->deleteAsset();
$this->model->sqlLog();
$this->errorText = 'Asset record deleted successfully.';
break;
}
return $this->model->tupleID;
}
public function manageGatepass($action, $passID) {
$this->model->tableID = 'hms_gatepasses';
$this->model->tupleID = $passID;
$hostelID = $this->params[0];
$allotmentID = $this->params[1];
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'refresh':
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save record
$assetIDs = $_POST["assetID"];
$description = $_POST["description"];
$this->model->saveGatepass($allotmentID,$description,$assetIDs);
$this->model->sqlLog();
$this->errorText = 'Gatepass record saved successfully.';
break;
case 'delete':
// delete record
$this->model->deleteGatepass();
$this->model->sqlLog();
$this->errorText = 'Gatepass record deleted successfully.';
break;
}
return $this->model->tupleID;
}
}
?>