| Current Path : /var/www/html/mmishra/erp/views/ |
| Current File : /var/www/html/mmishra/erp/views/erp_view.php |
<?php
error_reporting(E_ALL);
date_default_timezone_set('Asia/Kolkata');
// Include the main TCPDF library (search for installation path).
//require_once(dirname(__FILE__) .DIRECTORY_SEPARATOR. '../tcpdf/tcpdf.php');
//$path = (getenv('MPDF_ROOT')) ? getenv('MPDF_ROOT') : __DIR__;
require_once(dirname(__FILE__) .DIRECTORY_SEPARATOR. '../mpdf/vendor/autoload.php');
//require_once(dirname(__FILE__) .DIRECTORY_SEPARATOR. '../mpdf/src/Mpdf.php');
// template class
require_once(dirname(__FILE__) .DIRECTORY_SEPARATOR. '../templates/erp_template.php');
// face detector class
require_once(dirname(__FILE__) .DIRECTORY_SEPARATOR. '../FaceDetector.php');
//fpdf - pdf generator
require_once(dirname(__FILE__) .DIRECTORY_SEPARATOR. '../includes/fpdf.php');
class erpView {
var $controller;
var $model;
const SL = ' selected'; // for selection box
const DS = ' disabled'; // for selection/radio/check box
const CK = ' checked'; // for radio/check boc
var $rs = "<i class='fas fa-rupee-sign'></i> ";
var $do = "<i class='fas fa-dollar-sign'></i> ";
public function __construct($controller, $model) {
$this->controller = $controller; // instantiate controller
$this->model = $model; // instantiate model
}
public function __destruct() {
// throw last executed sql statement
//print("<hr>" .$this->model->sqlStmt);
if (!in_array($this->controller->app, ['', '/', 'switch', 'about', 'upload', 'logout']) && !in_array($this->controller->menu, ['district', 'state'])) {
print(":|:" .$this->erpMenus(). ":|:" .$this->erpXupdate(). ":|:" .$this->erpError(). ":|:" .$this->erpClock(). ":|:" .$this->erpLogin());
}
}
// ******************************************************************
// Switch Institute
// ******************************************************************
function erpInstitutes() {
$institutes = $this->model->selectInstitute();
foreach ($institutes as $institute) {
if ($_SESSION["instituteID"] == $institute['instituteID']) {
$inst['name'] = $institute['instituteName'];
$inst['logo'] = ($institute['logoImage'] ? "<img src='images/" .$institute['logoImage']. "' width='75' height='75' border='0'>" : '');
} else {
$inst['next'] .= "[ <a href='/?instituteID=" .$institute['instituteID']. "' title='" .$institute['instituteName']. "'>" .$institute['instituteCode']. "</a> ]";
///switch/" .$institute['instituteID']. "' title='" .$institute['instituteName']. "'>" .$institute['instituteCode']. "</a>";
}
}
// prepare institute banner
if ($inst['name']) {
$ttls = explode(' ', str_replace(',', '', $inst['name']));
foreach ($ttls as $ttl) {
if ($i == 0) {
$title .= strtoupper($ttl). "<img src='images/tricolor.png' width='175' height='22' border='0'><br>";
} else if ($i == 1) {
$title .= strtoupper($ttl). ' ';
} else {
$title .= strtoupper($ttl). '<br>';
}
$i++;
}
$inst['name'] = rtrim($title, '<br>');
}
$str .= "<div class='titlebar'>" .$inst['name']. "</div>
<div class='logobar'>" .$inst['logo']. "</div>
<div class='institutebar'></div>";//" .$inst['next']. "
return $str;
}
// ******************************************************************
// Switch Module
// ******************************************************************
function erpModules() {
$modules = $this->model->erpModules();
$str = "<ul style='list-style-type: none; font-size: 11pt; margin-top: -10px;'>";
foreach ($modules as $module) {
$str .= "<li style='padding: 2px'>";
if ($_SESSION["moduleID"] == $module['moduleID']) {
$str .= "<i style='display:inline-block; width: 30pt; height: 12pt;' class='" .$module['moduleIcon']. "'></i>" .$module['moduleName']. " <i class='fas fa-check'></i>";
} else {
$str .= "<a href='/?moduleID=" .$module['moduleID']. "' title='" .$module['description']. "'><i style='display:inline-block; width: 30pt; height: 12pt;' class='" .$module['moduleIcon']. "'></i>" .$module['moduleName']. "</a>";
}
$str .= "</li>";
}
$str .= "</ul>";
return $str;
}
// ******************************************************************
// Header Content
// ******************************************************************
public function erpHeader() {
if (isset($_REQUEST['batchYear'])) {
$_SESSION['batchYear'] = $_REQUEST['batchYear'];
header("Location: /");
//} else {
// $_SESSION['batchYear'] = date('Y');
}
$str = "<div class='fixedbar'>
<script language='Javascript'>
function toggle(source, id) {
var checkboxes = document.querySelectorAll('input[id=\"'+id+'\"]');
for (var i=0; i<checkboxes.length; i++) {
if (checkboxes[i] != source) checkboxes[i].checked=source.checked;
}
}
window.addEventListener('DOMContentLoaded', function(e) {
var myHilitor2 = new Hilitor('contentbar');
myHilitor2.setMatchType('left');
document.getElementById('keywords').addEventListener('keyup', function(e) {
myHilitor2.apply(this.value);
}, false);
}, false);
</script>
<div id='searchbar' class='searchbar'><span class='button'><i class='fas fa-search'></i></span><input id='keywords' name='keywords' size='12' placeholder='search'></div>
<div id-'versionbar' class='versionbar'><sub>Ver. 1.0</sub></div>" .$this->erpInstitutes(). "<div class='helpbar' id='helpbar'></div>
<div id='modulebar' class='modulebar'>" .$this->erpModules(). "</div>
<div id='batchbar' class='institutebar'><a href='/?batchYear=" .($_SESSION['batchYear'] - 1). "' title='Reset Batch Year to " .($_SESSION['batchYear'] - 1). "'><<</a> [ <a title='Currently Set Batch Year'>" .$_SESSION['batchYear']. "</a> ] <a href='/?batchYear=" .($_SESSION['batchYear'] + 1). "' title='Reset Batch Year to " .($_SESSION['batchYear'] + 1). "'>>></a></div>
<div id='clockbar' class='clockbar'>" .$this->erpClock(). "</div>
<div id='errorbar' class='errorbar'>" .$this->erpError(). "</div>
<div id='loginbar' class='loginbar'>" .$this->erpLogin(). "</div>
<div id='menubar' class='menubar'>" .$this->erpMenus(). "</div>
</div>";
return $str;
}
// ******************************************************************
// Page Content
// ******************************************************************
public function erpContent() {
$str = "<div class='contentbar' id='contentbar'>";
//for file upload, ajax will not work so a form with action='includes/erp_upload.php' is needed
switch ($_REQUEST["content"]) {
case 'ccmt':
$str .= "<div align='center'>
<object data='../uploads/Information-for-MTech-Freshers-2018-18-6-2018.pdf#page=1' type='application/pdf' width='100%' height='650px'></object>
</div>";
break;
case 'csabA':
$str .= "<div align='center'>
<object data='../uploads/Information-for-BTech-Freshers-2018-18-6-2018.pdf#page=1' type='application/pdf' width='100%' height='650px'></object>
</div>";
break;
case 'csabL':
$str .= "<div align='center'>
<object data='../uploads/InformationforIIITL_BTechFreshers2018_150618_edited_version.pdf#page=1' type='application/pdf' width='100%' height='650px'></object>
</div>";
break;
default:
$str .= $this->erpDashboard();
}
$str .= "</div>";
return $str;
}
// ******************************************************************
// Footer Content
// ******************************************************************
function erpFooter() {
$config = $this->model->getConfiguration(1);
$str = "<div class='footer'>
<span class='xloginbar' id='xloginbar'>" .$this->erpXlogin();
if ($_SESSION['sessionID']) $str .= "<br><a href='' onclick=\"inner('erp/passwd/open/0'); return false;\" title='Change LDAP Password'><i style='font-size:12px;' class='fas fa-key'></i> Change Password</a>";
$str .= "</span>
<span class='xupdatebar' id='xupdatebar'>" .$this->erpXupdate();
if ($_SESSION['sessionID']) $str .= "<br><a href='backup.php' title='Take backup of database'><i style='font-size:12px;' class='fas fa-database'></i> Backup Database</a>";
$str .= "</span><span class='plainbar'>
[ Your IP <i class='fa fa-laptop'></i> " .$this->controller->userIP. " ]
</span><hr>
<b><span style='font-size:14px;'>©</span> " .$config['copyrightInfo']. "<br>
" .$config['remark']. "<br>
Technical Contact: " .$config['supportPhone']. ", " .$config['supportEmail']. "<br>
General Contact: " .$config['ownerPhone']. ", " .$config['ownerEmail']. "<br>
Website: <a href='" .$config['ownerWWW']. "' target='_new' title='Homepage'>" .str_replace('http://', '', str_replace('https://', '', $config['ownerWWW'])). "</a></b><hr></div>";
return $str;
}
function erpMenus() {
// list menu items to interact with of ERP system, the first top level menu is HOME
$str = "<div align='left'>
<table><tr><td>
<!--sphider_noindex-->
<ul id='menu'><div class='spanx'>
<li><a href='/' class='drop'><font size=+1 color='skyblue'><i class='fa fa-home'></i></font> Home </a></li>
</div></ul>
<!--/sphider_noindex--></td>";
// list top level other menu items to interact with applications of ERP system
$apps = $this->model->erpApps();
foreach ($apps as $app) {
//if (strtoupper($app['appCode']) == 'AAA') $batch = "<hr><span class='alert'> Batch Year:</span> <a href='' onclick=\"inner('aaa/batch/reset/" .($_SESSION["batchYear"] - 1). "'); return false;\" style='display: inline;'> << </a> [ <a href='' onclick=\"inner('aaa/batch/reset/" .$_SESSION["batchYear"]. "'); return false;\" style='display: inline;'>" .$_SESSION["batchYear"]. "</a> ] <a href='' onclick=\"inner('aaa/batch/reset/" .($_SESSION["batchYear"] + 1). "'); return false;\" style='display: inline;'> >> </a><hr>";
//else $batch = '';
//if ($app['universal']) {
$str .= "<td><!--sphider_noindex-->
<ul id='menu'>
<div class='spanx'>";
if (substr($app['appURL'], 0, 4) == "http") {
$str .= "<li><a href='" .$app['appURL']. "' class='drop' title='" .$app['description']. "' target='_new'><i style='display:inline-block; width: 20pt; height: 15pt; color: " .$app['iconColor']. "' class='" .$app['appIcon']. "'></i>" .$app['appName']. "</a></li>
<!-- End of top menu Item -->";
} else {
// list drop down menu items to list user interfaces for input, output and configuration of ERP system
$str .= "<li><a href='' onclick=\"inner('" .$app['appCode']. "/" .$app['appURL']. "/show/0'); return false;\" class='drop'><i style='display:inline-block; width: 20pt; height: 15pt; color: " .$app['iconColor']. "' class='" .$app['appIcon']. "'></i>" .$app['appName']. "</a>
<!-- Begin 4 columns Item -->
<div class='dropdown_4columns'><!-- Begin 4 columns container -->
<div class='col_4'>
<h2 style='font-stretch: ultra-expanded;'><i class='" .$app['appIcon']. "'></i> " .$this->model->getModuleName($app['moduleID']). " - " .$app['appName']. " panel</h2>
</div>
<div class='col_2'>
<h3><i class='far fa-question-circle'></i> ABOUT " .strtoupper($app['appCode']). "</h3>
<p>" .$app['description']. "</p>
<ul class='submenu'>";
// list interfaces for configuration of ERP system
$menus = $this->model->erpMenus($app['appID'], 'C');
foreach ($menus as $menu) {
if ($menu['parentID'] == 0) {
$str .= '<li>';
$submenus = $this->model->erpSubmenus($menu['menuID']);
if ($menu['protection'] == 0 || $this->model->checkReadACL($menu['menuID'])) {
if ($submenus) {
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$menu['menuURL']."/list/0'); return false;\" title='" .$menu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. " <i class='fas fa-caret-right'></i></a>
<ul><h3><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</h3>";
foreach ($submenus as $submenu) {
$str .= '<li>';
if ($submenu['protection'] == 0 || $this->model->checkReadACL($submenu['menuID'])) {
if (substr($menu['menuURL'], 0, 4) == "http") { // external link
$str .= "<a href='" .$menu['menuURL']. "' title='" .$menu['description']. "' target='_new'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
} else { // script
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$submenu['menuURL']."/show/0'); return false;\" title='" .$submenu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$submenu['menuIcon']. "'></i>" .$submenu['menuName']. "</a>";
}
} else if ($_SESSION['sessionID'] && $this->model->getUserACLs($_SESSION['loginID'])) {
if (substr($submenu['menuURL'], 0, 4) == "http") { // external link
$str .= "<a href='" .$submenu['menuURL']. "' title='" .$submenu['description']. "' target='_new'><i style='display:inline-block; width: 20pt;' class='fa " .$submenu['menuIcon']. "'></i>" .$submenu['menuName']. "</a>";
} else { // script
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$submenu['menuURL']."/show/0'); return false;\" title='" .$submenu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$submenu['menuIcon']. "'></i>" .$submenu['menuName']. "</a>";
}
}
$str .= '</li>';
}
$str .= "</ul>";
} else {
if (substr($menu['menuURL'], 0, 4) == "http") { // external link
$str .= "<a href='" .$menu['menuURL']. "' title='" .$menu['description']. "' target='_new'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
} else { // script
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$menu['menuURL']."/list/0'); return false;\" title='" .$menu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
}
}
} else if ($_SESSION['sessionID'] && $this->model->getUserACLs($_SESSION['loginID'])) {
if ($submenus) {
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$menu['menuURL']."/list/0'); return false;\" title='" .$menu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. " <i class='fas fa-caret-right'></i></a>
<ul><h3><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</h3>";
foreach ($submenus as $submenu) {
$str .= '<li>';
if (substr($submenu['menuURL'], 0, 4) == "http") { // external link
$str .= "<a href='" .$submenu['menuURL']. "' title='" .$submenu['description']. "' target='_new'><i style='display:inline-block; width: 20pt;' class='fa " .$submenu['menuIcon']. "'></i>" .$submenu['menuName']. "</a>";
} else { // script
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$submenu['menuURL']."/show/0'); return false;\" title='" .$submenu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$submenu['menuIcon']. "'></i>" .$submenu['menuName']. "</a>";
}
$str .= '</li>';
}
$str .= "</ul>";
} else {
if (substr($menu['menuURL'], 0, 4) == "http") {
$str .= "<a href='" .$menu['menuURL']. "' title='" .$menu['description']. "' target='_new'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
} else {
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$menu['menuURL']."/list/0'); return false;\" title='" .$menu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
}
}
}
$str .= "</li>";
}
}
$str .= "</ul>
</div>
<div class='col_2'>
<h3><i class='far fa-keyboard'></i> INTERFACES</h3>
<ul class='submenu'>";
// list interfaces for input to the ERP system
$menus = $this->model->erpMenus($app['appID'], 'I');
foreach ($menus as $menu) {
if ($menu['parentID'] == 0) {
$str .= '<li>';
$submenus = $this->model->erpSubmenus($menu['menuID']);
if ($menu['protection'] == 0 || $this->model->checkReadACL($menu['menuID'])) {
if ($submenus) {
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$menu['menuURL']."/list/0'); return false;\" title='" .$menu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. " <i class='fas fa-caret-right'></i></a>
<ul><h3><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</h3>";
foreach ($submenus as $submenu) {
$str .= '<li>';
if ($submenu['protection'] == 0 || $this->model->checkReadACL($submenu['menuID'])) {
if (substr($menu['menuURL'], 0, 4) == "http") { // external link
$str .= "<a href='" .$menu['menuURL']. "' title='" .$menu['description']. "' target='_new'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
} else { // script
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$submenu['menuURL']."/show/0'); return false;\" title='" .$submenu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$submenu['menuIcon']. "'></i>" .$submenu['menuName']. "</a>";
}
} else if ($_SESSION['sessionID'] && $this->model->getUserACLs($_SESSION['loginID'])) {
if (substr($submenu['menuURL'], 0, 4) == "http") { // external link
$str .= "<a href='" .$submenu['menuURL']. "' title='" .$submenu['description']. "' target='_new'><i style='display:inline-block; width: 20pt;' class='fa " .$submenu['menuIcon']. "'></i>" .$submenu['menuName']. "</a>";
} else { // script
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$submenu['menuURL']."/show/0'); return false;\" title='" .$submenu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$submenu['menuIcon']. "'></i>" .$submenu['menuName']. "</a>";
}
}
$str .= '</li>';
}
$str .= "</ul>";
} else {
if (substr($menu['menuURL'], 0, 4) == "http") { // external link
$str .= "<a href='" .$menu['menuURL']. "' title='" .$menu['description']. "' target='_new'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
} else { // script
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$menu['menuURL']."/list/0'); return false;\" title='" .$menu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
}
}
} else if ($_SESSION['sessionID'] && $this->model->getUserACLs($_SESSION['loginID'])) {
if ($submenus) {
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$menu['menuURL']."/list/0'); return false;\" title='" .$menu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. " <i class='fas fa-caret-right'></i></a>
<ul><h3><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</h3>";
foreach ($submenus as $submenu) {
$str .= '<li>';
if (substr($submenu['menuURL'], 0, 4) == "http") { // external link
$str .= "<a href='" .$submenu['menuURL']. "' title='" .$submenu['description']. "' target='_new'><i style='display:inline-block; width: 20pt;' class='fa " .$submenu['menuIcon']. "'></i>" .$submenu['menuName']. "</a>";
} else { // script
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$submenu['menuURL']."/show/0'); return false;\" title='" .$submenu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$submenu['menuIcon']. "'></i>" .$submenu['menuName']. "</a>";
}
$str .= '</li>';
}
$str .= "</ul>";
} else {
if (substr($menu['menuURL'], 0, 4) == "http") {
$str .= "<a href='" .$menu['menuURL']. "' title='" .$menu['description']. "' target='_new'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
} else {
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$menu['menuURL']."/list/0'); return false;\" title='" .$menu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
}
}
}
$str .= "</li>";
}
}
$str .= "</ul>
</div>
<div class='col_2'>
<h3><i class='fa fa-print'></i> REPORTS</h3>
<ul class='submenu'>";
// list interfaces for output from the ERP system
$menus = $this->model->erpMenus($app['appID'], 'O');
foreach ($menus as $menu) {
if ($menu['parentID'] == 0) {
$str .= '<li>';
$submenus = $this->model->erpSubmenus($menu['menuID']);
if ($menu['protection'] == 0 || $this->model->checkReadACL($menu['menuID'])) {
if ($submenus) {
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$menu['menuURL']."/list/0'); return false;\" title='" .$menu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. " <i class='fas fa-caret-right'></i></a>
<ul><h3><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</h3>";
foreach ($submenus as $submenu) {
$str .= '<li>';
if ($submenu['protection'] == 0 || $this->model->checkReadACL($submenu['menuID'])) {
if (substr($menu['menuURL'], 0, 4) == "http") { // external link
$str .= "<a href='" .$menu['menuURL']. "' title='" .$menu['description']. "' target='_new'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
} else { // script
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$submenu['menuURL']."/show/0'); return false;\" title='" .$submenu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$submenu['menuIcon']. "'></i>" .$submenu['menuName']. "</a>";
}
} else if ($_SESSION['sessionID'] && $this->model->getUserACLs($_SESSION['loginID'])) {
if (substr($submenu['menuURL'], 0, 4) == "http") { // external link
$str .= "<a href='" .$submenu['menuURL']. "' title='" .$submenu['description']. "' target='_new'><i style='display:inline-block; width: 20pt;' class='fa " .$submenu['menuIcon']. "'></i>" .$submenu['menuName']. "</a>";
} else { // script
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$submenu['menuURL']."/show/0'); return false;\" title='" .$submenu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$submenu['menuIcon']. "'></i>" .$submenu['menuName']. "</a>";
}
}
$str .= '</li>';
}
$str .= "</ul>";
} else {
if ($menu['protection'] == 0 || $this->model->checkReadACL($menu['menuID'])) {
if (substr($menu['menuURL'], 0, 4) == "http") { // external link
$str .= "<a href='" .$menu['menuURL']. "' title='" .$menu['description']. "' target='_new'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
} else { // script
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$menu['menuURL']."/list/0'); return false;\" title='" .$menu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
}
} else if ($_SESSION['sessionID'] && $this->model->getUserACLs($_SESSION['loginID'])) {
if (substr($menu['menuURL'], 0, 4) == "http") { // external link
$str .= "<a href='" .$menu['menuURL']. "' title='" .$menu['description']. "' target='_new'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
} else { // script
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$menu['menuURL']."/list/0'); return false;\" title='" .$menu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
}
}
}
} else if ($_SESSION['sessionID'] && $this->model->getUserACLs($_SESSION['loginID'])) {
if ($submenus) {
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$menu['menuURL']."/list/0'); return false;\" title='" .$menu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. " <i class='fas fa-caret-right'></i></a>
<ul><h3><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</h3>";
foreach ($submenus as $submenu) {
$str .= '<li>';
if (substr($menu['menuURL'], 0, 4) == "http") { // external link
$str .= "<a href='" .$menu['menuURL']. "' title='" .$menu['description']. "' target='_new'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
} else { // script
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$submenu['menuURL']."/show/0'); return false;\" title='" .$submenu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$submenu['menuIcon']. "'></i>" .$submenu['menuName']. "</a>";
}
$str .= '</li>';
}
$str .= "</ul>";
} else {
if (substr($menu['menuURL'], 0, 4) == "http") {
$str .= "<a href='" .$menu['menuURL']. "' title='" .$menu['description']. "' target='_new'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
} else {
$str .= "<a href='' onclick=\"inner('" .$app['appCode']. "/".$menu['menuURL']."/list/0'); return false;\" title='" .$menu['description']. "'><i style='display:inline-block; width: 20pt;' class='fa " .$menu['menuIcon']. "'></i>" .$menu['menuName']. "</a>";
}
}
}
$str .= "</li>";
}
}
$str .= "</ul>
</div>
</div><!-- End 4 columns container -->
</li><!-- End 4 columns Item -->
";
}
$str .= "</div>
</ul>
<!--/sphider_noindex--></td>";
//}
}
$str .= "</tr></table></div>";
return $str;
}
function erpClock() {
return "<i style='font-size:14px;' class='fas fa-clock'></i> " .date("l, d M, Y h:i:s A");
}
function erpHelper($tuple) {
if ($tuple == -1) {
$str = '';
} else {
$str = "<h2><span class='button'><i class='far fa-question-circle'></i></span> Help Tips <span class='toolbar'><a href='' onclick=\"inner('erp/helper/render/-1'); return false;\" title='Close Helper'><span class='button'><i class='far fa-times-circle'></i></span></a></span></h2>";
if ($tuple > 0) {
$str .= "<pre class='wordwrap'>" .$this->model->getMenuHelp($tuple). "</pre>";
} else {
$str .= "Helper does not offer any 'Help Tips' for this interface. Please contact support team for providing relevent 'Help Tips' here.";
}
}
return $str;
}
function erpError($errorText='') {
return "<i class='fas fa-bullhorn'></i> " .($errorText ? $errorText : $this->controller->errorText);
}
function erpXlogin() {
$str = "<i class='fas fa-exchange-alt'></i> ";
if ($_SESSION['loginID'] && $_SESSION["sessionID"]) {
$str .= $this->model->getXlogin();
} else {
$str .= "ERP displays last login timestamp here.";
}
return $str;
}
function erpXupdate() {
$tmstamp = $this->model->getXupdate();
$str = "<i class='far fa-clock'></i> " .($tmstamp ? "$tmstamp (ACL: " .$this->model->getUserACL($this->controller->menu). ")" : "ERP displays last-update timestamp of current record here.");
return $str;
}
function erpLogin() {
if ($_SESSION["sessionID"]) {
$str = "Welcome <b>" .strtoupper($_SESSION["loginID"]). "</b>! You are logged in as <b>" .strtoupper($this->model->getUserGroup()). "</b>.<br>
<span class='plainbar'>
Please <b>QUIT</b> your ERP session here.. <a href='/?logout=" .$_SESSION["instituteID"]. "' title='ERP Logout'><i style='font-size:14px; color:#247BBB' class='fas fa-sign-out-alt'></i></a>
</span>";
} else {
$str = "Please get into ERP here with a valid user credential.<br>
<span class='plainbar'>
<i style='font-size:14px;' class='fas fa-user'></i> <input type='text' name='loginID' size='10' value='" .$_SESSION["loginID"]. "' placeholder='login ID'>
<i style='font-size:14px;' class='fas fa-key'></i> <input type='password' name='pwd' size='10' placeholder='password' onkeypress=\"if (event.keyCode === 13) {document.querySelector('form').submit(); return false;}\">
<a href='javascript:void(0)' onclick=\"document.querySelector('form').submit(); return false;\" title='ERP Login'><i style='font-size:16px;' class='fas fa-sign-in-alt'></i></a>
</span>";
}
return $str;
}
function erpDashboard() {
if (!$_SESSION['sessionID']) {
$str .= "<br><br><center>
<h1>Welcome to ERP System! <br><br>Please login with your user credential.</h1>";
for ($i = 60; $i > 30; $i--) {
$str .= "<hr width='$i%'>";
}
if (substr($this->controller->userIP, 0 ,4) == '172.') {
$str .= "<form id='mm'>
Find <input type='text' id='eno' name='enrolmentNo' value='' size='20' placeholder='e.g. IIT2018101' onkeypress=\"if (event.keyCode === 13) {inner('aaa/student/find/'+this.value); return false;}\">
<a href='' onclick=\"inner('aaa/student/find/'+$('#eno').val()); return false;\" title='Student Detail'><span class='button'><i class='fas fa-search'></i></span></a>
</form>";
}
for ($i = 30; $i < 60; $i++) {
$str .= "<hr width='$i%'>";
}
$str .= "</center>";
} else {
$dashboard = $this->model->getDashboard();
$app = substr($dashboard, 0, 3);
$menu = substr($dashboard, 3);
try {
$action = 'show';
$tuple = 0;
$params = 0;
$appModel = __DIR__ .'/../models/' .$app. '_model.php';
$appController = __DIR__ .'/../controllers/' .$app. '_controller.php';
$appView = __DIR__ .'/' .$app. '_view.php';
if (file_exists($appModel) && file_exists($appController) && file_exists($appView)) {
require_once($appModel);
require_once($appController);
require_once($appView);
$modelName = $app.'Model';
$controllerName = $app.'Controller';
$viewName = $app.'View';
$appModel = new $modelName();
$appController = new $controllerName($appModel);
$appView = new $viewName($appController, $appModel);
// set controllers appID and menuID
$appController->app = $app;
$appController->menu = $menu;
$appController->action = $action;
$appController->tuple = $tuple;
$appController->params = $params;
$viewMethod = $app.ucwords($menu); // first and second parameter
// then we call the method via the view, dynamic call of the view
$str .= $appView->$viewMethod($action, $tuple); // third and fourth parameter
}
} catch (Exception $e) {
$str .= $e->getMessage();
}
}
return $str;
}
public function erpaDashboard() {
$data = $this->model->erpSummary();
foreach($data as $key => $value) {
$keys .= ucfirst($key). "<br>";
$values .= $value. "<br>";
}
$str .= "<table class='report'>
<tr><th colspan='2'><b>" .$this->model->getAppTitle('erpa'). "</b></th></tr>
<tr><td colspan='2' align='center'><b>ERP Summary</b></td></tr>
<tr><td nowrap>$keys</td><td style='font-size:8; font-weight:normal;'>$values</td></tr>
</table>";
return $str;
}
public function aaaDashboard1() {
$rows = $this->model->aaaAdmissions();
foreach($rows as $row) {
if ($row['programCode'] == $repet) {
$i++;
$tot += $row['no'];
$values .= ', ' .$row['no']. ' ' .$this->controller->genders[$row['gender']];
} else {
$keys .= ucfirst($row['programCode']). '<br>';
$values .= ($i ? ' (Total ' .$tot. ')<br>' : '') .($row['no'] ? $row['no']. ' ' .$this->controller->genders[$row['gender']] : 'Nil');
$i = 0;
$tot = $row['no'];
}
$repet = $row['programCode'];
}
$values .= ' (Total ' .$tot. ')<br>';
$str = "<table class='report'>
<tr><th colspan='2'><b>" .$this->model->getAppTitle('aaa'). "</b></td></tr>
<tr><td colspan='2' align='center'><b>Admissions " .$_SESSION['batchYear']. "</b></th></tr>
<tr><td>$keys</td><td style='font-size:8; font-weight:normal;'>$values</td></tr>
<tr><td colspan='2' align='center'><form id='mm'>
Enrollment No. <input type='text' id='eno' name='enrolmentNo' value='' size='20' placeholder='e.g. IIT2018101' onkeypress=\"if (event.keyCode === 13) {inner('aaa/student/detail/'+this.value); return false;}\">
<a href='' onclick=\"inner('aaa/student/detail/'+$('#eno').val()); return false;\" title='Student Detail'><span class='button'><i class='fas fa-search'></i></span></a>
</form></td></tr>";
if ($_SESSION['loginID']) $str .= "<tr><td colspan='2' align='right'><a href='' onclick=\"inner('aaa/dashboard/show/0'); return false;\" title='AAA Dashboard'>More...</a></td></tr>";
$str .= "</table>";
return $str;
}
public function libDashboard() {
$libsite = file_get_contents('http://library.iiita.ac.in/cgi-bin/opac.exe?Option=OPAC');
$lib = str_replace(substr($libsite, 0, strpos($libsite, 'BOOK-')), '', $libsite);
$lib = str_replace(substr($lib, strpos($lib, '<marquee scrollamount=2')), '', $lib);
$lib = str_replace(' ', '', $lib);
$data = explode(',</u><br>', $lib);
$catlogs = explode(',', $data[0]);
$loan = $data[1];
foreach ($catlogs as $value) {
$catlog = explode('-', $value);
if ($catlog[2]) {
$keys .= $catlog[0]. $catlog[1]. '<br>';
$values .= $catlog[2]. '<br>';
} else {
$keys .= $catlog[0]. '<br>';
$values .= $catlog[1]. '<br>';
}
}
$str = "<table class='report'>
<tr><th colspan='2'><b>" .$this->model->getAppTitle('lib'). "</b></th></tr>
<tr><td colspan='2' align='center'><b>Catlogs & Circulation</b></td></tr>
<tr><td>$keys</td><td style='font-size:8; font-weight:normal;'>$values</td></tr>
<tr><td colspan='2' style='font-size:8; font-weight:normal;'>$loan</td></tr>
<tr><td colspan='2' align='right'><a href='http://library.iiita.ac.in' title='Library Home'>More...</a></td></tr>
</table>";
return $str;
}
public function ihcDashboard() {
$rows = $this->model->ihcRegistrations();
foreach($rows as $row) {
if ($row['dated'] == $repet) {
$i++;
$tot += $row['no'];
$values .= ', ' .$row['no']. ' ' .$row['pgroup'];
} else {
$keys .= $row['dated']. '<br>';
$values .= ($i ? ' (Total ' .$tot. ')<br>' : '').($row['no'] ? $row['no']. ' ' .$row['pgroup'] : 'Nil');
$i = 0;
$tot = $row['no'];
}
$repet = $row['dated'];
}
$values .= ' (Total ' .$tot. ')<br>';
$str = "<table class='report'>
<tr><th colspan='2'><b>" .$this->model->getAppTitle('ihc'). "</b></th></tr>
<tr><td colspan='2' align='center'><b>Recent Registrations</b></td></tr>
<tr><td>$keys</td><td style='font-size:8;'>$values</td></tr>";
if ($_SESSION['loginID']) $str .= "<tr><td colspan='2' align='right'><a href='http://icure.iiita.ac.in/?pg=ihcSummary' title='Health Center Home'>More...</a></td></tr>";
$str .= "</table>";
return $str;
}
public function stDashboard() {
$rows = $this->model->stRequisitions();
foreach($rows as $row) {
if ($row['dated'] == $repet) {
$i++;
$tot += $row['no'];
$values .= ', ' .$row['no']. ' ' .$row['status'];
} else {
$keys .= $row['dated']. '<br>';
$values .= ($i ? ' (Total ' .$tot. ')<br>' : '').($row['no'] ? $row['no']. ' ' .$row['status'] : 'Nil');
$i = 0;
$tot = $row['no'];
}
$repet = $row['dated'];
}
if ($values) $values .= ' (Total ' .$tot. ')<br>';
$str = "<table class='report'>
<tr><th colspan='2'><b>" .$this->model->getAppTitle('st'). "</b></th></tr>
<tr><td colspan='2' align='center'><b>Recent Requisitions</b></td></tr>
<tr><td>$keys</td><td style='font-size:8; font-weight:normal;'>$values</td></tr>";
if ($_SESSION['loginID']) $str .= "<tr><td colspan='2' align='right'><a href='http://istore.iiita.ac.in/?pg=instatus' title='Indent Status'>More...</a></td></tr>";
$str .= "</table>";
return $str;
}
public function iwdDashboard() {
$rows = $this->model->iwdConsumptions();
foreach($rows as $row) {
$keys .= $row['month']. '<br>';
$values .= $row['reading']. ' Units<br>';
}
$str = "<table class='report'>
<tr><th colspan='2'><b>" .$this->model->getAppTitle('iwd'). "</b></th></tr>
<tr><td colspan='2' align='center'><b>Residential Consumptions</b></td></tr>
<tr><td>$keys</td><td style='font-size:8; font-weight:normal;'>$values</td></tr>";
if ($_SESSION['loginID']) $str .= "<tr><td colspan='2' align='right'><a href='http://ilight.iiita.ac.in/?pg=elrsummary' title='Consumption Summary'>More...</a></td></tr>";
$str .= "</table>";
return $str;
}
public function hmsDashboard() {
$hostels = $this->model->selectHostel();
$str = "<table class='report'>
<tr><th colspan='2'><b>" .$this->model->getAppTitle('hms'). "</b></th></tr>
<tr><th>Hostel</th><th>Floors</th><th>Actual Beds</th><th>Defined Beds</th><th>Allotted Beds</th><th>Vacant Beds</th></tr>";
foreach ($hostels as $hostel) {
$floors = $hostel['totalFloors'];
$hostelCode = $hostel['hostelCode'];
$type[1] = $hostel['singleBedded'];
$type[2] = $hostel['doubleBedded'];
$type[3] = $hostel['tripleBedded'];
$type[4] = $hostel['apartment'];
$type[5] = $hostel['suite'];
foreach ($this->controller->roomTypes as $key => $value) {
$$rooms = $this->model->filterRooms($hostelID, $key);
$no1 = count($rooms);
$no2 = $this->model->getAllotteeCountByRoomType($hostelID, $key);
if ($key == 2 || $key == 3)
$no3 = ($no1 * $key) - $no2;
else
$no3 = $no1 - $no2;
if ($key == 2 || $key == 3 && $type[$key]) {
$actual = str_repeat("<i class='fas fa-bed'></i> ", $key). "(" .$type[$key]. " x $key) ";
$allotted .= "($no1 x $key) ";
} else if ($type[$key]) {
$actual = "<i class='fas fa-bed'></i> (" .$type[$key]. ")";
$allotted .= "($no1) ";
}
$vacant .= "($no3) ";
}
$str .= "<tr><td>$hostelCode</td><td>$floors</td><td align='center'>$actual </td><td align='center'>$defined</td><td align='center'>$allotted</td><td align='center'>$vacant</td></tr>";
}
$str .= "</table>";
return $str;
}
public function erpExplorer($action, $moduleID) {
$app = $this->controller->app; // application envoked
$menu = $this->controller->menu; // menu envoked
$appID = $this->controller->params[0];
$menuID = $this->controller->params[1];
$moduleID = $this->controller->manageModule($action, $moduleID); // initiate controller action
$ro = $this->controller->editLock; // ensure default edit lock
$toolbar = $this->erpToolbar('', 1);
$str = $this->pageHeader($findbar, $toolbar);
$str .= "<ol class='listbar'>";
$modules = $this->model->listModules();
foreach($modules as $module) {
$str .= "<li>";
if ($module['moduleID'] == $moduleID && !$appID && !$menuID) {
$str .= "- <b><i class='" .$module['moduleIcon']. "'></i> " .$module['moduleName']. "</b> (ID: $moduleID, Status: " .$module['status']. ")
<dir>
<table class='interface'>
<tr><td width='20%' nowrap>Module Name</td><td width='80%'><input type='text' id='moduleName' name='moduleName' size='50' value='" .$module['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='" .$module['description']. "' $ro></td></tr>
<tr><td nowrap>Module Icon</td><td><input type='text' name='moduleIcon' size='50' value='" .$module['moduleIcon']. "' placeholder='Appears before module name' $ro></td></tr>
<tr><td nowrap>Icon Color</td><td><input type='text' name='iconColor' size='50' value='" .$module['iconColor']. "' $ro></td></tr>
<tr><td nowrap>Owner Departments</td><td><input type='text' name='moduleDept' size='50' value='" .$module['moduleDept']. "' $ro></td></tr>
<tr><td nowrap>Admin Name</td><td><input type='text' name='moduleAdmin' size='50' value='" .$module['moduleAdmin']. "' $ro></td></tr>
<tr><td nowrap>Admin Email</td><td><input type='text' name='adminEmail' size='50' value='" .$module['adminEmail']. "' placeholder='Receives critical mails on data operations' $ro></td></tr>
</table>
</dir>";
// application list
$str .= "<div align='left'>
<b>Applications:</b>
<ol class='listbar'>";
$apps = $this->model->listApps($moduleID);
foreach($apps as $app) {
$str .= "<li>";
if ($app['appID'] == $appID) {
$str .= "<b><i class='" .$app['appIcon']. "'></i> " .$app['appName']. "</b> (ID: $appID, Status: " .$app['status']. ")
<dir>
<table class='interface'>
<tr><td nowrap>App Name</td><td><input type='text' name='appName' size='50' value='" .$app['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='" .$app['description']. "' $ro></td></tr>
<tr><td nowrap>App Code</td><td><input type='text' name='appCode' size='50' value='" .$app['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='" .$app['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='" .$app['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='" .$app['iconColor']. "' $ro></td></tr>
<tr><td nowrap>Owner Departments</td><td><input type='text' name='appDept' size='50' value='" .$app['appDept']. "' $ro></td></tr>
<tr><td nowrap>Admin Name</td><td><input type='text' name='appAdmin' size='50' value='" .$app['appAdmin']. "' $ro></td></tr>
<tr><td nowrap>Admin Email</td><td><input type='text' name='adminEmail' size='50' value='" .$app['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'" .($app['universal'] == 0 ? ' checked' : ''). " $ro> No <input type='radio' name='universal' value='1'" .($app['universal'] == 1 ? ' checked' : ''). " $ro> Yes (Appears across the modules)</td></tr>
</table>
</dir>";
} else {
$str .= "<i class='" .$app['appIcon']. "'></i> <a href='' onclick=\"inner('$app/$menu/open/$moduleID/" .$app['appID']."'); return false;\">" .$app['appName']. "</a> (" .$app['status']. ")";
}
$str .= "</li>";
}
$str .= "</ol>
</div>";
} else {
$str .= "+ <i class='" .$module['moduleIcon']. "'></i> <a href='' onclick=\"inner('$app/$menu/open/" .$module['moduleID']."'); return false;\">" .$module['moduleName']. "</a> (" .$module['status']. ")";
}
$str .= "</li>";
}
if (!$moduleID) {
$str .= "<li>- <b>New module</b>
<dir>
<table class='interface'>
<tr><td width='20%' nowrap>Module Name</td><td width='80%'><input type='text' id='moduleName' name='moduleName' size='50' value='' placeholder='Appears as top level ERP section' $ro></td></tr>
<tr><td nowrap>Description</td><td><input type='text' name='description' size='50' value='' $ro></td></tr>
<tr><td nowrap>Module Icon</td><td><input type='text' name='moduleIcon' size='50' value='' placeholder='Appears before module name' $ro></td></tr>
<tr><td nowrap>Icon Color</td><td><input type='text' name='iconColor' size='50' value='' $ro></td></tr>
<tr><td nowrap>Owner Departments</td><td><input type='text' name='moduleDept' size='50' value='' $ro></td></tr>
<tr><td nowrap>Admin Name</td><td><input type='text' name='moduleAdmin' size='50' value='' $ro></td></tr>
<tr><td nowrap>Admin Email</td><td><input type='text' name='adminEmail' size='50' value='' placeholder='Receives critical mails on data operations' $ro></td></tr>
</table>
</dir>
</li>";
}
$str .= "</ol>";
return $str;
}
public function erpToolbar($toolExtra='', $toolPlus=0) {
$app = $this->controller->app;
$menu = $this->controller->menu;
$action = $this->controller->action;
$tuple = ($this->model->tupleID ? $this->model->tupleID : 0);
$param0 = $this->controller->params[0];
$param1 = $this->controller->params[1];
$param2 = $this->controller->params[2];
$userACL = $this->model->getUserACL($menu);
list($insert, $update, $delete) = explode(',', $userACL);
// toolbar according to aclInsert, acl Update, aclDelete privileges
$str = "<a href='' onclick=\"inner('$app/$menu/refresh/$tuple/$param0/$param1/$param2'); return false;\" title='Refresh page'><span class='button'><i class='fas fa-sync-alt'></i></span></a>";
if ($toolPlus != -1) {
// privileged insert operation
if ($insert) $str .= "<a href='' onclick=\"inner('$app/$menu/new/0/$param0/$param1/$param2'); return false;\" title='New record'><span class='button'><i class='far fa-file'></i></span></a>";
// privileged update operation
if ($update && $tuple) $str .= "<a href='' onclick=\"inner('$app/$menu/edit/$tuple/$param0/$param1/$param2'); return false;\" title='Edit record'><span class='button'><i class='far fa-edit'></i></span></a>";
// privileged save operation
if ($insert || $update) $str .= "<a href='' onclick=\"inner('$app/$menu/save/$tuple/$param0/$param1/$param2'); return false;\" title='Save record'><span class='button'><i class='far fa-save'></i></span></a>";
// privileged delete operation
if ($delete && $tuple) $str .= "<a href='' onclick=\"inner('$app/$menu/trash/$tuple/$param0/$param1/$param2'); return false;\" title='Delete record'><span class='button'><i class='far fa-trash-alt'></i></span></a>";
// initiated delete confirmation
if ($action == 'trash') $str .= "[<b class='alert'>Are you sure?</b><a href='' onclick=\"inner('$app/$menu/delete/$tuple/$param0/$param1/$param2'); return false;\" title='Confirm deletion'><span class='button'><i class='far fa-check-circle'></i></span></a>|<a href='' onclick=\"inner('$app/$menu/open/$tuple/$param0/$param1/$param2'); return false;\" title='Cancel deletion'><span class='button'><i class='far fa-times-circle'></i></span></a>]";
}
$str .= "<a href='' onclick=\"printMe('contentbar'); return false;\" title='Print record'><span class='button'><i class='fa fa-print'></i></span></a>
<a href='' onclick=\"inner('$app/helper/render/" .$this->model->getMenuID($menu). "'); return false;\" title='Helper Tips'><span class='button'><i class='far fa-question-circle'></i></span></a>";
$str .= ($tuple && $toolExtra ? $toolExtra : '');
switch ($toolPlus) {
case 1:
$str .= ($tuple && $update ? "<a href='' onclick=\"inner('$app/$menu/upper/$tuple/$param0/$param1/$param2'); return false;\" title='Move upward'><span class='button'><i class='fas fa-arrow-up'></i></span></a>" : "<span class='button'><i class='fas fa-arrow-up'></i></span>");
$str .= ($tuple && $update ? "<a href='' onclick=\"inner('$app/$menu/lower/$tuple/$param0/$param1/$param2'); return false;\" title='Move downward'><span class='button'><i class='fas fa-arrow-down'></i></span></a>" : "<span class='button'><i class='fas fa-arrow-down'></i></span>");
break;
case 2:
$str .= ($tuple && $update ? "<a href='' onclick=\"inner('$app/$menu/disable/$tuple/$param0/$param1/$param2'); return false;\" title='Disable record'><span class='button'><i class='far fa-thumbs-down'></i></span></a>" : "<span class='button'><i class='far fa-thumbs-down'></i></span>");
$str .= ($tuple && $update ? "<a href='' onclick=\"inner('$app/$menu/enable/$tuple/$param0/$param1/$param2'); return false;\" title='Enable record'><span class='button'><i class='far fa-thumbs-up'></i></span></a>" : "<span class='button'><i class='far fa-thumbs-up'></i></span>");
break;
case 3:
$str .= ($tuple && $update ? "<a href='' onclick=\"inner('$app/$menu/upper/$tuple/$param0/$param1/$param2'); return false;\" title='Move upward'><span class='button'><i class='fas fa-arrow-up'></i></span></a>" : "<span class='button'><i class='fas fa-arrow-up'></i></span>");
$str .= ($tuple && $update ? "<a href='' onclick=\"inner('$app/$menu/lower/$tuple/$param0/$param1/$param2'); return false;\" title='Move downward'><span class='button'><i class='fas fa-arrow-down'></i></span></a>" : "<span class='button'><i class='fas fa-arrow-down'></i></span>");
$str .= ($tuple && $update ? "<a href='' onclick=\"inner('$app/$menu/disable/$tuple/$param0/$param1/$param2'); return false;\" title='Disable record'><span class='button'><i class='far fa-thumbs-down'></i></span></a>" : "<span class='button'><i class='far fa-thumbs-down'></i></span>");
$str .= ($tuple && $update ? "<a href='' onclick=\"inner('$app/$menu/enable/$tuple/$param0/$param1/$param2'); return false;\" title='Enable record'><span class='button'><i class='far fa-thumbs-up'></i></span></a>" : "<span class='button'><i class='far fa-thumbs-up'></i></span>");
break;
}
return $str;
}
public function erpPrintbar() {
$app = $this->controller->app;
$menu = $this->controller->menu;
$action = $this->controller->action;
$tuple = $this->model->tupleID;
$param0 = $this->controller->params[0];
$param1 = $this->controller->params[1];
$param2 = $this->controller->params[2];
$str = "<a href='' onclick=\"inner('$app/$menu/refresh/$tuple'); return false;\" title='Refresh page'><span class='button'><i class='fas fa-sync-alt'></i></span></a>
<a href='' onclick=\"printMe('contentbar'); return false;\" title='Print record'><span class='button'><i class='fa fa-print'></i></span></a>";
return $str;
}
public function erpPasswd($action, $tuple) {
$app = $this->controller->app;
$menu = $this->controller->menu;
$tuple = $this->controller->managePasswd($action, $_SESSION["loginID"]);
$toolbar = "<span class='toolbar'>
<a href='' onclick=\"inner('$app/$menu/refresh/$tuple'); return false;\" title='Refresh Page'><span class='button'><i class='fas fa-sync-alt'></i></span></a>
<a href='' onclick=\"inner('$app/$menu/reset/1'); return false;\" title='Change Password'><span class='button'><i class='fas fa-save'></i></span></a>
</span>";
$str = "<h3><i class='fas fa-street-view'></i> Password Reset $toolbar</h3>
<table align='center' width='50%'>
<tr><th colspan='2'>userID: " .$_SESSION["loginID"]. "</th></tr>
<tr><td style='padding-left: 90px;'>New password</td><td width='55%'><input type='password' name='passwd1' size='30'></td></tr>
<tr><td style='padding-left: 90px;'>Confirm password</td><td><input type='password' name='passwd2' size='30'></td></tr>
</table><br>
Try to set a complex password comprising alphbets, number and special characters.<br>
Please keep on changing your password once in every month for better security of your account.";
return $str; // required to split content in ajax
}
// online pg service integratiob
public function erpPGrequest() {
return $str;
}
public function erpPGresponse() {
$HASHING_METHOD = 'sha512'; // md5,sha1
// This response.php used to receive and validate response.
if (!isset($_SESSION['SECRET_KEY']) || empty($_SESSION['SECRET_KEY']))
$_SESSION['SECRET_KEY'] = ''; //set your secretkey here
$hashData = $_SESSION['SECRET_KEY'];
ksort($_POST);
foreach ($_POST as $key => $value){
if (strlen($value) > 0 && $key != 'SecureHash') {
$hashData .= '|'.$value;
}
}
if (strlen($hashData) > 0) {
$secureHash = strtoupper(hash($HASHING_METHOD , $hashData));
if ($secureHash == $_POST['SecureHash']){
if($_POST['ResponseCode'] == 0) {
// update response and the order's payment status as SUCCESS in to database
//for demo purpose, its stored in session
$_POST['paymentStatus'] = 'SUCCESS';
$_SESSION['paymentResponse'][$_POST['PaymentID']] = $_POST;
} else {
// update response and the order's payment status as FAILED in to database
//for demo purpose, its stored in session
$_POST['paymentStatus'] = 'FAILED';
$_SESSION['paymentResponse'][$_POST['PaymentID']] = $_POST;
}
// Redirect to confirm page with reference.
$confirmData = array();
$confirmData['PaymentID'] = $_POST['PaymentID'];
$confirmData['Status'] = $_POST['paymentStatus'];
$confirmData['Amount'] = $_POST['Amount'];
$hashData = $_SESSION['SECRET_KEY'];
ksort($confirmData);
foreach ($confirmData as $key => $value){
if (strlen($value) > 0) {
$hashData .= '|'.$value;
}
}
if (strlen($hashData) > 0) {
$secureHash = strtoupper(hash($HASHING_METHOD , $hashData));
}
$str .= "<html>
<body onLoad='document.payment.submit();'>
<form action='confirm.php' name='payment' method='POST'>";
foreach($confirmData as $key => $value) {
$str .= "<input type='hidden' value='" .$value. "' name='" .$key. "'/>";
}
$str .= "<input type='hidden' value='" .$secureHash. "' name='SecureHash'/>
</form>
</body>
</html>";
} else {
$str .= "<h1>Error!</h1>
<p>Hash validation failed</p>";
}
} else {
$str .= "<h1>Error!</h1>
<p>Invalid response</p>";
}
return $str;
}
public function erpHDFC($action, $studentID) {
/* $app = $this->controller->app; // required for toolbar and urls
$menu = $this->controller->menu; // required for toolbar and urls
$applicantID = $this->model->getApplicantIDByStudentID($studentID);
$data = $this->model->getApplicant($applicantID); // get record
$programID = $data['programID'];
$program = $this->model->getProgram($programID);
$programID = $data['programID']; // to get program detail
$pwdStatus = $data['pwdStatus'];
$category = ($pwdStatus == 'Y' ? 'PWD' : $data['offerCategory']);
// save payments in database
$toolbar = "<a href='' onclick=\"inner('$app/pay$action/new/$studentID'); return false;\" title='Go Back'><span class='button'><i class='fas fa-arrow-circle-left'></i></span></a>";
// HDFC Bank PG
$HASHING_METHOD = "sha512"; // md5,sha1
$hashData = "020bc4ca9304d76f471b03213f73d035";
$pg1['channel'] = "10";
$pg1['mode'] = "LIVE";
$pg1['account_id'] = "25146";
$pg1['reference_no'] = $data['rollNo']. ($action == 'fees' ? ' - Fees payment' : ' Mess payment');
$pg1['description'] = $data['batchYear']. "-" .$program['programCode'];
$pg1['amount'] = $_POST['amount'];
$pg1['currency'] = $_POST['curency'];
$pg1['return_url'] = "https://erp.iiita.ac.in/inner/aaa/payment/save/$studentID";
$pg1['name'] = $data['nameEnglish'];
$pg1['phone'] = $data['phoneNo'];
$pg1['email'] = $data['email'];
$pg1['address'] = $data['homeAddress'];
$pg1['city'] = $this->model->getDistrictNameByDistrictID($data['homeDistrict']);
$pg1['state'] = $this->model->getStateNameByStateID($data['homeState']);
$pg1['postal_code'] = $data['homePIN'];
$pg1['country'] = $data['nationality'];
unset($_POST['securekey']);
unset($_POST['submitted']);
unset($_POST['curency']);
unset($_POST['studentID']);
unset($_POST['reg']);
ksort($pg1);
foreach ($pg1 as $key => $value){
//echo '[' .$key. '-' .$value. ']';
if (strlen($value) > 0) {
$hashData .= '|'.$value;
}
}
if (strlen($hashData) > 0) {
$secureHash = strtoupper(hash($HASHING_METHOD, $hashData));
}
foreach($pg1 as $key => $value) {
$pg .= "<input type='hidden' name='" .$key. "' value='" .$value. "'>";
}
$pg .= "<input type='hidden' name='secure_hash' value='" .$secureHash. "'>$hashData";
$str = $this->pageHeader($findbar, $toolbar);
$str .= "<table width='100%'>
<tr><th>Candidate #{$studentID} Details</th></tr>
<tr><td>" .$this->candidateProfile($studentID). "</td></tr>
<tr valign='top'><td>
<table class='interface' width='100%'>
<tr bgcolor='#f4f6f6'><td nowrap>". $program['entranceName']. " Roll No.</td><td><b>" .$data['rollNo']. "</b></td>
<td nowrap align='right'>Applicant Name</td><td><b>" .$data['nameEnglish']. ' (' .$data['nameHindi']. ")</b></td>
<td nowrap align='right'>Contact</td><td><b>" .$data['phoneNo']. ", " .$data['email']. "</b></td>
<td align='right'>Aadhaar No.</td><td><b>" .$data['aadhaarNo']. "</b></td></tr>
</table>
<tr><td align='center'>
<h4>Amount To Pay " .$_POST['curency'].' '.number_format($_POST['amount'], 2). " towards " .strtoupper($action). "</h4>
<button name='HDFC' value='HDFC'><a href='' onclick=\"document.erpForm.submit(); return false;\" title='Confirm Payment'>HDFC</a></button>
<h5>For payment you may route through either HDFC or CANARA Bank Gateway. Bank may charge for online transactions.</h5>
</td></tr>
</table>" .$this->pageFooter('', $toolbar). $pg;
*/
return $str;
}
public function erpATOM($action, $studentID) {
/* $app = $this->controller->app; // required for toolbar and urls
$menu = $this->controller->menu; // required for toolbar and urls
$applicantID = $this->model->getApplicantIDByStudentID($studentID);
$data = $this->model->getApplicant($applicantID); // get record
$programID = $data['programID'];
$program = $this->model->getProgram($programID);
$programID = $data['programID']; // to get program detail
$pwdStatus = $data['pwdStatus'];
$category = ($pwdStatus == 'Y' ? 'PWD' : $data['offerCategory']);
// save payments in database
$toolbar = "<a href='' onclick=\"inner('$app/payfees/new/$studentID'); return false;\" title='Go Back'><span class='button'><i class='fas fa-arrow-circle-left'></i></span></a>";
// CANARA Bank PG
$pg2['product'] = 'IIIT';
$pg2['TType'] = 'NBFundTransfer';
$pg2['AccountNo'] = '0627101019766';
$pg2['ru'] = 'https://erp.iiita.ac.in/canara/StatusTRAN.php';
$pg2['bookingid'] = '100001';
$pg2['clientcode'] = $data['rollNo']; //rollno
$pg2['udf1'] = $data['nameEnglish'];
$pg2['udf2'] = $data['email'];
$pg2['udf3'] = $data['phoneNo'];
$pg2['udf4'] = $data['rollNo']. ' - Fees payment';
$pg2['udf5'] = $data['batchYear']. "-" .$program['programCode'];
$pg2['udf9'] = 1; // semester
$pg2['amount'] = $_POST['amount'];
foreach ($pg2 as $key => $value) {
$queryString .= $key . '=' .$value. '&';
}
$str = $this->pageHeader($findbar, $toolbar);
$str .= $this->candidateProfile($studentID);
$str .= "<table class='interface' width='100%'>
<tr bgcolor='#f4f6f6'><td nowrap>". $program['entranceName']. " Roll No.</td><td><b>" .$data['rollNo']. "</b></td>
<td nowrap align='right'>Applicant Name</td><td><b>" .$data['nameEnglish']. ' (' .$data['nameHindi']. ")</b></td>
<td nowrap align='right'>Contact</td><td><b>" .$data['phoneNo']. ", " .$data['email']. "</b></td>
<td align='right'>Aadhaar No.</td><td><b>" .$data['aadhaarNo']. "</b></td></tr>
</table>
<h4>Amount To Pay " .$_POST['curency'].' '.number_format($_POST['amount'], 2). " towards FEES.</h4>
<a href='atompg.php?" .$queryString. "proceed=1' title='Confirm Payment' target='new'><img src='images/atom.png'></a>
<h5>From here you will be routed through ATOM Gateway for online transaction. Bank may charge for online transactions.</h5>
" .$this->pageFooter('', $toolbar). $pg;
*/
return $str;
}
//*********************************** erp backup generation
public function erpDb($action, $db) {
if ($action == 'backup') {
$str = $this->controller->erpBackup();
} else {
$str = "Action not mentioned.";
}
return $str;
}
public function pageHeader($findbar='', $toolbar='', $batchYear='') {
$app = $this->controller->app;
$menu = $this->controller->menu;
$this->dis = ($this->controller->editLock ? self::DS : '');
if ($menu == 'dashboard') {
$title = $this->model->getAppTitle($app). " Dashboard";
} else {
$title = $this->model->getMenuTitle($menu);
$title = "<i class='" .$title['menuIcon']. "'></i> " .$title['menuName'];
}
if (strpos($this->appURL, 'inner')) { // maintain erp activity log for inner contents
$this->model->erpLog($this->userIP, $this->appURL, $this->referer);
}
if (!$batchYear) $batchYear = $_SESSION['batchYear'];
if ($title) { // hidden form tag is required for search in page
return "<h3>$title " .($findbar ? "<span class='findbar'>$findbar</span>" : ''). ($toolbar ? "<span class='toolbar'>$toolbar</span>" : ''). "</h3>
<script language='Javascript'>
function toggle(source, id) {
var checkboxes = document.querySelectorAll('input[id=\"'+id+'\"]');
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i] != source) checkboxes[i].checked = source.checked;
}
}
window.addEventListener('DOMContentLoaded', function(e) {
var myHilitor2 = new Hilitor();
myHilitor2.setMatchType('left');
document.getElementById('keywords').addEventListener('keyup', function(e) {
myHilitor2.apply(this.value);
}, false);
}, false);
</script>";
flush();
} else {
return "<h3><i class='fas fa-times'></i> Title Missing</h3>";
}
}
public function pageFooter($findbar, $toolbar) {
return ($findbar ? "<span class='findbar'>$findbar</span>" : ''). ($toolbar ? "<span class='toolbar'>$toolbar</span>" : '');
}
public function dateTool($dated) {
$app = $this->controller->app; // application envoked
$menu = $this->controller->menu; // menu envoked
if (!$dated) $dated = date("Y-m-d");
$yester = date('Y-m-d', strtotime($dated .' -1 day'));
$tomoro = date('Y-m-d', strtotime($dated .' +1 day'));
$str = "<div align='center'>
<a href='' onclick=\"inner('$app/$menu/filter/$yester'); return false;\" title='Previous'> <span class='button'><i class='fas fa-chevron-circle-left'></i></span></a>
<b>[ " .$dated. " ]</b>" .($dated != date("Y-m-d") ? "
<a href='' onclick=\"inner('$app/$menu/filter/$tomoro'); return false;\" title='Next'> <span class='button'><i class='fas fa-chevron-circle-right'></i></span></a>" : ''). "
</div>";
return $str;
}
public function printGrid($rows) {
$str = "<table class='report'>
<tr valign='top'>";
foreach($rows as $row) {
$i++;
$str .= "<td style='border: 1px solid #247BBB; padding:10px;'>#" .$i. '<br>';
foreach ($row as $key => $value) {
//$str .= strtoupper($key). ':' .$value. '<br>';
$str .= $value. '<br>';
}
$str .= '</td>' .($i % 5 ? '' : "</tr><tr valign='top'>");
}
$str .= "</tr></table>";
return $str;
}
public function printDetail($rows) {
$str = "<table class='report'>";
foreach($rows as $row) {
foreach ($row as $key => $value) {
$str .= "<tr><td>>" .strtoupper($key). '</td><td>:</td><td>' .$value. '</td></tr>';
}
}
$str .= "</table>";
return $str;
}
public function printReport($rows) {
$str = "<table class='report'>";
foreach($rows as $row) {
$i++; $j = 0;
if ($i == 1) {
$str .= "<thead><tr><th id='col0'><button class='col' type='button' data-column='#col0' title='Click to hide this column'>#</button></th>";
foreach ($row as $key => $value) {
$j++;
$str .= "<th id='col$j'><button class='col' type='button' data-column='#col$j' title='Click to hide this column'>" .ucfirst($key). "</button></th>";
}
$str .= "</tr>";
}
$str .= "</thead><tr valign='top'><td>$i</td>";
foreach ($row as $key => $value) {
$str .= "<td>$value</td>";
}
$str .= "</tr>";
}
$str .= "</table>";
return $str;
}
//*********************************************** reports on session, log and sql commands
public function erpSessions($action, $dated='') {
$app = $this->controller->app; // application envoked
$menu = $this->controller->menu; // menu envoked
if (!$dated) $dated = date("Y-m-d");
$rows = $this->model->listSessions($dated);
if ($rows) $toolbar = $this->erpPrintbar();
$str = $this->pageHeader($findbar, $toolbar);
$str .= $this->dateTool($dated);
$str .= $this->printReport($rows);
if ($rows) $str .= $this->pageFooter('', $toolbar);
return $str;
}
public function erpLogs($action, $dated='') {
$app = $this->controller->app; // application envoked
$menu = $this->controller->menu; // menu envoked
if (!$dated) $dated = date("Y-m-d");
$rows = $this->model->listLogs($dated);
if ($rows) $toolbar = $this->erpPrintbar();
$str = $this->pageHeader($findbar, $toolbar);
$str .= $this->dateTool($dated);
$str .= $this->printReport($rows);
if ($rows) $str .= $this->pageFooter('', $toolbar);
return $str;
}
public function erpSqls($action, $dated='') {
$app = $this->controller->app; // application envoked
$menu = $this->controller->menu; // menu envoked
if (!$dated) $dated = date("Y-m-d");
$rows = $this->model->listSqls($dated);
if ($rows) $toolbar = $this->erpPrintbar();
$str = $this->pageHeader($findbar, $toolbar);
$str .= $this->dateTool($dated);
$str .= $this->printReport($rows);
if ($rows) $str .= $this->pageFooter('', $toolbar);
return $str;
}
function dateAdd($days) {
$curdate = getdate();
$cday = $curdate['mday'] + $days;
$cmonth = $curdate['mon'];
$cyear = $curdate['year'];
if ($cday > 31) {
$cmonth = $cmonth + 1;
$cday = $cday - 31;
if ($cmonth == 13) {
$cyear = $cyear + 1;
$cmonth = 1;
}
}
if ($cday < 10) $cday = '0' .$cday;
if ($cmonth < 10) $cmonth = '0' .$cmonth;
return $cyear. '-' .$cmonth. '-' .$cday;
}
function createPDF () {
// generate pdf file of receipt
$pdf = new \Mpdf\Mpdf();
$pdf->autoScriptToLang = true;
$pdf->autoLangToFont = true;
$pdf->SetDisplayMode(real, 'default');
// create first page
$pdf->AddPage();
$pdf->SetTitle('ERP PDF Generator');
$pdf->SetAuthor('IIIT-A');
$pdf->SetAutoPageBreak(0);
if (heading) {
$institute = $this->model->getInstitute();
// header starts
list($width, $height) = getimagesize('images/' .str_replace('c.', '.', $institute['nameHindi']));
if ($institute['logoImage']) $pdf->Image('images/' .$institute['logoImage'], 6, 8, 20);
$pdf->Image('images/' .str_replace('c.', '.', $institute['nameHindi']), ($pdf->w - 134) / 2, 7, 134, 6);
$pdf->SetXY(10, 12);
$pdf->SetFont('Helvetica','B', 15);
$pdf->Cell(0, 10, $institute['instituteName'], 0, 1, 'C');
$pdf->SetFont('Helvetica', 'I', 8);
$pdf->Cell(0, 3, '(' .$institute['brandTagline']. ')', 0, 1, 'C');
$pdf->SetFont('Helvetica', 'B', 10);
$pdf->Cell(0, 2, '', 0, 1, 'C');
$pdf->Cell(0, 4, $institute['address'], 0, 1, 'C');
$pdf->SetFont('Helvetica', 'B', 9);
$pdf->Cell(0, 4, 'Phone: ' .$institute['phoneNo']. ', Email: ' .$institute['email']. ', Web: ' .$institute['website'], 0, 1, 'C');
$pdf->Line(0, 36, 500, 36);
$pdf->Ln(1);
// header ends
}
if ($refNo && $title && $desc) {
$pdf->SetFont('Times', 'I', 8);
$pdf->SetXY(20, 40);
$pdf->Cell(178, 5, "Ref. No.: " .$refNo, 0, 0, 'R');
$pdf->SetXY(20, 44);
$pdf->Cell(178, 5, "Dated: " .date('d/m/Y'), 0, 0, 'R');
$pdf->SetXY(15, 55);
$pdf->SetFont('Times', 'U', 13);
$pdf->Cell(0, 0, $title, 0, 1, 'C');
$pdf->SetFont('Times', 'I', 11);
$pdf->Cell(0, 12, "( " .$desc. " )", 0, 1, 'C');
$pdf->Ln(3);
}
return $pdf;
}
function showPDF($path, $fileName) {
$fileName = strtolower($fileName); // just for caution
$str = "<object data='/uploads/$path/$fileName' type='application/pdf' title='ERP PDF' width='100%' height='650px'>
<embed src='/uploads/$path/$fileName' width='100%' height='650' type='application/pdf'>
<p>This browser does not support inbuilt PDF viewer. Please download the PDF to view it:<br><br><a href='/uploads/$path/$fileName'>Download PDF</a></p>
</embed>
</object>";
return $str;
}
function erpUpload() {
// check for uploaded file size
if ($_FILES['imagefile']['size'] > 50000 ) {
die ("ERROR: Large File Size");
}
//check if its image file
if (!getimagesize($_FILES['imagefile']['tmp_name'])) {
return "Invalid Image File...";
}
// restrict width and height if its image or photo file
list($width, $height, $type, $attr) = getimagesize($_FILES['imagefile']['tmp_name']);
if ($width > 100 || $height > 100) {
return "Maximum width and height exceeded. Please upload images below 100x100 px size";
}
$blacklist = array(".php", ".phtml", ".php3", ".php4", ".js", ".shtml", ".pl" ,".py");
foreach ($blacklist as $file) {
if(preg_match("/$file\$/i", $_FILES['userfile']['name'])) {
return "ERROR: Uploading executable files Not Allowed\n";
}
}
}
public function erpDistrict($action, $stateID) {
$districts = $this->model->selectDistrict($stateID);
foreach ($districts as $district) {
$str .= "<option value='" .$district['districtID']. "'>" .$district['districtName']. "</option>";
}
return $str;
}
function abbreviate($strString, $intLength = NULL) {
$defaultAbbrevLength = 8; //Default abbreviation length if none is specified
//Set up the string for processing
$strString = preg_replace("/[^A-Za-z0-9]/", '', $strString); //Remove non-alphanumeric characters
$strString = ucfirst( $strString ); //Capitalize the first character (helps with abbreviation calcs)
$stringIndex = 0;
//Figure out everything we need to know about the resulting abbreviation string
$uppercaseCount = preg_match_all('/[A-Z]/', $strString, $uppercaseLetters, PREG_OFFSET_CAPTURE); //Record occurences of uppercase letters and their indecies in the $uppercaseLetters array, take note of how many there are
$targetLength = isset( $intLength ) ? intval( $intLength ) : $defaultAbbrevLength; //Maximum length of the abbreviation
$uppercaseCount = $uppercaseCount > $targetLength ? $targetLength : $uppercaseCount; //If there are more uppercase letters than the target length, adjust uppercaseCount to ignore overflow
$targetWordLength = round( $targetLength / intval( $uppercaseCount ) ); //How many characters need to be taken from each uppercase-designated "word" in order to best meet the target length?
$abbrevLength = 0; //How long the abbreviation currently is
$abbreviation = ''; //The actual abbreviation
//Create respective arrays for the occurence indecies and the actual characters of uppercase characters within the string
for($i = 0; $i < $uppercaseCount; $i++) {
//$ucIndicies[] = $uppercaseLetters[1]; //Not actually used. Could be used to calculate abbreviations more efficiently than the routine below by strictly considering indecies
$ucLetters[] = $uppercaseLetters[0][$i][0];
}
$characterDeficit = 0; //Gets incremented when an uppercase letter is encountered before $targetCharsPerWord characters have been collected since the last UC char.
$wordIndex = $targetWordLength; //HACK: keeps track of how many characters have been carried into the abbreviation since the last UC char
while( $stringIndex < strlen( $strString ) ) { //Process the whole input string...
if( $abbrevLength >= $targetLength ) //...unless the abbreviation has hit the target length cap
break;
$currentChar = $strString[ $stringIndex++ ]; //Grab a character from the string, advance the string cursor
if( in_array( $currentChar, $ucLetters ) ) { //If handling a UC char, consider it a new word
$characterDeficit += $targetWordLength - $wordIndex; //If UC chars are closer together than targetWordLength, keeps track of how many extra characters are required to fit the target length of the abbreviation
$wordIndex = 0; //Set the wordIndex to reflect a new word
} else if( $wordIndex >= $targetWordLength ) {
if( $characterDeficit == 0 ) //If the word is full and we're not short any characters, ignore the character
continue;
else
$characterDefecit--; //If we are short some characters, decrement the defecit and carry on with adding the character to the abbreviation
}
$abbreviation .= $currentChar; //Add the character to the abbreviation
$abbrevLength++; //Increment abbreviation length
$wordIndex++; //Increment the number of characters for this word
}
return $abbreviation;
}
}
use \Mpdf\Mpdf;
class erpLetterPad extends Mpdf {
// header starts
function Header() {
list($width, $height, $type, $attr) = getimagesize('images/' .str_replace('c.', '.', $banner['nameHindi']));
if ($this->banner['logoImage']) $this->Image('images/' .$this->banner['logoImage'], 6, 8, 20);
$this->Image('images/' .str_replace('c.', '.', $this->banner['nameHindi']), ($this->w - 148) / 2, 7, 143, 6);
$this->SetXY(10, 12);
$this->SetFont('Helvetica','B', 15);
$this->Cell(0, 10, $this->banner['instituteName'], 0, 1, 'C');
$this->SetFont('Helvetica', 'I', 8);
$this->Cell(0, 3, '(' .$this->banner['brandTagline']. ')', 0, 1, 'C');
$this->SetFont('Helvetica', 'B', 10);
$this->Cell(0, 2, '', 0, 1, 'C');
$this->Cell(0, 4, $this->banner['address'], 0, 1, 'C');
$this->SetFont('Helvetica', 'B', 9);
$this->Cell(0, 4, 'Phone: ' .$this->banner['phoneNo']. ', Email: ' .$this->banner['email']. ', Web: ' .$this->banner['website'], 0, 1, 'C');
$this->Line(0, 36, 500, 36);
$this->Ln(10);
// header ends
}
}
class erpCard extends Mpdf {
var $extgstates = array();
function Header() {
if ($this->page % 2) {
$this->Rect(0, 0, 100, 17 , F);
$this->SetFillColor(0, 32, 100);
if ($this->banner['logoImage']) {
$this->Image('images/' .$this->banner['logoImage'], 1, 4, 10, 10);
//$x = ($this->w - 65) / 2;
$x1 = $this->page == 1 ? 10 : 10;
$x2 = $this->page == 1 ? 10 : 6;
} else {
$x1 = $this->page == 1 ? 6 : 7;
$x2 = $this->page == 1 ? 5.9 : 2;
}
$this->Image('images/' .$this->banner['nameHindi'], $x1, 1.5, 72.5, 4);
$this->SetTextColor(255, 245, 0);
$this->SetXY($x2 * 1.65, 7);
$this->SetFont('Helvetica', 'B', 8);
$this->Cell(0, 0, $this->banner['instituteName'], 0, 1, 'C');
$this->SetXY($x2, 10);
$this->SetFont('Helvetica', 'I', 6);
$this->Cell(0, 0, '(' .$this->banner['brandTagline']. ')', 0, 1, 'C');
$this->SetXY($x2, 12.5);
$this->SetFont('Helvetica', 'B', 6);
$this->Cell(0, 0, 'Government of India', 0, 1, 'C');
$this->SetXY($x2, 15.5);
$this->SetFont('Helvetica', '', 6);
$this->Cell(0, 0, $this->banner['address'], 0, 1, 'C');
$this->Line(0, 17, 100, 17);
$this->Ln(4);
}
}
// alpha: real value from 0 (transparent) to 1 (opaque)
// bm: blend mode, one of the following:
// Normal, Multiply, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn,
// HardLight, SoftLight, Difference, Exclusion, Hue, Saturation, Color, Luminosity
/*
function SetAlpha($alpha, $bm='Normal') {
// set alpha for stroking (CA) and non-stroking (ca) operations
$gs = $this->AddExtGState(array('ca'=>$alpha, 'CA'=>$alpha, 'BM'=>'/'.$bm));
$this->SetExtGState($gs);
}
function AddExtGState($parms) {
$n = count($this->extgstates)+1;
$this->extgstates[$n]['parms'] = $parms;
return $n;
}
function SetExtGState($gs) {
$this->_out(sprintf('/GS%d gs', $gs));
}
function _enddoc() {
if(!empty($this->extgstates) && $this->PDFVersion<'1.4')
$this->PDFVersion='1.4';
parent::_enddoc();
}
function _putextgstates() {
for ($i = 1; $i <= count($this->extgstates); $i++) {
$this->_newobj();
$this->extgstates[$i]['n'] = $this->n;
$this->_out('<</Type /ExtGState');
$parms = $this->extgstates[$i]['parms'];
$this->_out(sprintf('/ca %.3F', $parms['ca']));
$this->_out(sprintf('/CA %.3F', $parms['CA']));
$this->_out('/BM '.$parms['BM']);
$this->_out('>>');
$this->_out('endobj');
}
}
function _putresourcedict() {
parent::_putresourcedict();
$this->_out('/ExtGState <<');
foreach($this->extgstates as $k=>$extgstate)
$this->_out('/GS'.$k.' '.$extgstate['n'].' 0 R');
$this->_out('>>');
}
function _putresources() {
$this->_putextgstates();
parent::_putresources();
}
*/
}
class idCard extends FPDF {
var $extgstates = array();
// alpha: real value from 0 (transparent) to 1 (opaque)
// bm: blend mode, one of the following:
// Normal, Multiply, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn,
// HardLight, SoftLight, Difference, Exclusion, Hue, Saturation, Color, Luminosity
function SetAlpha($alpha, $bm='Normal') {
// set alpha for stroking (CA) and non-stroking (ca) operations
$gs = $this->AddExtGState(array('ca'=>$alpha, 'CA'=>$alpha, 'BM'=>'/'.$bm));
$this->SetExtGState($gs);
}
function AddExtGState($parms) {
$n = count($this->extgstates)+1;
$this->extgstates[$n]['parms'] = $parms;
return $n;
}
function SetExtGState($gs) {
$this->_out(sprintf('/GS%d gs', $gs));
}
function _enddoc() {
if(!empty($this->extgstates) && $this->PDFVersion<'1.4')
$this->PDFVersion='1.4';
parent::_enddoc();
}
function _putextgstates() {
for ($i = 1; $i <= count($this->extgstates); $i++) {
$this->_newobj();
$this->extgstates[$i]['n'] = $this->n;
$this->_out('<</Type /ExtGState');
$parms = $this->extgstates[$i]['parms'];
$this->_out(sprintf('/ca %.3F', $parms['ca']));
$this->_out(sprintf('/CA %.3F', $parms['CA']));
$this->_out('/BM '.$parms['BM']);
$this->_out('>>');
$this->_out('endobj');
}
}
function _putresourcedict() {
parent::_putresourcedict();
$this->_out('/ExtGState <<');
foreach($this->extgstates as $k=>$extgstate)
$this->_out('/GS'.$k.' '.$extgstate['n'].' 0 R');
$this->_out('>>');
}
function _putresources() {
$this->_putextgstates();
parent::_putresources();
}
function Header() {
if ($this->page % 2) {
$this->SetDisplayMode(real, 'default');
$this->Rect(0, 0, 100, 17 , F);
$this->SetFillColor(0, 32, 100);
if ($this->banner['logoImage']) {
$this->Image('images/' .$this->banner['logoImage'], 1, 4, 10, 10);
$x1 = $this->page == 1 ? 10 : 10;
$x2 = $this->page == 1 ? 10 : 6;
} else {
$x1 = $this->page == 1 ? 6 : 7;
$x2 = $this->page == 1 ? 5.9 : 2;
}
$this->Image('images/' .$this->banner['nameHindi'], $x1, 1.5, 72.5, 4);
$this->SetTextColor(255, 245, 0);
$this->SetXY($x2 * 1.65, 7);
$this->SetFont('Helvetica', 'B', 8);
$this->Cell(0, 0, $this->banner['instituteName'], 0, 1, 'C');
$this->SetXY($x2, 10);
$this->SetFont('Helvetica', 'I', 6);
$this->Cell(0, 0, '(' .$this->banner['brandTagline']. ')', 0, 1, 'C');
$this->SetXY($x2, 12.5);
$this->SetFont('Helvetica', 'B', 6);
$this->Cell(0, 0, 'Government of India', 0, 1, 'C');
$this->SetXY($x2, 15.5);
$this->SetFont('Helvetica', '', 6);
$this->Cell(0, 0, $this->banner['address'], 0, 1, 'C');
$this->Line(0, 17, 100, 17);
$this->Ln(4);
try {
// set alpha to semi-transparency
$this->SetAlpha(0.5);
$this->Image('images/' .strtolower($this->banner['instituteCode']). '.png', 4, 17, 78, 33);
$this->SetAlpha(1);
} catch (Exception $e) {
$this->Write(5, $e->getMessage());
}
}
}
}
class ihcReport extends FPDF {
function Header() {
//if ($this->page == 1) {
list($width, $height) = getimagesize('images/' .str_replace('c.', '.', $this->banner['nameHindi']));
if ($this->banner['logoImage']) $this->Image('images/' .$this->banner['logoImage'], 6, 8, 20);
$this->Image('images/' .str_replace('c.', '.', $this->banner['nameHindi']), ($this->w - 134) / 2, 7, 134, 6);
$this->SetXY(10, 12);
$this->SetFont('Helvetica','B', 15);
$this->Cell(0, 10, $this->banner['instituteName'], 0, 1, 'C');
$this->SetFont('Helvetica', 'I', 8);
$this->Cell(0, 3, '(' .$this->banner['brandTagline']. ')', 0, 1, 'C');
$this->SetFont('Helvetica', 'B', 10);
$this->Cell(0, 2, '', 0, 1, 'C');
$this->Cell(0, 4, $this->banner['address'], 0, 1, 'C');
$this->SetFont('Helvetica', 'B', 9);
$this->Cell(0, 4, 'Phone: ' .$this->banner['phoneNo']. ', Email: ' .$this->banner['email']. ', Web: ' .$this->banner['website'], 0, 1, 'C');
$this->SetAlpha(0.5);
$this->Image('images/icure.jpg', 275, 8, 16);
$this->SetAlpha(1);
$this->Line(0, 36, 500, 36);
$this->Ln(14);
//}
}
function Footer() {
/*
$this->SetY(-10);
$this->SetDrawColor(188, 188, 188);
$this->SetLineWidth(1);
$this->Line(startpoint, 25, endpoint-30, 25);
$this->SetXY(65, -5);
$this->SetFont('Helvetica', 'I', 8);
$this->Write(5, 'Please use this receipt for your education loan from any bank.');
*/
}
}
?>