
	

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



function getdays()
{
  var temproomtype = $("#roomtype").val() ;
  
  
 const getroomtypeamount = temproomtype.split("==");
let roomtype = getroomtypeamount[0];
  
  

	 var checkin = document.getElementById('checkin').value;

	 var checkout = document.getElementById('checkout').value;
	     var date1 = new Date(checkin);
    var date2 = new Date(checkout);
   var Difference_In_Time = date2.getTime() - date1.getTime();
      
    // To calculate the no. of days between two dates
    var Difference_In_Days = Difference_In_Time / (1000 * 3600 * 24);
	 	 var myfinaltotal = roomtype*Difference_In_Days;
				
                 document.getElementById("totalamount").value = myfinaltotal;

//alert(myfinaltotal);



}












      
</script> 
				 
				 
				 
				 
				 
				 
				 
				 
				 
				 
				 
				 
		      <script type="text/javascript">
  
		$(this).ready( function() {  
            $("#mysupplier").autocomplete({  
 
                minLength: 1,  
                source:   
                function(req, add){  
                    $.ajax({  
                        url: "<?php echo base_url(); ?>Systemusers/customerSaleslookup",  
                        dataType: 'json',  
                        type: 'POST',  
                        data: req,  
                        success:      
                        function(data){  
                            if(data.response =="true"){  
                                add(data.message);  
                                console.log(data);
                            }  
                        },  
                    });  
                },  
                     
            });  
        });
		
		
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid").val(itemid); 
		  
		  
		   
        });
		
		
		 $(document).on("click", "#managebtncheckout", function()
        {
          var itemid2 = $(this).data('id');
		  $("#itemid1").val(itemid2); 
		  
		    var houseno2 = $(this).data('houseno');
		  $("#houseno2").val(houseno2); 
		     var plotno2 = $(this).data('plotno');
		  $("#plotno2").val(plotno2); 
		   
        });
		
		
		
		
		
		
		$(function () {
        $("#type").change(function () {
            if ($(this).val() == "Cash") {
             $("#due").hide();
		   $("#accountno").hide();
              $("#cash").focus().value = "";
  	 var myfinaltotal = document.getElementById('myfinaltotal').value;

            document.getElementById("mpesa").value = myfinaltotal;
						
			document.getElementById("credit").value = 0;
			 document.getElementById("card").value = 0;
			document.getElementById("voucher").value = 0;

			 document.getElementById("cheque").value = 0;
			document.getElementById("points").value = 0;
			document.getElementById("creditnotee").value = 0;


            } else if ($(this).val() == "Mpesa") {
              $("#accountno").show();
				$("#name").hide();
               $("#due").hide();
              
$("#mpesa").focus().value = "";
  	 var myfinaltotal = document.getElementById('myfinaltotal').value;

            document.getElementById("mpesa").value = myfinaltotal;
						
			document.getElementById("cash").value = 0;
			document.getElementById("credit").value = 0;
			 document.getElementById("card").value = 0;
			document.getElementById("voucher").value = 0;

			 document.getElementById("cheque").value = 0;
			document.getElementById("points").value = 0;
			document.getElementById("creditnotee").value = 0;



            }else if ($(this).val() == "Bank") {
             $("#accountno").show();
				$("#name").hide();
               $("#due").hide();
			   $("#cheque").focus().value = "";

			     	 var myfinaltotal = document.getElementById('myfinaltotal').value;

                 document.getElementById("cheque").value = myfinaltotal;
						
			document.getElementById("cash").value = 0;
			document.getElementById("credit").value = 0;
			 document.getElementById("card").value = 0;
			document.getElementById("voucher").value = 0;

			 document.getElementById("mpesa").value = 0;
			document.getElementById("points").value = 0;
			document.getElementById("creditnotee").value = 0;


            }else if ($(this).val() == "Voucher") {
            $("#accountno").show();
				$("#name").hide();
               $("#due").hide();
                     $("#voucher").focus().value = "";
  	 var myfinaltotal = document.getElementById('myfinaltotal').value;

            document.getElementById("voucher").value = myfinaltotal;
						
			document.getElementById("cash").value = 0;
			document.getElementById("credit").value = 0;
			 document.getElementById("mpesa").value = 0;
			document.getElementById("card").value = 0;

			 document.getElementById("cheque").value = 0;
			document.getElementById("points").value = 0;
			document.getElementById("creditnotee").value = 0;

            }else if ($(this).val() == "Creditnote") {
             $("#accountno").show();
				$("#name").hide();
               $("#due").hide();
               $("#creditnotee").focus().value = "";
  	 var myfinaltotal = document.getElementById('myfinaltotal').value;

            document.getElementById("creditnotee").value = myfinaltotal;
						
			document.getElementById("cash").value = 0;
			document.getElementById("credit").value = 0;
			 document.getElementById("mpesa").value = 0;
			document.getElementById("card").value = 0;

			 document.getElementById("cheque").value = 0;
			document.getElementById("points").value = 0;
			document.getElementById("voucher").value = 0;

            }else if ($(this).val() == "Points") {
           $("#accountno").show();
				$("#name").hide();
               $("#due").hide();
              
         $("#points").focus().value = "";
  	 var myfinaltotal = document.getElementById('myfinaltotal').value;

            document.getElementById("points").value = myfinaltotal;
						
			document.getElementById("cash").value = 0;
			document.getElementById("credit").value = 0;
			 document.getElementById("mpesa").value = 0;
			document.getElementById("card").value = 0;

			 document.getElementById("cheque").value = 0;
			document.getElementById("creditnotee").value = 0;
			document.getElementById("voucher").value = 0;
            }else if ($(this).val() == "Card") {
           $("#accountno").show();
				$("#name").hide();
               $("#due").hide();
              $("#card").focus().value = "";
  	 var myfinaltotal = document.getElementById('myfinaltotal').value;

            document.getElementById("card").value = myfinaltotal;
						
			document.getElementById("cash").value = 0;
			document.getElementById("credit").value = 0;
			 document.getElementById("mpesa").value = 0;
			document.getElementById("voucher").value = 0;

			 document.getElementById("cheque").value = 0;
			document.getElementById("points").value = 0;
			document.getElementById("creditnotee").value = 0;

            }
			
			
			
			else  if ($(this).val() == "Credit") {
           
				             $("#accountno").hide();
				$("#credit").focus().value = "";
  	 var myfinaltotal = document.getElementById('myfinaltotal').value;

            document.getElementById("credit").value = myfinaltotal;
						
						  document.getElementById("cash").value = 0;
			document.getElementById("mpesa").value = 0;
			 document.getElementById("card").value = 0;
			document.getElementById("voucher").value = 0;

			 document.getElementById("cheque").value = 0;
			document.getElementById("points").value = 0;
			document.getElementById("creditnotee").value = 0;

							 
				$("#due").show();
            }else  if ($(this).val() == "Invoice") {
              $("#accountno").hide();
			 $("#name").show(); 
				                
				$("#due").show();
					$("#credit").focus().value = "";
  	 var myfinaltotal = document.getElementById('myfinaltotal').value;

            document.getElementById("credit").value = myfinaltotal;
						
						  document.getElementById("cash").value = 0;
			document.getElementById("mpesa").value = 0;
			 document.getElementById("card").value = 0;
			document.getElementById("voucher").value = 0;

			 document.getElementById("cheque").value = 0;
			document.getElementById("points").value = 0;
			document.getElementById("creditnotee").value = 0;
            }
            else {
               $("#accountno").show();
				$("#name").hide();
               $("#due").hide();
            }
        });
    });
		
    </script>	 
			
