<?php
include_once("../include/main.inc.php");
check_session('MyCpanel', 'index.php');

@extract($_REQUEST);
if (empty($catID)) {
  $heading = "Add New Category";
} else {
  $heading = "Edit Category";
}
$res = getResult("admin_details", " where user_type='admin'");

$record_type = "New Category";
$script_name = "addeditcategory.php";
$redirect_script_name = "manage-category.php";
$table_name = "category_tbl";
#################### Add Record ##################
if ($id == 'remove_image') {
  mysqli_query($dbconn, "UPDATE $table_name SET $field='' where catID = '$catID'");
  // $_SESSION['session_message'] = $record_type . ' has been updated successfully';
  header("Location: " . SITE_ADMIN_URL . "/" . $script_name);
  exit;
}

if ($action == "add_record" && $catname != "") {
  $numCnt = getCount($table_name, " where catName='$catname' and parentID='$parentID' and catID!='$catID' and catgType='$catgType' ");
  if ($numCnt > 0) {
    $_SESSION['session_message'] = '<div class="btn btn-warning">' . $record_type . ' already exist  </div>';
  } else {
    if ($_FILES['image']['name'] != " ") {
      $file_extension = strtolower(getExtension($_FILES['image']['name']));
      if ($_FILES['image']['name'] != "") {
        $cat = str_replace(" ", "-", $catname);
        $img_name = $cat;
        $img = upload_file($img_name, "image", "uploaded-files/category/images");
      }
    }
    if ($_FILES['catIcon']['name'] != " ") {
      $file_extension = strtolower(getExtension($_FILES['catIcon']['name']));
      if ($_FILES['catIcon']['name'] != "") {
        $cat1 = str_replace(" ", "-", $catname);
        $img_name1 = $cat1;
        $img1 = upload_file($img_name1, "catIcon", "uploaded-files/category/caticon");

        $width = "242";
        $height = "242";

        $source_folder = SITE_DIR_PATH . "/uploaded-files/category/caticon";
        $destination_folder = SITE_DIR_PATH . "/uploaded-files/category/caticon/thumbs/";
        saveResizedPhoto($img1, $width, $height, $source_folder, $destination_folder);
      }
    }


    if ($_FILES['header_icon_image']['name'] != " ") {
      $file_extension = strtolower(getExtension($_FILES['header_icon_image']['name']));
      if ($_FILES['header_icon_image']['name'] != "") {
        $cat1 = str_replace(" ", "-", $catname);
        $img_name1 = $cat1 . uniqid();
        $img1 = upload_file($img_name1, "header_icon_image", "uploaded-files/category/caticon");

        $width = "50";
        $height = "50";

        $source_folder = SITE_DIR_PATH . "/uploaded-files/category/caticon";
        $destination_folder = SITE_DIR_PATH . "/uploaded-files/category/caticon/thumbs/";
        saveResizedPhoto($img1, $width, $height, $source_folder, $destination_folder);
      }
    }


    if ($_FILES['cat_home_image']['name'] != " ") {
      $file_extension = strtolower(getExtension($_FILES['cat_home_image']['name']));
      if ($_FILES['cat_home_image']['name'] != "") {
        $cat1 = str_replace(" ", "-", $catname);
        $img_name1 = $cat1 . uniqid();
        $img2 = upload_file($img_name1, "catIcon", "uploaded-files/category/images");

        //Thumb Cut
        $width = "242";
        $height = "242";

        $source_folder = SITE_DIR_PATH . "/uploaded-files/category/images";
        $destination_folder = SITE_DIR_PATH . "/uploaded-files/category/images/thumbs/";
        saveResizedPhoto($img2, $width, $height, $source_folder, $destination_folder);
      }
    }

    $maxRes = mysqli_fetch_array(mysqli_query($dbconn, "select max(catOrder) from `$table_name` where parentID='$parentID'"));
    $catOrder = $maxRes[0] + 1;
    // $catgurl = getValidFileName($catname);
    // $catalogname = $_FILES['catalog']['name'];
    // $cimg = upload_file($catalogname, "catalog", "uploaded_files/catalog_images");
    // echo $sql_insert = "insert into `$table_name` set parentID='$parentID',catName='".$catname."',displayName='".$catDname."',catgurl='$catgurl',catDesc='".$shortdesc."',catDesc1='".$fulldesc."',catImage='".$img."',catOrder='$catOrder',pageTitle='".$metatitle."',pageKeywords='".$metakeyword."',pageDescription='".$metadesc."', gst='$gst',mca='$mca',epf='$epf',iec='$iec',ptr='$ptr',eticket='$eticket',cp='$cp',cbe='$cbe',etp='$etp',vb='$vb',dgft='$dgft',iet='$iet'";
    // die();
    $sql = mysqli_query($GLOBALS['dbconn'], "insert into `$table_name` set parentID='$parentID',catName='" . $catname . "',catUrl='" . $catUrl . "',displayName='" . $catDname . "',catDesc='" . $shortdesc . "',catDesc1='" . $fulldesc . "',catImage='" . $img . "',cat_home_image='$img2',catOrder='$catOrder',catIcon='$img1',heading1='" . $heading1 . "',heading2='" . $heading2 . "',heading3='" . $heading3 . "',pageTitle='" . $metatitle . "',pageKeywords='" . $metakeyword . "',pageDescription='" . $metadesc . "',alt='" . $alt . "',title='" . $title . "',is_redirect='" . $is_redirect . "',redirect_link='" . $redirect_link . "',header_icon_image='" . $header_icon_image . "'");

    header("Location: " . SITE_ADMIN_URL . "/" . $redirect_script_name . "?start=" . $start . "&parentID=" . $parentID . "&catID=" . $catID . "&pagesize=" . $pagesize);
    exit;
  }
}
################ Update Record ##################

