<?php session_start();
include("./../config/config.php");  
include("./backend/validated_admin.php");  

?>
<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="UTF-8">
      <title>Fetch Data - iCouponWorld | Coupons | Discounts| Promo Codes</title>
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <link id="favicon" rel="icon" type="image/x-icon" href="../images/web-images/home/favicon.png">
      <meta name="robots" content="index, follow" />
      <meta name="author" content="Design Collection">
      <meta name="description" content="iCouponWorld stores may offer a wide range of products, from clothing and accessories to electronics and home goods, and they may sell products from multiple brands or their own proprietary products.">
      <meta name="keywords" content="iCouponWorld stores, products, coupon, coupon code, promo code, cashback, offer, promotion, deal">
      <link rel="canonical" href="fetch-data.php"/>
      <!-- Viewport configuration, scaling options -->
      <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
      <!-- Bootstrap CSS -->
      <link href="../css/icouponworld.css" rel="stylesheet">
      <!-- CSS Stylesheet -->
      <link href="../css/dashboard.css" rel="stylesheet">
      <!-- Font Awesome icon -->
      <link href="../fontawesome/css/fontawesome.css" rel="stylesheet" />
      <!-- Roboto font  -->
      <link rel="preconnect" href="https://fonts.googleapis.com">
      <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
      <link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;1,100;1,300;1,400;1,500;1,700&display=swap" rel="stylesheet">
      <style>
        .lds-dual-ring.hidden { 
display: none;
}
.lds-dual-ring {
  display: inline-block;
  width: 80px;
  height: 80px;
}
.lds-dual-ring:after {
  content: " ";
  display: block;
  width: 64px;
  height: 64px;
  margin: 5% auto;
  border-radius: 50%;
  border: 6px solid #fff;
  border-color: #fff transparent #fff transparent;
  animation: lds-dual-ring 1.2s linear infinite;
  top: 27%;
    position: absolute;
    left: 50%;
}
@keyframes lds-dual-ring {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}


