<?php include "layouts/menu.php"; ?> 
    <?php $idd=$_REQUEST['id'];?>
  <?php $mfin2=$_REQUEST['mfin2'];?>
  <!--  page-wrapper -->

    <link href="vendors/pnotify/dist/pnotify.css" rel="stylesheet">
    <link href="vendors/pnotify/dist/pnotify.buttons.css" rel="stylesheet">
    <link href="../vendors/pnotify/dist/pnotify.nonblock.css" rel="stylesheet">
  <style> 
input[type=text] {
    width: 100%;
   
    box-sizing: border-box;
    border: 1px solid #555;
    outline: Gray;
	
}

input[type=text]:focus {
    background-color: #d1e0e3;
}

.div1 {
    width: 100%;
    height: 100%;
       border: 4px solid #ff3d39;
    background-color: #69f7db;
	float:center;
}

.div2 {
    width: 380px;
    height: 240px;    
background-color:#f4f6df;
    border: 4px solid #376ca1;
	float:right;
}
label {
  
  color: black;
  font-weight: bold;
  
}
td,th{
  
  color: black;
  font-weight: bold;
  
}

</style>

         <div class="right_col" role="main">
              <div class="">
          <?php
						$qry=mysqli_query($conn, "select * from customerdetails where id='$idd'");
						$row=mysqli_fetch_array($qry);
						$mfin2 = $row['mfin'];  $hpl = $row['hpl']; $hpll = $hpl + 1;
						$qry1=mysqli_query($conn, "select * from user where mfin='$mfin2' &&  hpl='$hpl'");
					$n1=mysqli_num_rows($qry1);
					$row1=mysqli_fetch_array($qry1);
				$remarks = $row['remarks'];
		if($remarks!=NULL){
echo '<script language="javascript">';
echo 'alert("'.$remarks.'")';
echo '</script>'; } 	?>



            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Customer Detailed View <small>Activity report</small></h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                        <ul class="dropdown-menu" role="menu">
                          <li><a href="#">Settings 1</a>
                          </li>
                          <li><a href="#">Settings 2</a>
                          </li>
                        </ul>
                      </li>
                      <li><a class="close-link"><i class="fa fa-close"></i></a>
                      </li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    <div class="col-md-3 col-sm-3 col-xs-12 profile_left">
                      <div class="profile_img">
                        <div id="crop-avatar">
                          <!-- Current avatar -->
						  <?php $imgg = $row['uimg']; 
if($imgg != NULL) { 
?>
<img class="img-responsive avatar-view" src="user/<?php echo $row['uimg']; ?>" alt="Avatar" title="Change the avatar">
<?php } 
else{ 
?>
                          <img class="img-responsive avatar-view" src="us.jpg" alt="Avatar" title="Change the avatar">
<?php } ?>
                        </div>
                      </div>
                      <h1><b><?php echo $row['name']; ?></b></h1>

                     <font color="blue"> <ul class="list-unstyled user_data">
                        <h4><b><li><i class="fa fa-map-marker fa-2x user-profile-icon"></i> 
						S/O <?php echo $row['fname']; ?> </br>
						<?php echo $row['address']; ?> </br>
						<?php echo $row['address1']; ?> </br>
						<?php echo $row['address2']; ?> 
					
                        </li></h4></b>
						
						 <h3><b><li><i class="fa fa-phone fa-2x user-profile-icon"></i> 
					
						<?php echo $row['pno']; ?></br>
						
					Area	<?php echo $row['model']; ?></br>
						
				Sub Area 		<?php echo $row['area']; ?>
                        </li></h3></b> </font>

                      
                      </ul>

<?php 

$mfin2 = $row['mfin'];
							$hpl = $row['hpl'];
							$sql333 = mysqli_query($conn, "select * from pending where mfin='$mfin2' && hpl='$hpl'");
							$row333 = mysqli_fetch_array($sql333);
							?>
                      <!-- start skills -->
             

                      <!-- end of skills -->

                    </div>
                    <div class="col-md-9 col-sm-9 col-xs-12">

                      <!-- <div class="profile_title">
                        <div class="col-md-6">
                          <h2>User Activity Report</h2>
                        </div>
                        <div class="col-md-6">
                          <div id="reportrange" class="pull-right" style="margin-top: 5px; background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #E6E9ED">
                            <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
                            <span>December 30, 2014 - January 28, 2015</span> <b class="caret"></b>
                          </div>
                        </div>
                      </div>
                      
                      <div id="graph_bar" style="width:100%; height:280px;"></div>
                      end of user-activity-graph -->

                      <div class="" role="tabpanel" data-example-id="togglable-tabs">
                        <ul id="myTab" class="nav nav-tabs bar_tabs" role="tablist">
                          <li role="presentation" class="active"><a href="#tab_content1" id="home-tab" role="tab" data-toggle="tab" aria-expanded="true"><h5><b>Loan Details</h5></b></a>
                          </li>
                          <li role="presentation" class=""><a href="#tab_content2" role="tab" id="profile-tab2" data-toggle="tab" aria-expanded="false"><h5><b>Co-Applicant /  Guarantor </h5></b></a>
                          </li>
                          <li role="presentation" class=""><a href="#tab_content3" role="tab" id="profile-tab2" data-toggle="tab" aria-expanded="false"><h5><b>Letter Print</h5></b></a>
                          </li>
						  <li role="presentation" class=""><a href="#tab_content4" role="tab" id="profile-tab4" data-toggle="tab" aria-expanded="false"><h5><b>Call History</h5></b></a>
                          </li>
                          </li>
						    <li role="presentation" class=""><a href="#tab_content5" role="tab" id="profile-tab5" data-toggle="tab" aria-expanded="false"><h5><b>Bill Report</h5></b></a>
                          </li>
                        </ul>
                        <div id="myTabContent" class="tab-content">
                          <div role="tabpanel" class="tab-pane fade active in" id="tab_content1" aria-labelledby="home-tab">
                       
						<table class="data table table-striped no-margin">


<tr><td>Loan Date :</td><td>&nbsp;&nbsp;&nbsp;</td><td><font color="red" size="4"><?php echo $row['hpdate'];?> </td></tr>
<tr><td>Loan Amount : </td><td>&nbsp;&nbsp;&nbsp;</td><td><font color="red" size="4"><?php echo $row['totalhpamt'];?></td></tr>
<tr><td>Due Month : </td><td>&nbsp;&nbsp;&nbsp;</td><td><font color="red" size="4">(<?php echo $row['duemnt'];?>)</td></tr>

<tr><td>Due Amount :</td><td>&nbsp;&nbsp;&nbsp;</td><td><font color="red" size="4"><?php echo $row['total'];?>  (<?php echo $row['dueamt'];?> + <?php echo $row['interest'];?>)</td></tr>
<tr><td>Pending Amt :</td><td>&nbsp;&nbsp;&nbsp;</td><td><font color="red" size="4"><?php echo $row333['penamt'];?></td></tr>
<tr><td>Pending Due :</td><td>&nbsp;&nbsp;&nbsp;</td><td><font color="red" size="4"><?php echo $row333['pendmnt'];?></td></tr>
           </table>     

			  <!-- end recent activity -->

                          </div>
                          <div role="tabpanel" class="tab-pane fade" id="tab_content2" aria-labelledby="profile-tab2">
