Server : Apache System : Linux profile 3.10.0-1160.88.1.el7.x86_64 #1 SMP Tue Mar 7 15:41:52 UTC 2023 x86_64 User : apache ( 48) PHP Version : 8.0.28 Disable Function : NONE Directory : /var/www/html/mmishra/erp-10-07-2018/controllers/ |
<?php
//if (!class_exists($erpController)) {
require_once __DIR__."/erp_controller.php";
//}
class erpaController extends erpController {
var $model;
public function __construct($erpaModel) {
// call parent constructor
// parent::__construct();
// initialize variables
$this->model = $erpaModel;
$this->model->tupleID = $this->tuple;
$this->appURL = $_SERVER["REQUEST_URI"]; // this is Request URI for log entry
$this->referer = $_SERVER["HTTP_REFERER"]; // requires for log entry, not mandatory
$this->userIP = $this->getIP(); // requires in log entry
$this->filterText = $_POST['filterText'];
if (isset($_SESSION["sessionID"])) {
$this->loginID = $_SESSION["loginID"]; // current user id
$this->sessionID = $_SESSION["sessionID"]; // current session id
$this->moduleID = $_SESSION["moduleID"]; // current module id
} else {
$this->loginID = ''; // initialize login id
$this->sessionID = ''; // initialize session id
$this->moduleID = 1; // default module id
}
// 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);
}
}
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 manageInstitute($action, $instituteID) {
$this->model->tableID = 'erp_institutes';
$this->model->tupleID = $instituteID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save record
$this->model->saveInstitute($_POST['instituteCode'],$_POST['instituteName'],$_POST['nameHindi'],$_POST['address'],$_POST['phoneNo'],$_POST['email'],$_POST['website'],$_POST['departments'],$_POST['programs'],$_POST['instituteHead'],$_POST['logoImage'],$_POST['brandTagline'],$_POST['idSignatory'],$_POST['idAddressee'],$_POST['signImage']);
//$this->model->sqlLog();
$this->errorText = 'Institute record saved successfully.';
break;
case 'upper':
// enable record
$this->model->upperInstitute();
$this->errorText = 'Institute record moved up/left successfully.';
break;
case 'lower':
// disable record
$this->model->lowerInstitute();
$this->errorText = 'Institute record moved down/right successfully.';
break;
case 'enable':
// enable record
$this->model->enableInstitute();
$this->model->sqlLog();
$this->errorText = 'Institute record enabled successfully.';
break;
case 'disable':
// disable record
$this->model->disableInstitute();
$this->model->sqlLog();
$this->errorText = 'Institute record disabled successfully.';
break;
case 'delete':
// delete record
$this->model->deleteInstitute();
$this->model->sqlLog();
$this->errorText = 'Institute record deleted successfully.';
break;
}
return $this->model->tupleID;
}
public function manageModule($action, $moduleID) {
$this->model->tableID = 'erp_modules';
$this->model->tupleID = $moduleID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save record
$this->model->saveModule($_POST['moduleName'],$_POST['description'],$_POST['moduleIcon'],$_POST['iconColor'],$_POST['moduleDept'],$_POST['moduleAdmin'],$_POST['adminEmail']);
$this->model->sqlLog();
$this->errorText = 'Module record saved successfully.';
break;
case 'upper':
// move up/left side
$this->model->upperModule();
$this->errorText = 'Module record moved up/left successfully.';
break;
case 'lower':
// move down/right side
$this->model->lowerModule();
$this->errorText = 'Module record moved down/right successfully.';
break;
case 'enable':
// enable record
$this->model->enableModule();
$this->errorText = 'Module and related records enabled successfully.';
break;
case 'disable':
// disable record
$this->model->disableModule();
$this->errorText = 'Module and related records disabled successfully.';
break;
case 'delete':
// delete record
$this->model->deleteModule();
$this->model->sqlLog();
$this->errorText = 'Module record deleted successfully.';
break;
case 'mail':
// mail record data
echo $this->erpMailer('mmishra@iiita.ac.in', 'Module test mail', 'This is a test mail');
break;
}
return $this->model->tupleID;
}
public function manageApp($action, $appID) {
$this->model->tableID = 'erp_apps';
$this->model->tupleID = $appID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
//save record
$this->model->saveApp($_POST['moduleID'],$_POST['appName'],$_POST['description'],$_POST['appCode'],$_POST['appURL'],$_POST['appIcon'],$_POST['iconColor'],$_POST['appDept'],$_POST['appAdmin'],$_POST['adminEmail'],$_POST['universal']);
$this->model->sqlLog();
$this->errorText = 'App record saved successfully.';
break;
case 'upper':
// move up/left side
$this->model->upperApp();
$this->errorText = 'App record moved up/left successfully.';
break;
case 'lower':
// move down/right side
$this->model->lowerApp();
$this->errorText = 'App record moved down/right successfully.';
break;
case 'enable':
// enable record
$this->model->enableApp();
$this->errorText = 'App and related records enabled successfully.';
break;
case 'disable':
// disable record
$this->model->disableApp();
$this->errorText = 'App and related records disabled successfully.';
break;
case 'delete':
//delete record
$this->model->deleteApp();
$this->model->sqlLog();
$this->errorText = 'App record deleted successfully.';
break;
case 'mail':
// mail record data
echo $this->erpMailer('mmishra@iiita.ac.in', 'App test mail', 'This is a test mail');
break;
}
return $this->model->tupleID;
}
public function manageMenu($action, $menuID) {
$this->model->tableID = 'erp_menus';
$this->model->tupleID = $menuID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
//save record
$this->model->saveMenu($_POST['appID'],$_POST['interface'],$_POST['menuName'],$_POST['description'],$_POST['menuURL'],$_POST['menuIcon'],$_POST['protection'],$_POST['menuHelp']);
$this->model->sqlLog();
$this->errorText = 'Menu record saved successfully.';
break;
case 'upper':
// move up/left side
$this->model->upperMenu();
$this->errorText = 'Menu record moved up/left successfully.';
break;
case 'lower':
// move down/right side
$this->model->lowerMenu();
$this->errorText = 'Menu record moved down/right successfully.';
break;
case 'enable':
// enable record
$this->model->enableMenu();
$this->errorText = 'Menu and related records enabled successfully.';
break;
case 'disable':
// disable record
$this->model->disableMenu();
$this->errorText = 'Menu and related records disabled successfully.';
break;
case 'delete':
//delete record
$this->model->deleteMenu();
$this->model->sqlLog();
$this->errorText = 'Menu record deleted successfully.';
break;
case 'mail':
// mail record data
echo $this->erpMailer('mmishra@iiita.ac.in', 'Menu test mail', 'This is a test mail');
break;
}
return $this->model->tupleID;
}
public function manageGroup($action, $groupID) {
$this->model->tableID = 'erp_groups';
$this->model->tupleID = $groupID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
//save record
$i = 0;
foreach ($_POST['groupID'] as $groupID) {
$this->model->tupleID = $groupID;
$groupName = $_POST["groupName$i"];
$description = $_POST["description$i"];
if ($groupName) {
$this->model->saveGroup($groupName,$description);
} else {
$this->model->deleteGroup();
}
$this->model->sqlLog();
$i++;
}
$this->errorText = 'Group record saved successfully.';
break;
case 'upper':
// move up/left side
$this->model->upperGroup();
$this->errorText = 'Group record moved up/left successfully.';
break;
case 'lower':
// move down/right side
$this->model->lowerGroup();
$this->errorText = 'Group record moved down/right successfully.';
break;
case 'enable':
// enable record
$this->model->enableGroup();
$this->errorText = 'Group and related records enabled successfully.';
break;
case 'disable':
// disable record
$this->model->disableGroup();
$this->errorText = 'Group and related records disabled successfully.';
break;
case 'delete':
//delete record
$this->model->deleteGroup();
$this->model->sqlLog();
$this->errorText = 'Group record deleted successfully.';
break;
}
return $this->model->tupleID;
}
public function manageUser($action, $groupID) {
$this->model->tableID = 'erp_users';
$this->model->tupleID = $groupID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
//save record
$i = 0;
foreach ($_POST['userID'] as $userID) {
$this->model->tupleID = $userID;
$loginID = $_POST["loginID"][$i];
$userName = $_POST["userName"][$i];
$authMode = $_POST["authMode"][$i];
$secretCode = $_POST["secretCode"][$i];
//foreach ($_POST as $key => $value) {
// echo $key. '-' .$value.'<br>';
//}
if ($loginID) {
//echo "$userID, $loginID,$userName,$groupID,$authMode,$secretCode<br>";
$this->model->saveUser($loginID,$userName,$groupID,$authMode,$secretCode);
$this->model->sqlLog();
} else if ($userID) {
$this->model->deleteUser();
$this->model->sqlLog();
}
$i++;
}
$this->errorText = 'User record saved successfully.';
$this->model->tupleID = $groupID;
break;
case 'enable':
// enable record
foreach ($_POST['userIDs'] as $userID) {
$this->model->tupleID = $userID;
$this->model->enableUser();
}
$this->errorText = 'User and related records enabled successfully.';
break;
case 'disable':
// disable record
foreach ($_POST['userIDs'] as $userID) {
$this->model->tupleID = $userID;
$this->model->disableUser();
}
$this->errorText = 'User and related records disabled successfully.';
break;
case 'delete':
//delete record
foreach ($_POST['userIDs'] as $userID) {
$this->model->tupleID = $userID;
$this->model->deleteUser();
$this->model->sqlLog();
}
$this->errorText = 'User record deleted successfully.';
break;
}
return $this->model->tupleID;
}
public function manageUacl($action, $userID) {
$this->model->tableID = 'erp_uacls';
$this->model->tupleID = $userID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
case 'search':
break;
case 'save':
//save record
foreach ($_POST['aclID'] as $aclID) {
$i++;
$this->model->tupleID = $aclID;
$menuID = $_POST["menuID$i"];
$aclRead = $_POST["aclRead$i"] ? 1 : 0;
$aclInsert = $_POST["aclInsert$i"] ? 1 : 0;
$aclUpdate = $_POST["aclUpdate$i"] ? 1 : 0;
$aclDelete = $_POST["aclDelete$i"] ? 1 : 0;
if ($menuID) {
//echo "$userID,$menuID,$aclRead,$aclInsert,$aclUpdate,$aclDelete --";
$this->model->saveUacl($userID,$menuID,$aclRead,$aclInsert,$aclUpdate,$aclDelete);
$this->model->sqlLog();
}
}
$this->errorText = 'User ACL record saved successfully.';
$this->model->tupleID = $userID; // because it was set to aclID for sql log entry
break;
case 'enable':
// enable record
$this->model->enableUacl();
$this->errorText = 'User ACL record enabled successfully.';
break;
case 'disable':
// disable record
$this->model->disableUacl();
$this->errorText = 'User ACL record diabled successfully.';
break;
case 'delete':
//delete record
$this->model->deleteUacl();
$this->model->sqlLog();
$this->errorText = 'User ACL record deleted successfully.';
break;
case 'filter':
//filter record
if ($this->filterText) $this->errorText = "ACL record filtered on " . strtoupper($this->filterText);
break;
case 'mail':
// mail record data
echo $this->erpMailer('mmishra@iiita.ac.in', 'User ACL test mail', 'This is a test mail');
break;
}
return $this->model->tupleID;
}
}
?>