

	 <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  House
                    	</a></li>
			<li>
            	<a href="#list" data-toggle="tab"><i class="entypo-plus-circled"></i>
				 All House
                    	</a></li>
						<li>
				 <a href="<?php echo base_url(); ?>admin/viewpallmyplots">Go Back</a>
								</li>
		</ul>
    	<!------CONTROL TABS END------>
        
		<div class="tab-content">
		
		<?php
					echo $this->session->flashdata('deletemsg'); 
		   $session_data = $this->session->userdata('logged_in');

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


			?>
            <!----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>House Code </th>
	<th>House Name</th>
	<th>Landlord</th>
	<th>Manager</th>
  
			<th>Rooms</th> 
	<th>Vacant</th> 

	<th>Occupied</th> 
	
	<th>Manage Rms</th> 

	<th>More</th> 

                 </tr>
             </thead>
<?php
$year = Date('Y') ;
		  $month = Date('m') ;
echo $this->session->flashdata('msg'); 
	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;
					}
 if(!is_array($plots)) 

 {


   
    
       echo '<div class="alert alert-warning text-center">There is no Plot found by now from system..</div>';
   
    }else {
?>
    
             <?php 
  
  	foreach ($plots as $c): 

		 

             ?>



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

?>

             <td><?php  $c->id ; ?>
			 
				   <a class="btn btn-primary" id="more" href="<?php echo base_url();?>admin/editplot?randomitemidentifier=<?php   {echo  $id;}  ?>"><?php echo $c->id?> </a>
 
			 
			 </td> 
				<td><?php echo $c->name ; ?></td> 

				<td><?php  $landlordid=  $c->landlordid ; 
							    $landlords = $this->accomodationmodel->getlandlordid($landlordid);
							


if(is_array($landlords)) {

   foreach($landlords as $landlordsrow){

  $names= $landlordsrow->lastname. "  ".$landlordsrow->firstname ; 
    
   ?>
   
                     <a class="active"  id="more" href="<?php echo base_url();?>admin/editlandlord?randomitemidentifier=<?php   {echo  $landlordid;}  ?>"><?php   {echo  $names;}  ?>  </a>

   
   <?php
}} else {
    echo $c->landlordid;
}
	
				
				?></td> 
				
				<td><?php  $agentid=  $c->agentid; 
							    $agent = $this->accomodationmodel->getagentid($agentid);
								


if(is_array($agent)) {

   foreach($agent as $agentrow){

   $names= $agentrow->firstname ; 
    
 ?>
   
                     <a class="active"  id="more" href="<?php echo base_url();?>admin/editagent?randomitemidentifier=<?php   {echo  $agentid;}  ?>"><?php   {echo  $names;}  ?>  </a>

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

                 <td><?php echo $c->totalhouse ; ?></td>
                     <td><?php 
					 
					 $vacanthouse = $this->accomodationmodel->displayvacant($id);
					 if($vacanthouse==FALSE){
						 
						 echo "0";
					 }else{
						 
						//echo $vacanthouse; 
											?>
							   <a class="btn btn-warning" id="more" href="<?php echo base_url();?>admin/viewplot?randomitemidentifier=<?php   {echo  $id;}  ?>&status=vacant"><?php   {echo  $vacanthouse;}  ?> </a>

					 
					 <?php 
					 }
					 
				
					 
					 
					 ?></td> 
					 
					    <td><?php 
					 
					 $occupiedhouse = $this->accomodationmodel->displayoccupied($id);
					 if($occupiedhouse==FALSE){
						 
						 echo "0";
					 }else{
						 
						//echo $occupiedhouse; 
						?>
							   <a class="btn btn-success" id="more" href="<?php echo base_url();?>admin/viewplot?randomitemidentifier=<?php   {echo  $id;}  ?>&status=occupied"><?php   {echo  $occupiedhouse;}  ?> </a>

					 
					 <?php 
					 
					 }
					 
				
					 
					 
					 ?></td> 
        
		      					 
                     <td>
	   <a class="btn btn-primary" id="more" href="<?php echo base_url();?>admin/viewplot?randomitemidentifier=<?php   {echo  $id;}  ?>"> Rooms </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>
    <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/deletebyid' , 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="view" value="plot">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="admin/viewallplots">
 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
          <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 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 House
            	</div>
            </div>
			<div class="panel-body">





				<?PHP
				echo $this->session->flashdata('msg'); 
		
                 echo form_open('addplot' , 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;?>
					
	<input type="hidden" name="action" value="<?php echo set_value('action','insert'); ?>"id="action" class="form-control" required >

    <div class="form-group">
    <label for="inputname" class="col-sm-2 control-label">House Name</label>
    <div class="col-sm-7">
		<input type="text" name="name" value="<?php echo set_value('name') ;?>" id="name" class="form-control" required placeholder="Enter name">
       <span class="text-danger"><?php echo form_error('name'); ?></span>
   </div>
  </div>
    <div class="form-group">
    <label for="inputlocation" class="col-sm-2 control-label">Location</label>
    <div class="col-sm-7">
				<input type="text" name="location" value="<?php echo set_value('location') ;?>" id="exampleInputlocation" class="form-control" required placeholder="Enter  location">
    <span class="text-danger"><?php echo form_error('location'); ?></span>
	</div>
  </div>
 
  
  <div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">landlord Name</label>
    <div class="col-sm-7">
				    	
			  	<select name="landlordid" class="chzn-select" required>
<option value="" >---Select landlord for this house---</option>

		<?php 

$landlord = $this->accomodationmodel->populatealllandlord();


if(is_array($landlord)) {

   foreach($landlord as $landlordrow){

    ?>
	    <option value="<?php echo set_value('landlord',$landlordrow->id); ?> "><?=$landlordrow->lastname." ".$landlordrow->firstname;?></option>

   
    <?php

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

?>
	</select>
				

	  <span class="text-danger"><?php echo form_error('landlordid'); ?></span>
	</div>
  </div>		
<div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">Manager Name</label>
    <div class="col-sm-7">
				    	
			  	<select name="agentid" class="chzn-select" required >
<option value="" >---Select Manager for this House---</option>

		<?php 

$allagents = $this->accomodationmodel->populateallagent();


if(is_array($allagents)) {

   foreach($allagents as $agentrow){

    ?>
	    <option value="<?php echo set_value('agentid',$agentrow->id); ?> "><?=$agentrow->lastname." ".$agentrow->firstname;?></option>

   
    <?php

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

?>
	</select>
				

	  <span class="text-danger"><?php echo form_error('landlordid'); ?></span>
	</div>
  </div>			
   <div class="form-group">
    <label for="inputphone3" class="col-sm-2 control-label">Total Rooms </label>
    <div class="col-sm-7">
				<input type="phone" name="totalhouse" value="<?php echo set_value('totalhouse'); ?>" id="totalhouse" class="form-control" required placeholder="Enter total house">
    <span class="text-danger"><?php echo form_error('totalhouse'); ?></span>
   </div>
  </div>
  <div class="form-group">
						<label for="field-2" class="col-sm-2 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="inputaccountname" class="col-sm-2 control-label">Account Name</label>
    <div class="col-sm-7">
				<input type="accountname" name="accountname" value="<?php echo set_value('accountname'); ?>" id="idno" class="form-control"  placeholder="Enter account name">
    <span class="text-danger"><?php echo form_error('accountname'); ?></span>
   </div>
  </div>
  
  
    
   <div class="form-group">
    <label for="inputaccountno" class="col-sm-2 control-label">Account Number</label>
    <div class="col-sm-7">
				<input type="accountno" name="accountno" value="<?php echo set_value('accountno'); ?>" id="idno" class="form-control"  placeholder="Enter  account number">
    <span class="text-danger"><?php echo form_error('accountno'); ?></span>
   </div>
  </div>
  
       <div class="form-group">
    <label for="inputcommission" class="col-sm-2 control-label">Commission(%) </label>
    <div class="col-sm-7">
				<input type="commission" name="commission" value="<?php echo set_value('commission'); ?>" id="idno" class="form-control"  placeholder="Enter  commission (%)">
    <span class="text-danger"><?php echo form_error('commission'); ?></span>
   </div>
  </div>
   <div class="form-group">
    <label for="inputdescription" 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>
    <?php
  
   if( $addhouse==true){
	 ?>
 <div class="form-group">
    <div class="col-sm-offset-2 col-sm-7">
     
	       <button type="submit" name="btn_plot"value="plot" class="btn btn-primary">Add House</button>

    </div>
  </div>
           


	 	<?php	

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


</div></div>


		
			
			