
<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 = "../admin/searchhousebalance";
		alert(" printing...........");
    }else {

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

		    // document.body.innerHTML = originalContents;

	}
}


       
		 
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid").val(itemid); 
		  
		  
		   
        });
		








	</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>







 <div class="row">

 

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

				 
				 	<div class="print-hide" id="non-printable"  >
<form name="print" method="post" action="">
 
 <div class="row">

 

   	<div class="col-md-6">
				 <a href="<?php echo base_url(); ?>admin/searchbalance">More reports</a><BR>
				 <a href="<?php echo base_url(); ?>admin/viewpallmyplots">	GO BACK</a> ||
				 										     <a data-toggle='modal' data-target='#viewsms' class="btn btn-primary">Search for Reservations Report </a></br>

										 <a href="<?php echo base_url(); ?>admin/viewbulkreservation">	Refresh</a>

	
</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> 
     
	 
	 <?php
	 	$session_data = $this->session->userdata('logged_in');

    $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
 $data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
        
		 $data['branchid'] = $session_data['branchid'];
	 $branchid = $data['branchid'];
			 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	        		$configuration = $this->usermodel->populateallarray('smsconfig','id',$companyid);
					
					    $deletebank=$this->usermodel->populatuserpermissionsdataarray('accounting','deletebank',$userid);
	 	      $givediscount=$this->usermodel->populatuserpermissionsdataarray('accomodation','givediscount',$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);


		

	 
	 ?>
	 
	 
	 


 <div class="panel panel-primary" data-collapsed="0">
 	<div class="table-responsive">
			<div id="printableArea">
			
			<table width="100%">
           
			
			<tr>
				 	
	<td colspan="2" width="100%">
	<center>
					
					
						<?php 
																				 $countbranch=$this->usermodel->countbranches($companyid);

										 if( $countbranch>1){
										 $mybranches= $this->usermodel->populateallarray('branch','id',$branchid);
										$branchdescription=$mybranches[0]['description']; if(isset($branchdescription)) {echo   $branchdescription; }


										}else{
									$bussinessname=$configuration[0]['businessname']; if(isset($bussinessname)) {echo   $bussinessname; }
 
											 
										 }
										?>
										   <center>DAILY RESERVATIONS  </Center>	
		</center>	
		</td>

			</tr>
			<?php if(isset($fromdate)) {
			
				
				
			
			?>
		<tr>
				<td>

												  

				<h4><b>Bookings  between <?php echo $MYfromdate = date("d/m/Y H:i:a", strtotime($fromdate)); ?> to  <?php  echo $MYtodate = date("d/m/Y H:i:a", strtotime($todate));  ?>.</b></h4>	</td>
					<td><h4><b>Printed on <?php echo $date = date("Y-m-d"); ?></b></h4></td>

		</tr>
			
			
				<?php 
				
				}
			
			?>
			
			
			
