<?php

// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);

if($_REQUEST['webtype']==1){

  $currentuser=get_current_user_id();
  $webTourType= $_REQUEST['webtype'];
  $webtourid=$_REQUEST['tourid'];
  $servername = "localhost";
  $username = "adventure_db";
  $password = "AnjYWAYPkEXhBBsx";
  $dbname = "adventure_db";
  $conn = new mysqli($servername, $username, $password, $dbname);
  $scraperQuery=$conn->query("select * from webscraptours where id='$webtourid'");
  $ftScrapperData=$scraperQuery ? $scraperQuery->fetch_assoc() : []; // Safe fetch
  $webTourName = $conn->real_escape_string($ftScrapperData['tourName']);
  $webTourSlug=strtolower(create_slug($webTourName));
  $webTourDescription = $conn->real_escape_string($ftScrapperData['description']);
  $getduration = $ftScrapperData['duration'];
  $webTourDuration = filter_var($getduration, FILTER_SANITIZE_NUMBER_INT);
  $webTourPrice = $ftScrapperData['price'];
 
  $webTourTermid = $ftScrapperData['termid'];
  $langArray = json_decode($ftScrapperData['languages'], true);
  $webTourLanguages = implode(", ", $langArray);
    // Get term_ids for languages from wpwr_terms
  $languageIds = [];
  if (!empty($langArray)) {
    foreach ($langArray as $lang) {
      $lang = trim($lang);
      if (!empty($lang)) {
        $langQuery = $conn->query("SELECT wpwr_terms.term_id, wpwr_terms.name FROM wpwr_terms, wpwr_term_taxonomy WHERE wpwr_term_taxonomy.taxonomy='guidelanguage' AND wpwr_terms.term_id = wpwr_term_taxonomy.term_id AND wpwr_terms.name = '$lang'");
       // echo "SELECT wpwr_terms.term_id, wpwr_terms.name FROM wpwr_terms, wpwr_term_taxonomy WHERE wpwr_term_taxonomy.taxonomy='guidelanguage' AND wpwr_terms.term_id = wpwr_term_taxonomy.term_id AND wpwr_terms.name = '$lang'";
      
        $langResult = $langQuery ? $langQuery->fetch_assoc() : null;
        if ($langResult && !empty($langResult['term_id'])) {
          $languageIds[] = $langResult['term_id'];
        }
      }
    }
  }
  $languageIdsString = implode(',', $languageIds);
  $highLightArray = json_decode($ftScrapperData['highlights'], true);
  $webTourHighlights = $conn->real_escape_string(implode(", ", $highLightArray));
  $webTourtravelStyle = $conn->real_escape_string($ftScrapperData['travelStyle']);
  $webTourAge = $ftScrapperData['age'];
  $webTourInclude = $ftScrapperData['include'];

  $webTourIncludeDecoded = json_decode($webTourInclude, true);
  $webTourIncludeText = $conn->real_escape_string(implode(", ", $webTourIncludeDecoded));
  $webTourExclude = $ftScrapperData['exclude'];

  $webTourExcludeDecoded = json_decode($webTourExclude, true);
  $webTourExcludeText = $conn->real_escape_string(implode(", ", $webTourExcludeDecoded));

  $webTourOperatorId = $ftScrapperData['oid'];
  $webUnformatedData = json_decode($ftScrapperData['itinerary'], true);

$newArray = [];

foreach ($webUnformatedData as $item) {
    // Split by first colon (:)
    $parts = explode(":", $item, 2);

    $title = trim($parts[0]); // Day 1
    $description = isset($parts[1]) ? trim($parts[1]) : '';

    $newArray[] = [
        "gettitle" => $title,
        "description" => $description
    ];
}

// Convert back to JSON
$webItineraryData = json_encode($newArray, JSON_UNESCAPED_UNICODE);

$locationQuery = $conn->query("SELECT 
    t.term_id,
    t.name,
    tm_long.meta_value AS longitude,
    tm_lat.meta_value AS latitude
FROM wpwr_terms t
INNER JOIN wpwr_term_taxonomy tt 
    ON t.term_id = tt.term_id
INNER JOIN wpwr_termmeta tm_long 
    ON t.term_id = tm_long.term_id 
    AND tm_long.meta_key = 'longitude'
INNER JOIN wpwr_termmeta tm_lat 
    ON t.term_id = tm_lat.term_id 
    AND tm_lat.meta_key = 'latitude'
WHERE tt.taxonomy = 'travel_locations'
AND t.term_id = '$webTourTermid'");


$locationData = [];
if ($locationQuery) {
    $locationResult = $locationQuery->fetch_assoc();
    if ($locationResult) {
        $locationData[] = [
            "location" => $locationResult['name'],
            "lat" => $locationResult['latitude'],
            "lng" => $locationResult['longitude']
        ];
    }
}
$locationJson = json_encode($locationData);

$contentupt = str_replace('→', '-', $webTourDescription);
  $checkdata=$conn->query("select * from tours order by tid DESC LIMIT 0, 1");
  $fetchTid=$checkdata ? $checkdata->fetch_assoc() : []; // Safe fetch
  $unid=(isset($fetchTid['tid']) ? $fetchTid['tid'] : 0) + 1; // Safe access and default
  $sql = "INSERT INTO tours (tid,tourname,tourslug,duration,travelstyle,content,highlights,guide_language,oid,tourtype) 
          VALUES ('$unid','$webTourName','$webTourSlug','$webTourDuration','$webTourtravelStyle','$contentupt','$webTourHighlights','$languageIdsString','$webTourOperatorId','$webTourType')";
   $conn->query($sql);
   $sqladdons = "INSERT INTO touraddons (oid,tid,roomtypes,transfertypes,optionaltypes,goodtoknow,faqs)  VALUES ('$webTourOperatorId', '$unid','','', '','','')";
   $conn->query($sqladdons);       
   $conn->query("INSERT INTO tours_price_data (oid,tid,seats,multiprice,tourprice) VALUES ('$webTourOperatorId','$unid','5','1','$webTourPrice')");
   $conn->query("INSERT INTO tour_itinerary (oid,tid,itineraryData) VALUES ('$webTourOperatorId','$unid','$webItineraryData')");
   $conn->query("INSERT INTO tours_include (oid,tid,otherinc,othernotinc) VALUES ('$webTourOperatorId','$unid','$webTourIncludeText','$webTourExcludeText')");
   $conn->query("INSERT INTO tour_itinerary_maps (oid,tid,mapdata) VALUES ('$webTourOperatorId','$unid','$locationJson')");
   $websqlupdate = $conn->query("UPDATE webscraptours  SET 
              tranfertour='1'
              WHERE id='$webtourid'");
?>
   <script>
          window.location.href = "https://dashboard.adventurerepubliq.com/operator-tour-dashboard/?tourid=<?php echo $unid;?>&thistrtype=<?php echo $webTourType;?>";
  </script>
<?php

}


if(isset($trtype)){ // Check if $trtype is set before using it

$currentuser=get_current_user_id();
$servername = "localhost";
$username = "adventure_db";
$password = "AnjYWAYPkEXhBBsx";
$dbname = "adventure_db";
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

  if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
  } 
      
       $checkdata=$conn->query("select * from tours order by tid DESC LIMIT 0, 1");
       $row_data_count = $checkdata ? $checkdata->num_rows : 0; // Safe access to num_rows
       if($row_data_count==0){
          $unid=2000;
         ?>
         <script>
             window.location.href = "https://dashboard.adventurerepubliq.com/operator-tour-dashboard/?tourid=<?php echo $unid;?>&thistrtype=<?php echo $trtype;?>";
         </script>
         <?php
      }
      else  {
          $fetchTid=$checkdata ? $checkdata->fetch_assoc() : []; // Safe fetch
          $unid=(isset($fetchTid['tid']) ? $fetchTid['tid'] : 0) + 1; // Safe access and default
      }
      
       $sql = "INSERT INTO tours (tid,oid,tourtype) VALUES ('$unid', '$currentuser','$trtype')";
       $conn->query($sql);
       $oid=get_current_user_id();   
       $sqladdons = "INSERT INTO touraddons (oid,tid,roomtypes,transfertypes,optionaltypes,goodtoknow,faqs)  VALUES ('$oid', '$unid','','', '','','')";
       $conn->query($sqladdons); 
       $oid=get_current_user_id();        
       $conn->query("INSERT INTO tours_price_data (oid,tid) VALUES ('$oid','$unid')");

       ?>
            <script>
          window.location.href = "https://dashboard.adventurerepubliq.com/operator-tour-dashboard/?tourid=<?php echo $unid;?>&thistrtype=<?php echo $trtype;?>";
        </script>
 <?php 
}
if(($_REQUEST['Action'] ?? '')=='Details'){ // Safe access for $_REQUEST['Action']

      $tid=$conn -> real_escape_string($_REQUEST['tid'] ?? ''); // Safe access
      $trtype=$conn -> real_escape_string($_REQUEST['thistrtype'] ?? ''); // Safe access
      $oid=$conn -> real_escape_string($_REQUEST['oid'] ?? ''); // Safe access
      $tourname=$conn -> real_escape_string($_REQUEST['tourname'] ?? ''); // Safe access
      $duration=$conn -> real_escape_string($_REQUEST['duration'] ?? ''); // Safe access
      $travelstyle=$conn -> real_escape_string($_REQUEST['travelstyle'] ?? ''); // Safe access
      $guidetype=$conn -> real_escape_string($_REQUEST['guidetype'] ?? ''); // Safe access
      $guidelang=$conn -> real_escape_string($_REQUEST['guidelang'] ?? ''); // Safe access
      $tourvibe=$conn -> real_escape_string($_REQUEST['tourvibe'] ?? ''); // Safe access
      $content=$_REQUEST['content'] ?? ''; // Safe access
      $lastpostId=$_REQUEST['lastpostId'] ?? ''; // Safe access
      $highlights=$_REQUEST['highlights'] ?? ''; // Safe access
      $customtype=$_REQUEST['customtype'] ?? ''; // Safe access
      $adults=$_REQUEST['adults'] ?? ''; // Safe access
      $kids=$_REQUEST['kids'] ?? ''; // Safe access
      $grtype=$_REQUEST['grtype'] ?? ''; // Safe access
      
      $tabstatus=$conn -> real_escape_string($_REQUEST['tabstatus'] ?? ''); // Safe access
      $jsonTourdata =  '{"guidetype":"'.$guidetype.'", 
                        "guidelang":"'.$guidelang.'",
                        "tourvibe":"'.$tourvibe.'"}';
                     
       $getData=$conn->query("select * from tours  WHERE oid='$oid' AND tid='$tid'");
       $fetchmeta=$getData ? $getData->fetch_assoc() : []; // Safe fetch

       /* Add Json tour activity */

       $oldactivity = $fetchmeta['touractivty'] ?? ''; // Safe access
       $newactivity = array();
       $activity = $_REQUEST['activity'] ?? []; // Safe access and ensure array
       $count = count($activity);
       for ($i = 0; $i < $count; $i++ ) {
          if ( ($activity[$i] ?? '') != '' ) : // Safe access
          $newactivity[$i]['activity'] = stripslashes($activity[$i]);
          endif;
       }
        $converjson=json_encode($newactivity);  
       if($oldactivity!=$converjson){
           $addjsondata=$converjson;
       }
       else{
            $addjsondata=$oldactivity;
       }

       /* Add Recommended Tour Data In Json */

       $oldrecommended = $fetchmeta['recommended'] ?? ''; // Safe access
       $newrecommended = array();
       $recommended = $_REQUEST['recommended'] ?? []; // Safe access and ensure array
       
       $count = count($recommended);
      for ($i = 0; $i < $count; $i++ ) {
          if ( ($recommended[$i] ?? '') != '' ) : // Safe access
          $newrecommended[$i]['recommended'] = stripslashes($recommended[$i]);
          endif;
       }
        $convertrecmd=json_encode($newrecommended);  
       if($oldrecommended!=$convertrecmd){
           $addjsonrecomm=$convertrecmd;
       }
       else{
            $addjsonrecomm=$oldrecommended;
       }
  
       $tourslug=strtolower(create_slug($tourname));

       $newslug=mb_strtolower($tourslug."-".$tid);

       if($user_id==770) {
   $sql = "UPDATE tours  SET 
              tourname='$tourname',
              tourslug='$newslug', 
              duration='$duration',
              touractivty='$addjsondata',
              travelstyle='$travelstyle',
              tourdetialsmeta='$jsonTourdata',
              recommended='$addjsonrecomm',
              content='$content',
              highlights='$highlights',
              customtype='$customtype',
              tabstatus='$tabstatus',  
              adults='$adults',
              kids='$kids',
              grtype='$grtype' 
              WHERE oid='$oid' AND tid='$tid'";
       }
       else {
              
              
             $sql = "UPDATE tours  SET 
              tourname='$tourname',
              tourslug='$newslug', 
              duration='$duration',
              touractivty='$addjsondata',
              travelstyle='$travelstyle',
              tourdetialsmeta='$jsonTourdata',
              recommended='$addjsonrecomm',
              content='$content',
              highlights='$highlights',
              customtype='$customtype',
              tabstatus='$tabstatus',  
              adults='$adults',
              kids='$kids',
              grtype='$grtype' 
              WHERE oid='$oid' AND tid='$tid'";
       }
          
           $conn->query($sql);
           $gevalue=$conn->query("select * from tour_itinerary_maps  WHERE tid='$tid'");
           $fetchItinery=$gevalue ? $gevalue->fetch_assoc() : []; // Safe fetch
           $checkduration=count(json_decode($fetchItinery['itineraryData'] ?? '') ?? []); // Safe decode and default to array
   
        ?>
         <script>
     window.location.href = "https://dashboard.adventurerepubliq.com/operator-tour-dashboard/?tourid=<?php echo $tid;?>&thistrtype=<?php echo $trtype;?>";
         </script>
       
        <?php
        
        
        }
