<?php
session_start();
// ============
include("../../asset/theme/css/myfunc.php");
include("../../php_crud/my_class.php");
include('alert.php');
$obj=new my_class();
// ============
$branchid = $_SESSION['LOGIN_BRANCH'];

extract($_GET);
$invoice = trim($invoice);

$sec = $obj->Details_By_Cond("_fee_master_invoice","_invoice_no='$invoice'");
$std = $obj->Details_By_Cond("_pf_std_personal_info","_id='".$sec['_std_id']."'");

$det_in = $obj->Details_By_Cond("_int_institute_setup_vw","section_id='".$sec['_section_id']."'");
//==================================================================
$lf_dept = $det_in['department_id'];
include("late_fine_date_chk.php");


//===================================================================
if($sec['_status']=='U' OR $sec['_status']=='PR'){
?>

<script src="module/fees/js/collect_fee.js" type="text/javascript"></script>

<div class="row-fluid">
	<div class="span2"></div>
	<div class="span8">
		<table id="sample-table-273" class="table table-striped table-bordered table-hover" style="font-size:13px;">
			<thead style="padding: 3px;">
				<tr>
					<td colspan="4" style="text-align: center; background-color:#438eb9; color:#FFFFFF; font-weight:bold; font-size:14px;"><?php echo $std['_full_name']; ?>'s Fee Information</td>
				</tr>
				<tr>
					<td width="16%" style="font-weight:bold; background-color:#FFFFFF; line-height:10px; text-align:right;">Shift : </td>
                    <td style="font-weight:bold; background-color:#FFFFFF; line-height:10px;"><span class="label label-success" style="font-weight:bold;"><?php echo $det_in['shift']; ?></span></td>
					<td width="16%" style="font-weight:bold; background-color:#FFFFFF; line-height:10px;text-align:right;">Medium : </td>
                    <td style="font-weight:bold; background-color:#FFFFFF; line-height:10px;"><span class="label label-success" style="font-weight:bold;"><?php echo $det_in['medium']; ?></span></td>
				</tr>
				<tr>
					<td style="font-weight:bold; line-height:10px;text-align:right;">Class :</td>
                    <td style="font-weight:bold; line-height:10px;"><span class="label label-warning" style="font-weight:bold;"><?php echo $det_in['class']; ?></span></td>
					<td style="font-weight:bold;line-height:10px;text-align:right;">Department </td>
                    <td style="font-weight:bold; line-height:10px;"><span class="label label-warning" style="font-weight:bold;"><?php echo $det_in['department']; ?></span></td>								
				</tr>
				<tr>
					<td style="font-weight:bold; background-color:#FFFFFF; line-height:10px;text-align:right;">Student Type : </td>
                    <td style="font-weight:bold; background-color:#FFFFFF; line-height:10px;"><span class="label label-success" style="font-weight:bold;"><?php echo $det_in['student_type']; ?></span></td>	
					<td style="font-weight:bold; background-color:#FFFFFF; line-height:10px;text-align:right;">Section : </td>
                    <td style="font-weight:bold; background-color:#FFFFFF; line-height:10px;"><span class="label label-success" style="font-weight:bold;"><?php echo $det_in['section']; ?></span></td>				
				</tr>
				<tr>				
					<td style="font-weight:bold; line-height:10px;text-align:right;">Roll : </td>
                    <td style="font-weight:bold; line-height:10px;"><span class="label label-warning" style="font-weight:bold;"><?php echo $std['_section_roll']; ?></span></td>
					<td style="font-weight:bold; line-height:10px;text-align:right;">Year : </td>
                    <td style="font-weight:bold; line-height:10px;"><span class="label label-warning" style="font-weight:bold;"><?php echo $sec['_year']; ?></span></td>
				</tr>
				<tr>				
					<td style="font-weight:bold; background-color:#FFFFFF; line-height:10px;text-align:right;">Month : </td>
                    <td style="font-weight:bold; background-color:#FFFFFF; line-height:10px;"><span class="label label-success" style="font-weight:bold;"><?php echo $obj->Month($sec['_month']); ?></span></td>
					<td style="font-weight:bold; background-color:#FFFFFF; line-height:10px;text-align:right;">Invoice : </td>
                    <td style="font-weight:bold; background-color:#FFFFFF; line-height:10px;"><span class="label label-success" style="font-weight:bold;"><?php echo $sec['_invoice_no']; ?></span></td>
				</tr>
			</thead>
		</table>
	</div>
	<div class="span2"></div>

</div>

<div class="row-fluid">
	<div class="span2">
		<input type="hidden" id="mod_id_1" value="<?php echo $mod_id; ?>">
	</div>
	<div class="span8">	
	<table id="sample-table-273" class="table table-striped table-bordered table-hover" style="font-size:12px;">
		<thead>
			<tr>
				<th>Sl</th>
				<th>Fee Head</th>
				<th>Req. Amount</th>
				<th>Discount</th>
			</tr>
		</thead>
		
		<tbody>
			<?php
			$i=0;
			foreach($obj->View_All_By_Cond("_fee_details_invoice","_invoice_no='$invoice' AND _br_id='$branchid'") as $v1){
			$i++;
			?> 			
			<tr>
				<td class="td_pad"><?php echo $i; ?></td>
				<td class="td_pad"><?php echo $v1['_fee_head']; ?></td>
				<td class="td_pad"><?php if($v1['_type']=='C'){ echo $v1['_amount']; }else{echo '-';} ?></td>
				<td class="td_pad"><?php if($v1['_type']=='D'){ echo $v1['_amount']; }else{echo '-';} ?></td>
			</tr>
			<?php } ?>	
		</tbody>	

		<tfooter>
		<?php
			$c = $obj->View_column_details_By_Cond("_fee_details_invoice","SUM(_amount) AS credit","_invoice_no='$invoice' AND _type='C' AND _br_id='$branchid'");
			$d = $obj->View_column_details_By_Cond("_fee_details_invoice","SUM(_amount) AS debit","_invoice_no='$invoice' AND _type='D' AND _br_id='$branchid'");
		?>
			<tr>
				<th colspan="2">Total = </th>
				<th><?php if($c['credit']!=''){ echo $c['credit']; }else{echo '-';} ?></th>
				<th><?php if($d['debit']!=''){ echo $d['debit']; }else{echo '-';} ?></th>
			</tr>
			<tr>
			<?php $tot = $obj->Details_By_Cond("_fee_master_invoice","_invoice_no='$invoice'");?>
				<th colspan="2">Net Payable = </th>
				<th colspan="2"><?php echo $tot['_due_amount']; ?></th>
			</tr>
			<tr>
				<th colspan="2">Discount = </th>
				<th colspan="2"><input type="text" name="discount" id="discount"></th>
			</tr>
		</tfooter>
	</table>
	<input type="hidden" name="inv" value="<?php echo $tot['_invoice_no']; ?>" id="inv">
	<input type="hidden" name="amount" value="<?php echo $tot['_due_amount']; ?>" id="amount">
    <input type="hidden" name="last_payment_date" value="<?php echo $sec['_last_payment_date']; ?>" id="last_payment_date">
    
    <input type="hidden" name="today" value="<?php echo date('Y-m-d'); ?>" id="today">
    
    
   
	</div>
</div>

<div class="row-fluid">
	<div class="span12" style="text-align:center;">
		<button class="btn btn-small btn-success" id="submit13" type="button">Payment Confirm</button>
	</div>
</div>



<?php
}
elseif($sec['_status']=='P'){
?>
<!--<div class="row-fluid">This Invoice Already Paid</div>-->
<div class="alert alert-error">
<button class="close" type="button" data-dismiss="alert">
<i class="icon-remove"></i>
</button>
<strong>
<i class="icon-remove"></i>
Oh snap!
</strong>
This Invoice Already Paid
<br>
</div>
<?php
}
elseif($sec['_status']=='AD'){
?>
<!--<div class="row-fluid">This Invoice Expired</div>-->
<div class="alert alert-error">
<button class="close" type="button" data-dismiss="alert">
<i class="icon-remove"></i>
</button>
<strong>
<i class="icon-remove"></i>
Oh snap!
</strong>
This Invoice Expired
<br>
</div>
<?php
}
else{
?>
<!--<div class="row-fluid">Invalid Invoice No or Barcode</div>-->
<div class="alert alert-error">
<button class="close" type="button" data-dismiss="alert">
<i class="icon-remove"></i>
</button>
<strong>
<i class="icon-remove"></i>
Oh snap!
</strong>
Invalid Invoice No or Barcode
<br>
</div>
<?php
}
?>