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

$uniq_id = trim($uniq_id);
//$sec = $obj->Details_By_Cond("_fee_master_invoice","_invoice_no='$invoice'");
$std = $obj->Details_By_Cond("_pf_std_personal_info","_uniq_id='".$uniq_id."'");
$std_id= $std['_id'];
$sec = $obj->Details_By_Cond("_pf_std_basic_info","_pid='".$std_id."'");
$section_id=$sec['_section_id'];
if($f_month=='01'){$mo11 = 'January';}
if($f_month=='02'){$mo11 = 'February';}
if($f_month=='03'){$mo11 = 'March';}
if($f_month=='04'){$mo11 = 'April';}
if($f_month=='05'){$mo11 = 'May';}
if($f_month=='06'){$mo11 = 'June';}
if($f_month=='07'){$mo11 = 'July';}
if($f_month=='08'){$mo11 = 'August';}
if($f_month=='09'){$mo11 = 'September';}
if($f_month=='10'){$mo11 = 'October';}
if($f_month=='11'){$mo11 = 'November';}
if($f_month=='12'){$mo11 = 'December';}



if($to_month=='01'){$mo1 = 'January';}
if($to_month=='02'){$mo1 = 'February';}
if($to_month=='03'){$mo1 = 'March';}
if($to_month=='04'){$mo1 = 'April';}
if($to_month=='05'){$mo1 = 'May';}
if($to_month=='06'){$mo1 = 'June';}
if($to_month=='07'){$mo1 = 'July';}
if($to_month=='08'){$mo1 = 'August';}
if($to_month=='09'){$mo1 = 'September';}
if($to_month=='10'){$mo1 = 'October';}
if($to_month=='11'){$mo1 = 'November';}
if($to_month=='12'){$mo1 = 'December';}



//echo $std_id;
$institute = $obj->Details_By_Cond(" _int_institute_setup_vw","section_id='".$sec['_section_id']."'");

$st_profile = $obj->Details_By_Cond(" _pf_std_personal_info","_id='".$std_id."'");
$where="_section_id='".$section_id."' AND _month BETWEEN ".$f_month." AND ".$to_month." AND _year BETWEEN '".$f_year."' AND '".$to_year."' AND _std_id='".$std_id."' AND _status!='AD'";

$where_p="_section_id='".$section_id."' AND _month BETWEEN ".$f_month." AND ".$to_month." AND _year BETWEEN '".$f_year."' AND '".$to_year."' AND _std_id='".$std_id."' AND _status!='AD'";
$where_u="_section_id='".$section_id."' AND _month BETWEEN ".$f_month." AND ".$to_month." AND _year BETWEEN '".$f_year."' AND '".$to_year."' AND _std_id='".$std_id."' AND _status!='AD'";

$total = $obj->View_column_details_By_Cond("_fee_master_invoice ","sum(_total_amount) as total","$where");
$total_p = $obj->View_column_details_By_Cond("_fee_master_invoice ","sum(_paid_amount) as paid","$where_p");
$total_u = $obj->View_column_details_By_Cond("_fee_master_invoice ","sum(_due_amount) as unpaid","$where_u");

//echo $st_profile['_full_name'];
//echo $total['total'];
				  
				   
?>

<style type="text/css">

th{

   font-size:13px;
   text-align: center;


}

i{
	cursor:pointer;
}

.select_list{
	width: 200px;
}

.input_sub{
	width: 185px;
}
.select_list1{
	width: 100px;
	float: left;
	margin-left: 3px;
	margin-right: 3px;
}
.centered{
	margin: 0 auto;
}


</style>

<div class=" row-fluid">
<legend style="text-align:center;">
   Student Fee Collection Summery  (<?php if($institute['shift']!="-"){echo '  SHIFT '.$institute['shift'].' / ';}
                      if($institute['medium']!="-"){echo '  MEDIUM :'.$institute['medium'].' / ';}
                      if($institute['class']!="-"){echo '  CLASS :'.$institute['class'].' / ';}
                      if($institute['department']!="-"){echo '  DEPARTMENT :'.$institute['department'].' / ';}
                      if($institute['student_type']!="-"){echo '  STUDENT TYPE :'.$institute['student_type'].' / ';}
                      if($institute['section']!="-"){echo '  SECTION :'.$institute['section']    ;}  ?>)
</legend>
	