if ($action == "update_record" && $catname != "") {

  if ($catUrl != $catOldUrl) {
    $catOldUrlUp = $catOldUrl;
  } else {
    $catOldUrlUp = $catOldUrlCheck;
  }

  $numCnt = getCount($table_name, " where catName='$catname' and parentID='$parentID' and catID!='$catID' and catgType='$catgType'");
  if ($numCnt > 0) {
    $_SESSION['session_message'] = '<div class="btn btn-warning">' . $record_type . ' already exist  </div>';
    header("Location: " . SITE_ADMIN_URL . "/" . $script_name);
    exit;
  }

  if ($_FILES['image']['name'] != "") {
    $file_extension = strtolower(getExtension($_FILES['image']['name']));
    if ($file_extension != "jpg" && $file_extension != "gif" && $file_extension != "jpeg" && $file_extension != "png" && $file_extension != "webp") {
      $_SESSION['session_message'] = '<div class="btn btn-warning"> Please upload image (.jpg,.gif,.png,.webp Format Only) </div>';
      header("Location: " . SITE_ADMIN_URL . "/" . $script_name);
      exit;
    }
    if ($_FILES['image']['name'] != "") {
      $categoryRes = getResult($table_name, " where catID='$catID'", "catImage");
      $filename = $categoryRes['catImage'];
      if ($filename != "") {
        $file = site_url . "/uploaded-files/category/images/" . $filename;
        if (file_exists($file)) {
          unlink($file);
        }

        $file_thumb = site_url . "/uploaded-files/category/images/thumbs/" . $filename;
        if (file_exists($file_thumb)) {
          unlink($file_thumb);
        }
      }
      $cat = str_replace(" ", "-", $catname);
      $img_name = $cat;
      $img = upload_file($img_name, "image", "uploaded-files/category/images");
      updateTable($table_name, " catImage='$img' where catID='$catID'");
    }
  }

  if ($_FILES['catIcon']['name'] != "") {
    $file_extension = strtolower(getExtension($_FILES['catIcon']['name']));
    if ($file_extension != "jpg" && $file_extension != "gif" && $file_extension != "jpeg" && $file_extension != "png" && $file_extension != "webp") {
      $_SESSION['session_message'] = '<div class="btn btn-warning"> Please upload image (.jpg,.gif,.png,.webp Format Only) </div>';
      header("Location: " . SITE_ADMIN_URL . "/" . $script_name);
      exit;
    }
    if ($_FILES['catIcon']['name'] != "") {
      $categoryRes = getResult($table_name, " where catID='$catID'", "catIcon");
      $filename = $categoryRes['catIcon'];
      if ($filename != "") {
        $file = site_url . "/uploaded-files/category/caticon/" . $filename;
        if (file_exists($file)) {
          unlink($file);
        }
      }
      $cat = str_replace(" ", "-", $catname);
      $img_name = $cat;
      $img1 = upload_file($img_name, "catIcon", "uploaded-files/category/caticon");
      if ($catID == 7) {
        $width = "221";
        $height = "417";
        $source_folder = SITE_DIR_PATH . "/uploaded-files/category/caticon";
        $destination_folder = SITE_DIR_PATH . "/uploaded-files/category/caticon/thumbs/";
        saveResizedPhoto($img1, $width, $height, $source_folder, $destination_folder);
      } else {
        $width = "281";
        $height = "284";
        $source_folder = SITE_DIR_PATH . "/uploaded-files/category/caticon";
        $destination_folder = SITE_DIR_PATH . "/uploaded-files/category/caticon/thumbs/";
        saveResizedPhoto($img1, $width, $height, $source_folder, $destination_folder);
      }



      updateTable($table_name, " catIcon='$img1' where catID='$catID'");
    }
  }


  if ($_FILES['header_icon_image']['name'] != "") {
    $file_extension = strtolower(getExtension($_FILES['header_icon_image']['name']));
    if ($file_extension != "jpg" && $file_extension != "gif" && $file_extension != "jpeg" && $file_extension != "png" && $file_extension != "webp") {
      $_SESSION['session_message'] = '<div class="btn btn-warning"> Please upload image (.jpg,.gif,.png,.webp Format Only) </div>';
      header("Location: " . SITE_ADMIN_URL . "/" . $script_name);
      exit;
    }
    if ($_FILES['header_icon_image']['name'] != "") {
      $categoryRes = getResult($table_name, " where catID='$catID'", "header_icon_image");
      $filename = $categoryRes['header_icon_image'];
      if ($filename != "") {
        $file = site_url . "/uploaded-files/category/caticon/" . $filename;
        if (file_exists($file)) {
          unlink($file);
        }
      }
      $cat = str_replace(" ", "-", $catname);
      $img_name = $cat . uniqid();
      $img1 = upload_file($img_name, "header_icon_image", "uploaded-files/category/caticon");

      $width = "50";
      $height = "50";
      $source_folder = SITE_DIR_PATH . "/uploaded-files/category/caticon";
      $destination_folder = SITE_DIR_PATH . "/uploaded-files/category/caticon/thumbs/";
      saveResizedPhoto($img1, $width, $height, $source_folder, $destination_folder);

      updateTable($table_name, " header_icon_image='$img1' where catID='$catID'");
    }
  }


  if ($_FILES['cat_home_image']['name'] != "") {
    $file_extension = strtolower(getExtension($_FILES['cat_home_image']['name']));
    if ($file_extension != "jpg" && $file_extension != "gif" && $file_extension != "jpeg" && $file_extension != "png" && $file_extension != "webp") {
      $_SESSION['session_message'] = '<div class="btn btn-warning"> Please upload image (.jpg,.gif,.png,.webp Format Only) </div>';
      header("Location: " . SITE_ADMIN_URL . "/" . $script_name);
      exit;
    }
    if ($_FILES['cat_home_image']['name'] != "") {
      $categoryRes = getResult($table_name, " where catID='$catID'", "cat_home_image");
      $filename = $categoryRes['cat_home_image'];
      if ($filename != "") {
        $file = site_url . "/uploaded-files/category/images/" . $filename;
        if (file_exists($file)) {
          unlink($file);
        }
      }
      $cat = str_replace(" ", "-", $catname);
      $img_name = $cat . uniqid();
      $img1 = upload_file($img_name, "cat_home_image", "uploaded-files/category/images");

      $width = "242";
      $height = "242";

      $source_folder = SITE_DIR_PATH . "/uploaded-files/category/images";
      $destination_folder = SITE_DIR_PATH . "/uploaded-files/category/images/thumbs/";
      saveResizedPhoto($img1, $width, $height, $source_folder, $destination_folder);

      updateTable($table_name, " cat_home_image='$img1' where catID='$catID'");
    }
  }



  $q = updateTable($table_name, " pageDescription='" . $metadesc . "', catName='" . $catname . "',catUrl='" . $catUrl . "',catOldUrl='" . $catOldUrlUp . "', displayName='" . $catDname . "', catDesc='" . $shortdesc . "',catDesc1='" . $fulldesc . "', heading1='" . $heading1 . "',heading2='" . $heading2 . "',heading3='" . $heading3 . "',pageTitle='" . $metatitle . "', pageKeywords='" . $metakeyword . "',alt='" . $alt . "',title='" . $title . "',is_redirect='" . $is_redirect . "',redirect_link='" . $redirect_link . "' where catID='$catID'");
  // $_SESSION['session_message'] = '<div class="btn btn-success">' . $record_type . ' has been added successfully  </div>';

  echo mysqli_error($db);

  //header("Location: " . SITE_ADMIN_URL . "/" . $redirect_script_name);

  header("Location: " . SITE_ADMIN_URL . "/" . $redirect_script_name . "?start=" . $start . "&parentID=" . $parentID . "&catID=" . $catID . "&pagesize=" . $pagesize);
  exit;
}
########################################################
admin_header();
$res = getResult($table_name, " where catID='$catID'");
?>
<div class="content-wrapper">
  <div class="page-header">
    <h3 class="page-title">
      <?= $heading; ?>
    </h3>
    <nav aria-label="breadcrumb">
      <ol class="breadcrumb">
        <li class="nav-item d-none d-lg-flex">
          <a class="nav-link" href="<?= admin_url ?>manage-category.php?parentID=<?= $parentID; ?>">
            <span class="btn btn-primary">Go Back</span>
          </a>
        </li>
      </ol>
    </nav>
  </div>
  <div class="row">

    <div class="col-12 grid-margin stretch-card">
      <div class="card">
        <div class="card-body">
          <form class="forms-sample" method="post" action="" enctype="multipart/form-data" onsubmit="return validate(this);">
            <div class="form-group row">
              <div class="col">
                <label>Category Name *</label>
                <div id="the-basics">
                  <input class="typeahead" type="text" id="catName" name="catname" placeholder="Category Name" value="<?= $res['catName'] ?>" required>
                </div>
              </div>
              <div class="col">
                <label>Category Display Name</label>
                <div id="bloodhound">
                  <input class="typeahead" type="text" name="catDname" value="<?= $res['displayName'] ?>" placeholder="Category Display Name" required>
                </div>
              </div>
            </div>
            <!-- <div class="form-group row">
              <div class="col">
                <label>Heading 1</label>
                <div id="the-basics">
                  <input class="typeahead" type="text" name="heading1" value="<?= $res['heading1'] ?>"
                    placeholder="Heading 1">
                </div>
              </div>
              <div class="col">
                <label>Heading 2</label>
                <div id="bloodhound">
                  <input class="typeahead" type="text" name="heading2" value="<?= $res['heading2'] ?>"
                    placeholder="Heading 2">
                </div>
              </div>
            </div> -->
            <div class="form-group">
              <label for="exampleTextarea1">Category URL*</label>
              <input class="typeahead" type="text" id="catUrl" name="catUrl" readonly value="<?= $res['catUrl']; ?>" placeholder="Category URL">

              <input class="typeahead" type="hidden" id="catOldUrl" name="catOldUrl" readonly value="<?= $res['catUrl']; ?>" placeholder="Category Old URL">

              <input class="typeahead" type="hidden" id="catOldUrlCheck" name="catOldUrlCheck" readonly value="<?= $res['catOldUrl']; ?>" placeholder="Category Old URL Pass">
            </div>



            <?php
            if ($res['catID'] == "") { ?>
              <div class="form-group row">
                <div class="col">
                  <label for="exampleTextarea1">Category Header Icon Image</label>
                  <input type="file" name="header_icon_image">
                </div>


              </div>
            <?php } else { ?>
              <div class="form-group row">
                <div class="col">
                  <label>Category Header Icon Image</label>
                  <input type="file" name="header_icon_image">
                </div>

                <div class="col">
                  <img src="<?= site_url . "/uploaded-files/category/caticon/" . $res['header_icon_image'] ?>" alt="image" width="50" height="50">
                </div>
              </div>
            <?php   } ?>





            <div class="form-group row">
              <div class="col-md-6">
                <label class="col-md-12 col-form-label le">Do you want redirect on existing Link
                  ?</label>
                <div class="row">
                  <div class="col-sm-4">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="is_redirect" value="1" <?= ($res['is_redirect'] == 1) ? 'checked' : ''; ?>> Yes
                      </label>
                    </div>
                  </div>
                  <div class="col-sm-5">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="is_redirect" value="0" <?= ($res['is_redirect'] == 0) ? 'checked' : ''; ?>>
                        No
                      </label>
                    </div>
                  </div>
                </div>
              </div>

            </div>

            <div class="form-group" style="display:none" id="redirectL">

              <input class="typeahead" type="text" name="redirect_link" placeholder="Enter Redirect Link" value="<?= $res['redirect_link'] ?>">
            </div>

            <div class="form-group">
              <label for="exampleTextarea1">Category Header Text</label>
              <input class="typeahead" type="text" name="heading2" placeholder="Category Header Text" value="<?= $res['heading2'] ?>" placeholder="Heading 3">
            </div>

            <!-- <div class="form-group row d-none">
              <div class="col">
                <label>User Type</label>
                <div id="bloodhound">
                  <select name="usertype" class="form-control">
                    <option value="Individual" <?= ($res['usertype'] == 'Individual') ? 'selected' : ''; ?>>Individual</option>
                    <option value="Organization" <?= ($res['usertype'] == 'Organization') ? 'selected' : ''; ?>>Organization
                    </option>
                  </select>
                </div>
              </div>
              <div class="col">
                <label>Price</label>
                <div id="the-basics">
                  <input class="typeahead" type="number" name="catprice" value="<?= $res['catprice'] ?>"
                    placeholder="Price">
                </div>
              </div>
            </div> -->
            <div class="form-group ">
              <label for="exampleTextarea1">Meta Title</label>
              <input class="typeahead" type="text" name="metatitle" value="<?= $res['pageTitle'] ?>" placeholder="Meta Title">
            </div>
            <div class="form-group">
              <label for="exampleTextarea1">Meta Keyword</label>
              <input class="typeahead" type="text" name="metakeyword" value="<?= $res['pageKeywords'] ?>" placeholder="Meta Keyword">
            </div>
            <div class="form-group">
              <label for="exampleTextarea1">Meta Description</label>
              <textarea class="form-control" name="metadesc"><?= $res['pageDescription'] ?></textarea>
            </div>
            <div class="form-group">
              <label for="exampleTextarea1">Category Short Description</label>
              <textarea class="form-control editor" name="shortdesc" rows="6"><?= $res['catDesc'] ?></textarea>
            </div>
            <div class="form-group">
              <label for="exampleTextarea1">Category Description</label>
              <textarea class="form-control editor" name="fulldesc" rows="4"><?= $res['catDesc1'] ?></textarea>
            </div>

            <!-- <div class="form-group">
              <label for="exampleTextarea1">Uses of Certificate</label>
              <textarea class="form-control editor" name="certificateUsed"
                rows="4"><?= $res['certificateUsed'] ?></textarea>
            </div> -->

            <?php
            if ($res['catID'] == "") { ?>
              <div class="form-group row">
                <div class="col">
                  <label for="exampleTextarea1">Category Image</label>
                  <input type="file" class="dropify" name="image">
                </div>


                <div class="col">
                  <label>Alt </label>

                  <input class="typeahead" type="text" name="alt" placeholder="Image Alt" value="<?= $res['alt'] ?>">
                </div>
                <div class="col">
                  <label>Title </label>

                  <input class="typeahead" type="text" name="title" placeholder="Image Title" value="<?= $res['title'] ?>">
                </div>



              </div>
            <?php } else { ?>
              <div class="form-group row">
                <div class="col">
                  <label>Category Image</label>
                  <input type="file" class="dropify" name="image">
                </div>
                <div class="col">
                  <label>Alt </label>

                  <input class="typeahead" type="text" name="alt" placeholder="Image Alt" value="<?= $res['alt'] ?>">
                </div>
                <div class="col">
                  <label>Title </label>

                  <input class="typeahead" type="text" name="title" placeholder="Image Title" value="<?= $res['title'] ?>">
                </div>
                <div class="col">
                  <img src="<?= site_url . "/uploaded-files/category/images/" . $res['catImage'] ?>" alt="image" width="200" height="200">
                </div>
              </div>
            <?php   } ?>

            <?php
            if ($res['catID'] == "") { ?>
              <div class="form-group">
                <label for="exampleTextarea1">Category Home Image (500 X 500 Px)</label>
                <input type="file" class="dropify" name="cat_home_image">
              </div>
            <?php } else { ?>
              <div class="form-group row">
                <div class="col">
                  <label>Category Home Image</label>
                  <input type="file" class="dropify" name="cat_home_image">
                </div>
                <div class="col">
                  <img src="<?= site_url . "/uploaded-files/category/images/" . $res['cat_home_image'] ?>" alt="image" width="200" height="200">
                </div>
              </div>
            <?php   } ?>

            <?php
            if ($parentID == 0) {
              if ($res['catID'] == "") { ?>
                <div class="form-group">
                  <label for="exampleTextarea1">Category Icon</label>
                  <input type="file" class="dropify" name="catIcon">
                </div>
              <?php } else { ?>
                <div class="form-group row">
                  <div class="col">
                    <label>Category Icon</label>
                    <input type="file" class="dropify" name="catIcon">
                  </div>
                  <div class="col">
                    <img src="<?= site_url . "/uploaded-files/category/caticon/" . $res['catIcon'] ?>" alt="image" width="200" height="200">
                  </div>
                </div>
            <?php  }
            } ?>




            <!-- <div class="form-group">
              <label for="exampleTextarea1">Category Icon</label>
              <input type="file" class="form-control editor" name="catIcon" value="">
            </div> -->
            <!-- <div class="form-group d-none">
              <label for="exampleTextarea1">Required Documents <span class="text-danger">(Must be seperate by 'comma')</span></label>
              <input type="text" class="form-control editor" name="required_doc" value="<?= $res['required_doc'] ?>">
            </div> -->
            <!-- <div class="form-group row">
              <div class="col-md-6">
                <label class="col-md-12 col-form-label le">GST, Income Tax, EPF, Patent Trademark Registration</label>
                <div class="row">
                  <div class="col-sm-4">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="gst" value="1"
                          <?= ($res['gst'] == 1) ? 'checked' : ''; ?>> Yes
                      </label>
                    </div>
                  </div>
                  <div class="col-sm-5">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="gst" value="0"
                          <?= ($res['gst'] == 0) ? 'checked' : ''; ?>>
                        No
                      </label>
                    </div>
                  </div>
                </div>
              </div>
              <div class="col-md-6">
                <label class="col-md-12 col-form-label le">MCA (ROC) Director’s KYC, Partner’s KYC</label>
                <div class="row">
                  <div class="col-sm-4">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="mca" value="1"
                          <?= ($res['mca'] == 1) ? 'checked' : ''; ?>>
                        Yes
                      </label>
                    </div>
                  </div>
                  <div class="col-sm-5">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="mca" value="0"
                          <?= ($res['mca'] == 0) ? 'checked' : ''; ?>>
                        No
                      </label>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="form-group row">
              <div class="col-md-6">
                <label class="col-md-12 col-form-label le"> Start-up India</label>
                <div class="row">
                  <div class="col-sm-4">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="epf" value="1"
                          <?= ($res['epf'] == 1) ? 'checked' : ''; ?>>
                        Yes
                      </label>
                    </div>
                  </div>
                  <div class="col-sm-5">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="epf" value="0"
                          <?= ($res['epf'] == 0) ? 'checked' : ''; ?>>
                        No
                      </label>
                    </div>
                  </div>
                </div>
              </div>
              <div class="col-md-6">
                <label class="col-md-12 col-form-label le">Import Export Code (IEC)</label>
                <div class="row">
                  <div class="col-sm-4">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="iec" value="1"
                          <?= ($res['iec'] == 1) ? 'checked' : ''; ?>>
                        Yes
                      </label>
                    </div>
                  </div>
                  <div class="col-sm-5">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="iec" value="0"
                          <?= ($res['iec'] == 0) ? 'checked' : ''; ?>>
                        No
                      </label>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="form-group row">
              <div class="col-md-6">
                <label class="col-md-12 col-form-label le">E-Ticketing</label>
                <div class="row">
                  <div class="col-sm-4">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="ptr" value="1"
                          <?= ($res['ptr'] == 1) ? 'checked' : ''; ?>>
                        Yes
                      </label>
                    </div>
                  </div>
                  <div class="col-sm-5">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="ptr" value="0"
                          <?= ($res['ptr'] == 0) ? 'checked' : ''; ?>>
                        No
                      </label>
                    </div>
                  </div>
                </div>
              </div>
              <div class="col-md-6">
                <label class="col-md-12 col-form-label le">IceGate – AD Code Reg.</label>
                <div class="row">
                  <div class="col-sm-4">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="eticket" value="1"
                          <?= ($res['eticket'] == 1) ? 'checked' : ''; ?>>
                        Yes
                      </label>
                    </div>
                  </div>
                  <div class="col-sm-5">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="eticket" value="0"
                          <?= ($res['eticket'] == 0) ? 'checked' : ''; ?>>
                        No
                      </label>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="form-group row">
              <div class="col-md-6">
                <label class="col-md-12 col-form-label le">IceGate - Customs Portal</label>
                <div class="row">
                  <div class="col-sm-4">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="cp" value="1"
                          <?= ($res['cp'] == 1) ? 'checked' : ''; ?>>
                        Yes
                      </label>
                    </div>
                  </div>
                  <div class="col-sm-5">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="cp" value="0"
                          <?= ($res['cp'] == 0) ? 'checked' : ''; ?>>
                        No
                      </label>
                    </div>
                  </div>
                </div>
              </div>
              <div class="col-md-6">
                <label class="col-md-12 col-form-label le">CBSE - School</label>
                <div class="row">
                  <div class="col-sm-4">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="cbe" value="1"
                          <?= ($res['cbe'] == 1) ? 'checked' : ''; ?>>
                        Yes
                      </label>
                    </div>
                  </div>
                  <div class="col-sm-5">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="cbe" value="0"
                          <?= ($res['cbe'] == 0) ? 'checked' : ''; ?>>
                        No
                      </label>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="form-group row">
              <div class="col-md-6">
                <label class="col-md-12 col-form-label le">Login into e-Tender Portal</label>
                <div class="row">
                  <div class="col-sm-4">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="etp" value="1"
                          <?= ($res['etp'] == 1) ? 'checked' : ''; ?>>
                        Yes
                      </label>
                    </div>
                  </div>
                  <div class="col-sm-5">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="etp" value="0"
                          <?= ($res['etp'] == 0) ? 'checked' : ''; ?>>
                        No
                      </label>
                    </div>
                  </div>
                </div>
              </div>
              <div class="col-md-6">
                <label class="col-md-12 col-form-label le">Vendor / Bidder (eProcure.gov.in) | E-Auctioning</label>
                <div class="row">
                  <div class="col-sm-4">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="vb" value="1"
                          <?= ($res['vb'] == 1) ? 'checked' : ''; ?>>
                        Yes
                      </label>
                    </div>
                  </div>
                  <div class="col-sm-5">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="vb" value="0"
                          <?= ($res['vb'] == 0) ? 'checked' : ''; ?>>
                        No
                      </label>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="form-group row">
              <div class="col-md-6">
                <label class="col-md-12 col-form-label le">DGFT - Foreign Trade</label>
                <div class="row">
                  <div class="col-sm-4">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="dgft" value="1"
                          <?= ($res['dgft'] == 1) ? 'checked' : ''; ?>>
                        Yes
                      </label>
                    </div>
                  </div>
                  <div class="col-sm-5">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="dgft" value="0"
                          <?= ($res['dgft'] == 0) ? 'checked' : ''; ?>>
                        No
                      </label>
                    </div>
                  </div>
                </div>
              </div>
              <div class="col-md-6">
                <label class="col-md-12 col-form-label le">Country of Origin-Code  </label>
                <div class="row">
                  <div class="col-sm-4">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="iet" value="1"
                          <?= ($res['iet'] == 1) ? 'checked' : ''; ?>>
                        Yes
                      </label>
                    </div>
                  </div>
                  <div class="col-sm-5">
                    <div class="form-check">
                      <label class="form-check-label">
                        <input type="radio" class="form-check-input" name="iet" value="0"
                          <?= ($res['iet'] == 0) ? 'checked' : ''; ?>>
                        No
                      </label>
                    </div>
                  </div>
                </div>
              </div>
            </div> -->
            <div class="cmmt_nav mb-5">
              <ul class="nav nav-tabs" id="myTab" role="tablist">
                <li class="nav-item">
                  <a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">First Tab</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Second Tab</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" id="contact-tab" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false">Third Tab</a>
                </li>
              </ul>
              <div class="tab-content" id="myTabContent">
                <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
                  <form>
                    <div class="form-row">
                      <div class="form-group col-md-6">
                        <label for="inputEmail4">Category Name *</label>
                        <input type="text" class="form-control" id="inputEmail4" placeholder="Category Name">
                      </div>
                      <div class="form-group col-md-6">
                        <label for="inputPassword4">Category Display Name</label>
                        <input type="text" class="form-control" id="inputPassword4" placeholder="text">
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="inputAddress">Category URL*</label>
                      <input type="text" class="form-control" id="inputAddress" placeholder="Category URL">
                    </div>
                    <div class="form-row align-items-center">
                      <div class="form-group col-md-7">
                        <label for="exampleTextarea1">Category Icon</label>
                        <input type="file" class="dropify" name="catIcon">
                      </div>
                      <div class="form-group col-md-5">
                        <img src="https://www.wpsbiz.com/wpsdev/uploaded-files/category/caticon/WEBSITES.webp" alt="image" width="200" height="200">
                      </div>
                    </div>
                    <div class="form-row">
                      <div class="form-group col-md-4">
                        <label for="inputCity">Meta Description</label>
                        <input type="text" class="form-control" id="inputCity">
                      </div>
                      <div class="form-group col-md-4">
                        <label for="inputState">List</label>
                        <select id="inputState" class="form-control">
                          <option selected>Choose...</option>
                          <option>...</option>
                        </select>
                      </div>
                      <div class="form-group col-md-4">
                        <label for="inputZip">Meta Keyword</label>
                        <input type="text" class="form-control" id="inputZip">
                      </div>
                    </div>
                    <div class="btn-grp">
                      <button class="btn btn-warning btn-icon-text btn-sm" type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalLong"><i class="far fa-edit mr-1"></i> Category List</button>
                    </div>
                  </form>
                </div>
                <div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">

                </div>
                <div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">

                </div>
              </div>
            </div>
            
            <?php
            if ($res['catID'] == "") {
            ?>
              <button type="submit" class="btn btn-primary mr-2" name="add_record">Submit</button>
              <input type="hidden" name="action" value="add_record">
            <?php
            } else {
            ?>
              <button type="submit" class="btn btn-primary mr-2" name="update_record">Update</button>
              <input type="hidden" name="action" value="update_record">
            <?php
            }
            ?>
            <button class="btn btn-light" onclick="javascript: window.location.href = '<?= SITE_ADMIN_URL; ?>/<?= $redirect_script_name; ?>?parentID=<?= $parentID; ?>&catID=<?= $catID; ?>&start=<?= $start; ?>&pagesize=<?= $pagesize; ?>'">Cancel</button>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
