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

extract($_GET);
//$invoice_no;
//$year;
$section_id;
$student_type_id;
$department_id;
$class_id;
$medium_id;
$shift_id;
$year;
$month;


?>
<script src="module/fees/js/section_wise_invoice_roleback.js" type="text/javascript"></script>
<style type="text/css">
	.input-append, .input-prepend {
		margin-bottom: 0px !important;
	}	
	.table th, .table td{
		padding: 2px !important;
		font-size: 12px;
	}
	.dataTable th[class*="sort"]::after {
	    margin-right: 0;
	}
	.select_in{
		max-width:90px !important;
	}
</style>

<?php
/*$chk_invo = $obj->Details_By_Cond("_fee_master_invoice","_invoice_no='$section_id'");
$section_id = $chk_invo['_section_id'];
$month = $chk_invo['_month'];
$year = $chk_invo['_year'];
$det_in = $obj->Details_By_Cond("_int_institute_setup_vw","section_id='$section_id'");

$tch_id = $obj->Details_By_Cond("_r_class_routine","_section_id='$section_id' AND _teacher_type='CT' AND _teacher_id!='0' GROUP BY _teacher_type");
$teacher_id =  $tch_id['_teacher_id'];

$tch_det = $obj->Details_By_Cond("_pf_emp_personal_info","_id='$teacher_id'");*/

?>

<div class="row-fluid">
<legend>
<?php /*?><div class="span12">
		<table id="sample-table-273" class="table table-striped table-bordered table-hover" style="font-size:13px;">
			<thead style="padding: 3px;">
				<tr>
					<td colspan="8" style="text-align: center; background-color:#438eb9; color:#FFFFFF; font-weight:bold; font-size:14px;">Students Payment Invoice</td>
				</tr>
				<tr>
					<td width="10%" style="font-weight:bold; line-height:10px; text-align:right;">Shift : </td>
                    <td style="font-weight:bold; line-height:10px;"><span class="label label-success" style="font-weight:bold;"><?php echo $det_in['shift']; ?></span></td>
					<td width="10%" style="font-weight:bold; line-height:10px;text-align:right;">Medium : </td>
                    <td style="font-weight:bold; line-height:10px;"><span class="label label-warning" style="font-weight:bold;"><?php echo $det_in['medium']; ?></span></td>
                    <td width="10%" style="font-weight:bold; line-height:10px;text-align:right;">Class :</td>
                    <td style="font-weight:bold; line-height:10px;"><span class="label label-success" style="font-weight:bold;"><?php echo $det_in['class']; ?></span></td>
				
                <td width="10%" 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-warning" style="font-weight:bold;"><?php echo $det_in['section']; ?></span></td>				
				
                	<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 $month; ?></span></td>				
					
					<td style="font-weight:bold; background-color:#FFFFFF; line-height:10px;text-align:right;">Year : </td>
                    <td style="font-weight:bold; background-color:#FFFFFF; line-height:10px;"><span class="label label-warning" style="font-weight:bold;"><?php echo $year; ?></span></td>
				</tr>
				
			</thead>
		</table>
	</div><?php */?>


	<?php /*?>Student Fee Invoice (<?php echo 'Class: '.$det_in['class'].', Department: '.$det_in['department'].', Student Type: '.$det_in['student_type'].', Section: '.$det_in['section'].', Month: '.$month.'-'.$year; ?>).<?php */?>
</legend>
</div>
<?php
$total_invoice = $obj->unpaid_invoice_count("_fee_total_receive","_br_id='$branchid' and _class_id='$class_id' and _section_id='$section_id' and _year='$year' and _month='$month' and _receive_amount>0");

?>
<!-- ==================================== -->

