Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/erp/views/
Upload File :
Current File : /var/www/html/mmishra/erp/views/dept_view.php

<?php
//if (!class_exists($erpView)) {
	require_once __DIR__."/erp_view.php";
//}

class deptView extends erpView {
    
    var $controller;
    var $model;
    
    public function __construct($controller, $model) {
        
        $this->controller 	= $controller; 	// instantiate controller
        $this->model 		= $model;		// 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 deptFundhead($action, $headID) {
		$app			= $this->controller->app;
		$menu			= $this->controller->menu;
		$headID 		= $this->controller->manageFundhead($action, $headID);// initiate controller action 
		// controller locks/unlocks field through manage call
		$ro 			= $this->controller->editLock;							// ensure default edit lock
        $rows 			= $this->model->listFundheads();					// get record
		$toolbar 		= $this->erpToolbar();
		
        $str = "<h3>" .$this->model->getMenuTitle($menu). "$toolbar</h3>
		<table width='100%'>
		<tr><th>#</th><th>Head Name</th><th>Nature</th><th>Status</th></tr>";
        foreach($rows as $row) {
			$i++;
			$bgcolor = ($i % 2) ? '#f4f6f6' : '';
						
			$str .= "<tr bgcolor='$bgcolor'>";
			if ($headID == $row['headID']) {
				$str .= "<td>$i<input type='hidden' name='headID' value='" .$row['headID']. "'></td>
				<td><input type='text' name='headName' size='50' value='" .$row['headName']. "' placeholder='Budget head name'></td>
				<td><select name='headNature' style='width: 265px'>";
				foreach ($this->controller->headNatures as $hn) {
					$str .= "<option value='" .$hn. "'" .($row['headNature'] == $hn ? ' selected' : ''). ">" .$hn. "</option>";
				}
				$str .= "</select></td>";
			} else {
				$str .= "<td><a href='' onclick=\"inner('$app/$menu/edit/" .$row['headID']. "'); return false;\" title='Edit record'>$i</a></td>
				<td>" .$row['headName']. "</td><td>" .$row['headNature']. "</td>";
			}
			$str .= "<td>" .($row['status'] == 'Enabled' ? "<i class='far fa-thumbs-up'></i></span>" : "<i class='far fa-thumbs-down'></i></span>"). "</td></tr>";
        }
		
		$str .= "<tr bgcolor='$bgcolor'>";
		if ($headID) {
			$str .= "<td><a href='' onclick=\"inner('$app/$menu/edit/0'); return false;\" title='New record'>New</a></td>";
		} else {
			$i++;
			$str .= "<td>$i<input type='hidden' name='headID' value='0'></td>
			<td><input type='text' name='headName' size='50' value='' placeholder='Budget head name'></td>
			<td><select name='headNature' style='width: 265px'>";
			foreach ($this->controller->headNatures as $hn) {
				$str .= "<option value='" .$hn. "'>" .$hn. "</option>";
			}
			$str .= "</select></td>";
		}
		$str .= "<td></td></tr>
		</table>$toolbar";
				
        return $str;
    }

    public function deptBudget($action, $budgetID) {
		$app 			= $this->controller->app;								// application envoked        
		$menu 			= $this->controller->menu;								// menu envoked        
		$instituteID 	= $this->controller->instituteID;								// menu envoked        
		$budgetID 		= $this->controller->manageBudget($action, $budgetID);  // initiate controller action  
		$ro 			= $this->controller->editLock; 							// ensure default edit lock    	
        $data 			= $this->model->getBudget($budgetID);					// get record
		$toolbar 		= $this->erpToolbar() .$this->erpTogglebar();

        $str = "<h3>" .$this->model->getMenuTitle($menu). "$toolbar</h3>
        <table width='100%'>
		<tr><th width='70%'>Budget Details (ID: $budgetID)</th><th width='30%'>Budget List</th></tr>
        <tr valign='top'><td>
        <table class='interface'>
        <tr><td width='20%' nowrap>Department</td><td><select name='deptID' style='width: 265px'>";
        $depts 	= $this->model->selectDepartment($instituteID);						// get module list
		foreach ($depts as $dept) {
			$str .= "<option value='" .$dept['deptID']. "'" .($row['deptID'] == $dept['deptID'] ? ' selected' : ''). ">" .$dept['deptName']. "</option>";
		}
		$str .= "</select></td></tr>
		<tr><td nowrap>Budget Head</td><td><select name='headID' style='width: 265px'>";
        $heads 	= $this->model->selectFundhead();						// get module list
		foreach ($heads as $head) {
			$str .= "<option value='" .$head['headID']. "'" .($head['headID'] == $data['headID'] ? ' selected' : ''). ">" .$head['headName']. "</option>";
		}
		$str .= "</select></td></tr>
        <tr><td nowrap>Account Year</td><td><input type='text' name='accountYear' size='15' value='" .$data['accountYear']. "' placeholder='yyyy-yy format' $ro></td></tr>
        <tr><td nowrap>Amount</td><td><input type='text' name='amount' size='50' value='" .$data['amount']. "' placeholder='In rupees' $ro></td></tr>
        </table>
        </td><td><ol class='listbar'>";
        
        $rows = $this->model->listBudgets();
        foreach($rows as $row) {
            $str .= "<li>";
            if ($row['budgetID'] == $budgetID) {
                $str .= "<b>" .$row['amount']. "</b> (" .$row['accountYear']. ")";
            } else {
                $str .= "<a href='' onclick=\"inner('$app/$menu/open/" .$row['budgetID']."'); return false;\">" .$row['amount']. "</a> (" .$row['accountYear']. ")";
            }
            $str .= "</li>";
        }
        $str .= "</ol></td></tr>
        </table>$toolbar";
		
        return $str;
    }