<!-- content-wrapper ends -->

<!-- Modal -->
<div class="modal fade" id="exampleModalLong" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header px-3 py-2 align-items-center">
        <h5 class="modal-title" id="exampleModalLongTitle">Category List</h5>
        <a href="#exampleModal" data-toggle="modal" data-dismiss="modal" class="btn btn-primary btn-sm ml-auto">+ Add New Category</a>
        <button type="button" class="close m-0 p-2" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body p-0">
        <div class="card">
          <div class="card-body p-3">
            <form action="" method="post">
              <div class="table-responsive">
                <table id="order-listing" class="table table-bordered table-hover">
                  <thead>
                    <tr>
                      <th class="_reab">#</th>
                      <th>S.No.</th>
                      <th>Heading</th>
                      <th>Header Menu</th>
                      <th>Image</th>
                      <th>View Order</th>
                      <th>Status</th>
                      <th>Actions</th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <td>
                        <div class="form-check mt-0">
                          <label class="form-check-label">
                            <input type="checkbox" class="form-check-input" name="cat_arr[]" value="4">
                            <i class="input-helper"></i>
                          </label>
                        </div>
                      </td>
                      <td>1</td>
                      <td>
                        <p class="ordern">Website</p>
                        <p class="user-dcs"> <a href="https://www.wpsbiz.com/wpsdev/admin/manage-category.php?parentID=4">Sub Categories <span>[6]</span></a></p>
                        <p class="user-dcs">
                          <a href="https://www.wpsbiz.com/wpsdev/admin/manage_location_content.php?category_id=4">Sub Domain Content </a>
                        </p>
                      </td>
                      <td>
                        <label class="toggleSwitch">
                          <input type="checkbox" id="toggle-input" data-catid="4" checked>
                          <span>
                            <span>No</span>
                            <span>Yes</span>
                          </span>
                          <a></a>
                        </label>
                      </td>
                      <td>
                      </td>
                      <td>
                        <input name="order_4" class="form-control order" type="text" size="2" value="1">
                      </td>
                      <td>
                        <p class="status-dcs"><label class="badge badge-success badge-pill">Active</label></p>
                      </td>
                      <td>
                        <p class="download-dcs">
                          <!-- <a href="https://www.wpsbiz.com/wpsdev/admin/addeditcategory.php?start=0&catID=4&parentID=0&pagesize=100">
                            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit-3">
                              <path d="M12 20h9"></path>
                              <path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"></path>
                            </svg>
                          </a> -->
                          <a href="#exampleModal" data-toggle="modal" data-dismiss="modal">
                            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit-3">
                              <path d="M12 20h9"></path>
                              <path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"></path>
                            </svg>
                          </a>
                        </p>
                      </td>
                    </tr>
                  </tbody>
                </table>
                <div class="btn-grp">
                  <button type="submit" name="active" onclick="return select_chk()" class="btn btn-success btn-icon-text btn-sm">
                    <i class="fas fa-toggle-on mr-1"></i>Activate
                  </button>
                  <button type="submit" name="inactive" onclick="return select_chk()" class="btn btn-warning btn-icon-text btn-sm">
                    <i class="far fa-times-circle mr-1"></i>Deactivate
                  </button>
                  <button type="submit" name="set_home" onclick="return select_chk()" class="btn btn-primary btn-icon-text btn-sm">
                    <i class="far fa-check-square mr-1"></i>Set
                  </button>
                  <button type="submit" name="unset_home" onclick="return select_chk()" class="btn btn-info btn-icon-text btn-sm">
                    <i class="fa fa-exclamation-triangle mr-1"></i>Unset
                  </button>

                  <button type="submit" name="action" value="Update" class="btn btn-default btn-icon-text btn-sm">
                    <i class="far fa-check-square mr-1"></i>Update Order
                  </button>
                  <button type="submit" name="delete" onclick="return select_chk()" class="btn btn-danger btn-icon-text btn-sm">
                    <i class="fas fa-trash-alt mr-1"></i>Delete
                  </button>

                </div>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header p-3">
        <h5 class="modal-title" id="exampleModalLabel">Edit Category</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body p-0">
        <div class="card">
          <div class="card-body">
            <form class="forms-sample" method="post" action="" enctype="multipart/form-data" onsubmit="return validate(this);">
              <div class="form-group row">
                <div class="col">
                  <label>Category Name *</label>
                  <div id="the-basics">
                    <input class="typeahead" type="text" id="catName" name="catname" placeholder="Category Name" value="<?= $res['catName'] ?>" required>
                  </div>
                </div>
                <div class="col">
                  <label>Category Display Name</label>
                  <div id="bloodhound">
                    <input class="typeahead" type="text" name="catDname" value="<?= $res['displayName'] ?>" placeholder="Category Display Name" required>
                  </div>
                </div>
              </div>
              <!-- <div class="form-group row">
              <div class="col">
                <label>Heading 1</label>
                <div id="the-basics">
                  <input class="typeahead" type="text" name="heading1" value="<?= $res['heading1'] ?>"
                    placeholder="Heading 1">
                </div>
              </div>
              <div class="col">
                <label>Heading 2</label>
                <div id="bloodhound">
                  <input class="typeahead" type="text" name="heading2" value="<?= $res['heading2'] ?>"
                    placeholder="Heading 2">
                </div>
              </div>
            </div> -->
              <div class="form-group">
                <label for="exampleTextarea1">Category URL*</label>
                <input class="typeahead" type="text" id="catUrl" name="catUrl" readonly value="<?= $res['catUrl']; ?>" placeholder="Category URL">

                <input class="typeahead" type="hidden" id="catOldUrl" name="catOldUrl" readonly value="<?= $res['catUrl']; ?>" placeholder="Category Old URL">

                <input class="typeahead" type="hidden" id="catOldUrlCheck" name="catOldUrlCheck" readonly value="<?= $res['catOldUrl']; ?>" placeholder="Category Old URL Pass">
              </div>



              <?php
              if ($res['catID'] == "") { ?>
                <div class="form-group row">
                  <div class="col">
                    <label for="exampleTextarea1">Category Header Icon Image</label>
                    <input type="file" name="header_icon_image">
                  </div>


                </div>
              <?php } else { ?>
                <div class="form-group row">
                  <div class="col">
                    <label>Category Header Icon Image</label>
                    <input type="file" name="header_icon_image">
                  </div>

                  <div class="col">
                    <img src="<?= site_url . "/uploaded-files/category/caticon/" . $res['header_icon_image'] ?>" alt="image" width="50" height="50">
                  </div>
                </div>
              <?php   } ?>





              <div class="form-group row">
                <div class="col-md-6">
                  <label class="col-md-12 col-form-label le">Do you want redirect on existing Link
                    ?</label>
                  <div class="row">
                    <div class="col-sm-4">
                      <div class="form-check">
                        <label class="form-check-label">
                          <input type="radio" class="form-check-input" name="is_redirect" value="1" <?= ($res['is_redirect'] == 1) ? 'checked' : ''; ?>> Yes
                        </label>
                      </div>
                    </div>
                    <div class="col-sm-5">
                      <div class="form-check">
                        <label class="form-check-label">
                          <input type="radio" class="form-check-input" name="is_redirect" value="0" <?= ($res['is_redirect'] == 0) ? 'checked' : ''; ?>>
                          No
                        </label>
                      </div>
                    </div>
                  </div>
                </div>

              </div>

              <div class="form-group" style="display:none" id="redirectL">

                <input class="typeahead" type="text" name="redirect_link" placeholder="Enter Redirect Link" value="<?= $res['redirect_link'] ?>">
              </div>

              <div class="form-group">
                <label for="exampleTextarea1">Category Header Text</label>
                <input class="typeahead" type="text" name="heading2" placeholder="Category Header Text" value="<?= $res['heading2'] ?>" placeholder="Heading 3">
              </div>

              <!-- <div class="form-group row d-none">
              <div class="col">
                <label>User Type</label>
                <div id="bloodhound">
                  <select name="usertype" class="form-control">
                    <option value="Individual" <?= ($res['usertype'] == 'Individual') ? 'selected' : ''; ?>>Individual</option>
                    <option value="Organization" <?= ($res['usertype'] == 'Organization') ? 'selected' : ''; ?>>Organization
                    </option>
                  </select>
                </div>
              </div>
              <div class="col">
                <label>Price</label>
                <div id="the-basics">
                  <input class="typeahead" type="number" name="catprice" value="<?= $res['catprice'] ?>"
                    placeholder="Price">
                </div>
              </div>
            </div> -->
              <div class="form-group ">
                <label for="exampleTextarea1">Meta Title</label>
                <input class="typeahead" type="text" name="metatitle" value="<?= $res['pageTitle'] ?>" placeholder="Meta Title">
              </div>
              <div class="form-group">
                <label for="exampleTextarea1">Meta Keyword</label>
                <input class="typeahead" type="text" name="metakeyword" value="<?= $res['pageKeywords'] ?>" placeholder="Meta Keyword">
              </div>
              <div class="form-group">
                <label for="exampleTextarea1">Meta Description</label>
                <textarea class="form-control" name="metadesc"><?= $res['pageDescription'] ?></textarea>
              </div>
              <div class="form-group">
                <label for="exampleTextarea1">Category Short Description</label>
                <textarea class="form-control editor" name="shortdesc" rows="6"><?= $res['catDesc'] ?></textarea>
              </div>
              <div class="form-group">
                <label for="exampleTextarea1">Category Description</label>
                <textarea class="form-control editor" name="fulldesc" rows="4"><?= $res['catDesc1'] ?></textarea>
              </div>

              <!-- <div class="form-group">
              <label for="exampleTextarea1">Uses of Certificate</label>
              <textarea class="form-control editor" name="certificateUsed"
                rows="4"><?= $res['certificateUsed'] ?></textarea>
            </div> -->

              <?php
              if ($res['catID'] == "") { ?>
                <div class="form-group row">
                  <div class="col">
                    <label for="exampleTextarea1">Category Image</label>
                    <input type="file" class="dropify" name="image">
                  </div>


                  <div class="col">
                    <label>Alt </label>

                    <input class="typeahead" type="text" name="alt" placeholder="Image Alt" value="<?= $res['alt'] ?>">
                  </div>
                  <div class="col">
                    <label>Title </label>

                    <input class="typeahead" type="text" name="title" placeholder="Image Title" value="<?= $res['title'] ?>">
                  </div>



                </div>
              <?php } else { ?>
                <div class="form-group row">
                  <div class="col">
                    <label>Category Image</label>
                    <input type="file" class="dropify" name="image">
                  </div>
                  <div class="col">
                    <label>Alt </label>

                    <input class="typeahead" type="text" name="alt" placeholder="Image Alt" value="<?= $res['alt'] ?>">
                  </div>
                  <div class="col">
                    <label>Title </label>

                    <input class="typeahead" type="text" name="title" placeholder="Image Title" value="<?= $res['title'] ?>">
                  </div>
                  <div class="col">
                    <img src="<?= site_url . "/uploaded-files/category/images/" . $res['catImage'] ?>" alt="image" width="200" height="200">
                  </div>
                </div>
              <?php   } ?>

              <?php
              if ($res['catID'] == "") { ?>
                <div class="form-group">
                  <label for="exampleTextarea1">Category Home Image (500 X 500 Px)</label>
                  <input type="file" class="dropify" name="cat_home_image">
                </div>
              <?php } else { ?>
                <div class="form-group row">
                  <div class="col">
                    <label>Category Home Image</label>
                    <input type="file" class="dropify" name="cat_home_image">
                  </div>
                  <div class="col">
                    <img src="<?= site_url . "/uploaded-files/category/images/" . $res['cat_home_image'] ?>" alt="image" width="200" height="200">
                  </div>
                </div>
              <?php   } ?>

              <?php
              if ($parentID == 0) {
                if ($res['catID'] == "") { ?>
                  <div class="form-group">
                    <label for="exampleTextarea1">Category Icon</label>
                    <input type="file" class="dropify" name="catIcon">
                  </div>
                <?php } else { ?>
                  <div class="form-group row">
                    <div class="col">
                      <label>Category Icon</label>
                      <input type="file" class="dropify" name="catIcon">
                    </div>
                    <div class="col">
                      <img src="<?= site_url . "/uploaded-files/category/caticon/" . $res['catIcon'] ?>" alt="image" width="200" height="200">
                    </div>
                  </div>
              <?php  }
              } ?>

              <div class="cmmt_nav mb-5">
                <ul class="nav nav-tabs" id="myTab" role="tablist">
                  <li class="nav-item">
                    <a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">First Tab</a>
                  </li>
                  <li class="nav-item">
                    <a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Second Tab</a>
                  </li>
                  <li class="nav-item">
                    <a class="nav-link" id="contact-tab" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false">Third Tab</a>
                  </li>
                </ul>
                <div class="tab-content" id="myTabContent">
                  <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
                    <form>
                      <div class="form-row">
                        <div class="form-group col-md-6">
                          <label for="inputEmail4">Category Name *</label>
                          <input type="text" class="form-control" id="inputEmail4" placeholder="Category Name">
                        </div>
                        <div class="form-group col-md-6">
                          <label for="inputPassword4">Category Display Name</label>
                          <input type="text" class="form-control" id="inputPassword4" placeholder="text">
                        </div>
                      </div>
                      <div class="form-group">
                        <label for="inputAddress">Category URL*</label>
                        <input type="text" class="form-control" id="inputAddress" placeholder="Category URL">
                      </div>
                      <div class="form-row align-items-center">
                        <div class="form-group col-md-7">
                          <label for="exampleTextarea1">Category Icon</label>
                          <input type="file" class="dropify" name="catIcon">
                        </div>
                        <div class="form-group col-md-5">
                          <img src="https://www.wpsbiz.com/wpsdev/uploaded-files/category/caticon/WEBSITES.webp" alt="image" width="200" height="200">
                        </div>
                      </div>
                      <div class="form-row">
                        <div class="form-group col-md-4">
                          <label for="inputCity">Meta Description</label>
                          <input type="text" class="form-control" id="inputCity">
                        </div>
                        <div class="form-group col-md-4">
                          <label for="inputState">List</label>
                          <select id="inputState" class="form-control">
                            <option selected>Choose...</option>
                            <option>...</option>
                          </select>
                        </div>
                        <div class="form-group col-md-4">
                          <label for="inputZip">Meta Keyword</label>
                          <input type="text" class="form-control" id="inputZip">
                        </div>
                      </div>
                    </form>
                  </div>
                  <div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">

                  </div>
                  <div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">

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

              <?php
              if ($res['catID'] == "") {
              ?>
                <button type="submit" class="btn btn-primary mr-2" name="add_record">Submit</button>
                <input type="hidden" name="action" value="add_record">
              <?php
              } else {
              ?>
                <button type="submit" class="btn btn-primary mr-2" name="update_record">Update</button>
                <input type="hidden" name="action" value="update_record">
              <?php
              }
              ?>
              <button class="btn btn-light" onclick="javascript: window.location.href = '<?= SITE_ADMIN_URL; ?>/<?= $redirect_script_name; ?>?parentID=<?= $parentID; ?>&catID=<?= $catID; ?>&start=<?= $start; ?>&pagesize=<?= $pagesize; ?>'">Cancel</button>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<?php
admin_footer();
?>

<script>
  $(document).ready(function() {
    var autocheck = $("input[type='radio'][name='is_redirect']:checked").val();
    if (autocheck == '1') {
      $('#redirectL').show();
    }

    $("input[type='radio'][name='is_redirect']").click(function() {

      var checkedVal = $(this).val();

      if (checkedVal == '1') {
        $('#redirectL').show();
      } else {
        $('#redirectL').hide();
      }

    })
  })
</script>
<script>
  $(document).ready(function() {
    $('#catName').on('input blur', function() {
      let input = $(this).val();
      let inputResponse = removeSpecialChars(input);

      $('#catUrl').val(inputResponse);


      // $.ajax({
      //     url: 'your-server-endpoint', // Replace with your server endpoint
      //     type: 'POST',
      //     data: { value: inputValue },
      //     success: function(response){
      //         $('#result').html(response);
      //     },
      //     error: function(xhr, status, error){
      //         console.error('AJAX Error: ' + status + error);
      //     }
      // });
    });
  });
</script>