<div class="row-fluid" style="background-color:#f5f5f5;-webkit-box-shadow: 0 8px 6px -6px black; -moz-box-shadow: 0 8px 6px -6px black; box-shadow: 0 8px 6px -6px black; padding:10px; text-align:center;">
	<div class="widget-header header-color-green2">
    	<h4 class="lighter smaller" style="font-weight:bold;">Section Wise Invoice Roleback Part</h4>
    </div> 
    <div class="infobox infobox-pink" style="height:90px;">
        <div class="infobox-icon">
            <i class="icon-shopping-cart"></i>
        </div>

        <div class="infobox-data" style="border:none;">
            <span class="infobox-data-number"><?php echo $total_invoice; ?></span>
            <div class="infobox-content">
            <h3 style="color:#c7266c;">Total Invoice</h3>
            </div>
        </div>
        <!--<div class="stat stat-important">+4%</div>-->
    </div>
    <div class="infobox" style="border:0px solid #f5f5f5; background-color:#f5f5f5;">
        <button <?php if($total_invoice==0){?> disabled="disabled" <?php }?> class="btn btn-small btn-success" onclick="roleback_invoice(<?php echo $section_id.','.$class_id.','.$branchid.','.$year.','.$month ;?>)" data-dismiss="modal" type="button" style=" display: block; text-align:center;"> Section Wise Roleback </button>

        
        <!--<div class="stat stat-important">+4%</div>-->
    </div>
 <div class="widget-header header-color-green2">
    	<h4 class="lighter smaller" style="font-weight:bold;">Section Wise Invoice Details</h4>
    </div>  		
	<table id="sample-table-273" class="table table-striped table-bordered table-hover" style="font-size:10px;">
		<thead>
			<th>Sl</th>
			<th>Student ID</th>
			<th>Name</th>
			<th>Roll</th>
			<th>Invoice</th>			
			<th>Payable Amount</th>
			<th>Due Amount</th>
			<th>Paid Amount</th>
			<th>Status</th>			
			<!--<th>Action</th>-->
		</thead>
		<tbody>
			<?php
			$i=0;
			foreach($obj->section_wise_invoice_roleback($section_id) as $value_s){
			extract($value_s);
			$i++;
			?>	
			<tr>
				<td class="td_pad">
					<?php echo $i; ?>
				</td>
				<td class="td_pad"><?php echo $value_s['_uniq_id']; ?></td>
				<td class="td_pad"><?php echo $value_s['_full_name']; if(!empty($value_s['_nick_name'])){echo ' ('.$value_s['_nick_name'].')'; } ?></td>
				<td class="td_pad"><?php echo $value_s['_section_roll']; ?></td>
				<td class="td_pad">
				<?php
					echo $obj->print_barcode($value_s['_invoice_no'], "20", "1");
				?>
				</td>
				<td class="td_pad"><?php echo $value_s['_total_amount']; ?></td>	
				<td class="td_pad"><?php echo $value_s['_due_amount']; ?></td>
				<td class="td_pad"><?php echo $value_s['_paid_amount']; ?></td>				
				<td class="td_pad">
				<?php if($value_s['_status']=='P'){ ?>
				<span class="btn btn-minier btn-success"><i class="icon-ok bigger-70"></i>Paid</span>
				<?php } elseif($value_s['_status']=='U'){ ?>
				<span class="btn btn-minier btn-danger">Unpaid</span>
				<?php } elseif($value_s['_status']=='PR'){ ?>
				<span class="btn btn-minier btn-warning">Partially Paid</span>
				<?php } elseif($value_s['_status']=='AD'){ ?>
				<span class="btn btn-minier btn-warning">Adjustment</span>
                <?php } elseif($value_s['_status']=='DEL'){ ?>
                <span class="btn btn-minier btn-danger">Deleted</span>
				<?php } ?>
				</td>

				<?php /*?><td class="td_pad">
				   	
                    <?php
					//if($_SESSION['delete']=='Y'){
					if($value_s['_status']=='P' || $value_s['_status']=='PR'){
					?>	
					-->
                    <button class="btn btn-small btn-success" onclick="delete_invoice(<?php echo $section_id;?>)" data-dismiss="modal" type="button" style=" display: block; float: left;"> Roleback </button>
                    
					<?php }else{ ?>
                    <span class="btn btn-minier btn-success"><i class="icon-ok bigger-70"></i>No Roleback</span>
					<?php }?>
				</td><?php */?>
				
							
				
			</tr>	
			<?php } ?>
			
			
		</tbody>	

	</table>

</div>

<!-- ========================== -->



<!--- Edit Invoice -->
<div id="modal-table_edit" class="modal hide fade  " style="left: 42%; width: 60%;"   tabindex="-1">
	<form class="form-vertical" >
	<div class="modal-header no-padding">
		<div class="table-header">
			<button type="button" class="close" data-dismiss="modal">&times;</button>
			Student Invoice Edit
		</div>
	</div>
	<div class="modal-body" id="model_table_value_edit" style="min-height: 350px !important;
    overflow-y: none;">
	</div>

	<div class="modal-footer">
		<button onclick="call_update_invoice()" id="btn_invoice" class="btn btn-small btn-success" data-dismiss="modal" type="button" style=" display: block; float: left;">
			<i class="icon-ok bigger-100"></i>
			Update
		</button>

		<button class="btn btn-small btn-danger pull-left" data-dismiss="modal" style="float: left;">
			<i class="icon-remove"></i>
			Close
		</button>		
	</div>
	</form>
									
</div>



<script type="text/javascript">

$(".chzn-select").chosen(); 

</script>


