


	 <link href="<?php echo base_url(); ?>assets/select/chosen.min.css" rel="stylesheet" media="screen">
	
		   
		   		   <script src="<?php echo base_url(); ?>assets/select/chosen.jquery.min.js"></script>

				   
	
        <script>
        $(function() {
<!--             $(".datepicker").datepicker(); -->
<!--             $(".uniform_on").uniform() -->;
            $(".chzn-select").chosen();
   <!--          $('.textarea').wysihtml5(); -->

        });
        </script>
                



<script>
	function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

    // document.body.innerHTML = printContents.fontsize(12);
     window.print();

	 if( window.print()) {
         window.location.href = "../user/searchhousebalance";
		alert(" printing...........");
    }else {

	
		      return      window.location.href = "../user/searchhousebalance";

		    // document.body.innerHTML = originalContents;

	}
}
	</script>
   <style type="text/css">
  
  

    #printable { display: none; }

    #myprint { display: none; }
#print{  	


    background-repeat: no-repeat;
	font-size;12px;
  
    


}


#sale{  	
background-image:url(images/add.png) ;

    background-repeat: no-repeat;
  
    width:100px; height:50px;


}
    
    @media print
    {
    	#non-printable { display: none; }
    	#printableArea { display: block; font-size:16; width:100%; }
		    	#myprint { display: block; font-size:16; width:100%; }

    }
    </style>
<ul class="nav nav-tabs bordered"  id="non-printable" >
			<li class="active">
            	<a href="#add" data-toggle="tab"><i class="entypo-menu"></i> 
			View House Details
                    	</a></li>
						
							<li>
            	<a href="#list" data-toggle="tab"><i class="entypo-plus-circled"></i>
			
				 <a href="<?php echo base_url(); ?>admin/searchbalance">	Go back
				 
				 	<div class="print-hide" id="non-printable"  >
<form name="print" method="post" action="">
 
 <div class="row">

 

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

	
</div>
   	<div class="col-md-6">
<input type="submit" id="print"  accesskey="p" class="btn btn-primary"  name="print"onclick="printDiv('printableArea')" value="print receipt!" />
</form></div></div>
							</div> 
				 
				 
				 </a>
                    	</a></li>
							<li>
						
										 <a href="<?php echo base_url(); ?>user/mysales">	Back to cashier sales</a>

                    	</a></li>
			
		</ul>
    	<!------CONTROL TABS END------>
        
		<div class="tab-content">
            <!----TABLE LISTING STARTS-->
            <div class="tab-pane box active " id="list">
				
     
	 
	 <?php
	
 
				//echo $this->session->flashdata('msg'); 
   $session_data = $this->session->userdata('logged_in');

      $mydate=date("Y-m-d H:i:s");
 $date = Date('Y-m-d') ;
		 	 $year = Date('Y') ;
		  $month = Date('m') ;
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
    $deletebank=$this->usermodel->populatuserpermissionsdataarray('accounting','deletebank',$userid);

    $mpesaaction=$this->usermodel->populatuserpermissionsdataarray('accomodation','mpesa',$userid);
	      $chequeaction=$this->usermodel->populatuserpermissionsdataarray('accomodation','cheque',$userid);
 $voucheraction=$this->usermodel->populatuserpermissionsdataarray('accomodation','voucher',$userid);
	      $creditaction=$this->usermodel->populatuserpermissionsdataarray('accomodation','credit',$userid);
		   $pointsaction=$this->usermodel->populatuserpermissionsdataarray('accomodation','points',$userid);
	      $cardaction=$this->usermodel->populatuserpermissionsdataarray('accomodation','card',$userid);
		    $cashpayment=$this->usermodel->populatuserpermissionsdataarray('accomodation','cash',$userid);


    $updatehouse=$this->usermodel->populatuserpermissionsdataarray('accomodation','updatehouse',$userid);
		   $cancelpayment=$this->usermodel->populatuserpermissionsdataarray('accomodation','cancel',$userid);
	      
		
	
	        		$configuration = $this->usermodel->populateallarray('smsconfig','id',$companyid);
					function formatMoney($number, $fractional=false) {
						if ($fractional) {
							$number = sprintf('%.2f', $number);
							
						}
						while (true) {
							$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
							if ($replaced != $number) {
								$number = $replaced;
							} else {
								break;
							}
						}
						return $number;
					}

	 
	 ?>
	 
	 
	 


 <div class="panel panel-primary" data-collapsed="0">
 	<div class="table-responsive">
			<div id="printableArea" style="width:100%" >
			
			<table width="100%">
           
			
			<tr>
				 	
	<td colspan="2" width="100%">
	<center>
					
										<?php $bussinessname=$configuration[0]['businessname']; if(isset($bussinessname)) {echo   $bussinessname; }?>
		</center>	
		</td>

			</tr>
				<tr>
				<td colspan="8">
				<CENTER> <B>OCCUPIED ROOMS REPORT</B>	</CENTER>
				</td>

		</tr>
			
			<tr>
				<td>