</br>
			 <div class="col-md-12 col-sm-12 col-xs-12 profile_details">
	
	<div class="col-md-6 col-sm-6 col-xs-12 profile_details">
                        <div class="well profile_view">
                          <div class="col-sm-12">
                            <h1 class="brief"><i><b>CO-Applicant  </b></i></h1>
                            <div class="left col-xs-7">
                              <h2><b><?php echo $row['cobname'];?></b></h2>
             <ul>   <li>	<b><font size="2.5" color="blue">S/O <?php echo $row['cofname']; ?></font></br></b>
	<b><font size="2.5" color="blue"><?php echo $row['co']; ?></font></br></b>
	<b><font size="2.5" color="blue"><?php echo $row['co01']; ?></font></br></b>
	<b><font size="2.5" color="blue"><?php echo $row['co02']; ?></font></br></b>
	<b><font size="2.5" color="blue"><?php echo $row['coalmark']; ?></font></br></b>
</li>
<li><i class="fa fa-phone"></i> Phone #: <?php echo $row['cobpno'];?> </br>
						</li>
                              </ul>
                            </div>
                            <div class="right col-xs-5 text-center">
				<?php $imgg = $row['uimg']; 
if($imgg != NULL) { 
?>
<img class="img-circle img-responsive" src="user/<?php echo $row['img']; ?>" alt="Avatar" title="Change the avatar">
<?php } 
else{ 
?>
                          <img class="img-circle img-responsive" src="us.jpg" alt="Avatar" title="Change the avatar">
<?php } ?>
                            </div>
                          </div>
                          <div class="col-xs-12 bottom text-center">
                            <div class="col-xs-12 col-sm-12 emphasis">
            </div>
                        </div>
                      </div>
					   </div>
					   
					    <div class="col-md-6 col-sm-6 col-xs-12 profile_details">
                        <div class="well profile_view">
                          <div class="col-sm-12">
                            <h1 class="brief"><i><b>Guarantor  </b></i></h1>
                            <div class="left col-xs-7">
                              <h2><b><?php echo $row['cobname2'];?></b></h2>
             <ul>   <li>		<b><font size="2.5" color="blue">S/O <?php echo $row['cofname2']; ?></font></br></b>
	<b><font size="2.5" color="blue"><?php echo $row['co2']; ?></font></br></b>
	<b><font size="2.5" color="blue"><?php echo $row['co201']; ?></font></br></b>
	<b><font size="2.5" color="blue"><?php echo $row['co202']; ?></font></br></b>
	<b><font size="2.5" color="blue"><?php echo $row['coalmark2']; ?></font></br></b>
</li>
<li><i class="fa fa-phone"></i> Phone #: <?php echo $row['cobpno2'];?> </br>
						</li>
                              </ul>
                            </div>
                            <div class="right col-xs-5 text-center">
				<?php $imgg = $row['uimg']; 
if($imgg != NULL) { 
?>
<img class="img-circle img-responsive" src="user/<?php echo $row['img']; ?>" alt="Avatar" title="Change the avatar">
<?php } 
else{ 
?>
                          <img class="img-circle img-responsive" src="us.jpg" alt="Avatar" title="Change the avatar">
<?php } ?>
                            </div>
                          </div>
                          <div class="col-xs-12 bottom text-center">
                            <div class="col-xs-12 col-sm-12 emphasis">
            </div>
                        </div>
                      </div>
					   </div>
			 <div class="col-md-6 col-sm-6 col-xs-12 profile_details">
                        <div class="well profile_view">
                          <div class="col-sm-12">
                            <h1 class="brief"><i><b>Office Address</b></i></h1>
                            <div class="left col-xs-7">
                            
             <ul>   <li>	
	<b><font size="2.5" color="blue"><?php echo $row['oaddress']; ?></font></br></b>
	<b><font size="2.5" color="blue"><?php echo $row['oaddress1']; ?></font></br></b>
	<b><font size="2.5" color="blue"><?php echo $row['oaddress2']; ?></font></br></b>
	<b><font size="2.5" color="blue"><?php echo $row['opno']; ?></font></br></b>
</li>
<li><i class="fa fa-phone"></i> Phone #: <?php echo $row['pnooffice'];?> </br>
						</li>
                              </ul>
                            </div>
                          
                          </div>
                          <div class="col-xs-12 bottom text-center">
                            <div class="col-xs-12 col-sm-12 emphasis">
            </div>
                        </div>
                      </div>
					   </div>		   

                </div>
                            <!-- end user projects -->

                          </div>
                          <div role="tabpanel" class="tab-pane fade" id="tab_content3" aria-labelledby="profile-tab3">
                           </BR>
						   
<a href="mathoor24.php?hpl=<?php echo $row['hpl']; ?>&name=<?php echo $row['name']; ?>&mfin=<?php echo $row['mfin']; ?>" target="_blank">
<button class="btn btn-warning btn-lg"><b>Ledger Print</b></button></a>
</br>

<a href="mathoor23.php?hpl=<?php echo $row['hpl']; ?>&name=<?php echo $row['name']; ?>&mfin=<?php echo $row['mfin']; ?>" target="_blank">
<button class="btn btn-success btn-lg"><b>History Ledger Print</b></button></a>
</br>


<a href="duecard.php?hpl=<?php echo $row['hpl']; ?>&name=<?php echo $row['name']; ?>&mfin=<?php echo $row['mfin']; ?>" target="_blank">
<button class="btn btn-info btn-lg"><b>Due Card Print</b></button></a>
</br>


<a href="interest3.php?hpl=<?php echo $row['hpl']; ?>&name=<?php echo $row['name']; ?>&mfin=<?php echo $row['mfin']; ?>" target="_blank">
<button class="btn btn-primary btn-lg"><b>Loan Defaulter Notice - Customer</b></button></a>
</br>

<a href="interest4.php?hpl=<?php echo $row['hpl']; ?>&name=<?php echo $row['name']; ?>&mfin=<?php echo $row['mfin']; ?>" target="_blank">
<button class="btn btn-info btn-lg"><b>Loan Defaulter Notice - Co Oblicant</b></button></a>
</br>

                          </div>
					     <div role="tabpanel" class="tab-pane fade" id="tab_content4" aria-labelledby="profile-tab4">
	  
						  <div class="col-md-12">