.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0,0,0,.8);
    z-index: 999;
    opacity: 1;
    transition: all 0.5s;
}

      </style>
      <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
      <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
      <![endif]-->
   </head>
   <body>
      <!--unique id begin -->
      <div id="s_mm">
         <!--scroll-top Begin-->
         <div id="scroll-top">
            <!--sidebarwrapper Begin-->
            <div id="sidebarwrapper">
               <!--Sidebarmenu Begin-->
              <?php include("./includefiles/sidebar.php"); ?>
               <!--Sidebarmenu End-->
               <!--content-wrapper Begin-->
               <div id="content-wrapper" class="d-flex flex-column dashboard-navbar">
                  <div id="maincontent">
                     <!-- Navbar Topbar Begin-->
                       <?php include("./includefiles/header.php"); ?>
                       <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
                     <!-- Navbar Topbar End-->
                     <!-- Container Begin-->
                     <div class="container-fluid px-4">
                        <div class="d-sm-flex align-items-center justify-content-between mb-4">
                           <h3>
                              Fetch Data
                           </h3>
                        </div>
                        <?php include("./includefiles/coupon_count.php"); ?>
                        <form>
                           <div class="row">
                              <!--Fetch Coupon Data Begin-->
                              <div class="col-md-6">
                                 <div class="card border-0  shadow mb-4">
                                    <div class="card-header bg-white border-bottom py-3">
                                       <h6 class="m-0 fw-bold text-inherit">Coupon data</h6>
                                    </div>
                                    <div class="card-body">
                                       <div class="row">
                                          <div class="col-md-12">
                                             <div class="mb-3">
                                                <label for="affiliatefuture " class="form-label">Fetch Coupon Data</label>
                                                <select class="form-select mb-3" aria-label=".form-select-lg example" id="coupon_fetch">
                                                <!-- <option value="vcommission" selected>Vcommission</option> -->
                                                <!-- <option value="Icubeswire">Icubeswire</option> -->
                                                <option value="admitad">Admitad</option>
                                                   <!-- <option value="affiliatefuture">Affiliatefuture</option> -->
                                                   <option value="awin">Awin</option>
                                                   <option value="brandreward">Brandreward</option>
                                                   <!-- <option value="cuelinks">Cuelinks</option> -->
                                                   <!-- <option value="flipkart" selected>Flipkart</option> -->
                                                   <!-- <option value="optimisemedia">Optimisemedia</option> -->
                                                 
                                                  
                                                   <option value="skimlinks">Skimlinks</option>
                                                  
                                                   <option value="tradedoubler">Tradedoubler</option>
                                                  <!-- <option value="2performant">2Performant</option> -->
                                                 
                                                </select>
                                             </div>
                                          </div>
                                        
                                          <!--Note Begin-->
                                          <div class="col-md-12">
                                             <div class="alert alert-primary fs-14" role="alert">
                                                <strong>Important message:</strong>   If you collect coupons from the Brandreward, Skimlinks. Every time a button is clicked. you will get skimlinks 100 coupons and 1000 coupon bardreward. If you want more bardreward, skimlinks coupons. you can click on the button any number of times.<span class="fw-bold"> How to fetch awin coupon data read <a href="https://www.icouponworld.com/documentation/fetch-data.html">our documentation</a>.</span>
                                             </div>
                                             <div class="alert alert-primary fs-14" role="alert">
                                                <strong>Note:</strong>   If you do not fetch the coupons of any affiliate company, then you can click on the start button two to three times.
                                             </div>
                                          </div>
                                          <!--Note End-->
                                          <div class="col-md-12">
                                             <button type="button" id="fetch_coupon" class="btn btn-primary mb-3">Start</button>
                                          </div>
                                       </div>
                                    </div>
                                    <div id="loader" class="lds-dual-ring hidden overlay">
                                       <h5 class="text-white text-dual-ring text-inherit">Do not click the back button or refresh the page. uploading of data is underway!..</h5>
                                    </div>
                                 </div>
                              </div>
                              <!--Fetch Product Data Begin-->
                              <div class="col-md-6">
                                 <div class="card border-0  shadow mb-4">
                                    <div class="card-header bg-white border-bottom py-3">
                                       <h6 class="m-0 fw-bold text-inherit">Product data</h6>
                                    </div>
                                    <div class="card-body">
                                       <div class="row">
                                          <div class="col-md-12">
                                             <div class="mb-3">
                                                <label for="affiliatefuture " class="form-label">Fetch Product Data</label>
                                                <select class="form-select mb-3" aria-label=".form-select-lg example" id="product_fetch">
                                                  <option  selected>Select</option>
                                                   <option value="awin">Awin</option>
                                                </select>
                                             </div>
                                          </div>
                                          <!--Important message Begin-->
                                          <div class="col-md-12">
                                             <div class="alert alert-primary fs-14" role="alert">
                                                <strong>Important message:</strong>   How to fetch awin product data read <a href="https://www.icouponworld.com/documentation/fetch-data.html">our documentation</a>.
                                             </div>
                                          </div>
                                          <!--Important message End-->
                                
                                          <div class="col-md-12">
                                             <button type="button" id="fetch_product" class="btn btn-primary mb-3">Start</button>
                                          </div>
                                          <?php
                                             if( $_SESSION['message']){?>
                                                <div class="alert alert-primary fs-14" role="alert">
                                                <strong>Invalid File</strong></div>
                                                <?php
                                             }unset($_SESSION['message']);
                                             if( $_SESSION["uploaded"]){?>
                                                <div class="alert alert-primary fs-14" role="alert">
                                                <strong>Congratulations!</strong>All Coupon deta uploaded successfully!</div>
                                                <?php
                                             }unset($_SESSION['uploaded']);
                                          ?>
                                       </div>
                                    </div>
                                 </div>
                              </div>
                           </div>
                        </form>
                     </div>
                     <!-- Container End-->
                  </div>
                  <!--Copyright Begin-->
                 <?php include("./includefiles/footer.php"); ?>
                  <!--Copyright End-->
               </div>
               <!--content-wrapper End-->
            </div>
            <!--sidebarwrapper End-->

       <div class="modal fade" id="productModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Upload Awin Product CSV File</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <form action="./backend/upload_csv_awin_product.php" method="post" enctype="multipart/form-data">
                                                <div class="row">
                                                   <div class="col-md-12">
                                                      <div class="mb-5">
                                                         
                                                         <input type="file" name="upload_data" class="form-control">
                                                      </div>
                                                   </div>
                                                
                                                   <div class="col-md-12 text-end">
                                                    
                                                       <input name="upload_data" type="hidden" value="slider" class="form-control">
                                                     
                                                      <button type="submit" class="btn btn-primary my-2">Upload</button>
                                                   </div>
                                                </div>
                                             </form>
      </div>
   
    </div>
  </div>