	public function deptUtilization($action, $expenseID) {
		$app1 			= $this->controller->app;							// application envoked        
		$menu 			= $this->controller->menu;							// menu envoked        
		$instituteID 	= $this->controller->instituteID;								// menu envoked        
		$expenseID 		= $this->controller->manageUtilization($action, $expenseID);	// initiate controller action
		$ro 			= $this->controller->editLock;						// ensure default edit lock
        $data 			= $this->model->getUtilization($expenseID);			// get app record
		$toolbar 		= $this->erpToolbar() .$this->erpTogglebar();

        $str = "<h3>" .$this->model->getMenuTitle($menu). "$toolbar</h3>
		<table width='100%'>
		<tr><th width='70%'>Utilization Details (ID: $expenseID)</th><th width='30%'>Utilization List</th></tr>
		<tr valign='top'><td>
		<table class='interface'>
		<tr><td width='20%' nowrap>Department</td><td><select name='deptID' style='width: 265px'>";
        $depts 	= $this->model->selectDepartment($instituteID);						// get module list
		foreach ($depts as $dept) {
			$str .= "<option value='" .$dept['deptID']. "'" .($dept['deptID'] == $data['deptID'] ? ' selected' : ''). ">" .$dept['deptName']. "</option>";
		}
		$str .= "</select></td></tr>
		<tr><td nowrap>Utilization Head</td><td><select name='headID' style='width: 265px'>";
        $heads 	= $this->model->selectFundhead();						// get module list
		foreach ($heads as $head) {
			$str .= "<option value='" .$head['headID']. "'" .($head['headID'] == $data['headID'] ? ' selected' : ''). ">" .$head['headName']. "</option>";
		}
		$str .= "</select></td></tr>
		<tr><td nowrap>Account Year</td><td><input type='text' name='accountYear' size='15' value='" .$data['accountYear']. "' placeholder='yyyy-yy format' $ro></td></tr>
		<tr><td nowrap>Amount</td><td><input type='text' name='amount' size='50' value='" .$data['amount']. "' placeholder='In rupees' $ro></td></tr>
		<tr><td nowrap>Description</td><td><input type='text' name='description' size='50' value='" .$data['description']. "' placeholder='Description of expenditure' $ro></td></tr>
		<tr><td nowrap>Faculty Name</td><td><input type='text' name='facultyID' size='50' value='" .$data['facultyID']. "' placeholder='Faculty user' $ro></td></tr>
        </table>
		
		</td><td><ul class='listbar'>";
		
        $rows = $this->model->listUtilizations();
        foreach($rows as $row) {
			if ($deptID != $row['deptID']) {
				$str .= ($deptID ? "</ol></li>" : '') . "<li><b>" .$row['deptID']. "</b><ol>";
			}
			$str .= "<li>";
            if ($row['headID'] == $headID) {
                $str .= "<b>" .$row['headID']. "</b> (" .$row['status']. ")";
            } else {
				$str .= "<a href='' onclick=\"inner('$app1/$menu/open/" .$row['expenseID']."'); return false;\">" .$row['expenseID']. "</a> (" .$row['status']. ")";
            }
            $str .= "</li>";
			$deptID = $row['deptID'];
        }
        $str .= "</ul></td></tr>
        </table>$toolbar";

        return $str;
	}  
/*
	public function deptPurchase($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);
        $apps	 		= $this->model->selectApp();				// list enabled apps only
        $acls 			= $this->model->getMenuACLs($menuID);
        $menus 			= $this->model->listMenus($filterText);
		$toolbar 		= $this->erpToolbar() .$this->erpTogglebar();

        $str = "<h3>" .$this->model->getMenuTitle($menu1). "$toolbar</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'>";
		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. " &nbsp;";
		}
		$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
       	foreach($acls as $acl) {
           	if ($acl['aclRead']) $str .= "<li>" .$acl['loginID']. " [ " .($acl['aclRead'] ? 'Read ' : '').($acl['aclInsert'] ? 'Insert ' : '').($acl['aclUpdate'] ? 'Update ' : '').($acl['aclDelete'] ? 'Delete ' : ''). " ]</li>";
       	}
        $str .= "</ol></td><td> 
		<ol class='listbar'>";
        foreach($menus as $row) {
			if ($appName != $row['appName']) {
				$str .= ($appName ? "</ol></li>" : '') . "<li><b>" .$row['appName']. "</b><ol>";
			}        
            $str .= "<li>";
            if ($row['menuID'] == $menuID) {
                $str .= "<b><i class='" .$row['menuIcon']. "'></i> " .$row['menuName']. "</b> (" .$row['status']. ")";
            } else {
                $str .= "<i class='" .$row['menuIcon']. "'></i> <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>$toolbar";

        return $str;
	}

	public function deptDocfile($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;

        $menus 			= $this->model->selectMenu();

        $rows 			= $this->model->listGroups($filterText);
		$i 				= 0;		
		$togglebar 		= $this->erpTogglebar();
		$toolbar 		= $this->erpToolbar();

        $str = "<h3>" .$this->model->getMenuTitle($menu). "$togglebar $toolbar</h3>
		<table width='100%' class='interface'>
		<tr><th>#</th><th>Group Name</th><th>Description</th><th>Dashboard</th><th>Members</th><th>Status</th></tr>";
        foreach($rows as $row) {
			$i++;
			$bgcolor = ($i % 2) ? '#f4f6f6' : '';
						
			$str .= "<tr bgcolor='$bgcolor'>";
			if ($groupID == $row['groupID']) {
				$str .= "<td>$i<input type='hidden' name='groupID' value='" .$row['groupID']. "'></td>
				<td nowrap><i class='fas fa-users'></i><input type='text' name='groupName' size='30' value='" .$row['groupName']. "' $ro> (ID: " .$row['groupID']. ")</td>
				<td><input type='text' name='description' size='50' value='" .$row['description']. "' placeholder='Define role of the group' $ro></td>
				<td><select name='dashboard' style='width: 200px'>
				<option value='erpDashboard'>Dafault</option>";
				foreach ($menus as $dboard) {
					$code = $dboard['appCode']. ucwords($dboard['menuURL']);
					if (substr($dboard['menuURL'], 0, 4) != "http") $str .= "<option value='" .$code. "'" .($row['dashboard'] == $code ? ' selected' : ''). ">" .$code. "</option>";
				}
				$str .= "</select></td><td>" .$row['memberCount']. "</td>";
			} else {
				$str .= "<td><a href='' onclick=\"inner('$app/$menu/edit/" .$row['groupID']. "'); return false;\" title='Edit record'>$i</a></td>
				<td><i class='fas fa-users'></i> " .$row['groupName']. "</td>
				<td>" .$row['description']. "</td><td>" .$row['dashboard']. "</td><td>" .$row['memberCount']. "</td>";
			}
			$str .= "<td>" .($row['status'] == 'Enabled' ? "<i class='far fa-thumbs-up'></i></span>" : "<i class='far fa-thumbs-down'></i></span>"). "</td></tr>";
        }
		
		$str .= "<tr bgcolor='$bgcolor'>";
		if ($groupID) {
			$str .= "<td><a href='' onclick=\"inner('$app/$menu/edit/0'); return false;\" title='New record'>New</a></td>";
		} else {
			$i++;
				
			$str .= "<td>New<input type='hidden' name='groupID' value='0'></td>
			<td nowrap><i class='fas fa-users'></i><select name='groupName' style='width: 250px'>
			<option value=''>Select from LDAP</option>";
			$ds 				= ldap_connect("ldap://172.31.1.41:389");
			ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);

			$data 				= ldap_search($ds, "dc=iiita,dc=ac,dc=in", "ou=*");
			$rows				= ldap_get_entries($ds, $data);
			arsort($rows);
			foreach ($rows as $row) {
				$dn 			= strtolower($row['dn']);
				$dn 			= str_replace(',dc=iiita,dc=ac,dc=in', '', $dn);
				$desc 			= $row['description'][0] . $row['gecos'][0] . $row['cn'][0];
				if (strpos($dn, 'employee') || strpos($dn, 'student')) {
					$ous1		= explode(',', $dn);
					$ous1 		= str_replace('ou=', '', $ous1);
					$ous3 		= '';
					foreach ($ous1 as $ou) {
						$ous3 = $ou. '-' .$ous3;
					}
					$ous3		= rtrim($ous3, '-');
					if ($ous3 && !$this->model->getGroupIDByGroupName($ous3)) {
						$str .= "<option value='$ous3'>" .$ous3. "</option>";
					}
				}
			}
			$str .= "<option value='Others'>Others</option></select></td>
			<td><input type='text' name='description' size='50' value='$desc' placeholder='Define role of this user group'></td>
			<td><select name='dashboard' style='width: 200px'>
			<option value='erpDashboard'>Dafault</option>";
			foreach ($menus as $dboard) {
				if (substr($dboard['menuURL'], 0, 4) != "http") $str .= "<option value='" .$dboard['appCode']. ucwords($dboard['menuURL']). "'" .($row['dashboard'] == $dboard['appCode'] ? ' selected' : ''). ">" .$dboard['appCode']. ucwords($dboard['menuURL']). "</option>";
			}
			$str .= "</select></td>";
			ldap_close($ds);
		}
		$str .= "<td></td></tr>
		</table>$togglebar $toolbar";
		
        return $str;
	}
	*/
}
?>