</div>
<div  class=" row-fluid" style="align:center;">
	<div class="span3">
	</div>

    <div class="profile-user-info profile-user-info-striped span6" >
		<div class="profile-info-row">
			<div class="profile-info-name"> Student Name </div>

			<div class="profile-info-value">
				<span class="editable" id=""><?php echo $st_profile['_full_name']; ?></span>
			</div>
		</div>
		<div class="profile-info-row">
			<div class="profile-info-name">Section Roll </div>

			<div class="profile-info-value">
				<span class="editable" id=""><?php echo $st_profile['_section_roll']; ?></span>
			</div>
		</div>
		<div class="profile-info-row">
			<div class="profile-info-name">Contact Mobile</div>

			<div class="profile-info-value">
				<span class="editable" id=""><?php echo $st_profile['_contact_mobile']; ?></span>
			</div>
		</div>
    </div>
</div>

<br/>





<div class="row-fluid" id="tab">


    <legend style="text-align:center;">
    (<?php echo $mo11.'/'.$f_year.' - '.$mo1.'/'.$to_year; ?>)
    </legend>


    
<div class="row-fluid"  style="margin-top: 15px;" >

        
			

	<table id="sample-table-121" class="table table-striped table-bordered table-hover"  >
		<thead style="">
			<th>Sl</th>
			<th>Invoice NO</th>
			<th>Month</th>
			<th>Year</th>
			<th>Total Amount</th>
			<th>Due Amount</th>
			<th>Paid Amount</th>
			<th>Status</th>
			<th>Action</th>
		</thead>
		<tbody>
<?php
$i=0;
 $where = "_std_id='".$std_id."' AND _section_id='".$section_id."' AND _month BETWEEN ".$f_month." AND ".$to_month." AND _year BETWEEN '".$f_year."' AND '".$to_year."' AND _status!='AD'";

 $table_name = "_fee_master_invoice";

foreach($obj->View_All_By_Cond($table_name,$where) as $value_st){
extract($value_st);
$i++;
$month=$value_st['_month'];
if($month=='01'){$mo1 = 'January';}
if($month=='02'){$mo1 = 'February';}
if($month=='03'){$mo1 = 'March';}
if($month=='04'){$mo1 = 'April';}
if($month=='05'){$mo1 = 'May';}
if($month=='06'){$mo1 = 'June';}
if($month=='07'){$mo1 = 'July';}
if($month=='08'){$mo1 = 'August';}
if($month=='09'){$mo1 = 'September';}
if($month=='10'){$mo1 = 'October';}
if($month=='11'){$mo1 = 'November';}
if($month=='12'){$mo1 = 'December';}

$value_st['_std_id'];



//$std_id= $value_head['_std_id'];

?>       
        <tr>
		    <td><?php echo  $i; ?></td>
		    <td><?php echo  $value_st['_invoice_no']; ?></td>
		    <td><?php echo  $mo1; ?></td>
		    <td><?php echo  $value_st['_year']; ?></td>
		   
		    <td style="text-align:center;"><?php echo  $value_st['_total_amount']; ?></td>	    
		    <td style="text-align:center;"><?php echo  $value_st['_due_amount']; ?></td>	    
		    <td style="text-align:center;"><?php echo  $value_st['_paid_amount']; ?></td>	    
		    <td style="text-align:center;">

                <?php if($value_st['_status']=='P'){ ?>
				<span class="btn btn-minier btn-success"><i class="icon-ok bigger-70"></i>Paid</span>
				<?php } 
				elseif($value_st['_status']=='PR'){ ?>
				<span class="btn btn-minier btn-warning">Partial Paid</span>
				<?php }  elseif($value_st['_status']=='U'){ ?>
				<span class="btn btn-minier btn-danger">Unpaid</span>
				<?php } ?>



		    </td>
			<td class="td_pad">
				   	<a href="module/fees/student_invoice_pdf.php?invoice_id=<?php echo $value_st['_invoice_no']; ?>" >
					<button type="button" class="btn btn-warning btn-minier">
						<i class="icon-print bigger-125 icon-on-right"></i>
					</button>
					</a>
			</td>
		</tr>

<?php } ?>
       </tbody>

       <tfoot>
 
		    <tr style="background-color: #e0e0d1;">
		      <td colspan="4" style="text-align:center; font-weight: bold;"></td>
		     
		      <td colspan="" style="text-align:center; font-weight: bold;">Total Amount : <?php echo   $total['total'];?></td>
		      <td colspan="" style="text-align:center;font-weight: bold;">Unpaid Amount : <?php echo   $total_u['unpaid']; ?></td>
		      <td colspan="" style="text-align:center;font-weight: bold;">Paid Amount : <?php echo   $total_p['paid']; ?></td>
		      <td colspan="" style="text-align:center;font-weight: bold;"></td>
			  <td></td>
		      
		    </tr>

		</tfoot>



       
      
</table>

</div>
</div>



