<?php 
include("../../db.php");
$pgMod="fee_summery";
$pgAct="view";

 $_SESSION["admin"]["session"]=$_REQUEST['session'];
 $_SESSION["admin"]["school_id"]= 1;
 $_REQUEST['fmonth']=$_GET['fmonth'];

	$fdate=$_GET["fyear"]."/".$_GET["fmonth"]."/".$_GET["fdate"];
	$tdate=$_GET["tyear"]."/".$_GET["tmonth"]."/".$_GET["tdate"];



	$pmode  = array();
	$ptotal = array();
	$pusers = array();
    $temp   = array();
    $tempuser = array();

		$overAllTotal=0;

		$inventoryReceipt = $db->getRows("SELECT *, r.id as rid, r.rid as rrid, i.name as item FROM faculty_inventory_receipt r left join inventory i on r.inventory_id=i.id WHERE r.school_id='".$_SESSION["admin"]["school_id"]."' and issue_date between '$fdate' and '$tdate' GROUP BY r.rid");
// 		echo $db->getErMsg().$db->getLastQuery();
		if(is_array($inventoryReceipt) && count($inventoryReceipt)>0){
			$tndate = date('Y/m/d', strtotime('-1 days',strtotime($tdate)));

			?>
            <center><h5><p style="float:right">Collection Date: 
			<?php if(strtotime($tndate)==strtotime($fdate)){
			echo date("d-M-Y",strtotime($tndate));?> - <?php echo date("l",strtotime($tndate));}
			else echo date("d-M-Y",strtotime($fdate)) ." to ".date("d-M-Y",strtotime($tndate)); ?></p> <p>Inventory Collection Report</p>	</h5></center>

            <style>
                @media print {
            
                    #myPrntbtn {
                        display :  none;
                    }
            
                }
            </style>



			<table class="table" cellspacing="0" cellpadding="0" border="1" id="tblData">
				<thead>
				<tr style="cursor:pointer">
                	<th>S.No</th>
					<th>Name</th>
                    <th>Father Name</th>
                    <th>Department</th>
					<th>Mobile</th>
					<th>Receipt No.</th>
					<th>payment Mode</th>
					<th>Item</th>
					<th>Quantity</th>
                    <th>Amount</th>
                    <th>Issue Date</th>
				</tr>
				</thead>
				<tbody>
					<?php $s=1;
						foreach($inventoryReceipt as $inv){
							$student=$db->getRow("select * from staff where school_id='".$_SESSION["admin"]["school_id"]."' and idno='".$inv[idno]."' ");
                            $total = $db->getVal("select sum(total_amount) from faculty_inventory_receipt where rid='".$inv["rrid"]."' ");
                            
                            $usr1 = $db->getVal("select name from users where id='$inv[added_by]'"); 
                            array_push($pusers, $usr1);
                            if(in_array($usr1, $tempuser)){
                                 
                                } else { 
                                    array_push($tempuser,$usr1);  
                                }
                            if(count($student)>1){
                            ?>
						<tr>
                        	<td><?php echo $s; ?></td>
							<td><?php echo $student["name"] ?></td>
                            <td><?php echo $student["fname"] ?></td>
                            <td><?php echo $student["department"] ?></td>
							<td><?php echo $student["mobile"] ?></td>
							<td><?php echo $inv["rrid"] ?></td>
							<td><?php $m = $inv["payment_mode"];
							    echo $m;
							    $pm = $m;
       							 array_push($pmode, $inv["payment_mode"]);
           							 
   		                         if(in_array($pm, $temp)){
    
                                } else {
                                    array_push($temp,$pm);
                                }
							?></td>
                            <td><?php echo $inv["item"] ?></td>
                            <td><?php echo $inv["num_item"]; ?></td>
                            <td><?php echo $total; 
                            array_push($ptotal, $total);
                            $overAllTotal+=$total; ?></td>
							<td><?php echo date("d-m-Y",strtotime($inv['issue_date'])); ?></td>
						</tr>
						<?php
						$s++;
                            }
						}
					?>
				</tbody>
				
				<tfoot>
					<tr>
					    <td colspan="9">Total</td>
					    <td><? echo $overAllTotal; ?></td>
					    <td></td>
					</tr>
				</tfoot>
			</table>  
			
			<br><br>
			
	    <h5>Counterwise Fees Collection Details</h5>
		<table class="table" cellspacing="0" cellpadding="0" border="1" id="tblData">
            <thead>
		    <tr>
		        <th></th>
		        <th>Collected By</th>
		        <?php
		            foreach($temp as $pm1){
		                echo "<th>$pm1</th>";
		            }
		        ?>
		        <th>Total</th>
		    </tr>
		    </thead>
		    <tbody>
		    <?php $totalfeescollected = 0; $registrationtotal = 0;
            $j = 0;
            $valary = array(); 
            $feetotal = 0;

		    foreach($tempuser as $row){ ?> 
		    <tr>
		        <td></td>
		        <td>
		            <?php echo $row; $j++; ?>
		        </td>

		        <?php   $m = 0;
        		        $value = array();
                        $rowtotal = 0; 

    		            foreach($pmode as $pt){

                            if($row == $pusers[$m]){
    		                $j = array_search($pt, $temp);
                                $value[$j] += $ptotal[$m];
                                $valary[$j] += $ptotal[$m];
    		                }
    		                $m++;
    		            }

                        $n = 0;
    		            foreach($temp as $vs1){
    		                
    		                if($value[$n]){
    		                echo "<td>$value[$n]</td>";
    		                $rowtotal += $value[$n];
    		                } else echo "<td>0</td>";
    		                $n++;
    		            }
		        ?>
		        <td><?php echo $rowtotal; ?></td>
		    </tr>
		    <?php } ?>
		    </tbody>
		    
		    <tfoot>
		        <tr>
		            <td>Total</td>
		            <td></td>
                    <?php $nm = 0;
		            foreach($temp as $vs1){
		                echo "<td>$valary[$nm]</td>";
		                $feetotal += $valary[$nm];
		                $nm++;
		            }	?>
		            <td><?php echo $feetotal; ?></td>
		        </tr>
		    </tfoot>
		</table>
			
            Print Date : <?php echo date('d-M-Y'); ?>
            
            
            
            
			<?php
		}else{
			echo "No record found<br />".$db->getErMsg();
		}


