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-7-6-18/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 erpaInstitute($action, $instituteID) {
$app = $this->controller->app;
$menu = $this->controller->menu;
$instituteID = $this->controller->manageInstitute($action, $instituteID);// initiate controller action
// controller locks/unlocks field through manage call
$ro = $this->controller->editLock; // ensure default edit lock
$filterText = $this->controller->filterText;
$data = $this->model->getInstitute($instituteID); // get record
$str = "<h3>" .$this->model->getMenuTitle($menu) .$this->erpToolbar(). "</h3>
<table width='100%'>
<tr><th width='70%'>Institute Details (ID: $instituteID)</th><th width='30%'>Institute List</th></tr>
<tr valign='top'><td>
<table class='interface'>
<tr><td nowrap>Institute Code</td><td><input type='text' name='instituteCode' size='50' value='" .$data['instituteCode']. "' placeholder='Institute abbreviation code' $ro></td></tr>
<tr><td nowrap>Institute Name</td><td><input type='text' name='instituteName' size='50' value='" .$data['instituteName']. "' placeholder='Name of the institute' $ro></td></tr>
<tr><td nowrap>Name in Hindi</td><td><input type='text' name='nameHindi' size='50' value='" .$data['nameHindi']. "' placeholder='Hindi name image file name' $ro></td></tr>
<tr><td nowrap>Address</td><td><input type='text' name='address' size='50' value='" .$data['address']. "' placeholder='Postal address of the institute' $ro></td></tr>
<tr><td nowrap>Phone No</td><td><input type='text' name='phoneNo' size='50' value='" .$data['phoneNo']. "' placeholder='Reception contact number' $ro></td></tr>
<tr><td nowrap>Email</td><td><input type='text' name='email' size='50' value='" .$data['email']. "' placeholder='Reception email address' $ro></td></tr>
<tr><td nowrap>Website</td><td><input type='text' name='website' size='50' value='" .$data['website']. "' placeholder='Address of website' $ro></td></tr>
<tr><td nowrap>Departments</td><td><input type='text' name='departments' size='50' value='" .$data['departments']. "' placeholder='No. of departments' $ro></td></tr>
<tr><td nowrap>Programs</td><td><input type='text' name='programs' size='50' value='" .$data['programs']. "' placeholder='No. of programs offered' $ro></td></tr>
<tr><td nowrap>Institute Head</td><td><input type='text' name='instituteHead' size='50' value='" .$data['instituteHead']. "' placeholder='Name of head' $ro></td></tr>
<tr><td nowrap>Logo Image</td><td><input type='text' name='logoImage' size='50' value='" .$data['logoImage']. "' placeholder='Logo image file name' $ro></td></tr>
<tr><td nowrap>Brand Tag Line</td><td><input type='text' name='brandTagline' size='50' value='" .$data['brandTagline']. "' placeholder='Brand tag line' $ro></td></tr>
<tr><td nowrap>ID Card Signatory</td><td><input type='text' name='idSignatory' size='50' value='" .$data['idSignatory']. "' placeholder='Official position name' $ro></td></tr>
<tr><td nowrap>ID Card Addressee</td><td><textarea name='idAddressee' rows='5' cols='50' placeholder='IF FOUND KINDLY RETURN TO' $ro>" .$data['idAddressee']. "</textarea></td></tr>
<tr><td nowrap>Sign Image</td><td><input type='text' name='signImage' size='50' value='" .$data['signImage']. "' placeholder='Signature image file name' $ro></td></tr>
</table>
</td><td>
<ol class='listbar'>";
$rows = $this->model->listInstitutes($filterText);
foreach($rows as $row) {
$str .= "<li>";
if ($row['instituteID'] == $instituteID) {
$str .= "<b>" .$row['instituteCode']. '-' .$row['website']. "</b> (" .$row['status']. ")";
} else {
$str .= "<a href='' onclick=\"inner('$app/$menu/open/".$row['instituteID']."'); return false;\">" .$row['instituteCode']. '-' .$row['website']. "</a> (" .$row['status']. ")";
}
$str .= "</li>";
}
$str .= "</ol></td></tr>
</table>";
return $str;
}
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>Owner Departments</td><td><input type='text' name='moduleDept' size='50' value='" .$data['moduleDept']. "' $ro></td></tr>
<tr><td nowrap>Admin Name</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>Module Name</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 ID</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>Owner Departments</td><td><input type='text' name='appDept' size='50' value='" .$data['appDept']. "' $ro></td></tr>
<tr><td nowrap>Admin Name</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>Universally Accessible?</td><td><input type='radio' name='universal' value='0'" .($data['universal'] == 0 ? ' checked' : ''). " $ro> No
<input type='radio' name='universal' value='1'" .($data['universal'] == 1 ? ' checked' : ''). " $ro> Yes (Appears across the modules)</td></tr>
</table>
</td><td><ol class='listbar'>";
$rows = $this->model->listApps($filterText);
foreach($rows as $row) {
if ($moduleName != $row['moduleName']) {
$str .= ($moduleName ? "</ol></li>" : '') . "<li><b>" .$row['moduleName']. "</b><ol>";
}
$str .= "<li>";
if ($row['appID'] == $appID) {
$str .= "<b>" .$row['appName']. "</b> (" .$row['status']. ")";
} else {
$str .= "<a href='' onclick=\"inner('$app1/$menu/open/" .$row['appID']."'); return false;\">" .$row['appName']. "</a> (" .$row['status']. ")";
}
$str .= "</li>";
$moduleName = $row['moduleName'];
}
$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>App Name</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['appName']. ' (under ' .$app['moduleName']. " module)</option>";
}
$str .= "</select></td></tr>
<tr><td nowrap>Interface Type</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='0'" .($data['protection'] == 0 ? ' checked' : ''). " $ro> No
<input type='radio' name='protection' value='1'" .($data['protection'] == 1 ? ' checked' : ''). " $ro> Yes (Login required)
<input type='radio' name='protection' value='2'" .($data['protection'] == 2 ? ' checked' : ''). " $ro> Hidden (Not menu)</td></tr>
<tr valign='top'><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) {
if ($appName != $row['appName']) {
$str .= ($appName ? "</ol></li>" : '') . "<li><b>" .$row['appName']. "</b><ol>";
}
$str .= "<li>";
if ($row['menuID'] == $menuID) {
$str .= "<b>" .$row['menuName']. "</b> (" .$row['status']. ")";
} else {
$str .= "<a href='' onclick=\"inner('$app1/$menu1/open/" .$row['menuID']."'); return false;\">" .$row['menuName']. "</a> (" .$row['status']. ")";
}
$str .= "</li>";
$appName = $row['appName'];
}
$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;
$rows = $this->model->listGroups($filterText);
$i = 0;
$str = "<h3>" .$this->model->getMenuTitle($menu) .$this->erpToolbar(). "</h3>
<table width='100%' class='interface'>
<tr><th>#</th><th>Group Name</th><th>Description</th><th>Members</th><th>Status</th></tr>";
foreach($rows as $row) {
$bgcolor = ($i % 2) ? '#f4f6f6' : '';
$groupID = $row['groupID'];
$str .= "<tr bgcolor='$bgcolor'><td>$i <input type='hidden' name='groupID[]' value='$groupID'></td>
<td nowrap><i class='fas fa-users'></i><input type='text' name='groupName$i' size='20' value='" .$row['groupName']. "' $ro></td>
<td><input type='text' name='description$i' size='50' value='" .$row['description']. "' placeholder='Define role of the group' $ro></td>
<td>" .$row['memberCount']. '</td><td>' .$row['status']. "</td></tr>";
$i++;
}
$str .= "<tr><td>New <input type='hidden' name='groupID[]' value='0'></td>
<td nowrap><i class='fas fa-users'></i><input type='text' name='groupName$i' size='20' value='' placeholder='Group name max. 10 characters'></td>
<td><input type='text' name='description$i' size='50' value='' placeholder='Define role of this user group'></td>
<td></td></tr>
</table>";
return $str;
}
public function erpaUser($action, $groupID) {
$app = $this->controller->app; // application envoked
$menu = $this->controller->menu; // menu envoked
$groupID = $this->controller->manageUser($action, $groupID);
$ro = $this->controller->editLock; // ensure default edit lock
$str = "<h3>" .$this->model->getMenuTitle($menu) .$this->erpToolbar(). "</h3>
<div align='center'>
Select Group <i class='fas fa-users'></i><select name='groupID' style='width: 150px' onchange=\"inner('$app/$menu/open/'+this.value); return false;\">
<option value='0'></option>";
$groups = $this->model->selectGroup(); // list enabled users only
foreach ($groups as $group) {
$str .= "<option value='" .$group['groupID']. "'" .($group['groupID'] == $groupID ? ' selected' : ''). ">" .$group['groupName']. "</option>";
}
$str .= "</select> to create/manage user account</div>";
if ($groupID) {
$str .= "
<table width='100%' class='interface'>
<tr><th>#</th><th>Login ID</th><th>User Name</th><th>Auth Mode</th><th>Password</th><th>Status</th></tr>";
$rows = $this->model->listUsers($groupID);
foreach($rows as $row) {
$i++;
$bgcolor = ($i % 2) ? '' : '#f4f6f6';
$str .= "<tr bgcolor='$bgcolor'><td>$i <input type='hidden' name='userID[]' value='" .$row['userID']. "'></td>
<td><i class='fas fa-user'></i><input type='text' name='loginID[]' size='30' value='" .$row['loginID']. "' placeholder='0 characters user id' $ro></td>
<td><input type='text' name='userName[]' size='50' value='" .$row['userName']. "' placeholder='Name of the account holder' $ro></td>
<td><select name='authMode[]' style='width: 100px'>";
foreach ($this->controller->authModes as $code => $desc) {
$str .= "<option value='$code'" .($row['authMode'] == $code ? ' selected' : ''). ">" .$desc. "</option>";
}
$str .= "</select></td>
<td><input type='password' name='secretCode[]' size='20' value='" .$row['secretCode']. "' placeholder='10 characters password' $ro></td>
<td>" .$row['status']. "</td></tr>";
}
$str .= "<tr><td>New<input type='hidden' name='userID[]' value='0'></td>
<td><i class='fas fa-user'></i><input type='text' name='loginID[]' size='30' value='' placeholder='10 characters user id'></td>
<td><input type='text' name='userName[]' size='50' value='' placeholder='Name of the account holder'></td>
<td><select name='authMode[]' style='width: 100px'>";
foreach ($this->controller->authModes as $code => $desc) {
$str .= "<option value='$code'>" .$desc. "</option>";
}
$str .= "</select></td>
<td><input type='password' name='secretCode[]' size='20' value='' placeholder='10 characters password'></td>
<td></td></tr>
</table>";
}
return $str;
}
public function erpaUacl($action, $userID) {
$app = $this->controller->app; // application envoked
$menu = $this->controller->menu; // menu envoked
$userID = $this->controller->manageUacl($action, $userID);
$ro = $this->controller->editLock; // ensure default edit lock
$filterText = $this->controller->filterText;
if ($action == 'filterg') {
$groupID = $userID;
$userID = 0;
} else {
$groupID = $_POST['groupID'];
}
$str = "<h3>" .$this->model->getMenuTitle($menu) .$this->erpToolbar(). "</h3>
<div align='center'>
Select Group <i class='fas fa-users'></i><select name='groupID' style='width: 150px' onchange=\"inner('$app/$menu/filterg/'+this.value); return false;\">
<option value='0'></option>";
$groups = $this->model->selectGroup(); // list enabled users only
foreach ($groups as $group) {
$str .= "<option value='" .$group['groupID']. "'" .($group['groupID'] == $groupID ? ' selected' : ''). ">" .$group['groupName']. "</option>";
}
$str .= "</select>
User <i class='fas fa-user'></i><select name='userID' style='width: 150px' onchange=\"inner('$app/$menu/open/'+this.value); return false;\">
<option value='0'></option>";
$users = $this->model->selectUser($groupID); // list enabled users only
foreach ($users as $user) {
$str .= "<option value='" .$user['userID']. "'" .($user['userID'] == $userID ? ' selected' : ''). ">" .$user['loginID']. "</option>";
}
$str .= "</select> to define/manage menu layer Access Control List (ACL)
</div>";
if ($userID) {
$str .= "<table width='100%' class='interface'>
<tr><th>#</th><th>App Name</th><th>Menu Name</th><th>Interface</th><th><input type='checkbox' onClick=\"toggle(this, 'aclRead')\"> Read Privilege</th><th><input type='checkbox' onClick=\"toggle(this, 'aclInsert')\"> Insert Privilege</th><th><input type='checkbox' onClick=\"toggle(this, 'aclUpdate')\"> Update Privilege</th><th><input type='checkbox' onClick=\"toggle(this, 'aclDelete')\"> Delete Privilege</th><th>Status</th></tr>";
$rows = $this->model->listUacls($userID);
foreach($rows as $row) {
if ($row['protection'] == 1) {
$aclID = ($row['aclID'] ? $row['aclID'] : 0);
$i++;
$bgcolor = ($i % 2) ? '' : '#f4f6f6';
$str .= "<tr bgcolor='$bgcolor'><td>$i <input type='hidden' name='aclID[]' value='$aclID'><input type='hidden' name='menuID$i' value='" .$row['menuID']. "'></td>
<td><i class='" .$row['appIcon']. "'></i> " .$row['appName']. "</td>
<td><i class='" .$row['menuIcon']. "'></i> " .$row['menuName']. "</td><td>" .($row['interface'] == 'I' ? 'Input' : ($row['interface'] == 'C' ? 'Configuration' : 'Output')). "</td>
<td><input type='checkbox' name='aclRead$i' value='1'" .($row['aclRead'] ? ' checked' : ''). " $ro></td>";
if ($row['interface'] == 'O') {
$str .= "<td></td><td></td><td></td>";
} else {
$str .= "<td><input type='checkbox' name='aclInsert$i' value='1'" .($row['aclInsert'] ? 'checked' : ''). " $ro></td>
<td><input type='checkbox' name='aclUpdate$i' value='1'" .($row['aclUpdate'] ? ' checked' : ''). " $ro></td>
<td><input type='checkbox' name='aclDelete$i' value='1'" .($row['aclDelete'] ? ' checked' : ''). " $ro></td>";
}
$str .= "<td>" .$row['status']. "</td></tr>";
}
}
$str .= "</table>";
}
return $str;
}
function javaToggle() {
$str = "
<script type='text/javascript'>
function toggle(source,id) {
//checkboxes = document.getElementsByName(id);
//for(var i=0, n=checkboxes.length;i<n;i++) {
for(var i=1, n=20; i<n; i++) {
tag = id.concat(String(i));
//alert(tag);
checktag = document.getElementsByName(tag);
if (checktag != null) {
//checkboxes.checked = source.checked;
checktag.checked = source.checked;
}
}
}
</script>";
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.";
}
}
?>