	 <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 type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
		
		
		
    </script>	 
			 
<ul class="nav nav-tabs bordered">
			<li class="active">
            	<a href="#add" data-toggle="tab"><i class="entypo-menu"></i> 
				Add Book this booking
                    	</a></li>
			<li>
            	<a href="#list" data-toggle="tab"><i class="entypo-plus-circled"></i>
					
					All Bookings for this booking
                    	</a></li>
						
						
						
						<li>
            
														 <a   id="more" href="<?php echo base_url();?>admin/rentinvoice?randomitemidentifier=<?php   {echo  $houseno;}  ?>&randomitemidentifier1=<?php   {echo  $plotno;}  ?>">Post Invoice  </a>

				
                    	</li>
						
						
						
						
						
						
							<li>
            
														 <a   id="more" href="<?php echo base_url();?>admin/viewplot?randomitemidentifier=<?php   {echo  $plotno;}  ?>&category=<?php   {echo  $category;}  ?>">Back to	Other meters  </a>

				
                    	</li>
						
							<li>
            
														 <a   id="more" href="<?php echo base_url();?>admin/viewallplots">Back to all Business  </a>

				
                    	</li>
							<li>
            
														 <a   id="more" href="<?php echo base_url();?>admin/viewpallmyplots">Back to Home  </a>

				
                    	</li>
						
		</ul>
    	<!------CONTROL TABS END------>
        
		<div class="tab-content">
            <!----TABLE LISTING STARTS-->
            <div class="tab-pane box" id="list">
				
     


 <div class="panel panel-primary" data-collapsed="0">
 
<table id="example"  cellspacing="1" class="table  table" width="100%">
             <thead>
			
         <tr>
    
    <th> Number </th>
	<th> Code</th>
    
<th>Customer</th> 	
	<th>Id Number</th> 
	<th>Entry Date </th> 
		<th>Balance</th> 
			<th>Over payment</th> 
						<th>Deposite</th> 

	<th>Status</th>  
	 
	<th>update</th> 
		<th>Refund</th> 

<th>More</th> 



                 </tr>
             </thead>
<?php



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

		
	 $session_data = $this->session->userdata('logged_in');

   		 $imgid = rand(100, 990000).time();

 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];

 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
				echo $this->session->flashdata('msg');
		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 
  
  	foreach ($booking as $c): 

		 

             ?>



             <tr>
                
            <?php 
		$id=$c->id;


?>

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

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


if(is_array($tenants)) {

   foreach($tenants as $tenantsrow){

   echo $tenantsrow->lastname. "  ".$tenantsrow->firstname ; 
    

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

}} else {
    echo $c->tenantid;
}
				 
				 
				 
				 
				 
				 ?></td>
              
                     <td><?php echo $c->createdat; ?></td>
					 
					 
					     <td><?php echo formatMoney($c->totalamount,true) ; ?></td>
										   			       <td><?php echo formatMoney($c->overpayment,true) ; ?></td>
														       <td><?php echo formatMoney($c->deposite,true) ; ?></td>
				
				<td><?php echo $c->status ; ?></td> 
         				
                     <td>
                     <a class="btn btn-primary"  id="more" href="<?php echo base_url();?>admin/editallocate?randomitemidentifier=<?php   {echo  $id;}  ?>">update  </a>
         </td>
		           <td>
                     <a class="btn btn-info"  id="more" href="<?php echo base_url();?>admin/refundmoney?randomitemidentifier=<?php   {echo  $id;}  ?>">Refund  </a>
         </td>
		  <td>
		
					<div class="btn-group">
                                    <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">
                                        More <span class="caret"></span>
                                    </button>
									<?php
										if($usertype=="admin"){
											
											?>
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        
                                        <!-- teacher EDITING LINK -->
                                      
										
											  <li> 
										 <a class="btn btn-danger managebtn" id="managebtndelete"		 data-id='<?php echo  $c->id;?>'     data-toggle='modal' data-target='#myModal<?php  $c->id; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Delete
                                                </a>
                                                        </li>
									
									
                                        <li class="divider"></li>
                                        
                                        <!-- teacher DELETION LINK -->
                                        
                                    </ul>
											<?php
										}
										?>
                                </div>
		 
		 </td>
             </tr>

             <?php endforeach; ?>

              <?php }?>

        </table>


</div>