<?php
if($fromdate !=""){
?>
				<h4><b>Bookings  between <?php echo $fromdate; ?> AND <?php echo $todate; ?>.</b></h4>	</td>
					
<?php
}
?>
					<td><h4><b>Printed on <?php echo $date = date("Y-m-d"); ?></b></h4></td>

		</tr>
			
			
			
			
			
			
</table >
			
			
			
			
			

<table  border="1"width="100%">
             <thead>
	
			
         <tr>
		 		     <th>No </th>
  <th>Rm No </th>

<th>Customer</th> 	
    
	<th>Pax</th> 
	

		 <th>Description  </th> 
		 		     <th>Booking Date </th>

		
  
		     <th>RCT No </th>

		 
		 
    
  
	<!--
	<th>Amount</th> 
 -->
	<th>Status</th> 


	 <th id="non-printable">Staff</th> 

	 <th id="non-printable">Update</th> 



                 </tr>
             </thead>
<?php
	
				echo $this->session->flashdata('msg');
				 echo $this->session->flashdata('deletemsg'); 
		if(validation_errors()):
		 endif;
 if(!is_array($booking)) 

 {




    
       echo '<div class="alert alert-warning text-center">There is no booking found by now from system..</div>';
    
    }else {
?>
    
             <?php 
  $totalamount=0;
  $totalpaid=0;
    $totalbalance=0;
	    $roomtype=0;
			    $ttamount=0;

   $mpesa=0;
       $people=0;
	          $people1=0;

      $card=0;
	   $cash=0;
	  $mycount=0;
	  			    $count=1; 
  	foreach ($booking as $c): 

		$id=$c->id;
		$roomtype=(double)$roomtype+(double)$c->roomtype;




  $card=(double)$card+(double)$c->card;
  $cash=(double)$cash+(double)$c->amount;
   $mpesa=(double)$mpesa+(double)$c->mpesa;
   $totalamount=(double)$mpesa+(double)$cash+ (double)$card;
   
   	    $ttamount= (double)$ttamount+(double)$c->total;
   $houseno=$c->houseno;
   $plotno=$c->plotno;
$mycount= (double)$mycount++;
  $myhouse = $this->usermodel->populatealldataarray('house','plotno', $plotno,'houseno', $houseno);
						$roomidentifier=$myhouse[0]["id"];
 if($c->houseno=="Group"){
	 		$count--;

             ?>
			<tr>	 
<td colspan="10">
<?PHP if($c->houseno=="Group"){
				 
				
				 			$subbooking = $this->usermodel->populatealldatanoarray('dailycharges','transactioncode',$c->transactioncode,'ordersales',"active");

				 			//$subbooking = $this->usermodel->populateall('dailycharges', 'transactioncode',$c->transactioncode);
 if(is_array($subbooking)) 

 {
	 
?>

<?php
foreach ($subbooking as $row){
	$count ++;
	
if($count==$count){
	
}
$people1=$people1+(double)$row->qty;


	?>
	<tr>
				             <td><?php echo $count ; ?></td> 

	<td><?php echo $row->houseno ; ?></td>
	<td><?php echo $row->customer; ?></td> 	
	<td><?php echo $row->qty; ?></td> 	
<td><?php

						   $chargename = $this->usermodel->populateallarray('charges','id', $row->code);

	echo $chargename=$chargename[0]['type'];

 ?></td> 
 
 			     <td><?php  $row->checkin ;

															echo $datespent = date("d/m/Y H:i:a", strtotime($row->checkin));







				 ?></td> 
 			     <td><?php echo $c->id ; ?></td> 
             <td><?php echo $c->paymentstatus ; ?></td> 

	 <td id="non-printable">	
	
	<?php 
	
	$users = $this->usermodel->populateallarray('people','id', $c->userid);

	 echo$firstnames=$users[0]['firstname'];


	
	?>
	
	
	</td> 
	 <td id="non-printable">	
						 	<?php

 if( $updatehouse==true){
											
											?>
		 						<a  id="more" class=" btn-warning" href="<?php echo base_url();?>user/mychangepayment?myid=<?php echo $c->transactioncode ?>&randomitemidentifier=<?php echo $houseno ?>&randomitemidentifier1=<?php echo $plotno ?>&roomidentifier=<?php echo $roomidentifier ?>"> Update /View  </a>
	 <?php }?>
	 		 		 	
		  	
		 
		 
		 
		 												 
	 </td>	
	 
	</tr>
<?php


}	
//$count ++;
 }
				
				 
			 }

			 
			 ?>

</td>
			</tr>
            <?php 
 }else{
	 
	 		$people=$people+$c->people;


?>

             <tr>
                
            <?php 
			
	
?>

				             <td><?php echo $count ; ?></td> 

             <td><?php 
			 echo $c->houseno ;
			 
			?></td> 
	 				         <td><?php 
					
   $tenantid=$c->tenantid;
   					 $tenants= $this->usermodel->populateall('people','id',$tenantid);

					
 if(is_array($tenants)) {
   foreach($tenants as $tenantsrow){

    $names=$tenantsrow->lastname. " ".$tenantsrow->firstname ; 
   
   ?>
   
                     <a class=" btn-default" id="non-printable" target="_blank" href="<?php echo base_url();?>admin/edittenant?randomitemidentifier=<?php   {echo  $tenantid;}  ?>"><?php   {echo  $names;}  ?>  </a>
						 <span id="myprint"><?php echo $names ; ?></span>

   
   <?php
    

}
    } else {
    echo 'No customer.';
}
?>
				 
				 
		</td>
		
				             <td><?php echo $c->people ; ?></td> 

			 <!--
					
				
				<td><?php  $tenantid=$c->tenantid ; 
				 
				 
								   					 $tenantsid= $this->usermodel->populateall('people','id',$tenantid);



if(is_array($tenantsid)) {

   foreach($tenantsid as $tenantsidrow){

   echo $tenantsidrow->idno; 
    

}} else {
    echo $c->tenantid;
}
				 
				 
				 
				 
				 
				 ?></td>
				 -->	
															 <td>	
			<?php

 $chargename = $this->usermodel->populateallarray('charges','id', $c->chargeid);

	 echo$chargename=$chargename[0]['type'];
		
			
			if($c->chargeid==""){
				
				echo  $c->description;
			}
			
			?></td>
			
		             <td>
					 
					 
					 
					 <?php 
			 												


															echo $datespent = date("d/m/Y H:i:a", strtotime($c->createdat));


					 ?></td> 

             <td><?php echo $c->id ; ?></td> 


					

				 
				  <!--
					
		
				 											       <td><?php echo$c->currency.". ";
						  								echo formatMoney($c->total, true);


																   ?></td>

				 	-->	
				 
              							

             <td><?php echo $c->paymentstatus ; ?></td> 

								

					 
					 
					 
					 
					 
					 
					 
					 
					 
					 
				
	
               
		 <td id="non-printable">
												 
	<?php 
					// $branch="";
					 $userid=$c->userid;


 $user = $this->usermodel->populateallarray('people','id', $c->userid);

	 echo$firstname=$user[0]['firstname'];


?>											 
	 </td>	

		 

		 												 
	 <td id="non-printable">	
						 	<?php

 if( $updatehouse==true){
											
											?>
		 						<a  id="more" class=" btn-warning" href="<?php echo base_url();?>user/mychangepayment?myid=<?php echo $c->transactioncode ?>&randomitemidentifier=<?php echo $houseno ?>&randomitemidentifier1=<?php echo $plotno ?>&roomidentifier=<?php echo $roomidentifier ?>"> Update /View  </a>
	 <?php }?>
	 		 		 	
		  	
		 
		 
		 
		 												 
	 </td>	
		 
		 
		 
		 
		  
             </tr>

             <?php
 }
 			$count ++;


			 endforeach; ?>
				 <tr>
				 <td></td>
			 			   <td  colspan="2"> <b>TT PAX: </b></td>

			  <td> <b> <?php echo  $people+$people1;  ?> </b></td>
		
		  <td> <b>  </b></td>
			 			 			

			 			  <td colspan="2"> <b> <?php 
						  
						  								 formatMoney($ttamount, true);

						  
						  ?> </b></td>
			 		

			
			
			 </tr>

              <?php }?>

        </table>

    </div>    </div>