$tourData_tourdetialsmeta = $tourData['tourdetialsmeta'] ?? ''; // Safe access
$data = json_decode($tourData_tourdetialsmeta);
$tourData_guide_language = $tourData['guide_language'] ?? ''; // Safe access
$seleted_language=explode(",",$tourData_guide_language);
 if(($trtype ?? '')==1 || ($_REQUEST['thistrtype'] ?? '')==1){ // Safe access
?>
<style>
    .bgt-hover:hover {
      padding-top: 44px !important
    }
.bgt-block:hover .bgt-hover{
    padding: 0 10px;
    position: absolute;
    top: 0px;
    height: 100%;
}
</style>
<?php  }


// $imagePath = "https://www.adventurerepubliq.com/wp-content/uploads/2020/01/13221288_10154044627302254_3275606631357736751_o-2.jpg";
// $newPath = "/test/Uploads/";
// $ext = '.jpg';
// $newName  = $newPath."a".$ext;

// $copied = copy($imagePath , $newName);

// if ((!$copied)) 
// {
//     echo "Error : Not Copied";
// }
// else
// { 
//     echo "Copied Successful";
// }
$reqID=$_REQUEST['tourid'] ?? ''; // Safe access

?>

<div class="container">
  <div class="row" >
  <div class="col-sm-12 formbg">
    <form id="updateTouraa" method="post" action="<?php the_permalink();?>?tourid=<?php echo $_REQUEST['tourid'] ?? '';?>&thistrtype=<?php echo $_REQUEST['thistrtype'] ?? '';?>" data-trtype="<?php echo  $_REQUEST['thistrtype'] ?? '';?>" data-tourid="<?php echo  $_REQUEST['tourid'] ?? '';?>">
      <div id="response" class="response"></div>
       <div class="form-group">
           <label for="name">Tour Name
              <span class="mandtory">Required</span>
           </label>
          <input type="text" autocomplete= "off" data-val="<?php echo stripslashes($tourData['tourname'] ?? '');?>" required name="tourname" id="changetrname" class="form-control required" placeholder="Tour Name" value="<?php echo stripslashes($tourData['tourname'] ?? '');?>">
       </div>
        <?php
        if(($tourData['tourtype'] ?? '')==1 || ($_REQUEST['thistrtype'] ?? '')==1): // Safe access?>
           <div class="form-group">
               <label for="name">Duration   <span class="mandtory">Required</span></label><br>
               <input type="number" required name="duration"  data-valdr="<?php echo stripslashes($tourData['duration'] ?? '');?>"  autocomplete="off" class="form-control drct required" placeholder="Duration" min="1"  value="<?php echo $tourData['duration'] ?? '';?>" style="width: 200px !important;">
               <span class="drys">DAYS</span>
           </div>
       <?php else:?>
           <div class="form-group">
                <label for="name">Duration   <span class="mandtory">Required</span></label><br>
                <input type="text" id="getduration" required  data-valdr="<?php echo stripslashes($tourData['duration'] ?? '');?>" name="duration" value="<?php echo $tourData['duration'] ?? '';?>" required="required" class="getduration form-control drct required" data-time-format="H:i" data-step="15" data-min-time="00:15" data-max-time="24:00" data-show-2400="true" autocomplete="off" style="width: 200px !important;">
              <span class="drys">Hrs/Mins</span>
           </div>
       <?php endif;?>
           <div class="form-group touract">
         
                 <div class="multichecks">
                   <label for="name">Select Included Tour Activities  <span class="mandtory">Required</span></label>
                      <div class="rmborder">
                       <span class="sperror" style="display:none">Please Select at least one</span>
                       <?php echo get_multidays_terms_chekboxes('tourkind', $args = array('hide_empty'=>false), $tourData['touractivty'] ?? '', $reqID);?>
                      </div>
                    </div>
            
             </div>
        <div class="form-group">
           <label for="name">Travel Style   <span class="mandtory">Required</span>
             
           </label>
          <div class="row style rdstyle">
              <div class="col-sm-4 hoverblock">
                 <input type="radio" class="required" required value="Luxury" id="luxury" name="travelstyle" <?php if(($tourData['travelstyle'] ?? '')=='Luxury'):?> checked <?php endif;?>>
                  <div class="bgt-block" <?php if(($tourData['travelstyle'] ?? '')=='Luxury'):?>  id="activestyle" <?php endif;?> >
                    <img src="/wp-content/uploads/2019/03/luxury.jpg">
                     <div class="bgt-hover">
                      <h3>Luxury</h3>
                        <p>
                      Provide your customers with high-quality tour experiences that will be forever cherished. The highest level of comfort and service. All accommodations in four or five-star hotels, resorts, camps, boutique lodges or high-end homestays. at the most affordable prices.      
                       </p>
                   </div>
                  </div>
              </div>
               <div class="col-sm-4 hoverblock"> 
                 <input type="radio" value="Premium"  required class="required" id="premium" name="travelstyle" <?php if(($tourData['travelstyle'] ?? '')=='Premium'):?> checked <?php endif;?>>
                  <div class="bgt-block" <?php if(($tourData['travelstyle'] ?? '')=='Premium'):?>  id="activestyle" <?php endif;?>>
                    <img src="https://dashboard.adventurerepubliq.com/wp-content/uploads/2019/03/permium-1.jpg">
                     <div class="bgt-hover">
                       <h3>Premium</h3>
                       <p>
                   Provide your customers with a perfect combination of luxury and budget tours at the best prices available. with accommodations ranging from comfortable lodges, camps, guesthouses, and homestays,  3 to 4-star western hotel equivalents.     
                       </p>
                   </div>
                  </div>
               </div>
                <div class="col-sm-4 hoverblock">
                 <input type="radio" value="Budget"  required id="budget" class="required" name="travelstyle" <?php if(($tourData['travelstyle'] ?? '')=='Budget'):?> checked <?php endif;?>>
                  <div class="bgt-block" <?php if(($tourData['travelstyle'] ?? '')=='Budget'):?> id="activestyle" <?php endif;?>>
                    <img src="/wp-content/uploads/2019/03/budget-trips.jpg">
                     <div class="bgt-hover">
                       <h3>Budget</h3>
                        <p>
                     Help millions of people travel more by providing the best budget tours with the best standard of comfort and service, including no-frills accommodations, but clean and comfortable, 1 to 3-star hotels or guesthouses, camps.Surprise your customers by providing services of permium and luxury standard in budget prices!!!      
                       </p>
                   </div>
                </div>
              </div>
              
          </div>
        </div>
   
       <div class="form-group">
            <div class="row">
                  <div class="col-sm-4">
                    <?php if (isset($data) && is_object($data) && isset($data->guidetype) ): // Safe access?>
                          <label for="name"> Guiding Type <?php echo htmlspecialchars($data->guidetype); ?></label>
                      <?php else: ?>
                          <label for="name"> Guiding Type</label>
                      <?php endif; ?>
                      <?php
                      $guidetype = (isset($data) && is_object($data) && isset($data->guidetype)) ? $data->guidetype : '';
                      ?>
                          <select name="guidetype" required class="form-control formbox">
                              <option value="" <?php if ($guidetype == '') echo 'selected="selected"'; ?>>Select One</option>
                              <option value="Live Guide/Instructor" <?php if ($guidetype == "Live Guide/Instructor") echo 'selected="selected"'; ?>>Live Guide/Instructor</option>
                              <option value="Partially Guided" <?php if ($guidetype == "Partially Guided") echo 'selected="selected"'; ?>>Partially Guided</option>
                              <option value="Self Guided/Independent" <?php if ($guidetype == "Self Guided/Independent") echo 'selected="selected"'; ?>>Self Guided/Independent</option>
                              <option value="Self Drive" <?php if ($guidetype == "Self Drive") echo 'selected="selected"'; ?>>Self Drive</option>
                          </select>
                     </div>
            <div class="col-sm-7">
                         <div class="e1dedb6f0 css-1k5xo9g e1uvdqdt0"></div>
                                 <div class="css-14bghfh e1u829440">
                                 <div class="css-1rskh6o e1u829441"></div>
                                 <div class="css-omv1s3 eubkn3g0">Does This tour Includes Guide or is it self-guided?</div>
                          </div>
                    </div>
               </div>
            </div>         
     
        
        <div class="form-group">
            <div class="row">
             <div class="col-sm-4">
                   <label for="name">Guide Language
                    
                   </label>
                   <div class="reloadvalue rmrsd"> 
                    <?php
                          $guidelanguage = $tourData['guide_language'] ?? ''; // Safe access
                          $seleted_language = explode(",", $guidelanguage); // Safe explode
                          get_guidelanguage_chekboxes('guidelanguage', ['hide_empty' => false], $guidelanguage, $tourid, $seleted_language, $check = 1);
                          selected_language('guidelanguage', ['hide_empty' => false], $seleted_language, $tourid, $check = 1);
                          ?>
                </div>
              </div>
            <div class="col-sm-7">
                         <div class="e1dedb6f0 css-1k5xo9g e1uvdqdt0"></div>
                                 <div class="css-14bghfh e1u829440">
                                 <div class="css-1rskh6o e1u829441"></div>
                                 <div class="css-omv1s3 eubkn3g0">Enter the languages spoken by your tour guide/leaders, crew, and team.</div>
                          </div>
                    </div>
               </div>
               </div>

         <?php
        if(($trtype ?? '')==2): // Safe access?>
           <div class="form-group">
            <div class="row">
                 <div class="col-sm-4">
               <label for="name">Tour Type <span class="mandtory">Required</span> </label>
                 <select name="guidetype" required class="form-control formbox required">
                  <option selected="selected" value=""> Select One</option>
                    <option  value="Group" >Group</option> 
                    <option  value="Private">Private</option> 
                    <option  value="Independent">Independent</option> 
                 </select>
           </div>
       <?php endif;?>
       <div class="form-group">
            <div class="row">
             <div class="col-sm-4">
             <label for="name"> Tour Vibe
                  <span class="mandtory">Required</span> </label>
                  <?php
              $tourvibe = (isset($data) && is_object($data) && isset($data->tourvibe)) ? $data->tourvibe : '';
              ?>

              <select name="tourvibe" required class="form-control formbox required">
                  <option value="" <?php if ($tourvibe == '') echo 'selected="selected"'; ?>>Select One</option>
                  <option value="Laid Back" <?php if ($tourvibe == "Laid Back") echo 'selected="selected"'; ?>>Laid Back</option>
                  <option value="Active" <?php if ($tourvibe == "Active") echo 'selected="selected"'; ?>>Active</option>
                  <option value="Testing Limits" <?php if ($tourvibe == "Testing Limits") echo 'selected="selected"'; ?>>Testing Limits</option>
                  <option value="Party Mode" <?php if ($tourvibe == "Party Mode") echo 'selected="selected"'; ?>>Party Mode</option>
              </select>
          
          </div>
            <div class="col-sm-7">
                         <div class="e1dedb6f0 css-1k5xo9g e1uvdqdt0"></div>
                                 <div class="css-14bghfh e1u829440">
                                 <div class="css-1rskh6o e1u829441"></div>
                                 <div class="css-omv1s3 eubkn3g0">Select the enjoyment and experience level of the tour</div>
                          </div>
                    </div>
               </div>
               </div>
      <div class="form-group rcmtouract">
             <label for="name"> Recommended For
                  <span class="mandtory">Required</span> 
               </label>
          <div class="rmborder">
                <span class="essperror" id="essperror" style="display:none">Please Select at least one</span>
                 <?php echo get_recommended_chekboxes('recommended', $args = array('hide_empty'=>false), $tourData['recommended'] ?? '');   ?>
             </div>
       </div>
      <div class="form-group checklist">
           <div class="row">
             <div class="col-sm-9 contentop">
                   <label for="name">Tour Introduction
                          <span class="mandtory">Required</span> </label>
                  
           <textarea name="content"  id="content" class="form-control required" ><?php echo stripslashes($tourData['content'] ?? '');?></textarea>
       </div>
            <div class="col-sm-3">
                         <div class="e1dedb6f0 css-1k5xo9g e1uvdqdt0"></div>
                                 <div class="css-14bghfh e1u829440">
                                 <div class="css-1rskh6o e1u829441"></div>
                                 <div class="css-omv1s3 eubkn3g0">Write a Brief Description of the Tour</div>
                          </div>
                    </div>
               </div>
               </div>

      <div class="form-group checklist2 ">
            <div class="row">
             <div class="col-sm-9 covid trhighlights">
               <label for="name">Tour Highlights
                     <span class="mandtory">Required</span> </label>
               
                <textarea name="highlights"  id="trhighlights"  class="form-control required" ><?php echo stripslashes($tourData['highlights'] ?? '');?></textarea>
           </div>
            <div class="col-sm-3">
                         <div class="e1dedb6f0 css-1k5xo9g e1uvdqdt0"></div>
                                 <div class="css-14bghfh e1u829440">
                                 <div class="css-1rskh6o e1u829441"></div>
                                 <div class="css-omv1s3 eubkn3g0">Tell us about tour Highlights</div>
                          </div>
                    </div>
                 </div>
             
            <input type="hidden" name="lastpostId"  value="<?php echo $tourData['lastpostId'] ?? '';?>">
              
       </div>

       <?php
      
             if(($user_id ?? '')==770): // Safe access?>
                 <div class="form-group checklist2">
                   <label for="name">Customize Tour Type</label>
                   <select name="customtype"  class="form-control formbox">
                          <option selected="selected" value=""> Select One</option>
                          <option  value="0" <?php if(($tourData['customtype'] ?? '')==0):?> selected="selected" <?php endif;?>>No</option> 
                          <option  value="1" <?php if(($tourData['customtype'] ?? '')==1):?> selected="selected" <?php endif;?>>Yes</option> 
                      </select>
                    </div>
                     <div class="form-group"><label for="name">No of  Adults</label>
                      <input type="text" autocomplete= "off" class="form-control " name="adults" value="<?php echo stripslashes($tourData['adults'] ?? '');?>">
                   </div>
                   <div class="form-group"><label for="name">No of  Kids</label>
                     <input type="text" autocomplete= "off" class="form-control " name="kids" value="<?php echo stripslashes($tourData['kids'] ?? '');?>">
                  </div>
                    <div class="form-group">
                         <label for="name">Pricing Types</label>
                          <select name="grtype"  class="form-control formbox">
                          <option selected="selected" value="800"> Select One</option>
                          <option  value="1" <?php if(($tourData['grtype'] ?? '')==1):?> selected="selected" <?php endif;?>>Per Person</option> 
                          <option  value="2" <?php if(($tourData['grtype'] ?? '')==2):?> selected="selected" <?php endif;?>>Group</option> 
                      </select>
                    </div>
  
        <?php else:?>
         <input type="hidden" name="customtype" value="0">
          <input type="hidden" name="adults" value='0'>
           <input type="hidden" name="kids" value="0">
            <input type="hidden" name="grtype" value="0">
         <?php endif;?>  
            <input type="hidden"  id="savedata">
            <input type="hidden" name="oid" value="<?php echo get_current_user_id();?>">
            <input type="hidden" name="tid" value="<?php echo $_REQUEST['tourid'] ?? '';?>">
             <input type="hidden" name="tabstatus" value="<?php echo $tourData['tabstatus'] ?? '';?>">
            <input type="hidden" name="thistrtype" value="<?php echo $_REQUEST['thistrtype'] ?? '';?>">
            <input type="hidden" name="Action" value="Details">
         
            <button type="submit" class="btn btn-primary details">Save</button>
     
</form>
</div>
</div>
</div>
<?php
    function create_slug($string){
           $slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $string);
           return $slug;
       } 
?>
<script>
    
     $(function() {
            $('.selectit input').attr('name', 'tax_input[]');
});
</script>