<div class="col-md-6">
 <form name="form1" class="form-horizontal" method="post" action="" enctype="multipart/form-data">
 <B>CALL HISTORY</B>
 <textarea cols="7"  rows="2" name="remarks" placeholder="Enter Call History"><?php echo $row['remarks']; ?></textarea>
 <input type="date" name="rdate" value="<?php echo $row['rdate']; ?>">
  <input type="hidden" name="hpl" value="<?php echo $row['hpl']; ?>">
 <input type="hidden" value="<?php echo $idd; ?>" name="idd">
  <button type="submit" class="btn btn-primary" name="s3">Update Call</button>
	<?php if(isset($_POST['s3']))
							{
								extract($_POST);  
			$insert22=mysqli_query($conn, "insert into res(mfin,scode,remarks,rdate,hpl)
					values('$mfin','$scode','$remarks','$rdate','$hpl')");
								$insert=mysqli_query($conn, "update customerdetails set remarks='$remarks',rdate='$rdate' where id='$idd'");
								}		
								?>
 </form>
</div>	
<div class="col-md-6">
 <form name="form1" class="form-horizontal" method="post" action="" enctype="multipart/form-data">
 <B>CUSTOMER PROOF HISTORY</B>
 <textarea cols="7"  rows="2" name="remarks" placeholder="Place of Book"></textarea>
 <input type="date" name="rdate" value="<?php echo $row['rdate']; ?>">
  <input type="hidden" name="hpl" value="<?php echo $row['hpl']; ?>">
 <input type="hidden" value="<?php echo $idd; ?>" name="idd">
  <button type="submit" class="btn btn-primary" name="s355">Update</button>
	<?php if(isset($_POST['s355']))
							{
								extract($_POST);  
			$insert223=mysqli_query($conn, "insert into resrc(mfin,scode,remarks,rdate,hpl)
					values('$mfin','$scode','$remarks','$rdate','$hpl')");
								//$insert=mysqli_query($conn, "update customerdetails set remarks='$remarks' where id='$idd'");
								}		
								?>
 </form>
</div>

</div>


</br> <H4><B>CALL HISTORY</H4></B>
						
						 <div class="table-responsive">
  <table class="table table-bordered table-hover"><thead>
  <tr class="info">
						<th>S.No</th>
						
						<th>Date</th>
						<th>Remarks</th>
						<th>Staff</th>
					  <th>Cancel</th>
					</tr></thead><tbody>
  
                    <?php
				
						$qry=mysqli_query($conn, "select * from res where mfin='$mfin2' &&  hpl='$hpl'");
						
						$n=mysqli_num_rows($qry);
						if($n==0)
						{
							
						}
						else
					{ 
						?></p>
					 
					<?php $i = 0;
					while($row=mysqli_fetch_array($qry))
						{ $i++;
				$ppp = $row['rdate'];
					$pp2  = date('d-m-Y',strtotime($ppp));
					?>
					<tr>
					 
						<td><?php echo $i;?></td>
						<td><?php echo $pp2;?></td>
						<td><?php echo $row['remarks'];?></td>
						<td><?php echo $row['scode'];?></td>
										<td><a href="canres.php?id=<?php echo $row['id'];?>" class="btn btn-primary btn-xs" onclick="return confirm('Are you sure WANT TO CANCEL?');">Cancel</a></b></td>

						</tr> <?php } } ?>

</tbody> </table>						
</div>


</br> <H4><B>BOOK HISTORY</H4></B>
						
						 <div class="table-responsive">
  <table class="table table-bordered table-hover"><thead>
  <tr class="info">
						<th>S.No</th>
						
						<th>Date</th>
						<th>Remarks</th>
						<th>Staff</th>
					  <th>Cancel</th>
					</tr></thead><tbody>
  
                    <?php
				
						$qry=mysqli_query($conn, "select * from resrc where mfin='$mfin2' &&  hpl='$hpl'");
						
						$n=mysqli_num_rows($qry);
						if($n==0)
						{
							
						}
						else
					{ 
						?></p>
					 
					<?php $i = 0;
					while($row=mysqli_fetch_array($qry))
						{ $i++;
				$ppp = $row['rdate'];
					$pp2  = date('d-m-Y',strtotime($ppp));
					?>
					<tr>
					 
						<td><?php echo $i;?></td>
						<td><?php echo $pp2;?></td>
						<td><?php echo $row['remarks'];?></td>
						<td><?php echo $row['scode'];?></td>
										<td><a href="canresrc.php?id=<?php echo $row['id'];?>" class="btn btn-primary btn-xs" onclick="return confirm('Are you sure WANT TO CANCEL?');">Cancel</a></b></td>

						</tr> <?php } } ?>

</tbody> </table>	

</div>
                        </div>
									     <div role="tabpanel" class="tab-pane fade" id="tab_content5" aria-labelledby="profile-tab5">
		
						 <?php $a1 = 0;  $a2 = 0;   $a3 = 0;   $a4 = 0;   $a5 = 0; 
		$qry1=mysqli_query($conn, "select * from user  where mfin='$mfin2' &&  hpl='$hpl' order by paydate2 asc");
					if($n1==0)
						{
							echo "Nothing To Display";
						}
						else
					{ 
						?></p>
					<table class="table table-striped" table class="table" border="0" align="center" cellspacing="0" cellpadding="10" >
					
					 <tr class="alert alert-info">
					<th style="width:7%">Rcpt No</th>	
							<th style="width:10%">Status</th>
						
						
						<th>Pay Date</th>
							<th>Total</th>
						<th>Due Amt</th>
						<th>Princ</th>
						<th>Intst</th>
						<th>Fine</th>
						<th>HLoan</th>	<th>Reloan</th>
				<th>#Edit</th>
			
						<th>Create </th>
							<th>Altered</th>
					
					</tr>
					
					<?php $i = 0; 
					
				while($row=mysqli_fetch_array($qry1)) 	
					{ 
					$i++;
					 $aaa  = $row['urname'];
					 $sts = $row['status'];
$sts2 = "Reloan";
?>				<tr>
					<td><b><?php echo $row['roll'];?></b></td>
						
						 <?php if($sts == $sts2){ ?>
<td><b><a href="editrcpt.php?fid=<?php echo $row['fid'];?>"><button class="btn btn-warning">Reloan</button></a></b></td>
						 <?php } else { ?>
			<td><b><a href="editrcpt.php?fid=<?php echo $row['fid'];?>"><button class="btn btn-success">Due</button></a></b></td>			 
						 <?php } ?>
				
						
						<td><b><?php echo $row['paydate'];?></b></td>
							<td><b><?php echo $aaa;?></b></td>
						<td><b><?php echo $row['dueamount'];?></b></td>
						<td><b><?php echo $row['pass'];?></b></td>
						<td><b><?php echo $row['rno'];?></b></td>
						<td><b><?php echo $row['fine'];?></b></td>
						<td><b><?php echo $row['hloan'];?></b></td>
					
					<td><b><?php echo $row['rloan'];?></b></td>
						<?php $damt = $damt + $row['dueamount']; $pass = $pass + $row['pass']; $rno = $rno + $row['rno']; 
						$fine = $fine + $row['fine']; $hll = $hll + $row['hloan']; $bal = $bal + $row['bal'];$a22 = $a22 + $a2; $urname = $urname + $aaa; ?>
					    
				<td><b>
<a href="editrcpt.php?fid=<?php echo $row['fid'];?>" class="btn btn-danger btn-xs" onclick="return confirm('Are you sure WANT TO Edit?');">Edit</a>				

</br><a href="cancel.php?fid=<?php echo $row['fid'];?>" class="btn btn-primary btn-xs" onclick="return confirm('Are you sure WANT TO CANCEL?');">Cancel</a></b></td>	

						<td><b><font size="1"><?php echo $row['createdate'];?></br>
						<?php echo $row['scode'];?></font>
						</b></td>
						<td><b><font size="1"><?php echo $row['altdate'];?></br><?php echo $row['altby'];?></b></font></td>
		</tr>  <?php 
					}
					}
					?>
				
						</table>

					      <?php
						$qry=mysqli_query($conn, "select * from net where mfin='$mfin2' &&  hpl='$hpl'");
						$n=mysqli_num_rows($qry);
						if($n==0)
						{
							echo "Nothing To Display";
						}
						else
					{ 
						?></p>
				
  <table class="table table-bordered table-hover"><thead>
  <tr class="info">
						<th style="width:7%">Rcpt No</th>	
							<th style="width:10%">Status</th>
						
						
						<th> Date</th>
							<th>Total</th>
					
						<th>Prin Amt</th>
						<th>Int Amt</th>
						<th>Def Amt</th>
						<th>HL Amt</th>
			<?php  if(($postt == 'MD') || ($postt == 'Office All')) { ?> 	<th>#Options</th> <?php } ?>
				<th>Created By </th>
							<th>Altered By</th>
					
					</tr>
					</tr></thead>
					<?php 
					while($row=mysqli_fetch_array($qry))
						{
					?>
					<tbody><tr class="warning">
					
									<td><b><?php echo $row['rrno'];?></b></td>

						<td><b><a href="editsettle.php?fid=<?php echo $row['id'];?>"><button class="btn btn-danger">Close</button></a></b></td>
						
						
						<td><b><?php echo $row['paydate'];?></b></td>
						<td><b><?php echo $row['tot'];?></b></td>
		
						<td><b><?php echo $ss=$row['dueamt']  - $row['addless'];?></b></td>
						<td><b><?php echo $row['amt'];?></b></td>
						<td><b><?php echo $row['fine'];?></b></td>
						<td><b><?php echo $row['hloan'];?></b></td>
						
				<?php	 $pass = $pass + $ss; $rno = $rno + $row['amt']; 
						$fine = $fine + $row['fine']; $urname = $urname + $row['tot']; 
						 $hll = $hll + $row['hloan'];
						?>
						
				
<?php  if(($postt == 'MD') || ($postt == 'Office All')) { ?> 
<td><b>
<a href="editsettle.php?fid=<?php echo $row['id'];?>" class="btn btn-danger btn-xs" onclick="return confirm('Are you sure WANT TO Edit?');">Edit</a>	
</br><a href="cancel2.php?fid=<?php echo $row['id'];?>" class="btn btn-primary btn-xs" onclick="return confirm('Are you sure WANT TO CANCEL?');">Cancel</a></b></td>					
<?php } ?>
						<td><font size="1"><b><?php echo $row['createdate'];?></br><?php echo $row['scode'];?></b></font></td>
					
						<td><font size="1"><b><?php echo $row['altdate'];?></br><?php echo $row['altby'];?></b></font></td>
						</tr></tbody>
					<?php
						}
					}
					?>				
					</table>
					 <H4><B>HAND LOAN HISTORY</H4></B>
						
  <table class="table table-bordered table-hover"><thead>
  <tr class="info">
						<th>Date</th>
						
						<th>Type</th><th>Remarks</th>
						<th>Agent</th>
						<th>Credit</th>
						<th>Debit</th>
						
					</tr></thead><tbody>
  
                    <?php
					$cr = 0; $dr = 0;
						$qry=mysqli_query($conn, "select * from customerdetails where mfin='$mfin2' &&  hpl='$hpl'");
						
						$n=mysqli_num_rows($qry);
						if($n==0)
						{
							
						}
						else
					{ 
						?></p>
					
					<?php 
					while($row=mysqli_fetch_array($qry))
						{ $cr = $cr + $row['hlamt'];
					$daq = $row['hlamt'];
					if(($daq != NULL) && ($daq != 0)) {
					?>
					<tr class="warning">
					<col width="100px">
						<td><?php echo $row['hpdate'];?></td>
						<td>Receipt</td>
						<td><?php echo $row['hlreturn'];?></td>
						<td>-</td>
						<td><?php echo $row['hlamt'];?></td>
						
						<td></td>
						</tr></tbody>
					<?php
					} }
					}
				
						$qry=mysqli_query($conn, "select * from hloan where mfin='$mfin2' && type!='COLLECTION' && hpl='$hpl'"); 
						
						$n=mysqli_num_rows($qry);
						if($n==0)
						{
							
						}
						else
					{ 
						?></p>
					
					<?php 
					while($row=mysqli_fetch_array($qry))
						{ 
						//$ggh = $row['reslt']; if($ggh == NULL) {
						$dr = $dr + $row['actamt2'];
					?>
					<tr class="warning">
					<col width="100px">
						<td><?php echo $row['date'];?></td>
						<td>HL-<?php echo $row['reslt'];?></td>
						<td><?php echo $row['remarks'];?></td>
						<td><?php echo $row['agent'];?></td>
						<td></td>
						<td><?php echo $row['actamt2'];?></td>
						
						
						</tr></tbody>
					<?php
						//}
						}
					}
					
					$qry=mysqli_query($conn, "select * from otherentry where mfin='$mfin2' &&  hpl='$hpl'");
						
						$n=mysqli_num_rows($qry);
						if($n==0)
						{
							
						}
						else
					{ 
						?></p>
					
					<?php 
					while($row=mysqli_fetch_array($qry))
						{ $dr = $dr + $row['postamt2'];
					?>
					<tr class="warning">
					<col width="100px">
						<td><?php echo $row['postdate'];?></td>
						<td>OE - <?php echo $row['result'];?></td>
						<td><?php echo $row['remark'];?></td>
						<td><?php echo $row['agentname'];?></td>
						<td></td>
						<td><?php echo $row['postamt2'];?></td>
						
						
						</tr></tbody>
					<?php
						}
					}
				
					$qry=mysqli_query($conn, "select * from user where mfin='$mfin2' &&  hpl='$hpl'");
						
						$n=mysqli_num_rows($qry);
						if($n==0)
						{
							
						}
						else
					{ 
						?></p>
					
					<?php 
					while($row=mysqli_fetch_array($qry))
						{ $vv = $row['hloan'];
					if(($vv != NULL) && ($vv != 0)) { $cr = $cr + $row['hloan'];
					?>
					<tr class="warning">
						<td><?php echo $row['paydate'];?></td>
						<td>Recpt</td>
						<td></td>
						<td>-</td>
						
						<td><?php echo $row['hloan'];?></td>
						<td></td>
						
						</tr>
					<?php
					} }
					}
					
					
					$qry=mysqli_query($conn, "select * from net where mfin='$mfin2' &&  hpl='$hpl'");
						
						$n=mysqli_num_rows($qry);
						if($n==0)
						{
							
						}
						else
					{ 
						?></p>
					
					<?php 
					while($row=mysqli_fetch_array($qry))
						{ $vv = $row['hloan'];
					if($vv != NULL) { $cr = $cr + $row['hloan'];
					?>
					<tr class="warning">
						<td><?php echo $row['paydate'];?></td>
						<td>Closing</td>
						<td></td>
						<td>-</td>
						
						<td><?php echo $row['hloan'];?></td>
						<td></td>
						
						</tr>
					<?php
					} }
					}
				
					?>
					<tr class="succes">
					<col width="100px">
						<td></td>
						<td>Total</td>
						<td></td>
						<td>-</td>
						
						<td><?php echo $cr;?></td>
						<td><?php echo $dr;?></td>
						
						</tr>
						<tr class="warning">
					<col width="100px">
						<td></td>
						<td>Balance</td>
						<td></td>
						<td>-</td>
						<td></td>
						<td><b><h4><?php $ccc = $dr - $cr;  echo $ccc;?></h4></b></td>
						
						
						</tr>
						</tbody>
					</table>
			
				
                      </div>
					  
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
            <div class="row">
                <div class="col-lg-12">
                    <!-- Form Elements -->
                
      <!--  <div id="mydiv">
  <input type="button" value="Print" onclick="PrintElem('#mydiv')"  style="margin:20px;">
   <form name="form1" method="post" action="" enctype="multipart/form-data"> -->
<?php
						$qry=mysqli_query($conn, "select * from customerdetails where id='$idd'");
						$row=mysqli_fetch_array($qry);
						$mfin2 = $row['mfin'];  $hpl = $row['hpl']; $hpll = $hpl + 1;
						$qry1=mysqli_query($conn, "select * from user where mfin='$mfin2' &&  hpl='$hpl'");
					$n1=mysqli_num_rows($qry1);
					$row1=mysqli_fetch_array($qry1);
				$remarks = $row['remarks'];
	
			$qqry=mysqli_query($conn, "select * from pending where mfin='$mfin' && hpl='$hpl'");
$nq=mysqli_num_rows($qqry);
$drow=mysqli_fetch_array($qqry); $iig++;
$x = $row['hpl'];
$pno = $row['pno'];
$ni = $row['pendmnt'];

$caa = round($row['defamt'],0);
$hlbal = round($row['hlbal'],0);
$tottt = round($row['penamt'],0);
$spddd = $tottt - $caa - $hlbal;
$hpl = $row['hpl'];
$vno = $row['vno'];
$cobpno = $row['cobpno'];


$message="Pls Pay Due ".$ni.", Amt Rs.".$spddd.",Default Rs.".$caa."-HL amt ".$hlbal.", Total Amt Rs.".$tottt." for a/c No-".$hpl.",Regn no.".$vno."- ".$mfin." .";

$damt = $row['total'];			
	$defamt = $row['defamt'];	
	//$defamt = (($damt*$defamt2)/100)/30;	
?>		
<center><?php if($postt == 'MD')   { ?>
<a href="canled.php?id=<?php echo $row['id'];?>" class="btn btn-primary btn-xs" onclick="return confirm('Are you sure WANT TO CANCEL?');">DELETE</a>
<?php } 		$ss = $row['status'];
	if($ss == 'Closed') {
						?>
		
<a href="editled.php?id=<?php echo $row['id'];?>&mfin=<?php echo $row['mfin'];?>" data-toggle="tooltip" title="Led Edit!"><i class="fa fa-edit fa-2x" style="color:blue;"  aria-hidden="true"></i></a>&nbsp;&nbsp;
<a href="reloan5.php?id=<?php echo $row['id'];?>&mfin=<?php echo $row['mfin'];?>" data-toggle="tooltip" title="Clone!"><i class="fa fa-clone fa-2x" style="color:black;"  aria-hidden="true"></i></a>&nbsp;&nbsp;
<a href="https://api.whatsapp.com/send?phone=91<?php echo $row['pno'];?>&text=<?php echo $message;?>"  data-toggle="tooltip" title="WhatsApp!"><i class="fa fa-whatsapp fa-3x" style="color:green;" aria-hidden="true"></i></a> &nbsp;&nbsp;
		<?php $ff = $row['lat']; if($ff>0) { ?>	<a href="https://www.google.com/maps/?q=<?php echo $row['lat'];?>,<?php echo $row['lang'];?>"  data-toggle="tooltip" title="Google Map !" title="Full View!" target="_blank"><i class="fa fa-map-marker fa-2x" style="color:purple;" aria-hidden="true"></i></a> <?php } ?>

				<?php }
elseif($ss == 'Reloan') { ?>
				
			
<a href="editled.php?id=<?php echo $row['id'];?>&mfin=<?php echo $row['mfin'];?>" data-toggle="tooltip" title="Led Edit!"><i class="fa fa-edit fa-2x" style="color:blue;"  aria-hidden="true"></i></a>&nbsp;&nbsp;
<a href="reloan5.php?id=<?php echo $row['id'];?>&mfin=<?php echo $row['mfin'];?>" data-toggle="tooltip" title="Clone!"><i class="fa fa-clone fa-2x" style="color:black;"  aria-hidden="true"></i></a>&nbsp;&nbsp;
<a href="udelete.php?id=<?php echo $row['id'];?>&mfin2=<?php echo $row['mfin']; ?>"  data-toggle="tooltip" title="Full View!"><i class="fa fa-feed fa-2x" style="color:navi;" aria-hidden="true"></i></a>
<a href="https://api.whatsapp.com/send?phone=91<?php echo $row['pno'];?>&text=<?php echo $message;?>"  data-toggle="tooltip" title="WhatsApp!"><i class="fa fa-whatsapp fa-3x" style="color:green;" aria-hidden="true"></i></a> &nbsp;&nbsp;
		<?php $ff = $row['lat']; if($ff>0) { ?>	<a href="https://www.google.com/maps/?q=<?php echo $row['lat'];?>,<?php echo $row['lang'];?>"  data-toggle="tooltip" title="Google Map !" title="Full View!" target="_blank"><i class="fa fa-map-marker fa-2x" style="color:purple;" aria-hidden="true"></i></a> <?php } ?>

				<?php }
				elseif($ss == 'Sized') { ?>
				
<a href="registerf2.php?hpl=<?php echo $row['hpl'];?>&mfin2=<?php echo $row['mfin'];?>" data-toggle="tooltip" title="Receipt!"><i class="fa fa-print fa-2x"  style="color:green;" aria-hidden="true"></i></a>&nbsp;&nbsp;
<a href="editled.php?id=<?php echo $row['id'];?>&mfin=<?php echo $row['mfin'];?>" data-toggle="tooltip" title="Led Edit!"><i class="fa fa-edit fa-2x" style="color:blue;"  aria-hidden="true"></i></a>&nbsp;&nbsp;
<a href="fullsettle2.php?hpl=<?php echo $row['hpl'];?>&mfin2=<?php echo $row['mfin'];?>" data-toggle="tooltip" title="Full Settlement!"><i class="fa fa-close fa-2x" style="color:red;"  aria-hidden="true"></i></a>&nbsp;&nbsp;	
<a href="reloan2.php?hpl=<?php echo $row['hpl'];?>&mfin2=<?php echo $row['mfin'];?>" data-toggle="tooltip" title="Reloan!"><i class="fa fa-random fa-2x" style="color:Maroon;"  aria-hidden="true"></i></a>&nbsp;&nbsp;		
<a href="reloan5.php?id=<?php echo $row['id'];?>&mfin=<?php echo $row['mfin'];?>" data-toggle="tooltip" title="Clone!"><i class="fa fa-clone fa-2x" style="color:black;"  aria-hidden="true"></i></a>&nbsp;&nbsp;			
<a href="https://api.whatsapp.com/send?phone=91<?php echo $row['pno'];?>&text=<?php echo $message;?>"  data-toggle="tooltip" title="WhatsApp!"><i class="fa fa-whatsapp fa-3x" style="color:green;" aria-hidden="true"></i></a> &nbsp;&nbsp;
		<?php $ff = $row['lat']; if($ff>0) { ?>	<a href="https://www.google.com/maps/?q=<?php echo $row['lat'];?>,<?php echo $row['lang'];?>"  data-toggle="tooltip" title="Google Map !" title="Full View!" target="_blank"><i class="fa fa-map-marker fa-2x" style="color:purple;" aria-hidden="true"></i></a> <?php } ?>

				<?php } else {?>
			
<a href="mobm.php?hpl=<?php echo $row['hpl'];?>&mfin2=<?php echo $row['mfin'];?>" data-toggle="tooltip" title="Receipt!"><i class="fa fa-print fa-2x"  style="color:green;" aria-hidden="true"></i></a>&nbsp;&nbsp;
<a href="editled.php?id=<?php echo $row['id'];?>&mfin=<?php echo $row['mfin'];?>" data-toggle="tooltip" title="Led Edit!"><i class="fa fa-edit fa-2x" style="color:blue;"  aria-hidden="true"></i></a>&nbsp;&nbsp;
<a href="fullsettle2.php?hpl=<?php echo $row['hpl'];?>&mfin2=<?php echo $row['mfin'];?>" data-toggle="tooltip" title="Full Settlement!"><i class="fa fa-close fa-2x" style="color:red;"  aria-hidden="true"></i></a>&nbsp;&nbsp;	<!--
<a href="reloan2.php?hpl=<?php echo $row['hpl'];?>&mfin2=<?php echo $row['mfin'];?>" data-toggle="tooltip" title="Reloan!"><i class="fa fa-random fa-2x" style="color:Maroon;"  aria-hidden="true"></i></a>&nbsp;&nbsp;	
<a href="reloan5.php?id=<?php echo $row['id'];?>&mfin=<?php echo $row['mfin'];?>" data-toggle="tooltip" title="Clone!"><i class="fa fa-clone fa-2x" style="color:black;"  aria-hidden="true"></i></a>&nbsp;&nbsp;			
<a href="netamta.php?hpl=<?php echo $row['hpl'];?>&mfin=<?php echo $row['mfin'];?>" data-toggle="tooltip" title="Add Seize List!"><i class="fa fa-motorcycle fa-2x" style="color:orange;"  aria-hidden="true"></i></a>&nbsp;&nbsp;	
-->
<a href="udelete.php?id=<?php echo $row['id'];?>&mfin2=<?php echo $row['mfin']; ?>"  data-toggle="tooltip" title="Full View!"><i class="fa fa-feed fa-2x" style="color:navi;" aria-hidden="true"></i></a>
<a href="https://api.whatsapp.com/send?phone=91<?php echo $row['pno'];?>&text=<?php echo $message;?>"  data-toggle="tooltip" title="WhatsApp!"><i class="fa fa-whatsapp fa-3x" style="color:green;" aria-hidden="true"></i></a> &nbsp;&nbsp;
		<?php $ff = $row['lat']; if($ff>0) { ?>	<a href="https://www.google.com/maps/?q=<?php echo $row['lat'];?>,<?php echo $row['lang'];?>"  data-toggle="tooltip" title="Google Map !" title="Full View!" target="_blank"><i class="fa fa-map-marker fa-2x" style="color:purple;" aria-hidden="true"></i></a> <?php } ?>
	
				<?php }?>
				
				</BR><h3><b>	</b></h3></center>
<center><h3><b>Default Per Day : Rs. <?php echo round($defamt,0); ?>/=</b></h3></center>
 <table id="datatable-buttons" id="datatable-buttons" class="table table-striped table-bordered"  border="1px" color="solid black">
					<thead>
						<tr>
						<th>Due</th>
						<th>Due Date</th>
						<th>Rcpt No</th>
						<th>Rcpt Date</th>
						<th>Due Amt</th>
						<th>Due Rcvd</th>
						<th>Due Bal</th>
				        <th>Def Days</th>
						<th>Penalty</th>
						<th>Payed Fine</th>
	
					
					
						
					</tr></thead>
					<tbody>
		<?php $noo = 0; $less = 0; $spdue= 0 ; $spfine = 0; $spdd = 0;
			$ttp = 0;	$tti = 0; $ttdue = 0;	$ttdd = 0;	$ttfine = 0;	$ttpf = 0;	$tthl = 0;	
				$tttot = 0;	$zz = 1;
				$qdue = 0; $qdue25 = 0;
			$ttp = 0;	$tti  = 0; $ttdue = 0;	$ttdd = 0;	$ttfine = 0;	$ttpf = 0;	$tthl = 0;	
				$tttot = 0;	$dmm = 0; $sts = 0;
						$qry=mysqli_query($conn, "select * from customerdetails where mfin='$mfin2' &&  hpl='$hpl'");			
$row = mysqli_fetch_array($qry);
	   $duedat = str_replace('/', '-', $row['hpdate']);
	    $hpdate = str_replace('/', '-', $row['hpdate']);
						$pp = $row['duemnt'];
						$addr = $row['addrwess'];
			$damt = $row['total'];		
$intt = $row['inter'];
$intt2 = $row['interest'];
$prin = $row['dueamt'];			
	$defamt2 = $row['defamt'];	
	$defamt = (($damt*$defamt2)/100)/30;	
  $d1 = strtotime($duedat);
$d2 = strtotime("today");
$min_date = min($d1, $d2);
$max_date = max($d1, $d2);

if($iii>$pp)
{ $iii=$pp; }
$rc = $iii - $sql5 ;
$sql9 = $sql5 + $rc ; $vv = 1; $ii = 0;
 
$qry5=mysqli_query($conn, "select * from user where mfin='$mfin2' && hpl='$hpl' order by paydate2 asc");			
while($row5 = mysqli_fetch_array($qry5)) { $rr = 0;
$duemnt = $row5['paymnt'];
$rcptno = $row5['roll'];
$fidd = $row5['fid'];
$gi = 0;
$rno1 = $row5['rno'];
$rno = $rno1/$duemnt;
$pass1 = $row5['pass'];
$pday = $row5['paydate'];
$pass = $pass1/$duemnt;
$urname1 = $row5['urname'];
$hloan = $row5['hloan'];
$fine1 = $row5['fine'];
$urname = ($urname1 - $hloan - $fine1) /$duemnt;
$dmm = $urname1 - $hloan - $fine1;
$ff55 = 0;
while($dmm>0) { $gi++; $rr++;
if($ff55 == 0){
	$fine18 = $fine1;
	$hloan8 = $hloan;
}
else {
	$fine18 = 0;
	$hloan8 = 0;
}
$ff55++;
if($sts==0) {
if($dmm>$damt){
	$sts = 1; $less = 0;
	$pamt = $damt;
	$noo++;
}
elseif($dmm==$damt){
	$sts = 0; $less = 0;
	$pamt = $damt;
	$noo++;
}
else{
	$sts = 2;
	$pamt = $dmm;
	$less = $damt - $dmm;
}
$ii++; $zzzz++;
$selected_date=$duedat;
		  	$selected_date=strtotime( $selected_date );
			$mysqldate = date( 'd-m-Y', $selected_date );
			$month = date( 'm', $selected_date );
			$day = date( 'd', $selected_date );
			$yyyy = date( 'Y', $selected_date );
			$zzz = $zz * 1;
$duedat = date("d-m-Y", strtotime("$hpdate + " . $zzz . " DAY"));
$pday = $row5['paydate'];


  $d11 = strtotime($duedat);
$d22 = strtotime($pday);
$min_date1 = min($d11, $d22);
$max_date1 = max($d11, $d22);
$i6 = 0;
if($d11<=$d22) {
while (($min_date1 = strtotime("+1 DAY", $min_date1)) <= $max_date1) {
    $i6++;
}
}
if($i6 <= 3){
    
$fine2 = 0;
} else {
$fine2 = (($defamt/$damt)*($i6 * $pamt)); }
if($fine2 < 0) {
	$fine2 = 0;
}

	?>
<tr>
					<td><?php echo $ii; ?></td>
					<td> 
					<?php $tdue = $urname - $hloan - $fine1; ?>
						<a href="editrcpt.php?fid=<?php echo $fidd; ?>"<button class="btn btn-default text-center">
                        <i class="fa  fa-pencil fa-1x"></i><b><?php echo $duedat; $zz++; ?></b>
                    </button></a></td><td><?php echo $rcptno; ?></td>
					<td><?php echo $pday; ?></td>
					<td><?php echo $damt; ?></td>
				<!--	<td><?php //echo $pass; ?></td>
					<td><?php //echo $rno; ?></td> -->
					<td><?php echo $pamt; ?></td><td></td>
				<td><?php echo $i6;?></td>	<td><?php echo round($fine2,0);?></td>	
				 <td><?php echo $fine18;?></td> 
				
			
</tr>
<?php $dmm = $dmm - $pamt;
$spfine = $spfine + $fine2;
$spdd = $spdd + $i6; $spdue = $spdue + $pamt;
$spff = $spff + $fine18;
$sphl = $sphl + $hloan8;
 } 

elseif($sts == 1) {
	if($dmm>$damt){
	$sts = 1; $less = 0;
	$pamt = $damt;
	$noo++;
}
elseif($dmm==$damt){
	$sts = 0; $less = 0;
	$pamt = $damt;
	$noo++;
}
else{
	$sts = 2;
	$pamt = $dmm;
	$less = $damt - $dmm;
} $ii++; $zzzz++;
$selected_date=$duedat;
		  	$selected_date=strtotime( $selected_date );
			$mysqldate = date( 'd-m-Y', $selected_date );
			$month = date( 'm', $selected_date );
			$day = date( 'd', $selected_date );
			$yyyy = date( 'Y', $selected_date );
			$zzz = $zz * 1;
$duedat = date("d-m-Y", strtotime("$hpdate + " . $zzz . " DAY"));



  $d11 = strtotime($duedat);
$d22 = strtotime($pday);
$min_date1 = min($d11, $d22);
$max_date1 = max($d11, $d22);
$i6 = 0;
if($d11<=$d22) {
while (($min_date1 = strtotime("+1 DAY", $min_date1)) <= $max_date1) {
    $i6++;
}
}
if($i6 <= 3){
    
$fine2 = 0;
} else {
$fine2 = (($defamt/$damt)*($i6 * $pamt)); }
if($fine2 < 0) {
	$fine2 = 0;
} 
	?>
<tr>
					<td><?php echo $ii; ?></td>
					<td> 
					<?php $tdue = $urname - $hloan - $fine1; ?>
						<a href="editrcpt.php?fid=<?php echo $fidd; ?>"<button class="btn btn-default text-center">
                        <i class="fa  fa-pencil fa-1x"></i><b><?php echo $duedat; $zz++;?></b>
                    </button></a></td><td><?php echo $rcptno; ?></td>
					<td><?php echo $pday; ?></td>
					<td><?php echo $damt; ?></td>
				<!--	<td><?php //echo $pass; ?></td>
					<td><?php //echo $rno; ?></td> -->
					<td><?php echo $pamt; ?></td><td></td>
				<td><?php echo $i6;?></td>	<td><?php echo round($fine2,0);?></td>	
			<td><?php echo $fine18;?></td> 
					
			
</tr>

<?php $dmm = $dmm - $pamt;
$spfine = $spfine + $fine2;
$spdd = $spdd + $i6; $spdue = $spdue + $pamt;
$spff = $spff + $fine18;
$sphl = $sphl + $hloan8;
 } 
else { 
  $d11 = strtotime($duedat);
$d22 = strtotime($pday);
$min_date1 = min($d11, $d22);
$max_date1 = max($d11, $d22);
$i6 = 0;
if($d11<=$d22) {
while (($min_date1 = strtotime("+1 DAY", $min_date1)) <= $max_date1) {
    $i6++;
}
}
if($i6 < 3){
    
$fine2 = 0;
} else {
$fine2 = (($defamt/$damt)*($i6 * $less));
 }
if($fine2 < 0) {
	$fine2 = 0;
}
if($less>$dmm){
$dmm2 = $less - $dmm; $noo++;
$less2 = $less  - $dmm2; 
$spdue = $spdue + $less;
$dmm = 0;
	?><tr>
					<td></td>
					<td></td>	
					<td></td>
					<td><?php echo $pday; ?></td>
					<td></td>
				<!--	<td><?php //echo $pass; ?></td>
					<td><?php //echo $rno; ?></td> -->
					<td><?php echo $less2; ?></td><td></td>
				<td><?php echo $i6; ?></td>	
				<td><?php echo round($fine2,0); ?></td>	
				<?php if($gi==1) { ?> <td></td> <?php } else { ?>
<td></td>
				<?php } ?>
				
				
</tr> <?php
if($dmm>$damt){
	$sts = 1;
	$less = 0;
	$pamt = $damt;
	$noo++;
}
elseif($dmm==$damt){
	$sts = 0; $less = 0;
	$pamt = $damt;
	$noo++;
}
else{
	
	$sts = 2;
	$pamt = $less2;
	$less = $dmm2;
}
$pamt = $less2;	
}
else{
$dmm = $dmm - $less; $noo++;
$spdue = $spdue + $less;
	?><tr>
					<td></td>
					<td></td>	
					<td></td>
					<td><?php echo $pday; ?></td>
					<td></td>
				<!--	<td><?php //echo $pass; ?></td>
					<td><?php //echo $rno; ?></td> -->
					<td><?php echo $less; ?></td><td></td>
				<td><?php echo $i6; ?></td>	
				<td><?php echo round($fine2,0); ?></td>	
				<?php if($gi==1) { ?> <td></td> <?php } else { ?>
<td></td>
				<?php } ?>
				
				
</tr> <?php
if($dmm>$damt){
	$sts = 1;
	$less = 0;
	$pamt = $damt;
	$noo++;
}
elseif($dmm==$damt){
	$sts = 0; $less = 0;
	$pamt = $damt;
	$noo++;
}
else{
	
	$sts = 0;
	$pamt = $dmm;
	$less = 0;
}
$pamt = $dmm; }
?>

<?php $dmm = $dmm;
$spfine = $spfine + $fine2;
$spdd = $spdd + $i6; $spff = $spff + $fine18;  
$sphl = $sphl + $hloan8;
 }  
$ttp = $ttp + $pass; $tti = $tti + $rno; $ttdue = $ttdue + $urname;	$ttdd = $ttdd + $i6;	
$ttfine = $ttfine + $fine2;	
$ttpf = $fine1 + $ttpf;	$tthl = $tthl + $hloan;	$tttot = $tttot + $urname1;
				
} } 





$qry51=mysqli_query($conn, "select * from net where mfin='$mfin2' &&  hpl='$hpl'");
					$n51=mysqli_num_rows($qry51);
					$row51 = mysqli_fetch_array($qry51);
					if($n51>0){ ?>
			<tr>
					<td></td>
					<td> 
					<?php $tdue = $urname - $hloan - $fine1; ?>
						<a href="editrcpt.php?fid=<?php echo $fidd; ?>"<button class="btn btn-success text-center">
                        A/C Closed
                    </button></a></td><td><?php echo $row51['roll']; ?></td>
					<td><?php echo $row51['paydate']; ?></td>
					<td></td>
				<!--	<td><?php //echo $pass; ?></td>
					<td><?php //echo $rno; ?></td> -->
					<td><?php echo $row51['tot']; ?></td><td></td>
				<td></td>	<td></td>	
				 <td><?php echo $row51['fine']; ?></td> 
					
			
</tr>			
				<?php $ttt = $row51['tot'];  $spdue = $spdue + $ttt;	}
else { 
if($less > 0){
	$tday = date('d-m-Y');
  $d11 = strtotime($duedat);
$d22 = strtotime($tday);
$min_date1 = min($d11, $d22);
$max_date1 = max($d11, $d22);
$i6 = 0;
if($d11<=$d22) {
while (($min_date1 = strtotime("+1 DAY", $min_date1)) <= $max_date1) {
    $i6++;
}
}
if($i6 < 3){
    
$fine2 = 0;
} else {
$fine2 = (($defamt/$damt)*($i6 * $less));
 }
if($fine2 < 0) {
	$fine2 = 0;
}

$dmm = 0;
	?><tr>
					<td></td>
					<td></td>	
					<td></td>
					<td></td>
					<td></td>
				<!--	<td><?php //echo $pass; ?></td>
					<td><?php //echo $rno; ?></td> -->
					<td></td><td><?php echo $less; ?></td>
				<td><?php echo $i6; ?></td>	
				<td><?php echo round($fine2,0); ?></td>	
				<?php if($gi==1) { ?> <td></td> <?php } else { ?>
<td></td>
				<?php } ?>
				
				
</tr>  <?php	
$spfine = $spfine + $fine2;
$spdd = $spdd + $i6;
$sppp = $sppp + $less;
}
$ii++;
while($ii<=$pp) {
	$zzzz++;
	$selected_date=$duedat;
		  	$selected_date=strtotime( $selected_date );
			$mysqldate = date( 'd-m-Y', $selected_date );
			$month = date( 'm', $selected_date );
			$day = date( 'd', $selected_date );
			$yyyy = date( 'Y', $selected_date );
			$zzz = $zz * 1;
$duedat = date("d-m-Y", strtotime("$hpdate + " . $zzz . " DAY"));
  $d11 = strtotime($duedat);
$d22 = strtotime("today");
$min_date1 = min($d11, $d22);
$max_date1 = max($d11, $d22);
$i6 = 0;
if($d11<=$d22) {
while (($min_date1 = strtotime("+1 DAY", $min_date1)) <= $max_date1) {
    $i6++;
} }

if($i6 <= 3){
    
$fine2 = 0;
} else {
$fine2 = $defamt * $i6; }
if($fine2 < 0) {
	$fine2 = 0;
}
	?>
<tr>
					<td><?php echo $ii; ?></td>
						<?php if($i6 > 0){ ?>
					<td><button class="btn btn-danger text-center"><i class="fa  fa-pencil fa-1x"></i><b><?php echo $duedat; $zz++;?></b>
                    </button></td>
					<?php } else { ?>
					<td><button class="btn btn-success text-center"><i class="fa  fa-pencil fa-1x"></i><b><?php echo $duedat; $zz++;?></b>
                    </button></td> <?php } ?><td></td><td></td>
					<td><?php echo $damt; ?></td>
					<!--<td><?php //echo $prin; ?></td>
					<td><?php //echo $intt2; ?></td> -->
					<td></td><td><?php echo $damt; ?></td>
						<td><?php echo $i6;?></td><td><?php echo round($fine2,0);?></td><td>-</td>
					
				
</tr> 

<?php  $ii++; 
$ttdd = $ttdd + $i6;	
$ttfine = $ttfine + $fine2;	
$spfine = $spfine + $fine2;
$spdd = $spdd + $i6;
$sppp = $sppp + $damt;
} } ?>	
<tr>
						<td></td>
						<td></td>
						<td></td>
						<td></td>
						<td><b><?php $ccc = $spdue + $sppp; echo $ccc; ?></b></td>
					<!--	<td><?php //echo $ttp; ?></td>
					<td><?php //echo $tti; ?></td> -->
						<td><b><?php echo $spdue; ?></b></td>
						<td><b><font color="red"><?php echo $sppp; ?></font></b></td>
						<td><b><?php echo $spdd; ?></b></td>
						<td><b><?php echo round($spfine,0); ?></b></td>
						<td><b><?php echo $spff; ?></b></td>
						
		</tr>		
					</tbody></table>
  
				<?php $rec = $spdue;
$pendfhj = $redd;
$balfhjh = $yel;
$totjkl = $ccc;
$selv1 = (($rec/$totjkl)*100);
$selv2 = (($pendfhj/$totjkl)*100);
$selv3 = (($balfhjh/$totjkl)*100);
  ?>
<div class="table-responsive">
  <div class="progress-bar progress-bar-striped active progress-bar-info" role="progressbar" style="width:<?php echo $selv1; ?>%">
    Paid
  </div>
  <div class="progress-bar progress-bar-striped active progress-bar-danger" role="progressbar" style="width:<?php echo $selv2; ?>%">
    Pending
  </div>
  <div class="progress-bar progress-bar-striped active progress-bar-success" role="progressbar" style="width:<?php echo $selv3; ?>%">
    Balalnce
  </div>
</div>

  
		

<div class="col-md-12">

</br><H4><B>SEND SMS</H4></B>
 <form name="form1" class="form-horizontal" method="post" action="" enctype="multipart/form-data">

 <textarea cols="12" class="form-control"  rows="5" name="sms" placeholder="ENTER THE MESSAGE"><?php echo $message;?></textarea>
  </br> <input type="text" class="form-control" name="pno" value="<?php echo $pno; ?>">

  </br><button type="submit" class="btn btn-primary" name="s321">SEND Now</button>
	<?php if(isset($_POST['s321']))
							{
								extract($_POST);  
			$username="senthoor"; 

$password="Somu1712.";

$message=$sms;

$sender="SENTOR"; //ex:INVITE

$mobile_number=$pno;

$url="http://osm.bulksms5.com/sendmessage.php?user=".urlencode($username)."&password=".urlencode($password)."&mobile=".urlencode($mobile_number)."&message=".urlencode($message)."&sender=".urlencode($sender)."&type=".urlencode('3');

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

echo $curl_scraped_page = curl_exec($ch);

curl_close($ch);
								}		
								?>
 </form>
</div>	




<div class="col-md-12"><div class="col-md-8"></div><div class="col-md-4">
 <form name="form14444"  class="form-horizontal" method="post" action="" enctype="multipart/form-data">
 <input type="text" class="form-control" value="<?php echo $hpll; ?>" name="hpll">
  <button type="submit" class="btn btn-primary" name="s3123">Next Acc</button>
	<?php if(isset($_POST['s3123']))
							{
								extract($_POST);  
				header("Location:udelete10.php?hpl=$hpll&mfin=$mfin2");
								}		
								?>
 </form>
</div>	</div>						
</div>
</div></div>
		  
		  
		  </div>     </div>
                <!-- end of weather widget -->
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->

        <!-- footer content -->
       <script src="vendors/pnotify/dist/pnotify.js"></script>
    <script src="vendors/pnotify/dist/pnotify.buttons.js"></script>
    <script src="vendors/pnotify/dist/pnotify.nonblock.js"></script>
	   <?php include "layouts/footer.php"; ?>
  </body>
</html>