</div>

</div>
		<!----CREATION FORM STARTS---->
	   <div id="Checkout" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Check Out</h4>
      </div>
      <div class="modal-body">
        <h3>Are you sure you want to Check out this customer? </h3>
      </div>
      <div class="modal-footer">
	  	

     
		<?PHP
				$session_data = $this->session->userdata('adminlogged_in');
 echo $this->session->flashdata('deletemsg'); 

		
                 echo form_open('admin/updatechekout' , array('class' => 'form-horizontal ', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>  								  		<input type="hidden" name="roomidentifier" value="<?php  echo $roomidentifier ; ?>"id="roomidentifier" class="form-control"  placeholder="Enter roomidentifier">

 <input type="hidden" id="table"name="table" class="table" placeholder="bookroom" value="bookroom">
 <input type="hidden" id="view2"name="view2" class="view2" placeholder="view2" value="&randomitemidentifier1=">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="admin/allocate?randomitemidentifier=">
 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
           <input type="hidden" id="houseno"name="houseno" class="form-control" placeholder="houseno"  value="<?php echo $houseno;?>">

          <input type="hidden" id="plotno1"name="plotno" class="form-control" placeholder="plotno"  value="<?php echo $plotno;?>">
 		   		  	         <button type="submit" name="updatecharges" value="charges" class="btn btn-success"> Yes  </button>

 <button type="button" class="btn btn-danger" data-dismiss="modal">No</button>


	<?php echo form_close();?>
      </div>
    </div>

  </div>

  </div>
		
</div>




			