<?php
session_start();
error_reporting(0);
$user_name=$_SESSION['user_name'];
if(empty($user_name))
 {
 header("location:index.php");
 }

include_once("database_connection.php"); 
$sqlu="select id from user_tblsbifi where user_name='$user_name' " ;
$resultu=mysqli_query($conn,$sqlu);
$datau=mysqli_fetch_array($resultu);
$idu=$datau['id'];

?>
<html>
<body style='bgcolor="#E6E6FA" border="10px;solid black;" width=100%; height=100%'>
<head>
  <title>Case:Management</title>
    <script type="text/javascript">
    function noBack() { window.history.forward(); }
    noBack();
    window.onload = noBack;
    window.onpageshow = function (evt) { if (evt.persisted) noBack(); }
    window.onunload = function () { void (0); }
	</script>	
  <style>
  #searchbutton  {
	background-color:#228B22;
	color:#FFF;
	padding:5px;
	border-radius:8px;
	font-weight:bold;
}
#searchbutton:hover  {
	background-color:#228B22;
	color:#FFF;
	padding:5px;
	border-radius:8px;
}
.button {
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;
}


.button {background-color: #0080ff;}
</style>
  <link type="text/css" href="menu/menu_admin.css" rel="stylesheet" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<style type="text/css">
    .bs-example{
    	margin: 20px;
    } 
	.center {
 text-align: center
}
</style>
  </head>
<body>
<div class="background">
<form method ="post" action=""/>
<?php
if(isset($_POST['txtsubmit']) && $_POST['txtsubmit']=='Refresh')
	{		
		$_POST['case_id']='';		
		$_POST['agency_code']='';
		$_POST['mobile_no']='';
		$_POST['app_no']='';
}
if(isset($_POST['txtsubmit']) && $_POST['txtsubmit']=='Filter')
	{
	$case_id=$_POST['case_id'];		
	$agency_code=	$_POST['agency_code'];
	$mobile_no=	$_POST['mobile_no'];
	$app_no=	$_POST['app_no'];
	}

	include("header2.php");
	if(($_SESSION['unique_id']=='B'))
	{
	include("menu/menu_bank.php");
	}	
	else
	{
	header("location:index.php");
	}
	?>
	<table style="width:98%" align="center">
<tr bgcolor="#008CBA">
<td  style="width:400px;height:35px;" ><font color="white" font size="4px;"> Case Management &nbsp;&nbsp;</font>&nbsp;
<input type="text" name="app_no" style="width:200px;height:35px;" placeholder="Agency Code" value="<?php echo $_POST['app_no'];?>"/ >
	&nbsp;<input type="text" name="case_id" style="width:200px;height:35px;" placeholder="Reference Number" value="<?php echo $_POST['case_id'];?>"/ >
	&nbsp;<input type="text" name="mobile_no" style="width:200px;height:35px;" placeholder="Mobile No" value="<?php echo $_POST['mobile_no'];?>"/ >
	&nbsp;<input type="submit" name="txtsubmit" button class="button button" value="Filter"></button>
	&nbsp;<input type="submit" name="txtsubmit" button class="button button" value="Refresh"></button>
</td>

</tr>
</table>
 <table style="width:98%" align="center" border="1" class="salary-data"  cellpadding="5" cellspacing="0" rules="all">
	      <tr height="25" >
	<td align="center" ><font color="#488AC7"><b>Agency Code</b></font></td>
	<td align="center" ><font color="#488AC7"><b>App No</b></font></td>
	<td align="center" ><font color="#488AC7"><b>Reference Number</b></font></td>
	<td align="center" ><font color="#488AC7"><b>Applicant Type</b></font></td>
	<td align="center" ><font color="#488AC7"><b>Name</b></font></td>
	<td align="center" ><font color="#488AC7"><b>FI Type</b></font></td>
	<td align="center" ><font color="#488AC7"><b>Address</b></font></td>	
	<td align="center" ><font color="#488AC7"><b>Mobile Number</b></font></td>
	<td align="center" ><font color="#488AC7"><b>Create Date</b></font></td>	
	<td align="center" ><font color="#488AC7"><b>Status</b></font></td>
	<td align="center" ><b>Action</b></td>	
	</tr>       
	<?php
	if($case_id)
	{
	$sql2="select * from sbialloc_tbl where case_id='$case_id' and promo_code='$idu'  " ;
	$result2=mysqli_query($conn,$sql2);
	}
	elseif($app_no)
	{
	$sql2="select * from allocation_tbl where app_no = '$app_no ' and (promo_code='$idu' or bank_name='SBI AUTO LOAN')  " ;
	$result2=mysqli_query($conn,$sql2);
	}
	elseif($mobile_no)
	{
	$sql2="select * from sbialloc_tbl where mobile_no= '$mobile_no' and promo_code='$idu'  " ;
	$result2=mysqli_query($conn,$sql2);
	}
	else
	{	
	$sql2="select * from sbialloc_tbl where  `promo_code`='$idu' and `status`='1' order by id desc  " ;
	$result2=mysqli_query($conn,$sql2);
	}
	$i=1;
	while($data2=mysqli_fetch_array($result2))
	{
	$id=$data2['id'];	
	$case_id=$data2['case_id'];
	
	$sqlapp="select id,app_no,status, sbiref_id,city from allocation_tbl where case_id='$case_id'  and sbiref_id='$id' and bank_name='SBI' order by id asc";
	$resultapp=mysqli_query($conn,$sqlapp);
	$dataapp=mysqli_fetch_array($resultapp);
	
	$status=$dataapp['status'];
	$app_no=$dataapp['app_no'];
	$idd=$dataapp['id'];
	if($data2['type']=="DOCS")
	{
	if($data2['loan_type']=="BANK STATEMENT")
	{
	 $ac="ACCOUNT NO - " ;  
	 $address= $data2['loan_type'].'- '.  $data2['bank_name'].' -'.$ac.' '.$data2['account_no'];
	}
	else
	{
	 $p="PAN NO - ";
	 $y="YEAR - ";
	 $address= $data2['loan_type'].'- '.$p.' '. $data2['pan_no'].' '.$y.' '.$data2['assesment_year1'].' '.$data2['assesment_year2'].' '.$data2['assesment_year3'];
	}
	
	}
	else
	{
	 $address= $data2['address1']  ; 
	}
	if($data2['status']=="1")
	{
	$status="InProgress";
	}
	elseif($status=="4")
	{
	$status="InProgress - DataVerified";
	}
	elseif($status=="5")
	{
	$status="InProgress - FieldVerified";
	}
	elseif($data2['status']=="0" and $data2['type']=="DOCS" )
	{
	 if($data2['final_status']=="Positive" or $data2['final_status']=="POSITIVE")
	{
	$p=$data2['final_status'];
	$tt="Verified - Address and Details Confirmed";
	$status=$p.' / '.$tt;
	}
	elseif($data2['final_status']=="Negative" or $data2['final_status']=="NEGATIVE")
	{
	$n=$data2['final_status'];
	$tt="Verified - Any Other Reason (Not covered by above)";
	$status=$n.' / '.$tt;
	}
	else
	{
	$status=$data2['final_status'];
	}
	}
	
	elseif($status=="0" and $data2['type']=="RV" )
	{
	$idd=$idd;
	$sqlrv="select final_status from res_verification where ref_id='$idd' ";
	$resultrv=mysqli_query($conn,$sqlrv);
	$datarv=mysqli_fetch_array($resultrv);
	if($datarv['final_status']=="Positive" or $datarv['final_status']=="POSITIVE")
	{
	$p=$datarv['final_status'];
	$tt="Verified - Address and Details Confirmed";
	$status=$p.' / '.$tt;
	}
	elseif($datarv['final_status']=="Negative" or $datarv['final_status']=="NEGATIVE")
	{
	$n=$datarv['final_status'];
	$tt="Verified - Any Other Reason (Not covered by above)";
	$status=$n.' / '.$tt;
	}
	else
	{
	$status=$datarv['final_status'];
	}
	}
	elseif($status=="0" and $data2['type']=="OV" )
	{
	$idd=$idd;
	$sqlrv="select final_status from bvsalaried where ref_id='$idd' ";
	$resultrv=mysqli_query($conn,$sqlrv);
	$datarv=mysqli_fetch_array($resultrv);
	if($datarv['final_status']=="Positive" or $datarv['final_status']=="POSITIVE")
	{
	$p=$datarv['final_status'];
	$tt="Verified - Address and Details Confirmed";
	$status=$p.' / '.$tt;
	}
	elseif($datarv['final_status']=="Negative" or $datarv['final_status']=="NEGATIVE")
	{
	$n=$datarv['final_status'];
	$tt="Verified - Any Other Reason (Not covered by above)";
	$status=$n.' / '.$tt;
	}
	
	else
	{
	$status=$datarv['final_status'];
	}
	}
	
	else
	{
	$status="";
	}	
	$idd2=base64_encode($data2['id']);
	$agencycode=$user_name.'-'.$data2['id'];
	?>
	<tr>
	<td align="center" ><?php echo $agencycode;?></td>
	<td align="center" ><?php echo $app_no;?></td>
	<td align="center"><?php echo $data2['case_id'];?></td>
	<td align="center"><?php echo $data2['appco_applicant'];?></td>
	<td align="center"><?php echo $data2['name'];?></td>
	<td align="center"><?php echo $data2['type'];?></td>
	<?php
	if($data2['type']=="DOCS")
	{
	 if($data2['loan_type']=="Bank Statement" or $data2['loan_type']=="BANK STATEMENT") 
	 {
	  $address1= 'Bank Name - '.$data2['bank_name'].', Account No-'.$data2['account_no'] ; 
	 ?> 
	<td align="center" ><?php echo $address1;?></td>
	<?php
	 }
	 else
	 {
	   $panno=$data2['pan_no'];
		$p1=substr($panno, 0, 5);
		$p2=substr($panno, 5, 4);
		$p3=substr($panno, 9, 9); 
	 ?>
	 	<td align="center" ><?php echo strtoupper($data2['pan_no']);?>
	 	<!--<input type="text" name="pan_no1" class="field"  style="width:70px;" value="<?php echo strtoupper($p1);?>"  />  
		<input type="text" name="pan_no1" class="field"  style="width:50px;" value="<?php echo $p2;?>"  />
		<input type="text" name="pan_no1" class="field"  style="width:25px;" value="<?php echo strtoupper($p3);?>"  />-->&nbsp;    
		Assesment Year- <?php echo $data2['assesment_year1'] ;?>
	 	</td>
	 	<?php
	 }
	}
	else
	{
	 $address1= $data2['address1'] ;     
	?>
	<td align="center" ><?php echo $address1;?></td>
	<?php
	}
	?>
	<td align="center" ><?php echo $data2['mobile_no'];?></td>
	<td align="center" ><?php echo $data2['entry_date'].' '.$data2['entry_time'];?></td>		
	<td align="center" ><?php echo $status;?></td>
	<td align="center" style="width:125px;"><a href="" onClick="window.open('casedetails.php?id=<?php echo "$idd2"; ?>','popup','width=850,height=350,scrollbars=yes,resizable=no,toolbar=no,directories=no,location=center,menubar=no,status=no,left=100,top=100'); return false" title="View Case"><img src="images/user.png" style="width:25px;height:15px;"/></a>
	<?php
	if($data2['case_status']=="Done" and $data2['type']=="RV" and $dataapp['sbiref_id']==$id)
	{	
	?>
	
	<a href="casedetailsrv.php?id=<?php echo "$idd2"; ?>" title="View Response" target="_blank"><img alt="View Response" src="images/verified_cases.png" style="width:25px;height:15px;"/></a>
	<?php
	if($dataapp['city']=="DOCS")
	{
	?>
	<a href="http://kandarp.in/combinebanking/tcpdf/examples/sbidocs_residencepdf.php?id=<?php echo "$idd"; ?>" title="Create Pdf" target="_blank"><img alt="Create Pdf" src="images/Pdf.png" style="width:25px;height:15px;"/></a>
	<?php
	}
	else
	{
	?>
	<a href="http://kandarp.in/combinebanking/tcpdf/examples/sbi_residencepdf.php?id=<?php echo "$idd"; ?>" title="Create Pdf" target="_blank"><img alt="Create Pdf" src="images/Pdf.png" style="width:25px;height:15px;"/></a>
	<?php
	}
	}	
	elseif($data2['case_status']=="Done" and $data2['type']=="OV" and $dataapp['sbiref_id']==$id)
	{
	?>
	<a href="casedetailsov.php?id=<?php echo "$idd2"; ?>" title="View Response" target="_blank"><img src="images/verified_cases.png" style="width:25px;height:15px;"/></a>
	<?php
	if($dataapp['city']=="DOCS")
	{
	?>
	<a href="http://kandarp.in/combinebanking/tcpdf/examples/sbidocs_officepdf.php?id=<?php echo "$idd"; ?>" title="Create Pdf" target="_blank"><img alt="Create Pdf" src="images/Pdf.png" style="width:25px;height:15px;"/></a>
	<?php
	}
	else
	{
	?>
	<a href="http://kandarp.in/combinebanking/tcpdf/examples/sbi_officepdf.php?id=<?php echo "$idd"; ?>" title="Create Pdf" target="_blank"><img alt="Create Pdf" src="images/Pdf.png" style="width:25px;height:15px;"/></a>
	<?php
	}
	}
	elseif($data2['case_status']=="Done" and $data2['type']=="DOCS"  )
	{
	if($data2['loan_type']=="BANK STATEMENT" )
	{
	?>
	<a href="casedetailsdocsbk.php?id=<?php echo "$id"; ?>" title="View Response" target="_blank"><img src="images/verified_cases.png" style="width:25px;height:15px;"/></a>
	<a href="http://kandarp.in/combinebanking/tcpdf/examples/sbidocs_bankstementpdf.php?id=<?php echo "$id"; ?>" title="Create Pdf" target="_blank"><img alt="Create Pdf" src="images/Pdf.png" style="width:25px;height:15px;"/></a>
	<?php
	}
	
	else
	{
	?>
	<a href="casedetailsdocsitr.php?id=<?php echo "$id"; ?>" title="View Response" target="_blank"><img src="images/verified_cases.png" style="width:25px;height:15px;"/></a>
	<a href="http://kandarp.in/combinebanking/tcpdf/examples/sbidocs_itrpdf.php?id=<?php echo "$id"; ?>" title="Create Pdf" target="_blank"><img alt="Create Pdf" src="images/Pdf.png" style="width:25px;height:15px;"/></a>
	<?php
	}
	}
	else
	{
	}
	?>
	</td>	
	</tr>
	<?php
	$i++;
	} ?>		
  </table>		
		
			</form>
			</body>
			</html>