</table >
			
			
		<?php
		
			$totlbal=0;
		$collected=0;
		 $totlbal=0;
				 $actualtotal=0;

		
		
		
		
		
 if( $display!="balance"){
	 ?>
   
	
				
			
			

  <table cellpadding="0" cellspacing="0" border="1" class="table table-bordered table-striped table-hover" id="example" style="border-color:#CCCCCC; width:100%;"  >
             <thead>
	
			
         <tr>
		 
		 		   <th>Rct No </th>

		 
		
    
    <th>Rm No </th>
	<th>HS No</th>
    
<th>Customer</th> 	
	<th>Id Number</th> 
	<th>Phone Number</th> 
	<th>Check-In </th> 
		<th>Check-Out </th>
		 <th>Pple</th> 		

 <th>Days</th> 		
	 <th>TT Exp</th> 
		 <th>Sale Price</th> 


	 <th>Cash </th> 
	  <th>Mpesa </th> 
	 <th>Card </th> 
	 	 <th>Cheque </th> 


	<?php
 if( $creditaction==true){
	 ?>
   
	 <th>Credit </th> 
		 
	 	<?php	
		}
		?>
		
					
 
 	<?php
 if( $voucheraction==true){
	 ?>
   
		 	 	 <th>Voucher </th> 

		 
	 	<?php	
		}
		?>
		
		 	<?php
 if( $givediscount==true){
	 ?>
   

						 		 	 	 <th>Dsc </th> 
 
	 	<?php	
		}
		?>
		
	
	  


	 <th> Status </th> 

	
		 <th>Code  </th> 

	
	
	
	
	
	
	 <th>Rm Status</th> 

		 <th>NB  </th> 

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



                 </tr>
             </thead><tbody>
<?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;
    //$actualtotal=0;
    $people=0;
    $discount=0;

    $totalbalance=0;
	    $roomtype=0;
   $mpesa=0;
      $card=0;
	   $cash=0;
	    $credit=0;
			    $cheque=0;
			    $count=0;

	   $voucher=0;
	  $mycount=0;

  	foreach ($booking as $c): 
									// echo$totalpaid= $c->card+$c->amount+$c->mpesa+$c->voucher+$c->cheque;;
		  $count++

             ?>



             <tr>
                
            <?php 
		$id=$c->id;
		 //  $count=count($id);
			$myroomtype=($c->roomtype);
		$roomtype=($roomtype)+($myroomtype);

$people=$people+$c->people;
  $voucher=$voucher+$c->voucher;
$actualtotal=$actualtotal+$c->total;
  $credit=$credit+$c->credit;
    $card=$card+$c->card;

  $cash=$cash+$c->amount;
    $cheque=$cheque+$c->cheque;
	    $discount=$discount+$c->discount;
   $houseno=$c->houseno;
   $plotno=$c->plotno;

   $mpesa=$mpesa+$c->mpesa;
   $totalamount=$mpesa+$cash+ $card+$voucher+$credit+$cheque;
$mycount= $mycount++;
		  $myhouse = $this->usermodel->populatealldataarray('house','plotno', $plotno,'houseno', $houseno);
						$roomidentifier=$myhouse[0]["id"];

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


             <td><?php echo $c->houseno ;
			 ?></td> 
				<td><?php echo $c->plotno ; ?></td> 


<td>
 
  <?php  $mycustomer= $c->tenantid ;
  $idno="";
    if($mycustomer!=""){

$myuser=$this->usermodel->getpeople($mycustomer);
    $myname=$myuser[0]['company'];
	    $phone=$myuser[0]['phone'];
    $idno=$myuser[0]['idno'];
     $firstname=$myuser[0]['firstname'];
   if($myname!=""){
	   echo $myname;
	   
   }else{
	   
	   echo $firstname; 
	   
   }
	}else{
		echo $mycustomer;
		
	}
  ?>
 
 
 </td>


				 		<td><?php  
				 echo $idno;
				 
		
				 ?></td>
				 
				 
				 		<td><?php  $tenantid=$c->tenantid ; 
				 
				 
				    $tenantsid = $this->accomodationmodel->gettenantbyid($tenantid);
								


if(is_array($tenantsid)) {

   foreach($tenantsid as $tenantsidrow){

   echo $tenantsidrow->phone; 
    

}} else {
   echo" GENERAL";
}
				 
				 
				 
				 
				 
				 ?></td>
				 
				 <td><?php echo $c->createdat;
												//   	  echo $datespent = date("H:i:a", strtotime($c->createdat));


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

												   	  //echo $datespent = date("H:i:a", strtotime($c->checkoutdate));


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

       <td><?php echo $c->number; ?></td>
					                      <td><?php echo $myroomtype; ?></td>
					               					                      <td><?php echo $c->total; ?></td>


									<td><?php echo $c->amount; ?></td>
					 <td><?php echo $c->mpesa; ?></td>
					 					 <td><?php echo $c->card; ?></td>
									<td><?php echo $c->cheque; ?></td>

										  
										  
										  
										  
										  	<?php
 if( $creditaction==true){
	 ?>
   
										 		 <td><?php echo $c->credit; ?></td>
		 
	 	<?php	
		}
		?>
		
					
 
 	<?php
 if( $voucheraction==true){
	 ?>
   
										 <td><?php echo $c->voucher; ?></td>

		 
	 	<?php	
		}
		?>
		
		 	<?php
 if( $givediscount==true){
	 ?>
   

										  <td><?php echo $c->discount; ?></td>
 
	 	<?php	
		}
		?>
		
										  
										  
										  
										  
										  
										  
										  
										  
										  


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

									
								

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

					 
					 
					 
					 
					 
					 
					 
					 
					 
					 
					 
					 
						 
								 
				<td><?php  $status = $c->status ;
				if($status=="reserved"){
					
					echo "reserved";
				}else 
				if($status=="active"){
					
					echo "occupaid";
				}else{
					echo "vacant";
					
				}
				?></td> 	 										 <td><?php echo $c->description; ?></td>
	
               
		 <td>
												 
	<?php 
					// $branch="";
					 $userid=$c->userid;

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



if(is_array($user)) {

   foreach($user as $userhrow){

   echo $userhrow->surname;
 
 
}} else {
    echo 'No Name.';
}
	
?>
												 
	 </td>	

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

		 
		 
		 
		 
		 
		  
		 	
		  
				
		 		  	<td id="non-printable">

		 
		 						<a  id="more" class=" btn-warning" href="<?php echo base_url();?>admin/verifybulkreservationcheckin?randomitemidentifier=<?php echo $c->transactioncode ?>&transactiontype=checkin">  Checkin  </a>
								<br>
								<a  id="more" class=" btn-success" href="<?php echo base_url();?>admin/verifybulkreservationcheckin?randomitemidentifier=<?php echo $c->transactioncode ?>&transactiontype=reserved">  Reserve   </a>

								
	 		<a  id="more" class=" btn-info" href="<?php echo base_url();?>admin/viewbalance?invoice=<?php echo $c->transactioncode ?>&randomitemidentifier=<?php echo $houseno ?>&randomitemidentifier1=<?php echo $plotno ?>&roomidentifier=<?php echo $roomidentifier ?>"> Receive  </a>

		 </td>
		  
             </tr>

             <?php endforeach; ?>
			 
			 </tbody>	 <tfoot>
			 <tr>
			 			   <td  colspan="2"> <b>TT Rooms: </b></td>

			  <td> <b> <?php echo  $count;  ?> </b></td>
		
			 <td colspan="3"> <b> Sales Total Summary: </b></td>
			 			 			   <td  colspan="2"> <b>TT People: </b></td>

			 			  <td colspan="2"> <b> <?php echo $people;  ?> </b></td>

			  <td> <b> <?php echo $roomtype;  ?> </b></td>

			  <td>  <b><?php echo $actualtotal;  ?> </b></td>

			  <td>  <b><?php echo $cash;  ?> </b></td>
			  <td >  <b><?php echo $mpesa;  ?> </b></td>
			  	<td >  <b><?php echo $card;  ?> </b></td>
				
				
				

			  	<td >  <b><?php echo $cheque;  ?> </b></td>
				
				
				
				
									  
										  
										  
										  	<?php
 if( $creditaction==true){
	 ?>
   
			     <td >  <b><?php echo $credit;  ?> </b></td>
		 
	 	<?php	
		}
		?>
		
					
 
 	<?php
 if( $voucheraction==true){
	 ?>
   
			  	<td >  <b><?php echo $voucher;  ?> </b></td>

		 
	 	<?php	
		}
		?>
		
		 	<?php
 if( $givediscount==true){
	 ?>
   

							  	<td >  <b ><?php echo $discount;  ?> </b></td>
 
	 	<?php	
		}
		?>
		
										  
										  
										  
				
				
				
				
				
				
				
				
				
				


										  	<td colspan="3">
											<b>
												<?php
												echo "Balance :";
												$collected=($cash+$mpesa+$card+$cheque);
										echo$totlbal=$actualtotal-$collected;
										
										
										
												?>
											
											</b>
											
											
											
											
											</td>

			 </tr>
 </tfoot>
              <?php
	}
			  }?>

        </table>
		
		
	 

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






