0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 3.133.145.168


Current Path : /var/www/oasis/src_old/
Upload File :
Current File : /var/www/oasis/src_old/getfeeinformation_bulk.php

<?php

	function getfeeInformation($aobj_context)
	{
		$query1="select group_concat(FCATEGORY separator '*') as cat from category order by FCATEGORY";
		$results1 = $aobj_context->mobj_db->GetRow($query1);

		$query = "select group_concat(distinct FEXAMNO separator '*') as exam from degree where ifnull(FEXAMNO,'') <> ''";
		$results = $aobj_context->mobj_db->GetRow($query);

		$query2="SELECT DISTINCT FCONSTYPE as internal_code,FCONSTYPE as value FROM admfeestr where ifnull(FCONSTYPE,'') <> '' ORDER BY 1 DESC ";
		$results2 = $aobj_context->mobj_db->GetAll($query2);

		$query3 = "select distinct fdeggrp as internal_code, fdeggrp as value from degree where ifnull(fdeggrp,'') <> '' order by fdeggrp";
		$results3 = $aobj_context->mobj_db->GetAll($query3);
		
		$arr['FEXAMNO']=$results;
		$arr['category']=$results1;
		$arr['FCONSTYPE']=$results2;
		$arr['FDEGREE']=$results3;
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
	}
	
	function displayfeeDetails($aobj_context)
	{
		$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
		$degreegrp = $aobj_context->mobj_data["degreegrp"];
		$examno = $aobj_context->mobj_data["examno"];
		$examno_array = json_decode($examno, true);
		$feetype = $aobj_context->mobj_data["feetype"];
		$category = $aobj_context->mobj_data["category"];
		$category_array = json_decode($category, true);
		
		$examno = implode("','", $examno_array);
		$category = implode("','", $category_array);

		$query = "select group_concat(distinct fdegree separator ',') as degree from degree where fdeggrp = '{$degreegrp}'";

		$results = $aobj_context->mobj_db->GetRow($query);

		$degree = $results['degree'];

		$degreeArr = explode(',', $degree);
		$degree = implode("','", $degreeArr);

		$feeHeadCntQuery = "select count(*) as headCnt from masfee where length(ffeecode) > 2";
		$feeHeadCntRes = $aobj_context->mobj_db->GetRow($feeHeadCntQuery);

		$feeHeadCnt = $feeHeadCntRes['headCnt'];

		$query = "select distinct mf.ffeecode, mf.fdescpn, ifnull(am.ffee,0) as ffee, 
		ifnull(am.fprfee,0) as fprfee, ifnull(am.fmaxfee,0) as fmaxfee, 
		ifnull(am.frepfee,0) as frepfee, ifnull(am.frepprfee,0) as frepprfee,
		'' as fromdate, '' as todate 
		from masfee mf left outer join  admfeestr am 
		on mf.ffeecode = am.fheadcode and am.fdegree in ('{$degree}') 
		and am.fexamno in ('{$examno}') and am.fcatcode in ('{$category}') 
		and am.fconstype = '{$feetype}'
		where length(mf.ffeecode) > 2 order by mf.fsequence";
		// var_dump($query);
		$results = $aobj_context->mobj_db->GetAll($query);

		$feeRowsCnt = count($results);

		$query1 = "select distinct mf.ffeecode, mf.fdescpn, ifnull(am.ffee,0) as ffee, 
		ifnull(am.fprfee,0) as fprfee, ifnull(am.fmaxfee,0) as fmaxfee, 
		ifnull(am.frepfee,0) as frepfee, ifnull(am.frepprfee,0) as frepprfee,
		date_format(am.fadmfeesdate,'%d/%m/%Y') as fromdate,
		date_format(am.fadmfeeedate,'%d/%m/%Y') as todate 
		from masfee mf left outer join  admfeestr am 
		on mf.ffeecode = am.fheadcode and am.fdegree in ('{$degree}') 
		and am.fexamno in ('{$examno}') and am.fcatcode in ('{$category}') 
		and am.fconstype = '{$feetype}'
		where length(mf.ffeecode) > 2 
		group by mf.ffeecode 
		order by mf.fsequence, am.fmaxfee desc";
		
		$results1 = $aobj_context->mobj_db->GetAll($query1);

		$i = 1;
		$j= 0;

		$details = "";
		
		foreach($results1 as $ak=>$av)
		{
				$details.="<tr class='content'>
				<td>
					<input type = 'text' id='head{$j}'  disabled name = 'feecode' value = '{$av['ffeecode']}'/>
				</td>
				<td>
					<input type = 'text' id='headname{$j}' name='descpn' style = 'width:150px'  disabled  value = '{$av['fdescpn']}'/>
				</td>
				<td>
					<input type = 'text' id='fee{$j}' name='fee' style = 'width:45px;text-align:right' value = '{$av['ffee']}' />
				</td> 
				<td width = '10px'> 
					<input type = 'text' id='feepr{$j}' name='prfee' style = 'width:45px;text-align:right' value = '{$av['fprfee']}'/> 
					<input type = 'hidden' id='feeprh{$j}' style = 'width:50px' value = 'T'/>
				</td>
				<td width = '10px'> 
					<input type = 'text' id='feemax{$j}' style = 'width:45px;text-align:right' name='maxfee' value = '{$av['fmaxfee']}'/> 
				</td> 
				<td width = '10px'> 
					<input type = 'text' id='feere{$j}' style = 'width:45px;text-align:right' name='repfee' value = '{$av['frepfee']}' />
				</td> 
				<td width = '10px'> 
					<input type = 'text' id='feerepr{$j}' style = 'width:45px;text-align:right' name='repprfee' value = '{$av['frepprfee']}'/> 
				</td>
				<td width = '150px'> 
					<input type = 'text' id='fromdate{$j}' name='fromdate' onkeydown = 'dmydateformat(event,this.id)'   maxlength = 10 style = 'width:80px;text-align:left;float:left;' placeholder = 'dd/mm/yyy' value = '{$av['fromdate']}'/>
				</td> 
				<td width = '10px'> 
					<input type = 'text' id='todate{$j}' name='todate' onkeydown = 'dmydateformat(event,this.id)'   style = 'width:100px;text-align:left' placeholder = 'dd/mm/yyy'  value = '{$av['todate']}'/>
				</td> 
			</tr>";
			$j++;
		}
		$arr['details'] = $details;
		$arr['totallength'] = $j;
		$arr['feeRowsCnt'] = $feeRowsCnt;
		$arr['feeHeadCntRes'] = $feeHeadCnt;

		if($feeRowsCnt == $feeHeadCnt){
			$arr['diff'] = 'F';
		}
		else
		{
			$arr['diff'] = 'T';	
		}
		
		echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
	
	}
	
	function savefeeInformation($aobj_context)
	{
		$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
		$degreegrp = $aobj_context->mobj_data["degreegrp"];
		$examno = $aobj_context->mobj_data["examno"];
		$examno_array = json_decode($examno, true);
		$feetype = $aobj_context->mobj_data["feetype"];
		$category = $aobj_context->mobj_data["category"];
		$category_array = json_decode($category, true);
		$fees = $aobj_context->mobj_data["feedetail"];
		$fee_array = json_decode($fees, true);

		$examno = implode("','", $examno_array);
		$category = implode("','", $category_array);

		$query = "select group_concat(distinct fdegree separator ',') as degree from degree where fdeggrp = '{$degreegrp}'";

		$results = $aobj_context->mobj_db->GetRow($query);

		$degree = $results['degree'];

		$degreeArr = explode(',', $degree);
		$degree = implode("','", $degreeArr);

		foreach($fee_array as $key=>$value)
		{
			$delete_query = "delete from admfeestr where fdegree in ('{$degree}') 
			and fexamno in ('{$examno}') and fcatcode in ('{$category}') 
			and fconstype = '{$feetype}' and fheadcode = '{$value['feecode']}'";
			$result1 = $aobj_context->mobj_db->Execute($delete_query);

			if($result1) {
				$insert_query = "insert into admfeestr (fdegree, fexamno, 
				fcombcode, fcatcode,
				fheadcode, fconstype, ffee, fprfee, fmaxfee, frepfee, frepprfee, 
				fadmfeesdate, fadmfeeedate)
				select dg.fdegree, dg.fexamno, 'EXAM', ct.fcategory, 
				'{$value['feecode']}', '{$feetype}', '{$value['fee']}', 
				'{$value['prfee']}', '{$value['maxfee']}', '{$value['repfee']}', 
				'{$value['repprfee']}',
				date_format(str_to_date('{$value['fromdate']}', 
				'%d/%m/%Y'),'%Y-%m-%d') as fadmfeesdate, 
				date_format(str_to_date('{$value['todate']}','%d/%m/%Y'),
				'%Y-%m-%d') as fadmfeeedate 
				from degree dg, category ct
				where dg.fdegree in ('{$degree}') and 
				dg.fexamno in ('{$examno}')
				and ct.FCATEGORY in ('{$category}')";
				$result2 = $aobj_context->mobj_db->Execute($insert_query);

				if(!$result2) {
					break;
				}
			}
			else {
				break;
			}
		}

		if($result2 && $result1) {
			$arr['msg'] = 'Fees updated successfully';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
		} else {
			$arr['msg'] = 'Error While updating the fees';
			echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"error");
		}
	}
?>