</div>



   <div class="modal fade" id="couponModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Upload Awin Coupon CSV File</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <form action="./backend/upload_csv_awin.php" method="post" enctype="multipart/form-data">
                                                <div class="row">
                                                   <div class="col-md-12">
                                                      <div class="mb-5">
                                                         
                                                         <input type="file" name="upload_data" class="form-control">
                                                      </div>
                                                   </div>
                                                
                                                   <div class="col-md-12 text-end">
                                                  
                                                       <input name="upload_data" type="hidden" value="slider" class="form-control">
                                                      
                                                      <button type="submit" class="btn btn-primary my-2">Upload</button>
                                                     
                                                   </div>
                                                </div>
                                             </form>
      </div>
     
    </div>
  </div>
</div>

<div class="modal fade" id="admitadcouponModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Upload Admitad Coupon CSV File</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
      <div class="alert alert-primary fs-14" role="alert">
             <strong>Note:</strong>  First you does download excel file to admited and convert in csv through this Link  <a target="_blank" href="https://cloudconvert.com/xlsx-to-csv">Excel to CSV</a>
         </div>
        <form action="./backend/upload_csv_admitad.php" method="post" enctype="multipart/form-data">
                                                <div class="row">
                                                   <div class="col-md-12">
                                                      <div class="mb-5">
                                                         
                                                         <input type="file" name="upload_data" class="form-control">
                                                      </div>
                                                   </div>
                                                
                                                   <div class="col-md-12 text-end">
                                                  
                                                       <input name="upload_data" type="hidden" value="slider" class="form-control">
                                                      
                                                      <button type="submit" class="btn btn-primary my-2">Upload</button>
                                                     
                                                   </div>
                                                </div>
                                             </form>
                                             
      </div>
     
    </div>
  </div>
</div>
            <!--Scroll to top Begin-->
            <a class="scroll-to-top rounded" href="#scroll-top">
            <i class="fas fa-angle-up"></i>
            </a>
            <!--Scroll to top End-->
            <!-- Jquery Script Begin-->
           
            <script src="../js/jquery-3.4.1.min.js"></script>
            <!-- Jquery Script End-->
            <!-- Bootstrap Script Begin-->
            <script src="../js/bootstrap.bundle.min.js"></script>
            <!-- Bootstrap Script End-->
            <!-- dashboard-icouponworld.js Begin -->
            <script src="../js/dashboard-icouponworld.js"></script>
            <!-- dashboard-icouponworld.js End -->
              <!-- sweetalert.min.js Script Begin-->
           <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
             <!-- sweetalert.min.js Script End-->
            
         </div>
         <!--scroll-top End-->
      </div>
      <!--unique id End -->
       <!-- fetch_coupon and fetch product Script Begin-->
      <script>
         $(document).ready(function() {
              $('#fetch_coupon').click(function() {
               $.ajax({
                url : './backend/coupon_fetch.php',
                data : {
                    api_type : $('#coupon_fetch').val()
                },
                 beforeSend: function() {
        $('#loader').removeClass('hidden')
    },
               success : function(responseText) {
               	var res=JSON.parse(responseText);
              
               	if(res.api=='awin'){
               		  $("#couponModal").modal('show');
               	}
                  else if(res.api=='admitad'){
               		  $("#admitadcouponModal").modal('show');
               	}
                  else{
                     swal("Congratulations!","All Coupon deta uploaded successfully!","success");

                  }
              
              $('#ajaxGetUserServletResponse').text(responseText);
              $('#loader').addClass('hidden');
      
                     

                          

                  
         }
      });
   });
});


         $(document).ready(function() {
              $('#fetch_product').click(function() {
               $.ajax({
                url : './backend/product_fetch.php',
                data : {
                    api_type : $('#product_fetch').val()
                },
                 beforeSend: function() {
        $('#loader').removeClass('hidden')
    },
               success : function(responseText) {
                  var res=JSON.parse(responseText);
              
                if(res.api=='awin'){
                    $("#productModal").modal('show');

                       

                }
              $('#ajaxGetUserServletResponse').text(responseText);
         },
  complete: function(){
        $('#loader').addClass('hidden');
        

    }
      });
   });
});

      </script>
      <!-- fetch_coupon and fetch product Script End-->
   </body>
</html>
