<?php  
$sqlcon = "SELECT * FROM api_coupan  WHERE api_type='affiliatefuture'";
    
      $myquerycon=$conn->query($sqlcon);
   $mydaracon= $myquerycon->fetchAll()  ;
   
   $rows_foundcon = $myquerycon->rowCount();
    if($rows_foundcon==0){
        $stat='0';
    }else{
         $stat='1';
    }

      foreach( $mydaracon as $rowcon ) {
            $con_id  = $rowcon['rowId'];
            $token   = $rowcon['api_key'];
            $tracking_id   = $rowcon['private_key'];
          //  $network_id = $rowcon['network_id'];
         
      }
?>  
<div class="row">
                                       <div class="col-lg-12 col-md-12">
                                          <div class="merchant-profile-right">
                                             <div class="card">
                                                <div class="card-body">
                                                   <!--Form Affiliatefuture  API Key Begin-->
                                                   <form class="profile-box" action="./backend/affiliatefuture.php" method="post" id="affilliatefuture-form">
                                                      <div class="bottom-line">
                                                         <h6 class="h5 mb-5">Affiliatefuture API Key</h6>
                                                      </div>
                                                      <div class="row">
                                                         <!--Affiliatefuture API Key-->
                                                         <div class="col-md-12">
                                                            <div class="mb-3">
                                                               <label class="fw-bold form-label">Affiliatefuture API Key:</label>
                                                               <input type="text" name="<?=SESS_MASTER ?>api_key" value="<?=$token?>" class="form-control">
                                                            </div>
                                                         </div>
                                                         <!--Affiliatefuture Passcode-->
                                                         <div class="col-md-12">
                                                            <div class="mb-3">
                                                               <label class="fw-bold form-label">Affiliatefuture Passcode:</label>
                                                               <input type="text" name="<?=SESS_MASTER ?>passcode" value="<?= $tracking_id?>" class="form-control">
                                                            </div>
                                                         </div>
                                                         <!--Save-->
                                                         <div class="col-md-12">
                                                         <input type="hidden" class="btn btn-primary btn-lg" name="<?=SESS_MASTER  ?>stat" value="<?=$stat?>">
                 <input type="hidden" class="btn btn-primary btn-lg" name="<?=SESS_MASTER  ?>api_type" value="affiliatefuture" required>
                                                            <button type="submit" class="btn btn-primary mb-3">Save</button>
                                                         </div>
                                                      </div>
                                                      <div id="success" class="text-primary">

                                                       </div>
                                                      <!--Note Bgin-->
                                                      <div class="alert alert-primary fs-14 mt-2" role="alert">
                                                         <strong>Note:</strong>  API requires user authentication. You will need an API key to pass with your requests to provide authentication.
                                                      </div>
                                                      <!--Note End-->
                                                      <!--MEssage BEgin-->
                                                      <div class="alert alert-primary fs-14 mt-2" role="alert">
                                                         <strong>Message :</strong>    you do not have affiliatefuture API , first go to <a href="https://afuk-affiliate.affiliatefuture.com/login.aspx?ReturnUrl=%2f"> Affiliatefuture.com</a> and register on affiliate link. then you can get coupon API. 
                                                      </div>
                                                      <!--MEssage End-->
                                                   </form>
                                                   <!--Form BrandrSkimlinks API Key End-->
                                                </div>
                                             </div>
                                          </div>
                                       </div>
                                    </div>
                                    <script src="./cpages/coupon_api_config/js/jquery-3.4.1.min.js"></script>
                               <script>
                        $('#affilliatefuture-form').on('submit', function(e) {
	
   e.preventDefault();
  var url = $(this).attr('action');
   var formData = new FormData(this);
//alert(formData)
  $.ajax({
     dataType: 'json',
     type: 'POST',
     url: url,
     data: formData,
     cache:false,
      contentType: false,
      processData: false,
     success: function(resp) {
   if(resp.status)
     {
    
      swal("Successfully!", "Affiliate coupon API has been saved!", "success");
     }
    
   //alert('success');
      //console.log(resp);
     },
     error: function(res) {
        console.log('there was a problem checking the fields');
        
     }
  }); 
});
                              </script>