?>
<style>.top-bar-minimize{display:none;}
thead, tfoot {display: table-header-group;}
.top-bar+.well,.accordion .accordion-heading+.accordion-body{display: inline-block !important;width: 100% !important;overflow: inherit !important;} 
.dynamic{display:none}
table td {
padding: 6px !important;
}
legend{line-height: 16px;font-weight:100;}



 .gmaps{margin:0;padding:0;height:400px;border-radius:0 0 5px 5px;overflow:hidden;box-sizing:content-box}
 .gmaps>div>div:nth-child(3),.gmaps>div>div:nth-child(2){display:none}
 .gmaps img{max-width:none}
 .gmaps.map-small{height:200px}
 table.dataTable td,table.dataTable th{padding:12px 0;line-height:24px}
 .table-bordered.table{background-color:#eee;border:1px solid #c2c2c2;box-shadow:0 1px 0 white}
 .table-bordered.table tbody>tr:nth-child(odd)>td,.table-bordered.table .table tbody>tr:nth-child(odd)>td,.table-bordered.table .data-table tbody>tr:nth-child(odd)>td,.table-bordered.table .table-striped tbody>tr:nth-child(odd)>th,.table-bordered.table .table tbody>tr:nth-child(odd)>th,.table-bordered.table .data-table tbody>tr:nth-child(odd)>th,.table-bordered.table tbody tr,.table-bordered.table tbody td,.table-bordered.table th,.table-bordered.table td{border:0;box-shadow:none}
 .table-bordered.table tbody>tr:nth-child(odd)>td,.table-bordered.table .table tbody>tr:nth-child(odd)>td,.table-bordered.table .data-table tbody>tr:nth-child(odd)>td,.table-bordered.table .table-striped tbody>tr:nth-child(odd)>th,.table-bordered.table .table tbody>tr:nth-child(odd)>th,.table-bordered.table .data-table tbody>tr:nth-child(odd)>th,.table-bordered.table tbody tr,.table-bordered.table tbody td,.table-bordered.table th,.table-bordered.table td{border-bottom:1px solid #c2c2c2;border-top:1px solid white}
 .table-bordered.table tbody tr:last-child td{border-bottom:0}
 table.dataTable{margin:0 auto;clear:both;width:100%}
 table.dataTable thead th{cursor:pointer;*cursor:hand}
 table.dataTable thead tr{background:#3B5999}
 .table thead{background:crimson;color:#fff;}
 table.dataTable tfoot th,table.dataTable thead th,table.dataTable thead td{font-weight:bold;background-image:-moz-linear-gradient(bottom,rgba(0,0,0,0.05) 0,rgba(255,255,255,0.05) 100%);background-image:-o-linear-gradient(bottom,rgba(0,0,0,0.05) 0,rgba(255,255,255,0.05) 100%);background-image:-webkit-linear-gradient(bottom,rgba(0,0,0,0.05) 0,rgba(255,255,255,0.05) 100%);background-image:linear-gradient(bottom,rgba(0,0,0,0.05) 0,rgba(255,255,255,0.05) 100%);color:#fff;border-bottom:1px solid #c2c2c2;-webkit-box-shadow:0 2px 0 #fff;-moz-box-shadow:0 2px 0 #fff;box-shadow:0 2px 0 #fff}
 table.dataTable tfoot th:first-child,table.dataTable thead th:first-child{padding-left:20px}
 table.dataTable thead th{border-top:1px solid #c2c2c2;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.7),0 2px 0 white;-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.7),0 2px 0 white;box-shadow:inset 0 1px 0 rgba(255,255,255,0.7),0 2px 0 white}
 table.dataTable td.center,table.dataTable td.dataTables_empty{text-align:center}
 .dataTables_length select{max-width:50px}
 .dataTables_wrapper{position:relative;clear:both;*zoom:1}
 th.center{text-align:center}
 .dataTables_length{float:left}
 .dataTables_filter{float:right;text-align:right;padding-left:0!important}
 .dataTables_filter,.dataTables_length{padding:24px 20px}
 .dataTables_filter select,.dataTables_length select,.dataTables_filter textarea,.dataTables_length textarea,.dataTables_filter input[type="text"],.dataTables_length input[type="text"],.dataTables_filter input[type="password"],.dataTables_length input[type="password"]{margin:0;margin-left:5px}
 .dataTables_length{padding-top:24px;padding-bottom:23px;padding-right:0;display:none;}
 .dataTables_info{clear:both;float:left;padding:12px 20px;color:blue}
 .dataTables_paginate{float:right;text-align:right;padding:12px 20px}
 .paginate_disabled_previous,.paginate_enabled_previous,.paginate_disabled_next,.paginate_enabled_next{height:18px;float:left;cursor:pointer;*cursor:hand;color:#6b8a41!important}
 .paginate_disabled_previous:hover,.paginate_enabled_previous:hover,.paginate_disabled_next:hover,.paginate_enabled_next:hover{text-decoration:none!important}
 .paginate_disabled_previous:active,.paginate_enabled_previous:active,.paginate_disabled_next:active,.paginate_enabled_next:active{outline:0}
 .paginate_disabled_previous,.paginate_disabled_next{color:#c5c5c5!important}
 .paginate_disabled_previous,.paginate_enabled_previous{padding-left:23px}
 .paginate_disabled_next,.paginate_enabled_next{padding-right:0;margin-left:10px}
 .paging_full_numbers{height:28px}
 .paging_full_numbers a:active{outline:0}
 .paging_full_numbers a:hover{text-decoration:none}
 .paging_full_numbers a.paginate_button,.paging_full_numbers a.paginate_active{border:1px solid #aaa;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;padding:2px 5px;margin:0 3px;cursor:pointer;*cursor:hand;color:#333!important}
 .paging_full_numbers a.paginate_button{background-color: #88DFE2;font-weight: 800}
 .paging_full_numbers a.paginate_button:hover{background-color:#ccc;text-decoration:none!important}
 .paging_full_numbers a.paginate_active{background-color:#99b3ff}
 .dataTables_processing{position:absolute;top:50%;left:50%;width:250px;height:30px;margin-left:-125px;margin-top:-15px;padding:14px 0 2px 0;border:1px solid #ddd;text-align:center;color:#999;background-color:white}
 table.dataTable thead th:active,table.dataTable thead td:active{outline:0}
 .dataTables_scroll{clear:both}
 .dataTables_scrollBody{*margin-top:-1px;-webkit-overflow-scrolling:touch}
 .gallery{padding:24px}
 .gallery .element{display:inline-block;padding:0 1.5% 3% 1.5%;position:relative;text-align:center;width:16%}
 .gallery .element .img-polaroid{padding:5%;border-radius:5px;border:0;background-color:#fcfcfc;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,1),0 2px 4px rgba(0,0,0,0.08),inset 0 -1px 0 rgba(0,0,0,0.25);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,1),0 2px 4px rgba(0,0,0,0.08),inset 0 -1px 0 rgba(0,0,0,0.25);box-shadow:inset 0 1px 0 rgba(255,255,255,1),0 2px 4px rgba(0,0,0,0.08),inset 0 -1px 0 rgba(0,0,0,0.25)}
 .gallery .element a .icon-eye-open,.gallery .element a .icon-eye-open:hover{position:absolute;z-index:1006;color:white;text-shadow:0 -1px 0 rgba(0,0,0,0.3);vertical-align:center;background-color:rgba(0,0,0,0.7);border-radius:200em;left:50%;top:44%;margin-left:-26px;margin-top:-25px;width:52px;height:50px;padding:.70em .5em;box-sizing:border-box}
 .img-polaroid{padding:10px;box-sizing:border-box}
 .gallery img{zoom:1;filter:alpha(opacity=75);opacity:.75}
 .gallery img:hover{filter:alpha(opacity=100);opacity:1}
 
 .table,.data-table{margin-bottom:0}
 .table-striped,.table,.data-table{color:blue;font-weight:bolder;width:100%}
 .table-striped th,.table th,.data-table th,.table-striped td,.table td,.data-table td{padding:8px;text-align:left;vertical-align:top}
 .table-striped th,.table th,.data-table th{font-weight:bold}
 .table-striped thead th,.table thead th,.data-table thead th{vertical-align:bottom}
 .table-striped thead th:first-child,.table thead th:first-child,.data-table thead th:first-child{padding-left:20px}
 .table-striped thead th:last-child,.table thead th:last-child,.data-table thead th:last-child{padding-right:20px}
 .table-striped tbody i,.table tbody i,.data-table tbody i{color:#cacaca}
 .table-striped tbody td:first-child,.table tbody td:first-child,.data-table tbody td:first-child{padding-left:20px}
 .table-striped tbody td:last-child,.table tbody td:last-child,.data-table tbody td:last-child{padding-right:20px}
 .table-striped tbody td,.table tbody td,.data-table tbody td,.table-striped tbody th,.table tbody th,.data-table tbody th{background-image:-moz-linear-gradient(bottom,rgba(0,0,0,0.01) 0,rgba(255,255,255,0.01) 100%);background-image:-o-linear-gradient(bottom,rgba(0,0,0,0.01) 0,rgba(255,255,255,0.01) 100%);background-image:-webkit-linear-gradient(bottom,rgba(0,0,0,0.01) 0,rgba(255,255,255,0.01) 100%);background-image:linear-gradient(bottom,rgba(0,0,0,0.01) 0,rgba(255,255,255,0.01) 100%);border-bottom:1px solid #c2c2c2;-webkit-box-shadow:0 2px 0 #fff;-moz-box-shadow:0 2px 0 #fff;font-weight:800;box-shadow:0 2px 0 #fff}
 .st{font-weight:800;}
 .controls .input-block-level{font-weight:800;}
 .table-striped tbody .small,.table tbody .small,.data-table tbody .small{text-align:right;color:#c3c3c3}
 .table-striped tbody>tr:nth-child(odd)>td,.table tbody>tr:nth-child(odd)>td,.data-table tbody>tr:nth-child(odd)>td,.table-striped tbody>tr:nth-child(odd)>th,.table tbody>tr:nth-child(odd)>th,.data-table tbody>tr:nth-child(odd)>th{background-color:#f9f9f9;background-image:-moz-linear-gradient(bottom,rgba(0,0,0,0.03) 0,rgba(255,255,255,0.03) 100%);background-image:-o-linear-gradient(bottom,rgba(0,0,0,0.03) 0,rgba(255,255,255,0.03) 100%);background-image:-webkit-linear-gradient(bottom,rgba(0,0,0,0.03) 0,rgba(255,255,255,0.03) 100%);background-image:linear-gradient(bottom,rgba(0,0,0,0.03) 0,rgba(255,255,255,0.03) 100%);border-bottom:1px solid #c2c2c2}
 table .btn{padding:0 6px;margin-right:0;margin-left:2px !important;}
 table .right .btn{float:right}
 table.dataTable thead th.right,table.dataTable tfoot th.right{text-align:right;padding-right:20px}
</style>