<!DOCTYPE html>
<html lang="en">

<head>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">

  <title>Featured Banner</title>

  <!-- Bootstrap core CSS -->
  <link href="../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" />
  <link href="https://fonts.googleapis.com/css2?family=Kufam:wght@400;500;600;700;800;900&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css" />
  <!-- Custom styles for this template -->
  <link href="../public/css/main.css" rel="stylesheet">

</head>

<body>

  <div class="d-flex" id="wrapper">

    <!-- Sidebar -->
    <?php

    include ('../sidebar_admin.php'); 
?>
    <!-- /#sidebar-wrapper -->

    <!-- Page Content -->
    <div id="page-content-wrapper">

        <?php
        include ('../navbar_admin.php');
        ?>


        <div class="container">
        <div class="page_name_candidate">
          <div class="candidate_div">
            <h1>Featured Banner List</h1>

          </div>
          <div class="select_sort_second">

            <div class="sort_btn">


              <a href="" data-toggle="modal" data-target="#add_payment_modal"class="addfeatued_btn" ><span class="span_btn "><svg width="12px"
                    height="12px" viewBox="0 0 18 18" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink"
                    xmlns="http://www.w3.org/2000/svg">
                    <desc>Created with Lunacy</desc>
                    <path
                      d="M10 8L17 8C17.5523 8 18 8.44772 18 9C18 9.55229 17.5523 10 17 10L10 10L10 17C10 17.5523 9.55229 18 9 18C8.44772 18 8 17.5523 8 17L8 10L1 10C0.447715 10 0 9.55229 0 9C0 8.44772 0.447715 8 1 8L8 8L8 1C8 0.447715 8.44772 0 9 0C9.55229 0 10 0.447715 10 1L10 8Z"
                      id="Path" fill="#FFFFFF" stroke="none" />
                  </svg></span>Add Featured</a>

            </div>
          </div>



        </div>

        <div class="cards">
          <div class="row">
            <div class="col-xl-12 mt-3 mb-3">
              <div class="card payment_method_card candidate">
                <div class="card-body ">
                  <div class="pagination_table">
                    <div class="results">
                    </div>
                    <div class="page">
                     

                      <span class="page_head">Results Per Page</span>
                      <div id="paginate">

                      </div>
                      <!-- <ul class="pagination pagination-sm">
                        <li class="page-item"><a class="page-link page_pre" href="#"><span><i
                                class="fas fa-angle-left"></i></span></a></li>
                        <li class="page-item"><a class="page-link" href="#">1</a></li>
                        <li class="page-item"><a class="page-link" href="#">2</a></li>
                        <li class="page-item"><a class="page-link" href="#">...</a></li>
                        <li class="page-item"><a class="page-link" href="#">19</a></li>
                        <li class="page-item"><a class="page-link page_next" href="#"><span><i
                                class="fas fa-angle-right"></i></span></a></li>
                      </ul> -->

                    </div>
                  </div>
                  <div class="search_product">
                    <form action="#">
                      <div class="input-group ">
                        <div class="input-group-prepend">
                          <span class="input-group-text" id="basic-addon1"><i class="fas fa-search"></i></span>
                        </div>
                        <input type="text" class="form-control" id="featured-search" placeholder="Searching for.." aria-label="Username"
                          aria-describedby="basic-addon1">
                      </div>
                    </form>

                  </div>

                  <table class="table table_centerd">
                    <!-- <thead>
                      <tr>

                        <th>Banner</th>
                        <th>Name</th>
                        <th>Type</th>
                        <th>Action</th>
                        <th>Enable</th>


                      </tr>
                    </thead>
                    <tbody>
                      
                    </tbody> -->
                  </table>

                </div>
              </div>

            </div>

          </div>

        </div>
      </div>
      <!-- /#page-content-wrapper -->
