<?php include('header.php');?>
<?php include('sidebar.php');?>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC6v5-2uaq_wusHDktM9ILcqIrlPtnZgEk&sensor=false">
</script>
<script type="text/javascript">
      var map;
        function initialize() {
            var myLatlng = new google.maps.LatLng(25.20670,55.29147);
            var myOptions = {
                zoom:5,
                center: myLatlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            map = new google.maps.Map(document.getElementById("gmap"), myOptions);
            // marker refers to a global variable
            marker = new google.maps.Marker({
                position: myLatlng,
                map: map
            });

            google.maps.event.addListener(map, "click", function(event) {
                // get lat/lon of click
                var clickLat = event.latLng.lat();
                var clickLon = event.latLng.lng();

                // show in input box
                document.getElementById("lat").value = clickLat.toFixed(5);
                document.getElementById("lon").value = clickLon.toFixed(5);

                  var marker = new google.maps.Marker({
                        position: new google.maps.LatLng(clickLat,clickLon),
                        map: map
                     });
            });
    }   

    window.onload = function () { initialize() };
</script>
     <style>
 div#gmap {
        width: 80%;
        height: 500px;
        border:double;
 }
    </style>
<?php 
include('includes/class.usertype.php');
$usertype = new Usertype();
 
if(!isset($user_id)){
	header('Location: dashboard.php');
}
?>
<?php
$maintitle="Hotels";
$page="hotels.php";
$table="tbl_hotels";
$field_id="hotelid";
$mode=$_REQUEST['mode'];
$search=$_REQUEST['search'];
$content_id=$_REQUEST['content_id'];
if(isset($_REQUEST['start'])){
$start=$_REQUEST['start']-1;
}
else {
$start=0;
}
?>
<?php
 
if(isset($_REQUEST['submit'])=="submit"){ 
$dataexist=array();
$required = array();
$values = $_POST;

unset($values['submit']);
unset($values['mode']);
 
$contypes= $helper->select("tbl_contracting_types","contractingtypeid,title",array("status"=>1),array());
foreach($contypes as $contype){	
unset($values[$contype['contractingtypeid']]);
}
 
/*$customurl=array("customurl"=>$slugexist);
$values=array_merge($values,$customurl);*/
$userid=array("user_id"=>$user_id);
$values=array_merge($values,$userid);
$image=$helper->image_upload($_FILES['frm_filename'],"hotels");
$photo=array("image"=>$image);
$actualdate=date('Y-m-d');
$indate=array("str_update"=>$actualdate);

if($photo!=""){
$values=array_merge($values,$photo);
   
}

if($_REQUEST['mode']=="add"){
		$message=$helper->insert($table,$values,$required,$dataexist);
		 foreach($contypes as $contype){		  
		 $comtype=explode("/",$_REQUEST[$contype['contractingtypeid']]);
		 $comid=$comtype[0];
		 $tyid=$comtype[1];
		 $convalues=array("companyid"=>$comid,"typeid"=>$tyid,"hotelid"=>$message['id']);
		 $helper->insert("tbl_hotelcontractors",$convalues,array(),array());
                 $hotelvalue=array("hotelid"=>$message['id']);
	         }
                 $helper->insert("tbl_hotelcompanies",$hotelvalue,array(),array());

}
 if($_REQUEST['mode']=="edit"){
         $values=array_merge($values,$indate);
         $message=$helper->update($table, $values,array($field_id=>$_REQUEST['contentid']),$required,$dataexist);
		  $message=$helper->delete("tbl_hotelcontractors", array("hotelid"=>$_REQUEST['contentid']));
         foreach($contypes as $contype){		  
		 $comtype=explode("/",$_REQUEST[$contype['contractingtypeid']]);
		 $comid=$comtype[0];
		 $tyid=$comtype[1];
		 $convalues=array("companyid"=>$comid,"typeid"=>$tyid,"hotelid"=>$_REQUEST['contentid']);
		 //$helper->insert("tbl_hotelcontractors",$convalues,array(),array());		  
	     }

}

}
if(isset($_REQUEST['submit2'])=="submit"){ 
$dataexist=array();
$required = array();
$values = $_POST; 
unset($values['submit2']);
unset($values['mode']);
$hotelexist=$helper->hotelexist($_REQUEST['contentid']);
if($hotelexist=="Hotel Exist Already") {
$message=$helper->update("tbl_hotelcompanies", $values,array($field_id=>$_REQUEST['contentid']),$required,$dataexist);
} else {
  $hotelid=array("hotelid"=>$_REQUEST['contentid']);
  $values=array_merge($values,$hotelid);  
  $message=$helper->insert("tbl_hotelcompanies", $values,$required,$dataexist);  
}
}
if(isset($_REQUEST['updatepass'])=="Update Password"){ 
 $pass=$_REQUEST['password'];
 $conpass=$_REQUEST['conpassword'];
 
if($pass==$conpass){
	$password=md5($pass);
	$required = array("password");
	$helper->update("tbl_clients", array("password"=>$password),array("userid"=>$user_id),$required);
	header("location:logout.php");
}
else{
	$error="Password not Matching";
}
}
?>
    



	 

