<?php 
/*
* Template Name: Download Form
*/
get_header(); 
$result = array('Resident Individual' ,'NRI' ,'HUF' ,'Trust' ,'Corporate' ,'LLP' ,'Resident but Foreign National' ,'Partnership');
//$results_1 = array('Acount opening','Kotak Closure','Part Redemption ','KYC Change ','Kotak Add Nominee');
$results_1 = array('Acount opening');
?>
<div id="full-content" class="about-page">
    <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
        <section style="background-image: url('<?php echo home_url(); ?>/wp-content/uploads/2018/11/about-banner-bg.jpg');"  class="about-banner-bg">
            <div class="container">
                <h1 class="page-title-cus">Forms</h1>
            </div>
        </section>
        
        <div class="container">
            <div class="row">
                  <div class="col-lg-12 col-md-12">
                      <form>
                      <div class="home-contact-tabs contact-us mb-5">
                              <div class="col-lg-12 col-md-12 mt-5 mb-5">
                                  <div class="row">
                                      <div class="col-lg-3 col-md-6">Select Type of Form</div>
                                      <div class="col-lg-4 col-md-6">
                                          <select name="type_of_form" id="type_of_form" class="required">
                                                <option value="">Select Type of Form</option>
                                                    <?php
                                                    foreach( $results_1 as $value ) { ?>
                                                      <option value="<?php echo $value; ?>"><?php echo $value; ?></option>
                                                    <?php
                                                    }
                                                  ?>
                                           </select>
                                      </div>
                                   </div>
                                  <div class="row">
                                      <div class="col-lg-3 col-md-6">Select Type of Account</div>
                                      <div class="col-lg-4 col-md-6">
                                          <select name="type_of_account" id="type_of_account" class="required">
                                                <option value="">Select Type of Account</option>
                                                    <?php
                                                    foreach( $result as $value ) { ?>
                                                      <option value="<?php echo $value; ?>"><?php echo $value; ?></option>
                                                    <?php
                                                    }
                                                  ?>
                                           </select>
                                      </div>
                                   </div>
                                   <div class="row" id="download_link">
                                     <div class="col-lg-3 col-md-6">&nbsp;</div>
                                      <div class="col-lg-4 col-md-6" id="download_file_name"></div>
                                   </div>
                                   <div class="row" id="download_link_error">
                                     <div class="col-lg-3 col-md-6">&nbsp;</div>
                                      <div class="col-lg-4 col-md-6" id="download_file_name_error" style="color: red"></div>
                                   </div>
                                  <div class="col-lg-12" id="fo-s-bt" align="center">
                                      <input type="button" value="Submit" class="wpcf7-form-control wpcf7-submit" id="get_data">
                                  </div>
                               </div>
                       </div>
                      </form>          
                  </div>

            </div>
            <div class="row">
                <div class="col-lg-12 col-md-12 mt-5 mb-5">
                    <h3 class="text-uppercase text-center section-title">Address</h3>
                    <p class="text-center">Marcellus Investment Managers <br>929, DBS Business Centre, Kanakia Wall Street<br>Andheri-Kurla Road, Andheri – East, Mumbai - 400 093 </p>
                </div>
            </div>
        </div>

    <?php endwhile; endif; ?>
</div>
<script type='text/javascript'>
jQuery(document).ready(function($){
 $("#type_of_account").change(function(){
    $('#get_data').show();
    $('#download_file_name').html('');
    $('#download_file_name_error').html('');
    //$('#type_of_form option[value=""]').attr('selected','selected');
 });

 $("#type_of_form").change(function(){
    $('#get_data').show();
    $('#download_file_name').html('');
    $('#download_file_name_error').html('');
 });

 var ajax_url = "<?php echo site_url('download_from_ajax.php'); ?>";
  $("#get_data" ).click(function() {
    var data = {
     'type_of_account': $("#type_of_account").val(),
     'type_of_form': $("#type_of_form").val()
    };

    $.ajax({
      url: ajax_url,
      type: 'post',
      data: data,
      dataType: 'json',
      success: function(response){
        if(response.status){
            $('#download_link').show();
            $('#download_file_name').html(response.download_link);            
            $('#get_data').hide();
            $('#download_link_error').hide();
        }else{
          $('#download_link').hide();
          $('#get_data').show();
          $('#download_link_error').show();
          $('#download_file_name_error').html(response.download_link);
        }
      },

    });
  });
});
</script>
  
<?php get_footer(); ?>