<ul class="nav nav-tabs bordered">




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

  ?>








			<li class="active">
            	<a href="#add" data-toggle="tab"><i class="entypo-menu"></i> 
			 Book this room
                    	</a></li>
			<li>
            
						
						
									<li>
            	<a href="#back" data-toggle="tab"><i class="entypo-plus-circled"></i>
			
				 <a href="<?php echo base_url(); ?>admin/viewpallmyplots">	Go back</a>
                    	</a></li>
						
						
								<li>
			
		</ul>
    	<!------CONTROL TABS END------>
        
		<div class="tab-content">
            <!----TABLE LISTING STARTS-->
            <div class="tab-pane box" id="list">
				
     


 <div class="table-responsive" >
  <div class="row">
  
   	

   	<div class="col-md-12"> 
<table  border="1" width="100%">
             <thead>
			
         <tr>
		 <th>Ref No</th> 	

    	<th>Check Out</th> 
		<th>Print </th> 
				<th>Form </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>Days</th> 		
	 <th>TT Exp</th> 
 <th>Sale Price</th> 


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

	 	 <th>Credit </th> 
		 	 	 <th>Voucher </th> 
				  <th>Food </th> 
	 <th>Dsc </th> 



	 <th> Status </th> 
	
		 <th>Code  </th> 

	
	
	
	
	
	
	 <th>Rm Status</th> 


		 <th>NB  </th> 

	 <th>Staff</th> 
	 
	 <th>View</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');
    $from=date("Y-m-d");

    $mydate=date("Y-m-d H:i:s");
	
	$next_date = date('Y-m-d', strtotime(' +1 day'));
    $closedatedate=($next_date);


 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
		 $imgid = rand(100, 990000).time();


 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	 
	 	      $givediscount=$this->usermodel->populatuserpermissionsdataarray('accomodation','givediscount',$userid);

	 	 	      $changepayment=$this->usermodel->populatuserpermissionsdataarray('accomodation','changepayment',$userid);
	       $checkinroom=$this->usermodel->populatuserpermissionsdataarray('accomodation','checkinroom',$userid);

	 
	 
				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 
  
  	foreach ($booking as $c): 
	$myroomtype=($c->roomtype);
		//$roomtype=($roomtype)+($myroomtype);
		 

             ?>



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


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

		 
		 
		 	<td>
			
			 <a class="btn btn-danger managebtn" id="managebtncheckout"	data-plotno='<?php echo  $c->plotno;?>' data-houseno='<?php echo  $c->houseno;?>' 	 data-id='<?php echo  $c->id;?>'     data-toggle='modal' data-target='#Checkout<?php  $c->id; ?>'>	 

						
                                               Check-out
						</a>

						
						
				</td>
				
		  	<td>
			
			 <a class="btn btn-primary"  target="_blank" id="more" href="<?php echo base_url();?>admin/housereceiptbyno?randomitemidentifier=<?php   {echo  $c->transactioncode;}  ?>&plotno=<?php   {echo  $c->plotno;}  ?>&houseno=<?php   {echo  $c->houseno;}  ?>">Print  </a>

						
						

				</td>
				  	<td>
			
			 <a class="btn btn-primary"  target="_blank" id="more" href="<?php echo base_url();?>admin/guestform?randomitemidentifier=<?php   {echo  $c->id;}  ?>&plotno=<?php   {echo  $c->plotno;}  ?>&houseno=<?php   {echo  $c->houseno;}  ?>">Form  </a>

						
						

				</td>
				
             <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){

    $names=$tenantsrow->lastname. " ".$tenantsrow->firstname ; 
   
   ?>
   
                     <a class="btn btn-warning"  target="_blank"   style="margin:5px" id="more" href="<?php echo base_url();?>admin/edittenant?randomitemidentifier=<?php   {echo  $tenantid;}  ?>"><?php   {echo  $names;}  ?>  </a>

   
   <?php
    

}
    } else {
    echo 'No tenant.';
}
?>
				 
				 
		</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  $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; ?></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>

										 <td><?php echo $c->credit; ?></td>
										 <td><?php echo $c->voucher; ?></td>
										 <td>
										 
										 <?php



 $roomsales = $this->usermodel->populatealldatanoarrayfour('roomsales','houseno', 'plotno', $plotno,'description', $c->id,'customerid', $c->tenantid);			   

				
				
				
				
				
 if(!is_array($roomsales)) 

 {


  
    }else {
?>
    
             <?php 
  $total=0;
  	foreach ($roomsales as $row){ 

		   $total=$total+$row->total;
	}
	}
			  								if(isset($total)) {echo   formatMoney($total, true); }
							 
										 
				?>						 </td>
										 
										 <td><?php echo $c->discount; ?></td>

								

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

		  </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>
									
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        

                                        
                                         <li> 
						<a  id="more" class="btn btn-warning" href="<?php echo base_url();?>user/mychangepayment?myid=<?php echo $c->id ?>&randomitemidentifier=<?php   ?>&randomitemidentifier1=<?php echo $plotno ?>&roomidentifier=<?php echo ""; ?>"> Update Payment  </a>


                                                </a>
                                                        </li>      
								<li class="divider"></li>														
										<?php
										if($usertype=="admin"){
											
											?>
											  <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>
																Cancel
                                                </a>
                                                        </li>
										<?php
										}
										?>
									
                                     
                                    </ul>
										
                                </div>
		 
		 </td>
             </tr>

             <?php endforeach; ?>

              <?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 ""; ; ?>"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="houseno2"name="houseno" class="form-control" placeholder="houseno"  value="">

		   
		   	<select class="form-control" name="status" required>
	<option  value=""  >--Select status-</option>
   <option value="vacant" selected="selected" >Vacant</option>
									  
 <option value="freezed" >Freezed</option>
																 									   <option value="Pending">Pending</option>



	