<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1><?php echo $maintitle;?></h1>
      <ol class="breadcrumb">
        <li><a href="dashboard.php"><i class="fa fa-dashboard"></i> <?php echo AL_DASHBOARD;?></a></li>
        <li class="active"><?php echo $maintitle;?></li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
    <?php
	if($mode=="add" || $mode=="edit"){ 
	?>
     <div class="row">
 <!-- Add / Edit / Delete --> 
          <div class="col-sm-12"> 
          <div class="box box-success">
         <div class="box-header">
              <i class="fa fa-building-o"></i>
              <h3 class="box-title"><?php echo $maintitle;?></h3>
              <div class="box-tools pull-right">
                <div class="btn-group">
                <a href="<?php echo $page;?>"><button class="btn btn-danger btn-flat">&nbsp;<?php echo AL_LISTALL;?> <?php echo $maintitle;?></button></a>
                   
                </div>
              </div>
            </div> 
            </div> 
            </div>

 <!-- Add / Edit / Delete --> 
 <?php
if($mode=="edit"){
$contentdetails=$helper->select($table,"*",array($field_id=>$_REQUEST['contentid']));
 
}
?><script type="text/javascript">

      var map;
        function initialize() {
            var myLatlng = new google.maps.LatLng(<?php echo $contentdetails[0]['latitude'];?>,<?php echo $contentdetails[0]['longitude'];?>);
            var myOptions = {
                zoom:13,
                center: myLatlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            map = new google.maps.Map(document.getElementById("gmap"), myOptions);
            // marker refers to a global variable
            marker = new google.maps.Marker({
                position: myLatlng,
                map: map
            });

            google.maps.event.addListener(map, "click", function(event) {
                // get lat/lon of click
                var clickLat = event.latLng.lat();
                var clickLon = event.latLng.lng();

                // show in input box
                document.getElementById("lat").value = clickLat.toFixed(5);
                document.getElementById("lon").value = clickLon.toFixed(5);

                  var marker = new google.maps.Marker({
                        position: new google.maps.LatLng(clickLat,clickLon),
                        map: map
                     });
            });
    }   

    window.onload = function () { initialize() };
</script>
     <style>
 div#gmap {
        width: 80%;
        height:350px;
        border:single;
 }
    </style>

     <div class="col-md-10">
          <!-- Horizontal Form -->
          <div class="box box-info">
            <div class="box-header with-border">
              <h3 class="box-title"><?php if($_REQUEST['mode']=="add"){ echo AL_ADD; } else { echo AL_EDIT; } ?> <?php echo $maintitle;?></h3>
            </div>
            
            <?php
			if($message!=""){
			?>
            <button class="btn btn-block btn-success btn-flat" type="button"><?php echo $message['message'];?></button>
			<?php	
			}
			?>
            <!-- /.box-header -->
            <!-- form start -->
            <div class="nav-tabs-custom">
             <ul class="nav nav-tabs">
              <li class="active"><a href="#activity" data-toggle="tab">Hotel Details</a></li>
              <?php
                if($mode=="edit"){
                    ?>
              <li><a href="#timeline" data-toggle="tab">Contracting Companies</a></li>
              <?php
                }
                ?>
            </ul>
            
            <div class="tab-content">
              <div class="active tab-pane" id="activity">
                  <form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
              <div class="box-body">
                  <div class="form-group">                    
                  <label for="inputEmail3" class="col-sm-3 control-label">Hotel Groups</label>
                  <div class="col-sm-4">
                    <?php
                  $hotelgroups= $helper->select("tbl_hotelgroups","groupid,groupname",array());				   
				  ?>
                  
                  <select name="hotelgroup" class="form-control" id="projectphase">
                  <option value="">---Select Group---</option>
                  <?php
				  foreach($hotelgroups as $hotelgroup){
				  ?>
                  <option <?php if($hotelgroup['groupid']==$contentdetails[0]['hotelgroup']){?> selected="selected" <?php } ?> value="<?php echo $hotelgroup['groupid'];?>"><?php echo $hotelgroup['groupname'];?></option>
                  <?php
				  }
				  ?>
                  </select>
                  </div>
                </div>
               <div class="form-group">                    
                  <label for="inputEmail3" class="col-sm-3 control-label">Project Phase</label>
                  <div class="col-sm-4">
                    <?php
                  $projectphases= $helper->select("tbl_phase","phaseid,title",array());				   
				  ?>
                  
                  <select name="projectphase" class="form-control" id="projectphase">
                  <option value="">---Select Project Phase---</option>
                  <?php
				  foreach($projectphases as $phase){
				  ?>
                  <option <?php if($phase['phaseid']==$contentdetails[0]['projectphase']){?> selected="selected" <?php } ?> value="<?php echo $phase['phaseid'];?>"><?php echo $phase['title'];?></option>
                  <?php
				  }
				  ?>
                  </select>
                  </div>
                </div>
                 
                <div class="form-group">                    
                  <label for="inputEmail3" class="col-sm-3 control-label">Percentage Completed</label>

                  <div class="col-sm-4">
                    <input type="text" value="<?php echo $contentdetails[0]['projectstatus'];?>" class="form-control" id="percentage" name="projectstatus" placeholder="Percentage Completed" >
                  </div>
                </div>
                <div class="form-group">                    
                  <label for="inputEmail3" class="col-sm-3 control-label">Project Category</label>
                  <div class="col-sm-4">
                    <?php
                  $projectcategory= $helper->select("tbl_category","categoryid,title",array());				   
				  ?>
                  <select name="projectcategory" class="form-control" id="projectcategory">
                  <option value="">---Select Project Category---</option>
                  <?php
				  foreach($projectcategory as $category){
				  ?>
                  <option <?php if($category['categoryid']==$contentdetails[0]['projectcategory']){?> selected="selected" <?php } ?> value="<?php echo $category['categoryid'];?>"><?php echo $category['title'];?></option>
                  <?php
				  }
				  ?>
                  </select>
                  </div>
                </div>
                <div class="form-group">                    
                  <label for="inputEmail3" class="col-sm-3 control-label">Hotel Type Group</label>
                  <div class="col-sm-4">
                    <?php
                  $hotel_type_groups= $helper->select("tbl_hotel_type_group","hoteltypeid,title",array());				   
				  ?>
                  <select name="hotel_type_group" class="form-control" id="hotel_type_group" >
                  <option value="">---Select Hotel Type Group---</option>
                  <?php
				  foreach($hotel_type_groups as $hotel_type_group){
				  ?>
                  <option <?php if($hotel_type_group['hoteltypeid']==$contentdetails[0]['hotel_type_group']){?> selected="selected" <?php } ?> value="<?php echo $hotel_type_group['hoteltypeid'];?>"><?php echo $hotel_type_group['title'];?></option>
                  <?php
				  }
				  ?>
                  </select>
                  </div>
                </div>
                 <div class="form-group">
                     <input type="hidden" name="mode" value="<?php echo $_REQUEST['mode'];?>"/>
                  <label for="inputEmail3" class="col-sm-3 control-label">Hotel Name</label>

                  <div class="col-sm-8">
                    <input type="text" value="<?php echo $contentdetails[0]['hotelname'];?>" class="form-control" id="hotelname" name="hotelname" placeholder="Hotel Name" required="required">
                  </div>
                </div>
                  <div class="form-group">
                    
                  <label for="inputEmail3" class="col-sm-3 control-label">Hotel Id</label>

                  <div class="col-sm-8">
                    <input type="text" value="<?php echo $contentdetails[0]['id'];?>" class="form-control" id="hotelname" name="id" placeholder="Hotel ID" >
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Stars</label>
                  <div class="col-sm-6">
                  <table class="table table-hover">
                  <tr>
                                 <td>1 Star<br/><input type="radio" name="stars" value="1" <?php if($contentdetails[0]['stars']==1) { echo "checked"; } ?>/></td>
                   		 <td>2 Star<br/><input type="radio" name="stars" value="2" <?php if($contentdetails[0]['stars']==2) { echo "checked"; } ?>/></td>
                 		 <td>3 Star<br/><input type="radio" name="stars" value="3" <?php if($contentdetails[0]['stars']==3) { echo "checked"; } ?>/></td>
                     	 <td>4 Star<br/><input type="radio" name="stars" value="4" <?php if($contentdetails[0]['stars']==4) { echo "checked"; } ?>/></td>
                         <td>5 Star<br/><input type="radio" name="stars" value="5" <?php if($contentdetails[0]['stars']==5) { echo "checked"; } ?>/></td>
                          <td>6 Star<br/><input type="radio" name="stars" value="6" <?php if($contentdetails[0]['stars']==6) { echo "checked"; } ?>/></td>
                           <td>7 Star<br/><input type="radio" name="stars" value="7" <?php if($contentdetails[0]['stars']==7) { echo "checked"; } ?>/></td>
                         <td><br>Apartment<br/><input type="radio" name="stars" value="Appartment" <?php if($contentdetails[0]['stars']=="Appartment") { echo "checked"; } ?>/></td>
                  </tr>
                  </table>
                    
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Rooms</label>
                  <div class="col-sm-8">
                    <input type="text" class="form-control" value="<?php echo $contentdetails[0]['rooms'];?>"  id="rooms" name="rooms" placeholder="Rooms" >
                  </div>
                </div>
                 <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">TBI (IN MIL USD)</label>
                  <div class="col-sm-8">
                    <input type="text" class="form-control" value="<?php echo $contentdetails[0]['tbi'];?>"  id="tbi" name="tbi" placeholder="TBI (IN MIL USD)">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Opening Date</label>
                  <div class="col-sm-8">
                    <input type="text" class="form-control" value="<?php echo $contentdetails[0]['openingdate'];?>"  id="openingdate" name="openingdate" placeholder="Opening Date">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputPassword3" class="col-sm-3 control-label">Scope</label>
                  <div class="col-sm-8">
                    <textarea class="form-control" name="scope" id="editor" placeholder="Notes"><?php echo $contentdetails[0]['scope'];?></textarea>
                  </div>
                </div>
                   <div class="form-group">
                  <label for="inputPassword3" class="col-sm-3 control-label">Notes</label>
                  <div class="col-sm-8">
                    <textarea class="form-control" name="notes" id="editor1" placeholder="notes"><?php echo $contentdetails[0]['notes'];?></textarea>
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Address</label>
                  <div class="col-sm-8">
                  <textarea class="form-control" name="address" id="address" placeholder="Address"><?php echo $contentdetails[0]['address'];?></textarea>
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">City</label>
                  <div class="col-sm-8">
                    <input type="text"   name="city" value="<?php echo $contentdetails[0]['city'];?>" class="form-control" id="city" placeholder="City" >
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">State</label>
                  <div class="col-sm-8">
                    <input type="text"  name="state" value="<?php echo $contentdetails[0]['state'];?>" class="form-control" id="state" placeholder="State" >
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Country</label>
                  <div class="col-sm-8">
                    <?php
                  $countries= $helper->select("tbl_country","countryid,country",array(),array());
                   
				  ?>
                  <select name="country" class="form-control" id="country">
                  <?php
				  foreach($countries as $country){
				  ?>
                  <option <?php if($country['countryid']==$contentdetails[0]['country']){ echo "selected";}?>  value="<?php echo $country['countryid'];?>"><?php echo $country['country'];?></option>
                  <?php
				  }
				  ?>
                  </select>
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">P.O Box</label>
                  <div class="col-sm-8">
                    <input type="text"   name="pobox" value="<?php echo $contentdetails[0]['pobox'];?>" class="form-control" id="pobox" placeholder="Pobox" >
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Email Address</label>
                  <div class="col-sm-8">
                    <input type="text"  name="email" value="<?php echo $contentdetails[0]['email'];?>" class="form-control" id="email" placeholder="Email Address" >
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Phone</label>
                  <div class="col-sm-8">
                    <input type="text" name="phone" value="<?php echo $contentdetails[0]['phone'];?>" class="form-control" id="phone" placeholder="Phone" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Nearest Landmark</label>
                  <div class="col-sm-8">
                    <input type="text" name="nearstlandmark" value="<?php echo $contentdetails[0]['nearstlandmark'];?>" class="form-control" id="nearstlandmark" placeholder="Nearest Landmark" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Area</label>
                  <div class="col-sm-8">
                    <input type="text" name="location" value="<?php echo $contentdetails[0]['location'];?>" class="form-control" id="nearstlandmark" placeholder="Location / Area" >
                  </div>
                </div>
                   <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Plot No.</label>
                  <div class="col-sm-8">
                    <input type="text" name="plotno" value="<?php echo $contentdetails[0]['plotno'];?>" class="form-control" id="nearstlandmark" placeholder="Plot no." >
                  </div>
                </div>
                 <div class="form-group">
				 <?php
			if($contentdetails[0]['image']!=""){
			?>
              <img class="profile-user-img img-responsive img-circle" src="<?php echo $site_url;?>thumb.php?src=<?php echo $site_url;?>images/hotels/<?php echo $contentdetails[0]['image'];?>&w=160&h=160" alt="<?php echo $contentdetails[0]['firstname'];?>">
              <?php
			} else {
			?>
             <img class="profile-user-img img-responsive img-circle" src="<?php echo $site_url;?>thumb.php?src=<?php echo $site_url;?>images/no-image.jpg&w=160&h=160" alt="<?php echo $contentdetails[0]['firstname'];?>">
            <?php
			}
			?>
            </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_IMAGE;?></label>

                  <div class="col-sm-8">
                    <input type="file" class="" name="frm_filename">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Location</label>
                  <div class="col-sm-8">
                     <center> 
                      <div id="gmap"></div> 
                      Lat: <input type="text" id='lat' name="latitude" value="<?php echo $contentdetails[0]['latitude'];?>">
                      Lon: <input type="text" id='lon' name="longitude" value="<?php echo $contentdetails[0]['longitude'];?>">
                      </center>
                  </div>
                </div>
                  <div class="box-footer">
                <button type="reset" class="btn btn-default"><?php echo AL_CANCEL;?></button>
                <input type="submit" name="submit" value="<?php echo AL_SUBMIT;?>" class="btn btn-info pull-right"/>
              </div>
                 
              </div>
                       </form>
              </div>
                <?php
                if($mode=="edit"){
                    ?>
                
              <div class="tab-pane" id="timeline"> 
                  <form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
                  <?php
if($mode=="edit"){
$contentdetails=$helper->select("tbl_hotelcompanies","*",array($field_id=>$_REQUEST['contentid']));
 
 }
?>
                 <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Owner</label>
                  <div class="col-sm-8">
                    <input type="text" name="developerowner" value="<?php echo $contentdetails[0]['developerowner'];?>" class="form-control" id="developerowner" placeholder="Owner" >
                  </div>
                </div> 
                   <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Developer Company</label>
                  <div class="col-sm-8">
                    <input type="text" name="developercompany" value="<?php echo $contentdetails[0]['developercompany'];?>" class="form-control" id="developercompany" placeholder="Developer company" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Developer Phone</label>
                  <div class="col-sm-8">
                    <input type="text" name="developerphone" value="<?php echo $contentdetails[0]['developerphone'];?>" class="form-control" id="developerphone" placeholder="Developer Phone" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Developer Address</label>
                  <div class="col-sm-8">
                    <input type="text" name="developeraddress" value="<?php echo $contentdetails[0]['developeraddress'];?>" class="form-control" id="developercompany" placeholder="Developer Address" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">client Representative Name</label>
                  <div class="col-sm-8">
                    <input type="text" name="client_rep_name" value="<?php echo $contentdetails[0]['client_rep_name'];?>" class="form-control" id="client_rep_name" placeholder="client Representative Name" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">client Representative Phone</label>
                  <div class="col-sm-8">
                    <input type="text" name="client_rep_phone" value="<?php echo $contentdetails[0]['client_rep_phone'];?>" class="form-control" id="client_rep_phone" placeholder="client representative phone" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">client Representative Email</label>
                  <div class="col-sm-8">
                    <input type="text" name="client_rep_email" value="<?php echo $contentdetails[0]['client_rep_email'];?>" class="form-control" id="client_rep_email" placeholder="client representative email" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Visit Time</label>
                  <div class="col-sm-8">
                    <input type="text" name="client_rep_visit_time" value="<?php echo $contentdetails[0]['client_rep_visit_time'];?>" class="form-control" id="client_rep_visit_time" placeholder="Visit Time" >
                  </div>
                </div>
                 
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Consultant Company</label>
                  <div class="col-sm-8">
                    <input type="text" name="consultant_company" value="<?php echo $contentdetails[0]['consultant_company'];?>" class="form-control" id="consultant_company" placeholder="Consultant company" >
                  </div>
                </div>
                   <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Consultant Address</label>
                  <div class="col-sm-8">
                    <input type="text" name="consultant_address" value="<?php echo $contentdetails[0]['consultant_address'];?>" class="form-control" id="consultant_address" placeholder="Consultant Address" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Consultant Phone</label>
                  <div class="col-sm-8">
                    <input type="text" name="consultant_phone" value="<?php echo $contentdetails[0]['consultant_phone'];?>" class="form-control" id="consultant_phone" placeholder="Consultant Phone" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Consultant Manager Name</label>
                  <div class="col-sm-8">
                    <input type="text" name="consultant_pm_name" value="<?php echo $contentdetails[0]['consultant_pm_name'];?>" class="form-control" id="consultant_pm_name" placeholder="Consultant Manager Name" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Consultant Manager Phone</label>
                  <div class="col-sm-8">
                    <input type="text" name="consultant_pm_phone" value="<?php echo $contentdetails[0]['consultant_pm_phone'];?>" class="form-control" id="consultant_pm_phone" placeholder="Consultant Manager Phone" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Consultant Manager Email</label>
                  <div class="col-sm-8">
                    <input type="text" name="consultant_pm_email" value="<?php echo $contentdetails[0]['consultant_pm_email'];?>" class="form-control" id="consultant_pm_email" placeholder="Consultant Manager Email" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Contracting Company</label>
                  <div class="col-sm-8">
                    <input type="text" name="contracting_company" value="<?php echo $contentdetails[0]['contracting_company'];?>" class="form-control" id="contracting_company" placeholder="Contracting Company" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Contracting Address</label>
                  <div class="col-sm-8">
                    <input type="text" name="contracting_address" value="<?php echo $contentdetails[0]['contracting_address'];?>" class="form-control" id="contracting_address" placeholder="contracting Address" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Contracting Phone</label>
                  <div class="col-sm-8">
                    <input type="text" name="contracting_phone" value="<?php echo $contentdetails[0]['contracting_phone'];?>" class="form-control" id="contracting_phone" placeholder="Contracting Phone" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Contracting Manager Name</label>
                  <div class="col-sm-8">
                    <input type="text" name="contracting_pm_name" value="<?php echo $contentdetails[0]['contracting_pm_name'];?>" class="form-control" id="contracting_pm_name" placeholder="Contracting Manager Name" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Contracting Manager Phone</label>
                  <div class="col-sm-8">
                    <input type="text" name="contracting_pm_phone" value="<?php echo $contentdetails[0]['contracting_pm_phone'];?>" class="form-control" id="contracting_pm_phone" placeholder="Contracting Manager Phone" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Contracting Manager Email</label>
                  <div class="col-sm-8">
                    <input type="text" name="contracting_pm_email" value="<?php echo $contentdetails[0]['contracting_pm_email'];?>" class="form-control" id="contracting_pm_email" placeholder="Contracting Manager Email" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Interior Designing Company</label>
                  <div class="col-sm-8">
                    <input type="text" name="interior_company" value="<?php echo $contentdetails[0]['interior_company'];?>" class="form-control" id="interior_company" placeholder="Interior Designing Company" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Interior Designing Company Address</label>
                  <div class="col-sm-8">
                    <input type="text" name="interior_address" value="<?php echo $contentdetails[0]['interior_address'];?>" class="form-control" id="interior_address" placeholder="Interior Designing Company address" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Contracting Phone</label>
                  <div class="col-sm-8">
                    <input type="text" name="interior_phone" value="<?php echo $contentdetails[0]['interior_phone'];?>" class="form-control" id="interior_phone" placeholder="interior_phone" >
                  </div>
                </div>
                   <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Interior Manager Name</label>
                  <div class="col-sm-8">
                    <input type="text" name="interior_pm_name" value="<?php echo $contentdetails[0]['interior_pm_name'];?>" class="form-control" id="interior_pm_name" placeholder="interior Manager Name" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Interior Manager Phone</label>
                  <div class="col-sm-8">
                    <input type="text" name="interior_pm_phone" value="<?php echo $contentdetails[0]['interior_pm_phone'];?>" class="form-control" id="interior_pm_name" placeholder="interior Manager phone" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Operator Company</label>
                  <div class="col-sm-8">
                    <input type="text" name="operator_company" value="<?php echo $contentdetails[0]['operator_company'];?>" class="form-control" id="operator_company" placeholder="Operator Company" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Operator Address</label>
                  <div class="col-sm-8">
                    <input type="text" name="operator_address" value="<?php echo $contentdetails[0]['operator_address'];?>" class="form-control" id="operator_address" placeholder="Operator Address" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Operator Phone</label>
                  <div class="col-sm-8">
                    <input type="text" name="operator_phone" value="<?php echo $contentdetails[0]['operator_phone'];?>" class="form-control" id="interior_pm_name" placeholder="Operator Phone" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Operator Manager Name</label>
                  <div class="col-sm-8">
                    <input type="text" name="operator_pm_name" value="<?php echo $contentdetails[0]['operator_pm_name'];?>" class="form-control" id="operator_pm_name" placeholder="Operator Manager Name" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Operator Manager Phone</label>
                  <div class="col-sm-8">
                    <input type="text" name="operator_pm_phone" value="<?php echo $contentdetails[0]['operator_pm_phone'];?>" class="form-control" id="operator_pm_phone" placeholder="Operator Manager Phone" >
                  </div>
                </div>
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label">Operator Manager Email</label>
                  <div class="col-sm-8">
                    <input type="text" name="operator_pm_email" value="<?php echo $contentdetails[0]['operator_pm_email'];?>" class="form-control" id="operator_pm_email" placeholder="Operator Manager Email" >
                  </div>
                </div>
                      <div class="box-footer">
                <button type="reset" class="btn btn-default"><?php echo AL_CANCEL;?></button>
                <input type="submit" name="submit2" value="<?php echo AL_SUBMIT;?>" class="btn btn-info pull-right"/>
              </div>
              </div>
              <!-- /.box-body -->
              
              <!-- /.box-footer -->
            </form>
          </div>
                <?php
                }
                ?>
         
        </div>
        </div>
        <?php
	    }
		else {
	    ?>
         <?php
		if(isset($user_id)){
		if($mode=="delete"){
			 $message=$helper->delete($table, array($field_id=>$_REQUEST['contentid']));
		}
		 
		if($mode=="approve"){
			$helper->update($table, array("status"=>1),array($field_id=>$_REQUEST['contentid']), array());
		}
		?>
         <?php
		if($mode=="pending"){
			$helper->update($table, array("status"=>2),array($field_id=>$_REQUEST['contentid']), array());
		}
		}
		?>
         
         
        <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <i class="fa fa-building-o"></i>

              <h3 class="box-title"><?php echo $maintitle;?></h3>

              <div class="box-tools pull-right">
                <div class="btn-group">
                <div class="searchbox">
                <form action="<?php echo $page;?>" method="post"><input type="text" name="search" class="searchtext" placeholder="Search by Hotel ID/Name"/>
                <button class="btn btn-danger btn-flat searchbtn" type="submit"><i class="glyphicon  glyphicon-search"></i>&nbsp;Search</button>
                </form>
                </div>
         <a href="<?php echo $page;?>?mode=add"><button class="btn btn-danger btn-flat"><i class="glyphicon  glyphicon-plus"></i>&nbsp;<?php echo AL_ADDNEW;?> <?php echo $maintitle;?></button></a>
                   
                </div>
              </div>
            </div>
            <?php
			
			if($search!=""){
			$listtypes=$helper->selecthotelsearch($table,"*",$search,$start,$limit);
			}
			else {
			$listtypes=$helper->selectlimit($table,"*",array(),$start,$limit);	
			}
			?>
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">
            <?php
			if($message!=""){
			?>
            <button class="btn btn-block btn-danger btn-flat" type="button"><?php echo $message;?></button>
			<?php	
			}
			?>
              <table class="table table-hover">
                <tr>
                  
                  <th>Hotel ID</th>
                  <th>NAME</th>
                  <th>PHASE</th>
                   <th>OPENING DATE</th>
                  <th>STARS</th>
                  <th>ROOMS</th>
                  <th>CITY</th>
                  
                  <th><?php echo AL_STATUS;?></th>
                  <th><?php echo AL_ACTION;?></th>
                   
                </tr>
                <?php
				$i=($start*$limit)+1;
				foreach($listtypes as $type){
				?>
                 <?php
				  if($_REQUEST['start']>0){
					  $limitpage=$_REQUEST['start'];
				  }
				  else {
					  $limitpage=1;
				  }
				 
                   //$valexist=$helper->datapresent("tbl_branch","clientid",$type[$field_id]);
				  ?>
                <tr>
                   
                  <td><?php echo $type['id'];?></td>
                  <td><?php echo $type['hotelname'];?></td>
                  <td>
				  <?php 
                  $hphase=$helper->select("tbl_phase","title",array("phaseid"=>$type['projectphase']));
				  echo $hphase[0]['title'];
				  ?>
				  </td>
                  
                  <td><?php echo $type['openingdate'];?></td>
                   <td>
                  <?php echo $type['stars'];?>
                  </td>
                  <td><?php echo $type['rooms'];?></td>
                  <td><?php echo $type['city'];?></td>
                  
                  
                  <td>
                  
                  <?php
				  if($type['status']==1){
				  ?>
<a href="<?php echo $admin_url;?><?php echo $page;?>?mode=pending&contentid=<?php echo $type[$field_id];?>&start=<?php echo $limitpage;?>"><span class="label label-success"><?php echo AL_APPROVED;?></span></a>
                  <?php
				  }
				  else {
				  ?>
				  <a href="<?php echo $admin_url;?><?php echo $page;?>?mode=approve&contentid=<?php echo $type[$field_id];?>&start=<?php echo $limitpage; ?>"><span class="label label-danger"><?php echo AL_PENDING;?></span></a>
                  <?php
				  }
				  ?>
                  </td>
                   <td><a href="<?php echo $admin_url;?><?php echo $page;?>?mode=edit&contentid=<?php echo $type[$field_id];?>&start=<?php echo $limitpage;?>"><span class="label label-primary"><i class="fa fa-edit"></i> <?php echo AL_EDIT;?></span></a>
                    <?php
				  if($valexist==0){
				  ?>
                   <a href="<?php echo $admin_url;?><?php echo $page;?>?mode=delete&contentid=<?php echo $type[$field_id];?>&start=<?php echo $limitpage;?>" onclick="return getConfirmation()"><span class="label label-danger"><i class="fa fa-times"></i> <?php echo AL_DELETE;?></span></a>
                   <?php
				  }
				  ?>
                   </td>
                   
                </tr>
                 
                <?php
				$i=$i+1;
				}
				?>
                
                
              </table>
              <?php
			    if($search!=""){
			         $counter_list= $helper->countofhotelsearch($table,$search,$limit);
				}
				else {
					 $counter_list= $helper->countofdata($table,array(),$limit,array("status"=>1));
				}
			  include('pagination/pagination.php');
			  ?>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
      </div>
      <?php
		}
		?>

    </section>
    <!-- /.content -->
  </div>
<?php include('footer.php');  ?>