</div>
		<!----CREATION FORM STARTS---->
		
		
		
		
		
		
		
		
		
		
		<div id="addModal" 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">Add new customer</h4>
      </div>
      <div class="modal-body">
      
	  	


		
				  		
	

				<?PHP

 $transactionid = 'rand' .rand(100, 9900) . 'trc' . time();

 
		 $date=date("Y-m-d");

                 echo form_open('addtenant' , 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="inputfirstname" class="col-md-3 control-label">Customer Name</label>
    <div class="col-sm-7">
	
	
	
					 <input type="hidden" name="type"    value="tenant"  class="form-control">
					 <input type="hidden" name="view"    value="admin/allocate?randomitemidentifier=<?php echo $houseno ?>&randomitemidentifier1=<?php echo $plotno ?>&roomidentifier=<?php echo $roomidentifier ?>"  class="form-control">

	
				 <input type="hidden" name="img_id"    value="<?php echo set_value('img_id', $imgid); ?>"  class="form-control">

	<input type="hidden" name="action" value="<?php echo set_value('action','insert'); ?>"id="action" class="form-control" required placeholder="Enter action">
	<input type="hidden" name="transactionid" value="<?php echo set_value('transactionid',$transactionid); ?>"id="transactionid" class="form-control" required placeholder="Enter transactionid">

		  		<input type="text" name="firstname" value="<?php echo set_value('firstname'); ?>"id="firstname" class="form-control" required placeholder="Enter customer name">
     <span class="text-danger"><?php echo form_error('firstname'); ?></span>
   </div>
  </div>
    <div class="form-group" style="display:none">
    <label for="inputlastname" class="col-md-3 control-label">Last Name</label>
    <div class="col-sm-7">
		<input type="text" name="lastname" value="<?php echo set_value('lastname') ;?>" id="lastname" class="form-control"  placeholder="Enter lastname">
       <span class="text-danger"><?php echo form_error('lastname'); ?></span>
   </div>
  </div>
    <div class="form-group">
    <label for="inputphone3" class="col-md-3 control-label">Id Number </label>
    <div class="col-sm-7">
				<input type="phone" name="idno" value="<?php echo set_value('idno'); ?>" id="idno" class="form-control" required  placeholder="Enter Id Number">
    <span class="text-danger"><?php echo form_error('idno'); ?></span>
   </div>
  </div>
  
	
   
		
 
  <div class="form-group">
    <label for="inputphone" class="col-md-3 control-label">Phone Number</label>
    <div class="col-sm-7">
				<input type="text" name="phone"  required value="<?php echo set_value('phone'); ?>" id="phone" class="form-control"  placeholder="Enter Your phone">
        <span class="text-danger"><?php echo form_error('phone'); ?></span>
	</div>
  </div>
  <div class="form-group">
						<label for="field-2" class="col-md-3 control-label">Country</label>
		                    <div class="col-sm-7">
		                        <select name="country" class="form-control" id="section_selector_holder">
		                            <option value="">--Select Country--</option>
									   <?php
									$country = $this->accomodationmodel->populateallcountries();


if(is_array($country)) {

   foreach($country as $countryrow){

    ?>
	    <option selected value="<?php echo set_value('country',$countryrow->id); ?> "><?=$countryrow->name;?></option>

   
    <?php

}} else {
    echo 'There is no other  country for this house.... Please add country first.';
}

?>
			                        
			                    </select>
								     <span class="text-danger"><?php echo form_error('country'); ?></span>
			                </div>
	</div>
	
   <div class="form-group">
						<label for="field-2" class="col-md-3 control-label">County</label>
		                    <div class="col-sm-7">
		                        <select name="county" class="form-control" id="section_selector_holder">
		                            <option selected="select" value="">--Select County--</option>
									   <?php
									$county = $this->accomodationmodel->populateallallacounties();


if(is_array($county)) {

   foreach($county as $countyrow){

    ?>
	    <option selected value="<?php echo set_value('county',$countyrow->id); ?> "><?=$countyrow->name;?></option>

   
    <?php

}} else {
    echo 'There is no other  county for this house.... Please add county first.';
}

?>
			                        
			                    </select>
								     <span class="text-danger"><?php echo form_error('county'); ?></span>
			                </div>
	</div>
	
	
  	 		
     <div class="form-group" >
    <label for="inputlocation" class="col-md-3 control-label">Company</label>
    <div class="col-sm-7">
				<input type="text" name="location" value="<?php echo set_value('location') ;?>" id="exampleInputlocation" class="form-control"  placeholder="Enter Your company/business name">
    <span class="text-danger"><?php echo form_error('location'); ?></span>
	</div>
  </div>
   <div class="form-group">
    <label for="inputEmail" class="col-md-3 control-label">Email</label>
    <div class="col-sm-7">
				<input type="email" name="email" value="<?php echo set_value('email') ;?>" id="exampleInputEmail" class="form-control"  placeholder="Enter Your email">
    <span class="text-danger"><?php echo form_error('email'); ?></span>
	</div>
  </div>

 
 <div class="form-group" >
						<label for="field-2" class="col-md-3 control-label">Gender</label>
		                    <div class="col-sm-7">
		                        <select name="gender"  class="form-control" id="section_selector_holder">
		                            <option value="" selected>--Select Gender--</option>
			                         <option value="Male">Male</option>
									   <option value="Female">Female</option>
			                    </select>
							 <span class="text-danger"><?php echo form_error('gender'); ?></span>

			                </div>
	</div>	
	
	
		
			
	
	
	
	
	
		
		
		
		
		
	   <div class="form-group" >
    <label for="inputphone3" class="col-md-3 control-label">Entry Date </label>
    <div class="col-sm-7">
				<input type="phone" name="entrydate" value="<?php echo set_value('entrydate',$date); ?>" id="idno" class="form-control"  placeholder="Enter Entry date">
    <span class="text-danger"><?php echo form_error('entrydate'); ?></span>
   </div>
  </div>
  	   <div class="form-group" >
    <label for="inputdob" class="col-md-3 control-label">Date of Birth </label>
    <div class="col-sm-7">
				<input type="date" name="dob" value="<?php echo set_value('dob'); ?>" id="d" class="form-control"  placeholder="Enter Date of Birth">
    <span class="text-danger"><?php echo form_error('dob'); ?></span>
   </div>
  </div>
  
  	  <div class="form-group" style="display:none">
						<label for="field-2" class="col-md-3 control-label">House Status</label>
		                    <div class="col-sm-7">
		                        <select name="status" required class="form-control" id="section_selector_holder">
		                            <option value="" >--Select Status--</option>
			                         <option selected="selected"value="active">active</option>
									   <option value="inactive">inactive</option>
			                    </select>
							 <span class="text-danger"><?php echo form_error('gender'); ?></span>

			                </div>
	</div>
	
	 <div class="form-group" style="display:none">
						<label for="field-2" class="col-md-3 control-label"> photo</label>
		                    <div class="col-sm-7">
		                      		<input type="file" name="photo" width="400"  value="<?php echo set_value('photo') ;?>" placeholder="Select Image"  class="form-control"  >

							 <span class="text-danger"><?php echo form_error('photo'); ?></span>

			                </div>
	</div>
	
	
	

   <div class="form-group" style="display:none">
    <label for="inputphone3" class="col-md-3 control-label">Comments </label>
    <div class="col-sm-7">
	<textarea name="description" id="ttt" rows="5" placeholder="Add any description/comment" class="form-control"></textarea>
    <span class="text-danger"><?php echo form_error('description'); ?></span>
   </div>
  </div>
    
  
  

	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	       <button type="submit" name="btn_tenant"value="tenant" class="btn btn-primary">Add Customer</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="&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="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 class="tab-pane box active" id="add" style="padding: 5px">
			
    	
	



		
<div class="row">
	<div class="col-md-12">
		<div class="panel panel-primary" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" >
            		<i class="entypo-plus-circled"></i>
				Add new Booking
            	</div>
            </div>
			<div class="panel-body">





				<?PHP
				echo $this->session->flashdata('msg'); 
		$date= Date("Y-m-d");
                 echo form_open('addrentbooking' , 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="inputhouseno" class="col-sm-2 control-label"> Number</label>
    <div class="col-sm-7">
			  		<input type="text" name="houseno" value="<?php  echo $houseno ; ?>"id="bookingno" class="form-control" required placeholder="Enter booking number">
  		<input type="hidden" name="action" value="<?php echo set_value('action','insert'); ?>"id="action" class="form-control" required >
			  		<input type="hidden" name="id" value="<?php  echo $roomidentifier  ; ?>"id="bookingno" class="form-control" required placeholder="Enter booking number">


     <span class="text-danger"><?php echo form_error('houseno'); ?></span>
   </div>
  </div>
  <div class="form-group" style="display:none">

    <label for="inputplotno" class="col-sm-2 control-label">Plot Number</label>
    <div class="col-sm-7">
			  		<input type="text" name="plotno" value="<?php  echo $plotno  ; ?>"id="bookingno" class="form-control" required placeholder="Enter booking number">


     <span class="text-danger"><?php echo form_error('plotno'); ?></span>
   </div>
  </div>

	  <div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">Customer Name</label>
    <div class="col-sm-7">
				    	
			  	<select name="tenantid"  class="chzn-select" required>
<option value="" >---Select Customer for booking---</option>

		<?php 

//$nation = $this->nationmodel->populatenation();
				$tenant= $this->accomodationmodel->populatealltenant();

	
if(is_array($mycurrenttenant)) {

   foreach($mycurrenttenant as $mycurrenttenanttrow){

    ?>
	    <option selected="selected" value="<?php echo set_value('tenant',$mycurrenttenanttrow->id); ?> "><?=$mycurrenttenanttrow->lastname." ".$mycurrenttenanttrow->firstname." IDNO ".$mycurrenttenanttrow->idno;;?></option>

   
    <?php

}} else {
    echo 'There is no other  tenant for this house.... Please add tenant first.';
}

if(is_array($tenant)) {

   foreach($tenant as $tenanttrow){

    ?>
	    <option value="<?php echo set_value('tenant',$tenanttrow->id); ?> "><?=$tenanttrow->lastname." ".$tenanttrow->firstname." IDNO ".$tenanttrow->idno;;?></option>

   
    <?php

}} else {
    echo 'There is no other  tenant for this house.... Please add tenant first.';
}



?>
	</select>
				<a data-toggle='modal' data-target='#addModal' class="btn btn-warning">Add Customer </a>


	  <span class="text-danger"><?php echo form_error('tenantid'); ?></span>
	</div>
  </div>			
  
  <div class="form-group">
    <label for="inputtotalamount" class="col-sm-2 control-label">Current Balance</label>
    <div class="col-sm-7">
				<input type="text" readonly name="totalamount" value="<?php echo set_value('totalamount',0); ?>" id="idno" class="form-control" required placeholder="Enter total balance">
        <span class="text-danger"><?php echo form_error('totalamount'); ?></span>
	</div>
  </div>
				
  
  
    
  <div class="form-group">
    <label for="inputoverpayment" class="col-sm-2 control-label">Over payment</label>
    <div class="col-sm-7">
				<input type="text" name="overpayment" value="<?php echo set_value('overpayment',0); ?>" id="idno" class="form-control" required placeholder="Enter total over payment">
        <span class="text-danger"><?php echo form_error('overpayment'); ?></span>
	</div>
  </div>
		    
  <div class="form-group">
    <label for="inputdeposite" class="col-sm-2 control-label">Deposite payment</label>
    <div class="col-sm-7">
				<input type="text" name="deposite" value="<?php echo set_value('deposite',0); ?>" id="idno" class="form-control" required placeholder="Enter total deposite payment">
        <span class="text-danger"><?php echo form_error('deposite'); ?></span>
	</div>
  </div>
			
  
  
   <div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">Entry Date</label>
    <div class="col-sm-7">
				<input type="text" name="entrydate" value="<?php echo set_value('entrydate',$date); ?>" id="idno" class="form-control" required placeholder="Enter Start Date">
        <span class="text-danger"><?php echo form_error('entrydate'); ?></span>
	</div>
  </div>
					
  
    	  <div class="form-group">
						<label for="field-2" class="col-sm-2 control-label">Status</label>
		                    <div class="col-sm-7">
		                        <select name="status" class="form-control" id="section_selector_holder">

			                         <option selected value="active">active</option>
									   <option value="inactive">inactive</option>
			                    </select>
							 <span class="text-danger"><?php echo form_error('status'); ?></span>

			                </div>
			 </div>
   <div class="form-group">
    <label for="inputphone3" class="col-sm-2 control-label">Description </label>
    <div class="col-sm-7">
	<textarea name="description" id="ttt" rows="5" placeholder="add Description" class="form-control"></textarea>
    <span class="text-danger"><?php echo form_error('description'); ?></span>
   </div>
  </div>
    
  
  
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-7">
     
	       <button type="submit" name="btn_booking" value="booking" class="btn btn-primary">Allocate Meter</button>

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


   </div>
</div>




			