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

	}
}


       
		 
  
		
		 $(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 href="<?php echo base_url(); ?>user/mysales">	Back to cashier sales</a>
				 <a class="btn btn-primary" href="<?php echo base_url(); ?>admin/roomcustomers">View all	Customer</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['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	        		$configuration = $this->usermodel->populateallarray('smsconfig','id',$companyid);

	 
	 ?>
	 
	 
	 


 <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 $bussinessname=$configuration[0]['businessname']; if(isset($bussinessname)) {echo   $bussinessname; }?>
		</center>	
		</td>

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

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

		</tr>
			
			
				<?php 
				
				}
			
			?>
			
			
			
</table >
			
			
			
			
			

<table  border="1"width="100%">
             <thead>
	<tr>
	<th colspan="11">
	
								<h4><b><center>CUSTOMER REGISTER</CENTER> </b></h4>	
</th> 
	</tr>
		

         <tr>
		 
		 		   <th>Date </th>

		 
    
   
    	 <th>Rm No </th>
<th>Customer</th>
<th>Guest</th>  	
	<th>Id Number</th> 
	<th>Phone Number</th> 
		<th>Country</th> 


		<th>Type</th>

	<th>Check-In </th> 
		<th>Check-Out </th>
		

	 <th>Served By</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;
    $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"];
		$TYPE=$myhouse[0]["type"];
?>
             <td><?php echo $c->createdat ; ?></td> 

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

						 				         <td><?php 
					
   $tenantid=$c->tenantid;
				    $tenants = $this->accomodationmodel->gettenantbyid($tenantid);
 if(is_array($tenants)) {
   foreach($tenants as $tenantsrow){

    $names=$tenantsrow->surname. " ".$tenantsrow->firstname ; 
   
   ?>
   
					 <?php   {echo  $names;}  ?> 
					
						 <span id="myprint"><?php echo $names ; ?></span>

   
   <?php
    

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

				 		<td><?php  $tenantid=$c->tenantid ; 
				 
				 
				    $tenantsid = $this->accomodationmodel->gettenantbyid($tenantid);
								
$country="";

if(is_array($tenantsid)) {

   foreach($tenantsid as $tenantsidrow){

   echo $tenantsidrow->idno; 
    $country=$tenantsidrow->country;

}} else {
    echo $c->tenantid;
}
				 
				 
				 
				 
				 
				 ?></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";
}
		//  $details->usermodel->populateallarray('people',$c->tenantid);
		 	 	
  //$phone=$details[0]['phone']; 		 
				 
				 
				 
				 
				 ?></td>
				<td><?php 
				  $nation = $this->usermodel->populateallarray('nation','id', $country);

	 echo$mycountry=$nation[0]['name'];
				
				
				?></td> 
				
				<td><?php echo $TYPE ; ?></td> 
              									<td><?php echo $c->createdat; ?></td>
													<td><?php echo $c->checkoutdate; ?></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>	

		 

		 
		 
             </tr>

             <?php endforeach; ?>
			

              <?php }?>

        </table>

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