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-22-05-2018/views/ |
<?php
//if (!class_exists($erpView)) {
require_once __DIR__."/erp_view.php";
//}
class erpaView extends erpView {
var $controller;
var $model;
public function __construct($erpaController, $erpaModel) {
$this->controller = $erpaController; // instantiate controller
$this->model = $erpaModel; // instantiate model
$this->controller->filterText = $_POST['filterText'];
}
public function __destruct() {
print(":|:" .$this->erpXupdate($this->controller->loginID, $this->controller->menu). ":|:" .$this->erpError(). ":|:" .$this->erpClock());
}
public function erpaModule($action, $moduleID) {
$app = $this->controller->app; // application envoked
$menu = $this->controller->menu; // menu envoked
$moduleID = $this->controller->manageModule($action, $moduleID); // initiate controller action
$ro = $this->controller->editLock; // ensure default edit lock
$filterText = $this->controller->filterText;
$data = $this->model->getModule($moduleID); // get record
$str = "<h3>" .$this->model->getMenuTitle($menu) .$this->erpToolbar(). "</h3>
<table width='100%'><tr><th width='70%'>Module Details (ID: $moduleID)</th><th width='30%'>ERP Modules</th></tr>
<tr valign='top'><td>
<table class='interface'>
<tr><td width='20%' nowrap>Module Name *</td><td><input type='text' id='moduleName' name='moduleName' size='50' value='" .$data['moduleName']. "' placeholder='Appears as top level ERP section' $ro></td></tr>
<tr><td nowrap>Description</td><td><input type='text' name='description' size='50' value='" .$data['description']. "' $ro></td></tr>
<tr><td nowrap>Module Icon</td><td><input type='text' name='moduleIcon' size='50' value='" .$data['moduleIcon']. "' placeholder='Appears before module name' $ro></td></tr>
<tr><td nowrap>Icon Color</td><td><input type='text' name='iconColor' size='50' value='" .$data['iconColor']. "' $ro></td></tr>
<tr><td nowrap>Module Dept.</td><td><input type='text' name='moduleDept' size='50' value='" .$data['moduleDept']. "' $ro></td></tr>
<tr><td nowrap>Module Admin</td><td><input type='text' name='moduleAdmin' size='50' value='" .$data['moduleAdmin']. "' $ro></td></tr>
<tr><td nowrap>Admin Email</td><td><input type='text' name='adminEmail' size='50' value='" .$data['adminEmail']. "' placeholder='Receives critical mails on data operations' $ro></td></tr>
</table>
</td><td><ol class='listbar'>";
$rows = $this->model->listModules($filterText);
foreach($rows as $row) {
$str .= "<li>";
if ($row['moduleID'] == $moduleID) {
$str .= "<b>" .$row['moduleName']. "</b> (" .$row['status']. ")";
} else {
$str .= "<a href='' onclick=\"inner('$app/$menu/open/" .$row['moduleID']."'); return false;\">" .$row['moduleName']. "</a> (" .$row['status']. ")";
}
$str .= "</li>";
}
$str .= "</ol></td></tr>
</table>";
return $str;
}
public function erpaApp($action, $appID) {
$app1 = $this->controller->app; // application envoked
$menu = $this->controller->menu; // menu envoked
$appID = $this->controller->manageApp($action, $appID); // initiate controller action
$ro = $this->controller->editLock; // ensure default edit lock
$filterText = $this->controller->filterText;
$data = $this->model->getApp($appID); // get app record
$str = "<h3>" .$this->model->getMenuTitle($menu) .$this->erpToolbar(). "</h3>
<table width='100%'><tr><th width='70%'>App Details (ID: $appID)</th><th width='30%'>ERP Apps</th></tr>
<tr valign='top'><td>
<table class='interface'>
<tr><td width='20%' nowrap>App Module *</td><td><select name='moduleID' style='width: 265px'>";
$modules = $this->model->selectModule(); // get module list
foreach ($modules as $module) {
$str .= "<option value='" .$module['moduleID']. "'" .($module['moduleID'] == $data['moduleID'] ? ' selected' : ''). ">" .$module['moduleName']. "</option>";
}
$str .= "</select></td></tr>
<tr><td nowrap>App Name *</td><td><input type='text' name='appName' size='50' value='" .$data['appName']. "' placeholder='Appears as top level menu item' $ro></td></tr>
<tr><td nowrap>Description</td><td><input type='text' name='description' size='50' value='" .$data['description']. "' $ro></td></tr>
<tr><td nowrap>App Code *</td><td><input type='text' name='appCode' size='50' value='" .$data['appCode']. "' placeholder='5 characters without space, used for controller access' $ro></td></tr>
<tr><td nowrap>App URL *</td><td><input type='text' name='appURL' size='50' value='" .$data['appURL']. "' placeholder='Defines controller name to call' $ro></td></tr>
<tr><td nowrap>App Icon</td><td><input type='text' name='appIcon' size='50' value='" .$data['appIcon']. "' placeholder='Awesome font e.g. far fa-building, appears before app name' $ro></td></tr>
<tr><td nowrap>Icon Color</td><td><input type='text' name='iconColor' size='50' value='" .$data['iconColor']. "' $ro></td></tr>
<tr><td nowrap>App Dept.</td><td><input type='text' name='appDept' size='50' value='" .$data['appDept']. "' $ro></td></tr>
<tr><td nowrap>App Admin</td><td><input type='text' name='appAdmin' size='50' value='" .$data['appAdmin']. "' $ro></td></tr>
<tr><td nowrap>Admin Email</td><td><input type='text' name='adminEmail' size='50' value='" .$data['adminEmail']. "' placeholder='Receives critical mails on data operations' $ro></td></tr>
<tr><td nowrap>Universal?</td><td><input type='radio' name='universal' value='1'" .($data['universal'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='universal' value='0'" .($data['universal'] == 0 ? ' checked' : ''). " $ro> No (Appears as menu item in all modules)</td></tr>
</table>
</td><td><ol class='listbar'>";
$rows = $this->model->listApps($filterText);
foreach($rows as $row) {
$str .= "<li>";
if ($row['appID'] == $appID) {
$str .= "<b>" .$row['moduleName'].'-'.$row['appName']. "</b> (" .$row['status']. ")";
} else {
$str .= "<a href='' onclick=\"inner('$app1/$menu/open/" .$row['appID']."'); return false;\">" .$row['moduleName'].'-'.$row['appName']. "</a> (" .$row['status']. ")";
}
$str .= "</li>";
}
$str .= "</ol></td></tr>
</table>";
return $str;
}
public function erpaMenu($action, $menuID) {
$app1 = $this->controller->app; // application envoked
$menu1 = $this->controller->menu; // menu envoked
$menuID = $this->controller->manageMenu($action, $menuID);
$ro = $this->controller->editLock; // ensure default edit lock
$filterText = $this->controller->filterText;
$data = $this->model->getMenu($menuID);
$str = "<h3>" .$this->model->getMenuTitle($menu1) .$this->erpToolbar(). "</h3>
<table width='100%'><tr><th width='70%'>Menu Details (ID: $menuID)</th><th width='30%'>ERP Menus</th></tr>
<tr valign='top'><td>
<table class='interface'>
<tr><td width='20%' nowrap>Menu App *</td><td><select name='appID' style='width: 265px'>";
$apps = $this->model->selectApp(); // list enabled apps only
foreach ($apps as $app) {
$str .= "<option value='" .$app['appID']. "'" .($app['appID'] == $data['appID'] ? ' selected' : ''). ">" .$app['moduleName'].'-'.$app['appName']. "</option>";
}
$str .= "</select></td></tr>
<tr><td nowrap>Interface To *</td><td>";
foreach ($this->controller->interfaces as $code => $desc) {
$str .= "<input type='radio' name='interface' value='" .$code. "'" .($data['interface'] == $code ? ' checked' : ''). " $ro> " .$desc. " ";
}
$str .= "</td></tr>
<tr><td nowrap>Menu Name *</td><td><input type='text' name='menuName' size='50' value='" .$data['menuName']. "' placeholder='Appears as drop down menu item' $ro></td></tr>
<tr><td nowrap>Description</td><td><input type='text' name='description' size='50' value='" .$data['description']. "' $ro></td></tr>
<tr><td nowrap>Menu URL *</td><td><input type='text' name='menuURL' size='50' value='" .$data['menuURL']. "' placeholder='Defines view method to call' $ro></td></tr>
<tr><td nowrap>Menu Icon</td><td><input type='text' name='menuIcon' size='50' value='" .$data['menuIcon']. "' placeholder='Appears before menu name' $ro></td></tr>
<tr><td nowrap>Access Control?</td><td><input type='radio' name='protection' value='1'" .($data['protection'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='protection' value='0'" .($data['protection'] == 0 ? ' checked' : ''). " $ro> No</td></tr>
<tr><td nowrap>Menu Help</td><td><textarea name='menuHelp' rows='5' cols='50' placeholder='Provide user help tips for this interface.' $ro>" .$data['menuHelp']. "</textarea></td></tr>
</table>
<h5>Users Acess Control List</h5>
<ol>";
// get user list granted access to this menu
$acls = $this->model->getMenuACLs($menuID);
if ($acls) {
foreach($acls as $acl) {
$str .= "<li>" .$acl['loginID']. " [ " .($acl['aclRead'] ? 'Read ' : '').($acl['aclInsert'] ? 'Insert ' : '').($acl['aclUpdate'] ? 'Update ' : '').($acl['aclDelete'] ? 'Delete ' : ''). " ]</li>";
}
}
$str .= "</ol></td><td>
<ol class='listbar'>";
$rows = $this->model->listMenus($filterText);
foreach($rows as $row) {
$str .= "<li>";
if ($row['menuID'] == $menuID) {
$str .= "<b>" .$row['appName'].'-'.$row['menuName']. "</b> (" .$row['status']. ")";
} else {
$str .= "<a href='' onclick=\"inner('$app1/$menu1/open/" .$row['menuID']."'); return false;\">" .$row['appName'].'-'.$row['menuName']. "</a> (" .$row['status']. ")";
}
$str .= "</li>";
}
$str .= "</ol></td></tr>
</table>";
return $str;
}
public function erpaGroup($action, $groupID) {
$app = $this->controller->app; // application envoked
$menu = $this->controller->menu; // menu envoked
$groupID = $this->controller->manageGroup($action, $groupID);
$ro = $this->controller->editLock; // ensure default edit lock
$filterText = $this->controller->filterText;
$data = $this->model->getGroup($groupID); // get record
$str = "<h3>" .$this->model->getMenuTitle($menu) .$this->erpToolbar(). "</h3>
<table width='100%'>
<tr><th width='70%'>Group Details (ID: $groupID)</th><th width='30%'>ERP Apps</th></tr>
<tr valign='top'><td>
<table class='interface'>
<tr><td width='20%' nowrap>Group Name *</td><td><input type='text' name='groupName' size='50' value='" .$data['groupName']. "' placeholder='Any name reflecting suitable role' $ro></td></tr>
<tr><td nowrap>Read Record?</td><td><input type='radio' name='aclRead' value='1'" .($data['aclRead'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='aclRead' value='0'" .($data['aclRead'] == 0 ? ' checked' : ''). " $ro> No</td></tr>
<tr><td nowrap>Insert Record?</td><td><input type='radio' name='aclInsert' value='1'" .($data['aclInsert'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='aclInsert' value='0'" .($data['aclInsert'] == 0 ? ' checked' : ''). " $ro> No</td></tr>
<tr><td nowrap>Update Record?</td><td><input type='radio' name='aclUpdate' value='1'" .($data['aclUpdate'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='aclUpdate' value='0'" .($data['aclUpdate'] == 0 ? ' checked' : ''). " $ro> No</td></tr>
<tr><td nowrap>Delete Record?</td><td><input type='radio' name='aclDelete' value='1'" .($data['aclDelete'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='aclDelete' value='0'" .($data['aclDelete'] == 0 ? ' checked' : ''). " $ro> No</td></tr>
</table>
</td><td><ol class='listbar'>";
$rows = $this->model->listGroups($filterText);
foreach($rows as $row) {
$str .= "<li>";
if ($row['groupID'] == $groupID) {
$str .= "<b>" .$row['groupName']. "</b> (" .$row['status']. ")";
} else {
$str .= "<a href='' onclick=\"inner('$app/$menu/open/" .$row['groupID']."'); return false;\">" .$row['groupName']. "</a> (" .$row['status']. ")";
}
$str .= "</li>";
}
$str .= "</ol></td></tr>
</table>";
return $str;
}
public function erpaGacl($action, $aclID) {
$app = $this->controller->app; // application envoked
$menu = $this->controller->menu; // menu envoked
$aclID = $this->controller->manageGacl($action, $aclID);
$ro = $this->controller->editLock; // ensure default edit lock
$filterText = $this->controller->filterText;
$data = $this->model->getGacl($aclID);
$str = "<h3>" .$this->model->getMenuTitle($menu) .$this->erpToolbar(). "</h3>
<table width='100%'><tr><th width='70%'>Group ACL Details (ID: $aclID)</th><th width='30%'>Group ACLs</th></tr>
<tr valign='top'><td>
<table class='interface'>
<tr><td width='20%' nowrap>User Group *</td><td><select name='groupID' style='width: 265px'>";
$groups = $this->model->selectGroup(); // list enabled groups only
foreach ($groups as $group) {
$str .= "<option value='" .$group['groupID']. "'" .($group['groupID'] == $data['groupID'] ? ' selected' : ''). ">" .$group['groupName']. "</option>";
}
$str .= "</select></td></tr>
<tr><td nowrap>Application *</td><td><select name='appID' style='width: 265px'>";
$apps = $this->model->selectApp(); // list enabled apps only
foreach ($apps as $app1) {
$str .= "<option value='" .$app1['appID']. "'" .($app1['appID'] == $data['appID'] ? ' selected' : ''). ">" .$app1['moduleName'].'-'.$app1['appName']. "</option>";
}
$str .= "</select></td></tr>
<tr><td nowrap>Read Record?</td><td><input type='radio' name='aclRead' value='1'" .($data['aclRead'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='aclRead' value='0'" .($data['aclRead'] == 0 ? ' checked' : ''). " $ro> No</td></tr>
<tr><td nowrap>Insert Record?</td><td><input type='radio' name='aclInsert' value='1'" .($data['aclInsert'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='aclInsert' value='0'" .($data['aclInsert'] == 0 ? ' checked' : ''). " $ro> No</td></tr>
<tr><td nowrap>Update Record?</td><td><input type='radio' name='aclUpdate' value='1'" .($data['aclUpdate'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='aclUpdate' value='0'" .($data['aclUpdate'] == 0 ? ' checked' : ''). " $ro> No</td></tr>
<tr><td nowrap>Delete Record?</td><td><input type='radio' name='aclDelete' value='1'" .($data['aclDelete'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='aclDelete' value='0'" .($data['aclDelete'] == 0 ? ' checked' : ''). " $ro> No</td></tr>
</table>
<h5>User Access Control List</h5>
<ol>";
// get app list granted to this group from erp model
$acls = $this->model->getGroupsACLs($groupID);
foreach($acls as $acl) {
$str .= "<li>" .$acl['appName']. " [ " .($acl['aclRead'] ? 'Read ' : '').($acl['aclInsert'] ? 'Insert ' : '').($acl['aclUpdate'] ? 'Update ' : '').($acl['aclDelete'] ? 'Delete ' : ''). "]</li>";
}
$str .= "</ol></td><td>
<ol class='listbar'>";
$rows = $this->model->listGacls($filterText);
foreach($rows as $row) {
$str .= "<li>";
if ($row['aclID'] == $aclID) {
$str .= "<b>" .$row['groupName'].'-'.$row['appName']. "</b> (" .$row['status']. ")";
} else {
$str .= "<a href='' onclick=\"inner('$app/$menu/open/" .$row['aclID']."'); return false;\">" .$row['groupName'].'-'.$row['appName']. "</a> (" .$row['status']. ")";
}
$str .= "</li>";
}
$str .= "</ol></td></tr>
</table>";
return $str;
}
public function erpaUser($action, $userID) {
$app = $this->controller->app; // application envoked
$menu = $this->controller->menu; // menu envoked
$userID = $this->controller->manageUser($action, $userID);
$ro = $this->controller->editLock; // ensure default edit lock
$filterText = $this->controller->filterText;
$data = $this->model->getUser($userID);
$str = "<h3>" .$this->model->getMenuTitle($menu) .$this->erpToolbar(). "</h3>
<table width='100%'><tr><th width='70%'>User Details (ID: $userID)</th><th width='30%'>ERP Users</th></tr>
<tr valign='top'><td>
<table class='interface'>
<tr><td width='20%' nowrap>Group</td><td><select name='groupID' style='width: 265px'>";
$groups = $this->model->selectGroup(); // list enabled groups only
foreach ($groups as $group) {
$str .= "<option value='" .$group['groupID']. "'" .($group['groupID'] == $data['groupID'] ? ' selected' : ''). ">" .$group['groupName']. "</option>";
}
$str .= "</select></td></tr>
<tr><td nowrap>Login ID</td><td><input type='text' name='loginID' size='50' value='" .$data['loginID']. "' placeholder='As defined in the LDAP database' $ro></td></tr>
<tr><td nowrap>Authentication</td><td><select name='authMode' style='width: 265px'>";
foreach ($this->controller->authModes as $code => $desc) {
$str .= "<option value='" .$code. "'" .($code == $data['authMode'] ? ' selected' : ''). ">" .$desc. "</option>";
}
$str .= "</select></td></tr>
<tr><td nowrap>Insert Record?</td><td><input type='radio' name='aclInsert' value='1'" .($data['aclInsert'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='aclInsert' value='0'" .($data['aclInsert'] == 0 ? ' checked' : ''). " $ro> No</td></tr>
<tr><td nowrap>Update Record?</td><td><input type='radio' name='aclUpdate' value='1'" .($data['aclUpdate'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='aclUpdate' value='0'" .($data['aclUpdate'] == 0 ? ' checked' : ''). " $ro> No</td></tr>
<tr><td nowrap>Delete Record?</td><td><input type='radio' name='aclDelete' value='1'" .($data['aclDelete'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='aclDelete' value='0'" .($data['aclDelete'] == 0 ? ' checked' : ''). " $ro> No</td></tr>
</table>
<h5>User Access Control List</h5>
<ol>";
// get menu list granted to this user from erp model
$acls = $this->model->getUsersACLs($userID);
foreach($acls as $acl) {
$str .= "<li>" .$acl['menuName']. " [ " .($acl['aclRead'] ? 'Read ' : '').($acl['aclInsert'] ? 'Insert ' : '').($acl['aclUpdate'] ? 'Update ' : '').($acl['aclDelete'] ? 'Delete ' : ''). "]</li>";
}
$str .= "</ol>
</td><td>
<ol class='listbar'>";
$rows = $this->model->listUsers($filterText);
foreach($rows as $row) {
$str .= "<li>";
if ($row['userID'] == $userID) {
$str .= "<b>" .$row['groupName'].'-'.$row['loginID']. "</b> (" .$row['status']. ")";
} else {
$str .= "<a href='' onclick=\"inner('$app/$menu/open/" .$row['userID']."'); return false;\">" .$row['groupName'].'-'.$row['loginID']. "</a> (" .$row['status']. ")";
}
$str .= "</li>";
}
$str .= "</ol></td></tr>
</table>";
return $str;
}
public function erpaUacl($action, $aclID) {
$app = $this->controller->app; // application envoked
$menu = $this->controller->menu; // menu envoked
$aclID = $this->controller->manageUacl($action, $aclID);
$ro = $this->controller->editLock; // ensure default edit lock
$filterText = $this->controller->filterText;
$data = $this->model->getUacl($aclID);
$str = "<h3>" .$this->model->getMenuTitle($menu) .$this->erpToolbar(). "</h3>
<table width='100%'><tr><th width='70%'>ACL Details (ID: $aclID)</th><th width='30%'>User ACLs</th></tr>
<tr valign='top'><td>
<table class='interface'>
<tr><td width='20%' nowrap>User ID *</td><td><select name='userID' style='width: 265px'>";
$users = $this->model->selectUser(); // list enabled users only
foreach ($users as $user) {
$str .= "<option value='" .$user['userID']. "'" .($user['userID'] == $data['userID'] ? ' selected' : ''). ">" .$user['loginID']. "</option>";
}
$str .= "</select></td></tr>
<tr><td nowrap>Menu Name *</td><td><select name='menuID' style='width: 265px'>";
$menus = $this->model->selectMenu(); // list enabled menus only
foreach ($menus as $menu1) {
$str .= "<option value='" .$menu1['menuID']. "'" .($menu1['menuID'] == $data['menuID'] ? ' selected' : ''). ">" .$menu1['appName'].'-'.$menu1['menuName']. "</option>";
}
$str .= "</select></td></tr>
<tr><td nowrap>Read Record?</td><td><input type='radio' name='aclRead' value='1'" .($data['aclRead'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='aclRead' value='0'" .($data['aclRead'] == 0 ? ' checked' : ''). " $ro> No</td></tr>
<tr><td nowrap>Insert Record?</td><td><input type='radio' name='aclInsert' value='1'" .($data['aclInsert'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='aclInsert' value='0'" .($data['aclInsert'] == 0 ? ' checked' : ''). " $ro> No</td></tr>
<tr><td nowrap>Update Record?</td><td><input type='radio' name='aclUpdate' value='1'" .($data['aclUpdate'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='aclUpdate' value='0'" .($data['aclUpdate'] == 0 ? ' checked' : ''). " $ro> No</td></tr>
<tr><td nowrap>Delete Record?</td><td><input type='radio' name='aclDelete' value='1'" .($data['aclDelete'] == 1 ? ' checked' : ''). " $ro> Yes
<input type='radio' name='aclDelete' value='0'" .($data['aclDelete'] == 0 ? ' checked' : ''). " $ro> No</td></tr>
</table>
</td><td>
<ol class='listbar'>";
$rows = $this->model->listUacls($filterText);
foreach($rows as $row) {
$str .= "<li>";
if ($row['aclID'] == $aclID) {
$str .= "<b>" .$row['loginID'].'-'.$row['menuName']. "</b> (" .$row['status']. ")";
} else {
$str .= "<a href='' onclick=\"inner('$app/$menu/open/" .$row['aclID']."'); return false;\">" .$row['loginID'].'-'.$row['menuName']. "</a> (" .$row['status']. ")";
}
$str .= "</li>";
}
$str .= "</ol></td></tr>
</table>";
return $str;
}
//*********************************************** reports on session, log and sql commands
public function erpaSession($action, $dated='') {
if ($this->controller->loginID) return $this->erpSession($action, $dated);
else return "You need to sign in to get the session information.";
}
public function erpaLog($action, $dated='') {
if ($this->controller->loginID) return $this->erpLog($action, $dated);
else return "You need to sign in to get the log information.";
}
public function erpaSql($action, $dated='') {
if ($this->controller->loginID) return $this->erpSql($action, $dated);
else return "You need to sign in to get the sql information.";
}
}
?>