<?php
require "commonincludefiles.php";
$str1 = "";
$str4 = "";
$str6 = "";
$str7 = "";
$objEmployeeMgmt = new EmployeeMgmt();
$objUserMgmt = new UserMgmt();
$objDesignationMgmt = new DesignationMgmt();
$objpayscaleMgmt = new payscaleMgmt();



$result = $objUserMgmt->getAllRecords($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "");
/*$qry = "SELECT * FROM `cms_usermaster`";
   $result = dbQuery($qry);*/
if (dbRows($result) > 0) {
	while ($record = dbArray($result)) {
		$str4 .= "['" . $record['user_id'] . "','" . $record['user_name'] . "'],";
	}
}
$result = $objDesignationMgmt->getAllRecords($limit = 0, $start = 0, $condition = "", $order_field = "designation_id", $order_type = "ASC");
/*$qry = "SELECT * FROM `cms_designation` ORDER BY `cms_designation`.`designation_id` ASC";
	  $result=dbQuery($qry);*/
$str2 = "";
if (dbRows($result) > 0) {
	while ($record = dbArray($result)) {
		$str2 .= "['" . $record['designation_id'] . "','" . $record['designation_nameeng'] . "','" . $record['dept_type'] . "'],";
	}
}
//echo $str2;
$result = $objpayscaleMgmt->getAllRecords($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "");

/*$qry = "SELECT * FROM cms_payscalemaster  ";
   $result=dbQuery($qry);*/
$payscale = "";
$str3 = "";
if (dbRows($result) > 0) {
	while ($record = dbArray($result)) {
		$payscale = $record["current_payscale"] . " / " . $record["payband"] . " / " . $record["gradepay"];
		$str3 .= "['" . $record['payscale_id'] . "','" . $payscale . "'],";
	}
}

/* year combo */
foreach (range(2000, 2025) as $number) {
	$str7 .= "['" . $number . "'],";
}


$condition = " AND em.employee_active='Yes' ";

if ($_SESSION["VedantnrUserRole"] != 'PowerUser' && $_SESSION['aUserId'] != '276' && $_SESSION['aUserId'] != '34') {
	$condition = " AND em.user_id ='" . $_SESSION["VedantnrUserId"] . "'";
}
$result = $objEmployeeMgmt->getSalaryRecords(0, 0, $condition, "", "");
if (dbRows($result) > 0) {
	while ($record = dbArray($result)) {
		$str6 .= "['" . $record['branch_id'] . "',
			           '" . $record['employee_id'] . "',
					   '" . $record['employee_no'] . "',
					   '" . $record['employee_name'] . "',
					   '" . $record['employee_basicsalary'] . "',
					    '" . $record['loan_amount'] . "',
						  '" . $record['employee_loan'] . "',
						'" . $record['loan_date'] . "',
						'" . $record['loan_month'] . "',
						
						
					   '" . $record['employee_payscale'] . "'],";
	}
}


$str2 = substr($str2, 0, strlen($str2) - 1);
$str3 = substr($str3, 0, strlen($str3) - 1);

$str6 = substr($str6, 0, strlen($str6) - 1);
$str7 = substr($str7, 0, strlen($str7) - 1);

?>
<script type="text/javascript" language="javascript">
	Ext.namespace('Ext.employee');
	Ext.employee.designation = [<?php echo $str2; ?>];
	Ext.employee.payscale = [<?php echo $str3; ?>];
	Ext.employee.userid = [<?php echo $str4; ?>];

	Ext.employee.salinfo = [<?php echo $str6; ?>];
	Ext.employee.year = [<?php echo $str7; ?>];

</script>