<script> 
function addajaxseries(){   
    document.getElementById("ncd_id").value = $("#applicationno").val();        

    if($('#ncd_id').val() == ''){
        alert('Please select the Application No');
         return false;        
     }
    if($('#freofinterestpayment').val() == ''){        
      alert('Please select the Frequency of interest Payment');
      return false;
    }
    if($('#minimumapplication').val()== ''){        
      alert('Please enter Minimum Application');
      return false;
    }
     if($('#facevalueofncd').val() == ''){        
      alert('Please enter Face Value of NCD(Rs/NCDs)');
      return false;
    }
    if($('#inmultipalofrs').val() == ''){        
      alert('Please enter In Multipal of Rs)');
      return false;
    }
    if($('#tenor').val() == ''){        
      alert('Please enter Tenor from Deemed Date of Allotment');
      return false;
    }
    if($('#couponofcategory').val() == ''){
        alert('Please enter Coupon(% per annum) of Category');
         return false;        
     }
    if($('#effectiveyieldforcategory').val() == ''){        
      alert('Please enter the Effective Yield for Category');
      return false;
    }
    if($('#amountonmaturityforcategory').val()== ''){        
      alert('Please enter Amount on Maturity for Category');
      return false;
    }
    if($('#maturitydate').val() == ''){        
      alert('Please enter Mturity Date');
      return false;
    }
    if($('#noofncdsapply').val() == ''){        
      alert('Please enter No of NCDs Apply');
      return false;
    }
    else {  
        $.ajax({
            type: 'get',
            url:  "../saveAjaxseries/",
            data: $('form#addajaxseries').serialize(),
            beforeSend: function(xhr) {
                    xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
            },
            success: function(response) {                      
                //var stringArray = (new Function("return [" + response + "];")());
                document.getElementById("seriesDetail").innerHTML = response;  
            },
            error: function(e) {
                   // alert("An error occurred: " + e.responseText.message);
                   // console.log(e);
            }
        });
    }
}
 </script>   
<div class="searies form large-9 medium-8 columns content">
     <?= $this->Form->create($seary,['id'=>'addajaxseries']) ?>
    <fieldset>
        <legend><?= __('Add Series') ?></legend>
       <div class="addmenu-col">
		<div class="subdiv-col">
		
		<fieldset class="fieldset2">
        <legend >Series</legend>
		<div class="column-box">
        <?php
            echo $this->Form->input('ncd_id', ['label' => 'NCDs Application Id','options' => $ncds,'type'=>'hidden']);
            $fripayment = array('cumulative' => 'Cumulative', 'monthly' => 'Monthly', 'annual' => 'Annual');
            echo $this->Form->input('freofinterestpayment',['label' => 'Frequency of interest Payment','options' => $fripayment]);
            echo $this->Form->input('minimumapplication',['label' => 'Minimum Application']);
            echo $this->Form->input('facevalueofncd',['label' => 'Face Value of NCD(Rs/NCDs)','type'=>'text']);
            echo $this->Form->input('inmultipalofrs',['label' => 'In Multipal of Rs','type'=>'text']);
            $tenor = array('400days' => '400 Days', '3year' => '3 Year', '5year' => '5 Year');
            echo $this->Form->input('tenor',['label' => 'Tenor from Deemed Date of Allotment','options' => $tenor]);
            echo $this->Form->input('couponofcategory',['label' => 'Coupon(% per annum) of Category']);
            echo $this->Form->input('effectiveyieldforcategory',['label' => 'Effective Yield for Category']);
            echo $this->Form->input('amountonmaturityforcategory',['label' => 'Amount on Maturity for Category']);
            $maturitydate = array('400days' => '400 Days', '3year' => '3 Year', '5year' => '5 Year');
            echo $this->Form->input('maturitydate',['label' => 'Maturity Date(from Deemed date of Allotment)','options' => $maturitydate]);
            echo $this->Form->input('noofncdsapply',['label' => 'No of NCDs Apply','type'=>'text']);
        ?>
     </div>
  
    </fieldset>
        <div class="modal-footer">	   
            <button type="button" class="btn btn-primary" onclick="javascript:addajaxseries();">Save</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
	</div> 	
    <?= $this->Form->end() ?>
</div>