<input type="hidden" id="page-no">
    </div>
    <!-- /#wrapper -->
    <!-- <div class="container">
      <h3 align="center">Live Data Search with Pagination in PHP Mysql using Ajax</h3>
      <br />
      <div class="card">
        <div class="card-header">Dynamic Data</div>
        <div class="card-body">
          <div class="form-group">
            <input type="text" name="search_box" id="search_box" class="form-control" placeholder="Type your search query here" />
          </div>
          <div class="table-responsive" id="dynamic_content">
            
          </div>
        </div>
      </div>
    </div> -->
    <!-- modals -->
    <!-- add modal -->
    <form class="childcatagories_modal_from" id="modal-form" action="">
      <div class="modal fade" id="add_payment_modal" tabindex="-1" role="dialog"
        aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
          <div class="modal-content">
            <div class="modal-header mh">
              <button type="button" class="close closmodel" data-dismiss="modal" aria-label="Close"
                onclick="colsemodel()">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body mb">
              <div>
                <div class="cat-folder-img">
                  <i class="fa fa-folder" aria-hidden="true"></i>
                </div>
              </div>
              <div class="form-group">
                <label for="cat-name-upload" class="customer-add-input-label txt-regular upload-input-label">
                  Name</label>
                <input type="text" id="addpro_cat" name="addpro_cat" placeholder="Enter Banner Name" value=""
                  class="customer-add-input feat_banner_name w-100" />
              </div>
              <div class="form-group">
                <div class="form-group">
                  <label for="banner-type" class="customer-add-input-label txt-regular upload-input-label" >type</label>
                  <select class="form-control " name="banner-type" id="banner-type">
                  <option value="" selected >select Type</option>
                    <option value="list" >List</option>
                    <option value="product" >Product</option>
                    
                  </select>
                </div>
              </div>
              <input type="hidden" id="select-type-name">
              <div class="form-group list_brands" style="display:none">
                  <label for="banner-type" class="customer-add-input-label txt-regular upload-input-label" >Brands</label>
                  <select class="form-control " name="banner-type" id="banner-brands">
                  <option selected >select Brands</option>
                   
                    
                  </select>
                </div>

              <div class="form-group pro_single" style="display: none;" >
                <label for="banner-brands" class="customer-add-input-label txt-regular upload-input-label" >Brands</label>
                  <select class="selectpicker form-control" name="banner-brands" id="banner-pro">
                 
                    
                  </select>
              </div>
              <div class="form-group pro_mul" style="display: none;" >
                <label for="banner-brands-mul" class="customer-add-input-label txt-regular upload-input-label" >Brands</label>
                  <select class="selectpicker form-control" multiple name="banner-brands-mul" id="banner-pro-mul">
                    
                    
                  </select>
              </div>
              <div>
                <div>
                  <div class="upload-text-heading">
                    <h5 class="coupon-code-main-heading txt-regular">
                      Upload Picture
                    </h5>
                  </div>
                  <div>
                    <p class="upload-main-paragraph txt-label2">
                      Drag and drop your files here
                    </p>
                  </div>
                </div>
                <div class="card text-center uload-card">
                  <div class="file-upload4">
                    <div class="image-upload-wrap4">
                      <input class="file-upload-input4" type="file" onchange="readURL4(this);" accept="image/*" />
                      <div class="drag-text4">
                        <div class="card-body upload-card-body4">
                          <div class="upload-img4">
                            <img src="../public/image/upload.png" alt="" />
                          </div>
                          <div class="upload-image-format4">
                            <p>
                              .PDF .JPG .PNG .DOC
                            </p>
                          </div>
                          <div class="upload-detail4">
                            <h4>You can also upload files by</h4>
                            <div class="upload-clicking4">
                              <a href="#" class="">Clicking here</a>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="file-upload-content4">
                      <img class="file-upload-image4" src="#" alt="your image" />
                      <div class="image-title-wrap4">
                        <button type="button" onclick="removeUpload4()" class="btn remove-image4">
                          Remove
                          <span class="image-title4" style="display: none;">Uploaded
                            Image</span>
                        </button>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="modal-footer mf">
              <button type="button" class="btn btn-primary addproduct">
                <img src="../public/image/tick (1).png" alt="" />
              </button>
            </div>
          </div>
        </div>
      </div>
    </form>
    <!-- edit modal -->
    <form class="childcatagories_modal_from" id="modal-form" action="">
      <div class="modal fade" id="add_payment_modal_edit" tabindex="-1" role="dialog"
        aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
          <div class="modal-content">
            <div class="modal-header mh">
              <button type="button" class="close closmodel" data-dismiss="modal" aria-label="Close"
                onclick="colsemodel()">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body mb">
              <div>
                <div class="cat-folder-img">
                  <i class="fa fa-folder" aria-hidden="true"></i>
                </div>
              </div>
              <div class="form-group">
                <label for="cat-name-upload" class="customer-add-input-label txt-regular upload-input-label">
                  Name</label>
                <input type="text" id="addpro_cat" name="addpro_cat" placeholder="Enter Banner Name" value=""
                  class="customer-add-input feat_banner_name_edit w-100" />
              </div>
              <div class="form-group">
                <div class="form-group">
                  <label for="banner-type" class="customer-add-input-label txt-regular upload-input-label" >type</label>
                  <select class="form-control " name="banner-type" id="banner-type-edit">
                  <option value="" selected >select Type</option>
                    <option class="type_list" value="list" >List</option>
                    <option class="type_product" value="product" >Product</option>
                    
                  </select>
                </div>
              </div>
              <input type="hidden" id="update-id">
              <input type="hidden" id="select-type-name">
              <div class="form-group list_brands">
                  <?php 
                   $query="SELECT * FROM Brand";
                   $result = queryRunner($query);
                  
                  ?>
                  <label for="banner-brands-edit" class="customer-add-input-label txt-regular upload-input-label" >Brands</label>
                  <select class="form-control " name="banner-type" id="banner-brands-edit">
                
                 
                    <?php
                    while ($row = rowRetriever($result)) {
                    ?>
                  <option class="banner_edit_option_<?php echo $row['id']; ?>" value="<?php echo $row['id']; ?>" data-id="<?php echo $row['id']; ?>" ><?php echo $row['name']; ?></option>
                  
                   
                    <?php 
                      }
                    
                    ?>
                  </select>
                </div>
               
              <div class="form-group pro_single_edit"  style="display: none;">
                <label for="banner-pro-edit" class="customer-add-input-label txt-regular upload-input-label" >products</label>
                  <select class="selectpicker form-control" name="banner-brands" id="banner-pro-edit">
                 
                    
                  </select>
              </div>
              <div class="form-group pro_mul_edit" style="display: none;" >
                <label for="banner-brands-mul-edit" class="customer-add-input-label txt-regular upload-input-label" >products</label>
                  <select class="selectpicker form-control" multiple name="banner-brands-mul-edit" id="banner-pro-mul-edit">
                    
                    
                  </select>
              </div>


              <div>
                <div>
                  <div class="upload-text-heading">
                    <h5 class="coupon-code-main-heading txt-regular">
                      Upload Picture
                    </h5>
                  </div>
                  <div>
                    <p class="upload-main-paragraph txt-label2">
                      Drag and drop your files here
                    </p>
                  </div>
                </div>
                <div class="card text-center uload-card">
                  <div class="file-upload4">
                    <div class="image-upload-wrap4">
                      <input class="file-upload-input4" type="file" onchange="readURL4(this);" accept="image/*" />
                      <div class="drag-text4">
                        <div class="card-body upload-card-body4">
                          <div class="upload-img4">
                            <img src="../public/image/upload.png" alt="" />
                          </div>
                          <div class="upload-image-format4">
                            <p>
                              .PDF .JPG .PNG .DOC
                            </p>
                          </div>
                          <div class="upload-detail4">
                            <h4>You can also upload files by</h4>
                            <div class="upload-clicking4">
                              <a href="#" class="">Clicking here</a>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="file-upload-content4">
                      <img class="file-upload-image4" src="#" alt="your image" />
                      <div class="image-title-wrap4">
                        <button type="button" onclick="removeUpload4()" class="btn remove-image4">
                          Remove
                          <span class="image-title4" style="display: none;">Uploaded
                            Image</span>
                        </button>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="modal-footer mf">
              <button type="button"  class="btn btn-primary addupdate">
                <img src="../public/image/tick (1).png" alt="" />
              </button>
            </div>
          </div>
        </div>
      </div>
    </form>

    <!-- Bootstrap core JavaScript -->
    <script src="../vendor/jquery/jquery.min.js"></script>
    <script src="../vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
    <script src="../public/js/customjs.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js"></script>

    <!-- Menu Toggle Script -->
    <script>
      $("#menu-toggle").click(function (e) {
        e.preventDefault();
        $("#wrapper").toggleClass("toggled");
      });
    </script>
    <script>
      $(document).ready(function () {

        load_data(1);

        function load_data(page, query = '') {
          $.ajax({
            contentType: "application/json; charset=utf-8",
            url: "featured_banner_action.php?type=loadData",
            method: "POST",
            data: JSON.stringify( {
              page: page,
              query: query
            }),
            success: function (data) {
              // console.log(data.output2);
              var data = JSON.parse(data);
              if(data.code == "202"){
                $('.table_centerd').html(data.response);
                $("#paginate").html(data.pagenate);
              } else if (data.code == "206") {
              console.log("Failed to Delete"+data.message);
              // $('.table_centerd').html('<tr><td colspan="5">No Data Found</td></tr>');
            }
             
            }
          });
        }

        $(document).on('click', '.page-link', function () {
          var page = $(this).data('page_number');
          var query = $('#featured-search').val();
          $('#page-no').val(page);
          load_data(page, query);
        });


        $('#featured-search').keyup(function () {
          var query = $('#featured-search').val();
          load_data(1, query);
        });

        // Delete Banner

        $(document).on('click', '#deletebanner', function () {
          var banner_id = $(this).data('id');
          var query = $('#featured-search').val();
          var page_no = $('#page-no').val();
          // load_data(page, query);
          $.ajax({
              contentType: "application/json; charset=utf-8",
              url: "featured_banner_action.php?type=delete_Banner",
              type: "POST",
              data: JSON.stringify({
                id: banner_id,

              }),
              success: function (data) {

                ////alert(data);

                if (data == "202") {
                  ///alert("Successfully Deleted");
                  console.log("Successfully Deleted");
                  load_data(page_no,query);
                  // $("#banner_row" + id).remove();
                  // refreshSubAndChildCategoryData();
                } else if (data == "206") {
                  ///alert("Failed to Delete");
                  console.log("Failed to Delete");
                }

              }
            });
        });

        // banner switch

        $(document).on('change', '.banner_switch', function () {
          var banner_id = $(this).data('id');
          var enable_val = $(this).val();
          var query = $('#featured-search').val();
          var page_no = $('#page-no').val();
          console.log(banner_id,enable_val);
          if(enable_val == "0"){
            enable_val = "1";

          }else {
            enable_val = "0";
          }
          // load_data(page, query);
          $.ajax({
              contentType: "application/json; charset=utf-8",
              url: "featured_banner_action.php?type=update_banner",
              type: "POST",
              data: JSON.stringify({
                id: banner_id,
                enable: enable_val

              }),
              success: function (data) {

                ////alert(data);

                if (data == "202") {
                  ///alert("Successfully Deleted");
                  console.log("Successfully Udated");
                  load_data(page_no,query);
                  // $("#banner_row" + id).remove();
                  // refreshSubAndChildCategoryData();
                } else if (data == "206") {
                  ///alert("Failed to Delete");
                  console.log("Failed to Delete");
                }

              }
            });
        });

        // sleccted value
        
        $(document).on('change', '#banner-type', function () {
          // var banner_id = $(this).data('id');
          var select_type = $(this).val();
          $("#select-type-name").val(select_type);
          // var brand_id;
          // var query = $('#featured-search').val();
          // var page_no = $('#page-no').val();
          console.log(select_type);
          if(select_type == "list"){
           
            // $(".list_brands").hide();
            // $(".list_brands_mul").show();
            // brand_id="#banner-brands-mul";

          }else {
            select_type = "product";
            // $(".list_brands").show();
            // $(".list_brands_mul").hide();
            // brand_id="#banner-brands";
          }
          $(".list_brands").show();
    
          $.ajax({
              contentType: "application/json; charset=utf-8",
              url: "featured_banner_action.php?type=list_of_brands",
            
              success: function (data) {

                var result = JSON.parse(data);
                console.log("Successfully Positioned " + result);

              for (var i = 0; i < result.length; i++) {

                      console.log("Data  Id = " + result[i].id + " Name = " + result[i].name);
                      var n = result[i].id;
                      var name = result[i].name;
                  

                      var text = '<option value="'+n+'">'+name+'</option>';
                      
                    
                      $("#banner-brands").append(text);
                      // $('.selectpicker').selectpicker('refresh');
                     
                    }
              }
            });
        });

        // select products
        $(document).on('change', '#banner-brands', function () {
          // var banner_id = $(this).data('id');
          var select_id = $(this).val();
          // alert(select_id);
          var select_brand = $("#select-type-name").val();
          var brand_id="";
          // var query = $('#featured-search').val();
          // var page_no = $('#page-no').val();
          console.log(select_brand);
          if(select_brand == "list"){
           
            $(".pro_single").hide();
            $(".pro_mul").show();
            brand_id="#banner-pro-mul";

          }else if(select_brand == "product"){
           
            $(".pro_single").show();
            $(".pro_mul").hide();
            brand_id="#banner-pro";
          } else {
            $(".pro_single").hide();
            $(".pro_mul").hide();
          }
          // $(".list_brands").show();
    
          $.ajax({
              contentType: "application/json; charset=utf-8",
              url: "featured_banner_action.php?type=list_of_products",
              type: "POST",
              data: JSON.stringify({
                    brand_id: select_id
              }),
              success: function (data) {
              
                var result = JSON.parse(data);
                console.log("Successfully Positioned " + result);

              for (var i = 0; i < result.length; i++) {

                      console.log("Data  Id = " + result[i].id + " Name = " + result[i].name);
                      var n = result[i].id;
                      var name = result[i].name;
                  

                      var text = '<option value="'+n+'">'+name+'</option>';
                      
                    
                      $(brand_id).append(text);
                      $('.selectpicker').selectpicker('refresh');
                     
                    }
              }
            });
        });

        // add product code

        $(document).on('click', '.addproduct', function () {
          
          var banner_name = $(".feat_banner_name").val();
          var brand_id = $("#banner-brands").val();
          var image = $(".file-upload-image4").attr("src");
          var query = $('#featured-search').val();
          var select_brand = $("#select-type-name").val();
         
          var product_id="";
         
          console.log(select_brand);
          if(select_brand == "list"){

            product_id=$("#banner-pro-mul").val();

          }else if(select_brand == "product"){

            product_id=$("#banner-pro").val();

          } else {
           product_id="";
          }
          // alert(product_id);
                    //  console.log("banner_name : "+banner_name +" : brand_id : "+brand_id+ "image : " + image + "selectbrand : "+select_brand+" product id : " +product_id);
    
          $.ajax({
              contentType: "application/json; charset=utf-8",
              url: "featured_banner_action.php?type=add_featured_banner",
              type: "POST",
              data: JSON.stringify({
                banner_name: banner_name,
                brand_id : brand_id,
                image : image,
                select_brand: select_brand,
                product_id : product_id
                  
              }),
              success: function (data) {
              
                if(data == "202"){
                  console.log("successfully");
                  load_data(1,query);
                  $("#add_payment_modal").modal('hide');
                }

             
              }
            });
        });
        
        // update record
        $(document).on('click', '.edit_banner', function () {
          var id =$(this).data('id');
          // alert(id);
          $("#update-id").val(id);
          $("#banner-pro-edit").empty();
          $("#banner-pro-mul-edit").empty();
    
          $.ajax({
              contentType: "application/json; charset=utf-8",
              url: "featured_banner_action.php?type=getData_Update",
              type: "POST",
              data: JSON.stringify({
                id: id,
              
              }),
              success: function (data) {
                var data = JSON.parse(data);
                // console.log(data.length);
                var result=data.response;
                var pro = data.product;
                
                if (data.code == "202") {
                    
                for (var i = 0; i < result.length; i++) {

                      console.log("Data  Id = " + result[i].id + " Name = " + result[i].name + " image = " + result[i].image + " type = " 
                      + result[i].type + " store = " + result[i].store + " product = " + result[i].product_id);
                     
                      $(".banner_edit_option_"+ result[i].store).attr("selected","selected");
                      $(".feat_banner_name_edit").val(result[i].name);
                      $(".image-upload-wrap4").hide();
                      $(".file-upload-content4").show();
                      $(".file-upload-image4").attr("src",result[i].image)
                                // getdata(result[i].store);
                                if(result[i].type == "list"){
                                  $(".type_list").attr("selected","selected");
                                
                                  $(".pro_mul_edit").show();
                                  $(".pro_single_edit").hide();
                                
                                
                                
                                }if(result[i].type == "product") {
                                  $(".type_product").attr("selected","selected");
                                
                                  $(".pro_single_edit").show();
                                  $(".pro_mul_edit").hide();
                                
                                
                                }
                                
         



                    }

                    for (var i = 0; i < pro.length; i++) {

                        console.log("Data  Id = " + pro[i].id + " Name = " + pro[i].name + " image = " + pro[i].selected);
                      
                        var s;
                        if(pro[i].selected){
                          s = "selected";
                        }
                        else {
                          s = "";
                        }
                        var text = '<option id="product_'+pro[i].id+'" '+s+' value="'+pro[i].id+'">'+pro[i].name+'</option>';
                                            
                                           
                                  $("#banner-pro-edit").append(text);
                                  $("#banner-pro-mul-edit").append(text);
                                  $('.selectpicker').selectpicker('refresh');
                                  if(pro[i].selected == "true"){
                                    $("#product_"+pro[i].id).attr("selected","selected");
                                  }
                                 
                                  
                                  




                        }
                          $("#add_payment_modal_edit").modal('show');

                }
             
                
              }
             
             
            });
        });

        // change product

        $(document).on('change', '#banner-brands-edit', function () {
          // var banner_id = $(this).data('id');
          var select_id = $(this).val();
          // alert(select_id);
          var select_brand = $("#banner-type-edit").val();
          var brand_id="";
          $("#banner-pro-edit").empty();
          $("#banner-pro-mul-edit").empty();
          
          // var query = $('#featured-search').val();
          // var page_no = $('#page-no').val();
          console.log(select_brand);
          if(select_brand == "list"){
           
            $(".pro_single_edit").hide();
            $(".pro_mul_edit").show();
            brand_id="#banner-pro-mul-edit";

          }else if(select_brand == "product"){
           
            $(".pro_single_edit").show();
            $(".pro_mul_edit").hide();
            brand_id="#banner-pro-edit";
          } else {
            $(".pro_single_edit").hide();
            $(".pro_mul_edit").hide();
          }
          // $(".list_brands").show();
    
          $.ajax({
              contentType: "application/json; charset=utf-8",
              url: "featured_banner_action.php?type=list_of_products",
              type: "POST",
              data: JSON.stringify({
                    brand_id: select_id
              }),
              success: function (data) {
              
                var result = JSON.parse(data);
                console.log("Successfully Positioned " + result);

              for (var i = 0; i < result.length; i++) {

                      console.log("Data  Id = " + result[i].id + " Name = " + result[i].name);
                      var n = result[i].id;
                      var name = result[i].name;
                  

                      var text = '<option value="'+n+'">'+name+'</option>';
                      
                    
                      $(brand_id).append(text);
                      $('.selectpicker').selectpicker('refresh');
                     
                    }
              }
            });
        });
        
        // add update button

        $(document).on('click', '.addupdate', function () {
          var update_id =$("#update-id").val();
          
          var banner_name = $(".feat_banner_name_edit").val();
          var brand_id = $("#banner-brands-edit").val();
          var image = $(".file-upload-image4").attr("src");
          var query = $('#featured-search').val();
          var select_brand = $("#banner-type-edit").val();
         
          var product_id="";
         
          console.log(select_brand);
          if(select_brand == "list"){

            product_id=$("#banner-pro-mul-edit").val();

          }else if(select_brand == "product"){

            product_id=$("#banner-pro-edit").val();

          } else {
           product_id="";
          }
          // alert(product_id);
                    //  console.log("banner_name : "+banner_name +" : brand_id : "+brand_id+ "image : " + image + "selectbrand : "+select_brand+" product id : " +product_id);
    
          $.ajax({
              contentType: "application/json; charset=utf-8",
              url: "featured_banner_action.php?type=update_featured",
              type: "POST",
              data: JSON.stringify({
                id :update_id,
                banner_name: banner_name,
                brand_id : brand_id,
                image : image,
                select_brand: select_brand,
                product_id : product_id
                  
              }),
              success: function (data) {
              
                if(data == "202"){
                  console.log("successfully");
                  load_data(1,query);
                  $("#add_payment_modal_edit").modal('hide');
                  $(".image-upload-wrap4").show();
                  $(".file-upload-content4").hide();
                 
                }

             
              }
            });
        });
        
        $(document).on('click','.addfeatued_btn',function (){
                 $(".image-upload-wrap4").show();
                  $(".file-upload-content4").hide();
        });



      });

     
    </script>

</body>

</html>