</select>
		   
          <input type="hidden" id="plotno2"name="plotno" class="form-control" placeholder="plotno"  value="">
 		   		  	         <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 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   ?>&randomitemidentifier1=<?php echo $plotno ?>&roomidentifier=<?php echo ""; ?>"  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"  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" 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" 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=<?php   ?>&randomitemidentifier1=<?php echo $plotno ?>&roomidentifier=<?php echo ""; ?>">
 <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="<?php  ?>">

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


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



			
			
			
			
			
			
				<?PHP
				echo $this->session->flashdata('msg'); 
			  $date = Date('Y-m-d') ;
		 	 $year = Date('Y') ;
		  $month = Date('m') ;
		  
		                   echo form_open('addbooking' , array('class' => 'form-horizontal form-groups-bordered validate', 'role'=>'login', '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="action" value="<?php echo set_value('action','insert'); ?>"id="action" class="form-control" required >


  								  		<input type="hidden" name="roomidentifier" value="<?php  echo ""; ; ?>"id="roomidentifier" class="form-control"  placeholder="Enter roomidentifier">

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













	
  <div class="form-group">

    <label for="inputhouseno" class="col-md-3 control-label">Room No</label>
	
    <div class="col-md-9">

			  		<input type="text" readonly name="houseno" style="width:10%" value="<?php   ?>"id="bookingno" class="form-control1" required placeholder="Enter booking number">
								  		
										Hs No:	<input type="text" style="width:10%" readonly name="plotno" value="<?php  ?>"id="bookingno" class="form-control1" required placeholder="Enter booking number">
						    		  						
	<input type="text" style="width:50%"  name="tenantid" value="" autofocus  id="mysupplier" class="form-control1" required placeholder="Enter customer name">

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

									


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

  
  
  <div class="form-group">
    <label for="inputroomtype" class="col-md-3 control-label">Room type?:</label>
    <div class="col-md-9">
				    	
			  	<select name="roomtype" id="roomtype" onchange="getdays()" class="form-control" required>
<option value="" >---Select charges type---</option>

		<?php 

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


if(is_array($charges)) {

   foreach($charges as $chargesrow){

  

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

	 $chargename=$chargename[0]['type'];
//
$roomdata=$chargesrow->cost."==".$chargesrow->chargeid;
  
   ?>
   
	    <option value="<?php echo $roomdata; ?> "><?=$chargename."(" .$chargesrow->name.":" .$chargesrow->cost.")"; ?></option>

   
    <?php   


   
   
  

}} else {
    echo 'There is no any  charges for this house.... PLease add charges first.';
}

?>
<!--<option value="all" >---ALL ---</option>-->

	</select>

	  <span class="text-danger"><?php echo form_error('roomtype'); ?></span>
	</div>
    </div>
   <div class="form-group">
 
   <label for="inputpeople" class="col-md-3 control-label">People</label>
    <div class="col-md-9">
				<input type="number" name="people" value="1" id="people" class="form-control" required placeholder="Enter No of people">
        <span class="text-danger"><?php echo form_error('people'); ?></span>
	</div>
	
  </div>
		
		
   <div class="form-group">
    
 
   <label for="inputidno" class="col-md-3  control-label">Check In</label>
    <div class="col-md-9">
				<input type="date"  id="checkin" onchange="getdays()" name="createdat" value="<?php echo set_value('createdat',$date); ?>"  class="tcal" required placeholder="Enter Check in Date">
        <span class="text-danger"><?php echo form_error('createdat'); ?></span>
	</div>
    </div>
   <div class="form-group">
	 <label for="inputidno" class="col-md-3 control-label">Check Out  </BR>  </BR> EXP Amount:	</label>
    <div class="col-md-9">
				<input type="date"  onchange="getdays()" id="checkout" name="checkoutdate" value="<?php echo set_value('checkoutdate',$closedatedate); ?>" class="tcal" required placeholder="Enter Check Out  Date">
        <span class="text-danger"><?php echo form_error('checkoutdate'); ?></span>
	
				<input type="text"  readonly name="totalamount" value="" id="totalamount" class="form-control" required placeholder="Exp Total amount(Auto calculated)">

	
	</div>
	
  </div>
  
  
  
  
  
													


   <div class="form-group">
    <label for="inputtype" class="col-md-3 control-label">Prefered Payment Mode</label>
    <div class="col-md-9">
       
													<select name="type" id="type" class="form-control">

<option value="Cash" selected="selected">Cash</option>
<option value="Credit">Credit</option>
<option value="Invoice">Invoice</option>
<option value="Mpesa">Mpesa</option>
<option value="Card">Card</option>

<option value="Bank">Bank</option>
<option value="Voucher">Voucher/Complimentary</option>
<option value="Points">Bonga Points</option>

</select>	
	   <span class="text-danger">Prefered Payment Mode<?php echo form_error('type'); ?></span>
	</div>
  </div>
     
	<?php
 if( $cashpayment==true){
	 ?>
   <div class="form-group">
   
     <label for="inputamount" class="col-md-3 control-label">Cash Paid</label>
    <div class="col-md-9">
				<input type="text" name="amount" value="0" id="cash" class="form-control" required placeholder="Enter amount">
        <span class="text-danger"><?php echo form_error('amount'); ?></span>
	</div>
	
	
     </div>
	 
	 	 
	 	<?php	
		}else{
?>
				<input type="hidden" name="amount" value="0" id="cash" class="form-control" required placeholder="Enter amount">


<?php

		}
  ?>
  
  
  
  <div class="form-group">
  
  <?php
  
   if( $givediscount==true){
	 ?>
 
    <label for="inputdiscount" class="col-md-3 control-label">Discount</label>
    <div class="col-md-9">
	
		<select class="form-control" name="discount" >
	
	<option value="0" selected="selected"  >---Select Discount---</option>

			<?php
			$getalldiscounts = $this->usermodel->populatealldatanoarray('discount', 'companyid',$companyid,'id >',0);

 		
				
	

	
if(is_array($getalldiscounts)) {

   foreach($getalldiscounts as $getalldiscountsrow){

   //echo $courserow->coursename;
    ?>
						<option  value="<?=  $getalldiscountsrow->discount.":=".$getalldiscountsrow->type;   ?>"><?=  $getalldiscountsrow->discount."(".$getalldiscountsrow->name."-".$getalldiscountsrow->type.")";?></option>




	<?php

}} else {
    echo 'No discount available. Please add them fisrt.';
}
	
?>
</select>
		
	
	
	
	
	
	
	
	
	
	
	
	
	
	

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


	 	<?php	
		//z

 }else{
	 ?>
	 
	 
	 	<input type="hidden" name="discount" value="0" id="discount" class="form-control"  placeholder="Enter discount">

	 	<?php
	 
 }
  ?>
      </div>
  
  
  
  
  
  
  <div class="form-group">
						<label for="field-2" class="col-md-3 control-label">Room Status</label>
		                    <div class="col-md-9">
		                        <select name="status" class="form-control" id="section_selector_holder">

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

			                </div>
			 </div>
			 
			 			
  
    	  <div class="form-group">
						<label for="field-2" class="col-md-3 control-label">Payment status</label>
		                    <div class="col-md-9">
		                        <select name="paymentstatus" class="form-control" id="section_selector_holder">

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

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

			                </div>

		  </div>
		   
	   <div class="form-group">
    <label for="inputpaymentcode" class="col-md-3 control-label">Ref No/ Transaction Code</label>
    <div class="col-md-9">
				<input type="text" name="paymentcode" value="<?php echo set_value('paymentcode'); ?>" id="idno" class="form-control"  placeholder="Enter Ref No / Transaction Code">
        <span class="text-danger"><?php echo form_error('paymentcode'); ?></span>
	</div>
    </div>
   
   <div class="form-group">
    <label for="inputphone3" class="col-md-3 control-label">Description </label>
    <div class="col-md-9">
					<input type="text" name="description" value="" id="description" class="form-control"  placeholder="Enter description">

    <span class="text-danger"><?php echo form_error('description'); ?></span>
   </div>
   
   
  </div>
  
  
   <div class="form-group">
						<label for="field-2" class="col-md-3 control-label">	Currency</label>
		                    <div class="col-md-9">
		                        <select name="currency" class="form-control" id="section_selector_holder">

			                
									   
									   
									   
		<?php 

      $currency = $this->usermodel->populateall('currency','companyid', $companyid);


if(is_array($currency)) {

   foreach($currency as $currencyrow){

  


  
   ?>
	    <option selected="selected" value="<?php echo $currencyrow->name; ?> "><?=$currencyrow->name;?></option>

   
    <?php   


   
   
  

}} else {
    echo 'There is no any  charges for this house.... PLease add charges first.';
}

?>
									   
									   
									   
									   
									   
									   
									   
									   
									   
									   

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

			                </div>

		  </div>
    					 	<?php
					
	if($checkinroom==true){
		?>
   <div class="form-group">
       <label for="inputphone3" class="col-md-4 control-label"> </label>

    <div class="col-md-8">
										       <button type="submit" name="btn_booking" value="booking" class="btn btn-primary">Check in this Room</button>
   <select name="receipt" class="form-control2" >

			                         <option selected value="Yes">Print Receipt</option>
									   <option value="No">No Receipt</option>

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


		
		<?php

}	
	?>
  
  </div>
    <div class="col-md-6">
  
  
  
  
  
  
  
  
  
  
  
  
  

  
  
  			  	<?php
 if( $mpesaaction==true){
	 ?>
   
	 	  <div class="form-group">
   <label for="inputmpesa" class="col-md-3 control-label">Mpesa Paid</label>
    <div class="col-md-9">
				<input type="text" name="mpesa" value="0" id="mpesa" class="form-control" required placeholder="Enter Mpesa">
        <span class="text-danger"><?php echo form_error('mpesa'); ?></span>
	</div>
  </div>
		  <div class="form-group">
   <label for="inputmpesa" class="col-md-3 control-label">Phone</label>

	 <div class="col-sm-4">
	 

	 	
				<input type="text" name="phone" value="2547" id="phone" class="form-control" required placeholder="Enter phone">



	 
	</div>
  </div>
	 	<?php	
		}else{
		?>
				<input type="hidden" name="mpesa" value="0" id="mpesa" class="form-control" required placeholder="Enter Mpesa">
				<input type="hidden" name="phone" value="2547" id="phone" class="form-control" required placeholder="Enter phone">


<?php

}
  ?>
  
  
  
  				  
				  	<?php
 if( $creditaction==true){
	 ?>
   
     <div class="form-group">
    <label for="inputcredit" class="col-md-3 control-label">Credit Amount</label>
    <div class="col-md-9">
				<input type="text" name="credit" value="0" id="credit" class="form-control" required placeholder="Enter credit amount">
        <span class="text-danger"><?php echo form_error('credit'); ?></span>
	</div>
   </div>
	 	 
		 
	 	<?php	
		}else{
		?>

				<input type="hidden" name="credit" value="0" id="credit" class="form-control" required placeholder="Enter credit amount">

<?php

}
  ?>
  
  			  	<?php
 if( $cardaction==true){
	 ?>
   
	 	    <div class="form-group">
    <label for="inputcard" class="col-md-3 control-label">Visa/Master Card</label>
    <div class="col-md-9">
				<input type="text" name="card" value="0" id="card" class="form-control" required placeholder="Enter card amount">
        <span class="text-danger"><?php echo form_error('card'); ?></span>
	</div>
  </div>
  
		 
	 	<?php	
		}else{
		?>
				<input type="hidden" name="card" value="0" id="card" class="form-control" required placeholder="Enter card amount">


<?php

}
  ?>
  
  
  				  
				  	<?php
 if( $chequeaction==true){
	 ?>
      <div class="form-group">
    <label for="inputcheque" class="col-md-3 control-label">Cheque/Bank</label>
    <div class="col-md-9">
				<input type="text" name="cheque" value="0" id="cheque" class="form-control" required placeholder="Enter cheque amount">
        <span class="text-danger"><?php echo form_error('cheque'); ?></span>
	</div>
   </div>
	 	 
		 
	 	<?php	
		}else{
		?>
				<input type="hidden" name="cheque" value="0" id="cheque" class="form-control" required placeholder="Enter cheque amount">


<?php

}
  ?>

		  


				  
				  	<?php
 if( $pointsaction==true){
	 ?>
   
	 	   <div class="form-group">
    <label for="inputpoints" class="col-md-3 control-label">L Points</label>
    <div class="col-md-9">
				<input type="text" name="points" value="0" id="points" class="form-control" required placeholder="Enter points amount">
        <span class="text-danger"><?php echo form_error('points'); ?></span>
	</div>
  </div> 
		 
	 	<?php	
		}else{
		?>
				<input type="hidden" name="points" value="0" id="points" class="form-control" required placeholder="Enter points amount">


<?php

}
  ?>

  
  
  
				  	<?php
 if( $voucheraction==true){
	 ?>
   
	 	 
	   <div class="form-group">
    <label for="inputvoucher" class="col-md-3 control-label">Complimentary</label>
    <div class="col-md-9">
				<input type="text" name="voucher" value="0" id="voucher" class="form-control" required placeholder="Enter voucher/Complimentary amount">
        <span class="text-danger"><?php echo form_error('voucher'); ?></span>
	</div>
 
  
  
    </div>
	 
	 	<?php	
		}else{
		?>

				<input type="hidden" name="voucher" value="0" id="voucher" class="form-control" required placeholder="Enter voucher/Complimentary amount">

<?php

}
  ?>
  
  
 
  
   
    	
   
	
	  </div>

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


   </div>
</div>

<link href="<?php echo base_url(); ?>assets/autocomplete/jquery-ui.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/autocomplete/ui.theme.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/autocomplete/autocomplete.css" rel="stylesheet">
	
			