<div id="viewsms" 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">Booking Report</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');

 $finalendate=date("Y-m-d H:59:59");
  $finalstartdate=date("Y-m-d 00:00:00");
  
  
  
//

				echo $this->session->flashdata('msg'); 
		
                 echo form_open('admin/searchbulkreservedrooms' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>

		


  
  
  
  
  

  <div class="form-group">
    <label for="inputfromdate" class="col-sm-2 control-label">From Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="fromdate" value="<?php echo set_value('fromdate',$finalstartdate); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('fromdate'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputtodate" class="col-sm-2 control-label">	To Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="todate" value="<?php echo set_value('todate',$finalendate); ?>" class="form-control" required placeholder="Enter End date">
		 
				
		<span class="text-danger"> <?php echo form_error('todate'); ?>
		
		</span>
	</div>
  </div>
  

  
    

   
  
  <div class="form-group">
    <label for="inputstatus" class="col-sm-2 control-label">Status </label>
    <div class="col-sm-10">
      <select name="status" required class="form-control" id="section_selector_holder">
		                            <option value="" >--Select Status--</option>
			                         		<option value="all" selected>all</option>

									 
									 <option value="Cleared">Cleared</option>
									 									 <option value="Not Cleared">Not Cleared</option>

									 			                         <option  value="reserved">Reserved</option>

									   	 <option value="closed">closed</option>

			                    </select>
		

		
	</div>
  </div>
  
  
     <div class="form-group">
   <label for="inputplotno" class="col-sm-2 control-label"> </label>

  
  <div class="col-sm-2">
					<div class="form-group">

                     		  		<input type="text" name="plotno" value="<?php echo set_value('plotno',"all"); ?>" class="form-control"  placeholder="Enter plot/House no ">

					</div>
				</div>
				<div class="col-sm-5">
					<div class="form-group">
					
                     		  		<input type="text" name="houseno" value="<?php echo set_value('houseno',"all"); ?>" class="form-control"  placeholder="Enter Rooms no ">


					</div>
				</div>
			
	</div>
			
  
  
  
  
  
  
	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="bookings" name="btn_BOOKINGS" class="btn btn-primary"> View SMS  </button>

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

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










	   <div id="myModal" 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">Delete</h4>
      </div>
      <div class="modal-body">
        <h3>Are you sure you want to delete this item? </h3>
      </div>
      <div class="modal-footer">
	  	

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

		
                 echo form_open('user/deleteallbyid' , 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" id="table"name="table" class="table" placeholder="bookroom" value="bookroom">
 <input type="hidden" id="view2"name="view2" class="view2" placeholder="view2" value="">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="admin/dailypayment">
 <input type="hidden" id="itemid"name="itemid" class="itemid" placeholder="itemid" value=""><br>
           <input type="hidden" id="houseno"name="houseno" class="form-control" placeholder="houseno"  value="">

          <input type="hidden" id="plotno1"name="plotno" class="form-control" placeholder="plotno"  value="">
 <button type="button" class="btn btn-success" data-dismiss="modal">No</button>
 		  	         <button type="submit" name="btn_delete" value="deletebyid" class="btn btn-danger"> Delete  </button>

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

  </div>

  </div>
</div>