
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>  
<%@ taglib prefix="sjs" uri="/struts-jquery-tags"  %>

<script lang="javascript" type="text/javascript"> 

 window.onload = function() {
	  document.getElementById("customerName").focus();
	
	 	 
	};

</script>

<div align="center" style="margin-top: 10px; ">
		<div class="ui-widget">
		<s:form method="post" name="addCustomerPaymentReminder" action="addCustomerPaymentReminder" theme="simple" enctype="multipart/form-data" acceptcharset="UTF-8" >
	
<table class="table table-bordered" style="height: 110px; width: 750px; font-size: 14px; ">


<tr  style="font-weight: bold; background-color: rgb(234,234,234);">
<td colspan="2" align="center">
Add Customer Payment Reminder
</td>
</tr>


<s:if test="hasActionErrors()" >
<tr>
<td colspan="2" align="center" >  
     
    <div class="alert alert-danger">
 	 <strong><s:property value="getText('header.error')" />! </strong>
     
      <s:iterator var="error" value="%{errorMessages}">
        <s:property value="%{error}"/>
    </s:iterator>
	</div>
      
</td>
</tr>
</s:if>

<s:if test="hasActionMessages()" >
<tr>
<td colspan="2" style="font-size: medium; height:30px; color: green;" align="center" >  
    
    <div class="alert alert-success">
  	<strong><s:property value="getText('header.success')" />! </strong>
   	<s:iterator var="message" value="%{actionMessages}">
        <s:property value="%{message}"/>
    </s:iterator>
    </div>
  
 



</td>
</tr>
</s:if>
<tr>
<td>Payment Reminder Add Date *</td>
<td  align="left" >
<s:textfield  id="paymentReminderAddDate" name="paymentReminderAddDate" cssClass="textBoxSmall" readonly="true"/>
</td>
</tr>

<tr>

 
<td align="left">Customer Name * </td>
<td>
<s:url id="customerList" action="databaseCustomerJSON" />
<sjs:autocompleter 				href="%{customerList}" 
								name="customerName" list="customerList" 
								id="customerName" 
								loadMinimumCount="2"								
								placeholder="Customer Name" 
								tabindex="1" 
								cssClass="textBoxMedium"
								onfocus="this.select();" onselect="this.select();"/>
								</td>
</tr>
<tr>
<td align="left">Outstanding Amount * </td>
<td>
<sjs:textfield id="outstandingAmount" name="outstandingAmount" cssClass="textBoxSmall" readonly="true"></sjs:textfield>
</td>
</tr>


<tr>
<td >Next Payment Promise Date*</td>
<td  align="left">
<sjs:datepicker displayFormat="dd-mm-yy" 
               timepicker="true" 
               name="paymentPromiseDate"
			   id="paymentPromiseDate"			 
			   changeMonth="true"
			   changeYear="true" 
			   readonly="true"
			   placeholder="Promise Date" cssClass="textBoxSmall" tabindex="2"/>
 
</td>
</tr>

<tr>
<td>Comments</td>
<td  align="left">
<s:textarea  rows="1" cols="20" id="comments" name="comments"  placeholder="Comments" tabindex="3" cssClass="textBoxMedium"/>
</td>
</tr>
 <tr>
  <td colspan="2" align="center">
   <button id="submit" name="submit" type='submit' class='btn btn-primary btn-sm ' tabindex="4">Add Reminder Details</button>
  </td>
  </tr>
</table>
</s:form>
</div>
</div>

<script type="text/javascript">

$(document).ready(function () 
		{
			
			jQuery.noConflict();(function( $ ) {
		
$('#customerName').keypress(function (e) 
		{
		    if (e.which == 13) {
		        e.preventDefault();            
		        $('#paymentPromiseDate').focus();
		    }
		});


$('#paymentPromiseDate').keypress(function (e) 
		{
		    if (e.which == 13) {
		        e.preventDefault();            
		        $('#comments').focus();
		    }
		});
		
$('#comments').keypress(function (e) 
		{
		    if (e.which == 13) {
		        e.preventDefault();            
		        $('#submit').focus();
		    }
		});
		


$('#customerName').focusout(function(){
    // Make the ajax request
    $.ajax({
        url: 'getCustomerCreditAmount',
        data: "customerName=" + $(customerName).val(),
        dataType: "json",
        success: function(data) {    
            // Set the inputs from the json object            
         
        	 $('#outstandingAmount').val(data.outstandingAmount);   	
	  	
            
        } 
    });
});


			})( jQuery );

			
			  
		});
		
</script>
