home *** CD-ROM | disk | FTP | other *** search
/ 61.19.244.139 / 61.19.244.139.zip / 61.19.244.139 / 2015-02-19 / views / agent-broker-setup-add.jsp < prev    next >
Text File  |  2015-02-19  |  20KB  |  616 lines

  1.  
  2. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  3. <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
  4. <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
  5. <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
  6. <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  7.  
  8. <form:form class="form-horizontal well" action="" id="frmAgentDetailSetup" name="frmAgentDetailSetup" method="POST" modelAttribute="agentDetailBean">
  9.                 <div class="widget-content">
  10.                     <div class="widget-box">
  11.  
  12.                         <fieldset>
  13.  
  14.                             <div class="box-tab">
  15.                                 <div class="tabbable">
  16.                                     <ul class="nav nav-tabs">
  17.                                         <li class="active"><a data-toggle="tab" href="#tab1"><i class="black-icons blocks_images"></i> α╕úα╕▓α╕óα╕Ñα╕░α╣Çα╕¡α╕╡α╕óα╕öα╕òα╕▒α╕ºα╣üα╕ùα╕Ö</a></li>
  18.                                         <li><a data-toggle="tab" href="#tab2"><i class="black-icons blocks_images"></i> α╕üα╕Ñα╕╕α╣êα╕í</a></li>
  19.                                         <li class=""><a data-toggle="tab" href="#tab3"><i class="black-icons abacus"></i> α╕úα╕▓α╕óα╕Ñα╕░α╣Çα╕¡α╕╡α╕óα╕ö</a></li>
  20.                                         <li><a data-toggle="tab" href="#tab4"><i class="black-icons abacus"></i> α╕üα╕│α╕½α╕Öα╕öα╕ºα╕çα╣Çα╕çα╕┤α╕Ö</a></li>
  21.  
  22.                                     </ul>
  23.  
  24.                                     <div class="tab-content">
  25.  
  26.                                         <!-- Tab1 -->
  27.                                         <div id="tab1" class="tab-pane active">
  28.                                             <div class=" row-fluid">
  29.  
  30.                                                 <div class="control-group">
  31.                                                     <label class="control-label" for="input01">α╕òα╕▒α╕ºα╣üα╕ùα╕Ö</label>
  32.                                                     <div class="controls">
  33.                                                         <form:input class="input-small" type="text" placeholder="α╕úα╕½α╕▒α╕¬α╕òα╕▒α╕ºα╣üα╕ùα╕Ö" name="agentId" id="agentId" path="agentId"/> 
  34.                                                         <form:input class="input-xlarge" type="text" placeholder="α╕èα╕╖α╣êα╕¡α╕òα╕▒α╕ºα╣üα╕ùα╕Ö" name="agentName" id="agentName" path="agentName"/>
  35.                                                     </div>
  36.                                                 </div>
  37.  
  38.  
  39.                                                 <div class="control-group">
  40.                                                     <label class="control-label" for="input02">α╕ùα╕╡α╣êα╕¡α╕óα╕╣α╣ê</label>
  41.                                                     <div class="controls">
  42.  
  43.                                                         <form:input class="input-xxlarge" type="text" id="address1" name="address1" path="address1" placeholder="α╕Üα╣ëα╕▓α╕Öα╣Çα╕Ñα╕éα╕ùα╕╡α╣ê α╕òα╕úα╕¡α╕ü α╕ïα╕¡α╕ó α╕ûα╕Öα╕Ö"/>
  44.                                                     </div>
  45.                                                 </div>
  46.  
  47.                                                 <div class="control-group">
  48.                                                     <label class="control-label" for="input02">α╕êα╕▒α╕çα╕½α╕ºα╕▒α╕ö</label>
  49.                                                     <div class="controls multiline-input">
  50.  
  51.  
  52.                                                         <form:select  class="input-medium" id="province" name="provinceId" path="provinceId">
  53.                                                             <c:if test="${not empty refProvinceBeanList}">
  54.                                                                 <c:forEach var="listValue" items="${refProvinceBeanList}">
  55.                                                                     <form:option value="${listValue.provCode}">${listValue.provName}</form:option>
  56.                                                                 </c:forEach>
  57.                                                             </c:if>
  58.                                                         </form:select> 
  59.                                                         
  60.                                                       
  61.                                                         
  62.                                                         <form:select path="amphurId" id="amphur"  class="input-medium"></form:select>
  63.                                                          
  64.                                                         <form:select path="tambonId" id="tambol"  class="input-medium"></form:select>
  65.                                                      
  66.                                                     </div>
  67.  
  68.                                                 </div>
  69.                                                 <div class="control-group">
  70.                                                     <label class="control-label" for="input02">α╕úα╕½α╕▒α╕¬α╣äα╕¢α╕úα╕⌐α╕ôα╕╡α╕óα╣î</label>
  71.                                                     <div class="controls">
  72.  
  73.                                                         <form:input class="autoZipCode input-small" type="text" name="prbZipcode" path="prbZipcode" id="prbZipcode" placeholder="α╕úα╕½α╕▒α╕¬α╣äα╕¢α╕úα╕⌐α╕ôα╕╡α╕óα╣î"/>
  74.                                                     </div>
  75.                                                 </div>
  76.                                                 <div class="control-group">
  77.  
  78.                                                     <label class="control-label" for="input02">α╕ùα╕╡α╣êα╕¡α╕óα╕╣α╣êα╕êα╕öα╕ùα╕░α╣Çα╕Üα╕╡α╕óα╕Öα╕éα╕▓α╕ó α╕₧α╕úα╕Ü.</label>
  79.                                                     <div class="controls">
  80.  
  81.                                                         <form:input class="input-xxlarge" type="text" id="prbAddress1" name="prbAddress1" path="prbAddress1" placeholder="α╕Üα╣ëα╕▓α╕Öα╣Çα╕Ñα╕éα╕ùα╕╡α╣ê α╕òα╕úα╕¡α╕ü α╕ïα╕¡α╕ó α╕ûα╕Öα╕Ö"/>
  82.                                                     </div>
  83.                                                 </div>
  84.  
  85.                                                 <div class="control-group">
  86.                                                     <label class="control-label" for="input02">α╕êα╕▒α╕çα╕½α╕ºα╕▒α╕ö</label>
  87.                                                     <div class="controls multiline-input">
  88.  
  89.  
  90.                                                         <form:select  class="input-medium" id="prbProvinceId" name="prbProvinceId" path="prbProvinceId">
  91.                                                          
  92.                                                             <c:if test="${not empty refProvinceBeanList}">
  93.                                                                 <c:forEach var="listValue" items="${refProvinceBeanList}">
  94.                                                                     <form:option value="${listValue.provCode}">${listValue.provName}</form:option>
  95.                                                                 </c:forEach>
  96.                                                             </c:if>
  97.                                                         </form:select> 
  98.                                                          
  99.                                                         <form:select path="prbAmphurId" id="prbAmphurId"  class="input-medium"></form:select>
  100.                                                         <form:select path="prbTambonId" id="prbTambonId"  class="input-medium"></form:select>
  101.                                                           </div>
  102.  
  103.                                                 </div>
  104.                                                 <div class="control-group">
  105.                                                     <label class="control-label" for="input02">α╣Çα╕Ñα╕éα╕ùα╕╡α╣êα╣âα╕Üα╕¡α╕Öα╕╕α╕ìα╕▓α╕òα╕┤</label>
  106.                                                     <div class="controls">
  107.  
  108.                                                         <form:input path="licenseCode" class="input-small" type="text" placeholder="α╣Çα╕Ñα╕éα╕ùα╕╡α╣êα╣âα╕Üα╕¡α╕Öα╕╕α╕ìα╕▓α╕òα╕┤" id="licenseCode" name="licenseCode"/> 
  109.                                 
  110.                                                         <form:checkbox   value="Y" name="licenseOwn" id="licenseOwn" path="licenseOwn"/>
  111.                                                         α╣Çα╕êα╣ëα╕▓α╕éα╕¡α╕çα╣âα╕Üα╕¡α╕Öα╕╕α╕ìα╕▓α╕òα╕┤
  112.  
  113.                                                     </div>
  114.                                                 </div>
  115.                                                 <div class="control-group">
  116.                                                     <label class="control-label">α╕¢α╕úα╕░α╣Çα╕áα╕ùα╕òα╕▒α╕ºα╣üα╕ùα╕Ö</label>
  117.                                                     <div class="controls">
  118.  
  119.                                                
  120.                                             <form:radiobutton name="agentType" path="agentType" id="agentType" value="AC" class="radio-b" />
  121.                                               α╕òα╕▒α╕ºα╣üα╕ùα╕Öα╕Öα╕┤α╕òα╕┤α╕Üα╕╕α╕äα╕äα╕Ñ   
  122.                                             <form:radiobutton name="agentType" path="agentType" id="agentType" value="AP" class="radio-b" />
  123.                                               α╕òα╕▒α╕ºα╣üα╕ùα╕Öα╕Üα╕╕α╕äα╕äα╕Ñα╕ÿα╕úα╕úα╕íα╕öα╕▓ <br />    
  124.                                             <form:radiobutton name="agentType" path="agentType" id="agentType" value="BC" class="radio-b" />
  125.                                               α╕Öα╕▓α╕óα╕½α╕Öα╣ëα╕▓α╕Öα╕┤α╕òα╕┤α╕Üα╕╕α╕äα╕Ñ    
  126.                                             <form:radiobutton name="agentType" path="agentType" id="agentType" value="BP" class="radio-b" />
  127.                                               α╕Öα╕▓α╕óα╕½α╕Öα╣ëα╕▓α╕Üα╕╕α╕äα╕äα╕Ñα╕ÿα╕úα╕úα╕íα╕öα╕▓
  128.  
  129.                                         </div>
  130.                                                 </div>
  131.                                             </div>
  132.  
  133.                                         </div>
  134.                                         <!-- end tab1 -->
  135.  
  136.  
  137.                                         <div id="tab2" class="tab-pane">
  138.                                             <div class=" row-fluid">
  139.  
  140.                                                 <div class="control-group">
  141.                                                     <label class="control-label" for="input01">α╕½α╕▒α╕ºα╕½α╕Öα╣ëα╕▓α╕üα╕Ñα╕╕α╣êα╕í</label>
  142.                                                     <div class="controls">
  143.                                                     
  144.                                             <form:select class="input-xlarge" name="headGrpId" id="headGrpId" path="headGrpId">
  145.                                                 <form:option value="">====α╣äα╕íα╣êα╕üα╕│α╕½α╕Öα╕ö====</form:option>
  146.                                                 <c:forEach var="ag" items="${agentDetailList}">
  147.                                                     <form:option value="${ag.agentId}">
  148.                                                         <c:out value="${ag.agentId}-${ag.agentName}" />
  149.                                                     </form:option>
  150.                                                 </c:forEach>
  151.                                             </form:select>
  152.  
  153.  
  154.  
  155.                                         </div>
  156.                                                 </div>
  157.  
  158.                                             </div>
  159.  
  160.                                         </div>
  161.                                         <!-- end Tab  2 -->
  162.  
  163.                                         <div id="tab3" class="tab-pane">
  164.                                             <div class=" row-fluid">
  165.  
  166.                                                 <div class="control-group">
  167.  
  168.                                                     <div class="control-group">
  169.                                                         <div class="controls">
  170.                                                             <label class="checkbox"> <form:checkbox value="Y" name="allPackage" id="allPackage" path="allPackage"/> All Packages
  171.                                                             </label>
  172.                                                         </div>
  173.                                                     </div>
  174.                                                 </div>
  175.  
  176.                                                 <div class="control-group">
  177.  
  178.                                                     <div class="controls">
  179.                                                         <form:select  multiple="true" path="agentPacks"  name="agentPackages" id="agentPackages">
  180.                                                              <form:options items="${activePackages}" itemLabel="packageCode" itemValue="packageCode"/>
  181.                                                         </form:select>
  182.  
  183.                                                     </div>
  184.  
  185.                                                 </div>
  186.  
  187.                                                 <div class="control-group">
  188.                                                     <label class="control-label">α╕üα╕▓α╕úα╕₧α╕┤α╕íα╕₧α╣îα╣Çα╕¡α╕üα╕¬α╕▓α╕úα╕¬α╕│α╕äα╕▒α╕ì</label>
  189.                                                     <div class="controls">
  190.                                                         <c:if test="${not empty agentDocBeans}">
  191.                                                             <c:forEach var="listValue" items="${agentDocBeans}" varStatus="status">
  192.                                                                 <label class="checkbox"> 
  193.                                                                 <form:checkbox value="Y" path="agentDocBeans[${status.index }].selected"/> 
  194.                                                                 <form:hidden path="agentDocBeans[${status.index }].refCode"/>
  195.                                                                 <form:hidden path="agentDocBeans[${status.index }].refName"/>
  196.                                                                 ${listValue.refName}
  197.                                                                 </label>
  198.                                                             </c:forEach>
  199.                                                         </c:if>
  200.  
  201.                                                     </div>
  202.                                                 </div>
  203.  
  204.  
  205.                                             </div>
  206.  
  207.                                         </div>
  208.                                         <!-- end Tab  3 -->
  209.  
  210.                                         <div id="tab4" class="tab-pane">
  211.                                             <div class=" row-fluid">
  212.                                                 <div class="control-group">
  213.  
  214.                                                     <div class="controls">
  215.                                                         <label class="checkbox"> <form:checkbox  value="Y" name="crLinePool" id="crLinePool" path="crLinePool"/> α╣âα╕èα╣ëα╕ºα╕çα╣Çα╕çα╕┤α╕Öα╣Çα╕öα╕╡α╕óα╕ºα╕üα╕▒α╕Üα╕½α╕▒α╕ºα╕½α╕Öα╣ëα╕▓α╕ùα╕╡α╕í
  216.                                                         </label>
  217.                                                     </div>
  218.                                                 </div>
  219.  
  220.                                                 <div class="control-group">
  221.                                                     <label class="control-label">α╕ºα╕çα╣Çα╕çα╕┤α╕Öα╕ùα╕╡α╣êα╣äα╕öα╣ëα╕úα╕▒α╕Ü</label>
  222.                                                     <div class="controls">
  223.                                                         <form:input path="crLimited" class="autoNumber input-medium" type="text" id="crLimited" name="crLimited" placeholder="α╕ºα╕çα╣Çα╕çα╕┤α╕Öα╕ùα╕╡α╣êα╣äα╕öα╣ëα╕úα╕▒α╕Ü"/>
  224.                                                     </div>
  225.                                                 </div>
  226.  
  227.                                                 <div class="control-group">
  228.                                                     <label class="control-label">α╕ºα╕çα╣Çα╕çα╕┤α╕Öα╕ùα╕╡α╣êα╣âα╕èα╣ëα╣äα╕¢</label>
  229.                                                     <div class="controls">
  230.                                                         <form:input path="crBalnace" class="autoNumber input-medium" type="text" id="crBalnace" name="crBalnace" placeholder="α╕ºα╕çα╣Çα╕çα╕┤α╕Öα╕ùα╕╡α╣êα╣âα╕èα╣ëα╣äα╕öα╣ë"/>
  231.                                                     </div>
  232.                                                 </div>
  233.  
  234.  
  235.                                                 <div class="control-group">
  236.                                                     <label class="control-label">α╕ºα╕çα╣Çα╕çα╕┤α╕Öα╕èα╕▒α╣êα╕ºα╕äα╕úα╕▓α╕º</label>
  237.                                                     <div class="controls">
  238.                                                         <form:input path="crTempLimit" class="autoNumber input-medium" type="text" id="crTempLimit" name="crTempLimit" placeholder="α╕ºα╕çα╣Çα╕çα╕┤α╕Öα╕èα╕▒α╣êα╕ºα╕äα╕úα╕▓α╕º"/>
  239.                                                     </div>
  240.                                                 </div>
  241.  
  242.                                                 <div class="control-group">
  243.                                                     <label class="control-label">α╕ºα╕▒α╕Öα╕¬α╕┤α╣ëα╕Öα╕¬α╕╕α╕öα╣âα╕èα╣ëα╕ºα╕çα╣Çα╕çα╕┤α╕Öα╕èα╕▒α╣êα╕ºα╕äα╕úα╕▓α╕º</label>
  244.                                                     <div class="controls" id="maxIndex">
  245.                                                         <form:input path="crExpireDate" class="input-medium" type="text" id="crExpireDate" name="crExpireDate" placeholder="dd/mm/yyyy"/>
  246.                                                     </div>
  247.                                                 </div>
  248.                                                 <div class="control-group">
  249.                                                     <label class="control-label">Credit Term</label>
  250.                                                     <div class="controls">
  251.                                                         <form:input path="crTerm" class="autoNumber input-medium" type="text" name="crTerm" placeholder="Credit Term"/>
  252.                                                     </div>
  253.                                                 </div>
  254.                                             </div>
  255.                                         </div>
  256.                                         <!-- end Tab4 - -->
  257.                                     </div>
  258.  
  259.                                 </div>
  260.                             </div>
  261.                             <!-- Eng Tab box -->
  262.  
  263.                             <%
  264.                                     if (request.getParameter("agentId") == null) {
  265.                                 %>
  266.                                 <button class="btn btn-success" name="saveBtn" id="saveBtn">α╕Üα╕▒α╕Öα╕ùα╕╢α╕ü</button>
  267.                                 <%
  268.                                     } else {
  269.                                 %>
  270.                                 <button class="btn btn-primary" name="editBtn" id="editBtn">α╣üα╕üα╣ëα╣äα╕é</button>
  271.                                  
  272.                                 
  273.                                 <%
  274.                                     }
  275.                                 %> 
  276.                                 <a class="btn" id="cancelBtn" onClick="$('#tableFrm').dialog('close'); return false;">α╕óα╕üα╣Çα╕Ñα╕┤α╕ü/α╕¢α╕┤α╕ö</a>
  277.                         </fieldset>
  278.                     </div>
  279.                 </div>
  280.          
  281.  
  282. </form:form>
  283.  
  284. <script>
  285. $(function() {
  286.     if($("#agentId").val() ){
  287.         $('#agentId').attr('readonly', true);
  288.         };
  289.     
  290. $('.autoNumber').autoNumeric('init', {aSep: ',', aDec: '.',vMin:'0.00',vMax:'1000000000.00'});
  291. $('.autoZipCode').autoNumeric('init', { aSep: '',aPad:false,vMin:'0',vMax:'99999'});
  292. $("#headGrpId").select2();
  293. $('#crExpireDate').datepicker({ dateFormat: 'dd/mm/yy'  });
  294.  
  295. $('#agentPackages').multiSelect({
  296.     afterSelect : function(values) {
  297.  
  298.     },
  299.     afterDeselect : function(values) {
  300.  
  301.     },
  302.     selectableHeader : "<div class='custom-header'>α╕ùα╕▒α╣ëα╕çα╕½α╕íα╕ö</div>",
  303.     selectionHeader : "<div class='custom-header'> α╕ùα╕╡α╣êα╕¬α╕▓α╕íα╕▓α╕úα╕ûα╕éα╕▓α╕óα╣äα╕öα╣ë</div>"
  304. });
  305.  
  306.  
  307. if($('#crLinePool').prop('checked' )){
  308.     
  309.     $('#crLimited').prop('readonly',true);
  310.     $('#crTempLimit').prop('readonly',true);
  311.     $('#crBalnace').prop('readonly',true);
  312.     $('#crExpireDate').prop('readonly',true);
  313.  
  314.     $('#crLimited').val('0');
  315.     $('#crTempLimit').val('0');
  316.     $('#crBalnace').val('0');
  317.     $('#crExpireDate').val('');
  318.     }else{
  319.         
  320.         $('#crLimited').prop('readonly',false);
  321.         $('#crTempLimit').prop('readonly',false);
  322.         $('#crBalnace').prop('readonly',false);
  323.         $('#crExpireDate').prop('readonly',false);
  324.     }
  325.  
  326.  
  327.  
  328. $('#crLinePool').click(function() {
  329.  
  330.  
  331.     if(this.checked){
  332.         $('#crLimited').prop('readonly',true);
  333.         $('#crTempLimit').prop('readonly',true);
  334.         $('#crBalnace').prop('readonly',true);
  335.         $('#crExpireDate').prop('readonly',true);
  336.  
  337.         $('#crLimited').val('0');
  338.         $('#crTempLimit').val('0');
  339.         $('#crBalnace').val('0');
  340.         $('#crExpireDate').val('');
  341.         }else{
  342.             
  343.             $('#crLimited').prop('readonly',false);
  344.             $('#crTempLimit').prop('readonly',false);
  345.             $('#crBalnace').prop('readonly',false);
  346.             $('#crExpireDate').prop('readonly',false);
  347.         }
  348.     
  349.  
  350.     //crLimited;
  351.  
  352. });
  353.  
  354.  
  355.  
  356.  
  357. $('#tambol').on('change', function() {
  358.     $.ajax({
  359.         type : "GET",
  360.         dataType : "json",
  361.         url : 'tambol?amphurCode=' + $('#amphur option:selected').val() + '&provCode=' + $('#province option:selected').val() + '&tambolCode=' + this.value,
  362.         success : function(data) {
  363.  
  364.             $('#prbZipcode').val(data.tabolZipcode);
  365.  
  366.         },
  367.         error : function(xhr, ajaxOptions, thrownError) {
  368.             alert(xhr.status);
  369.             alert(thrownError);
  370.         }
  371.     });
  372.  
  373. });
  374. var amphurChange  =true;
  375. var tambonChange  =true;
  376. $('#amphur').on('change', function() {
  377.     $.ajax({
  378.         type : "GET",
  379.         dataType : "json",
  380.         url : 'tambol-list?amphurCode=' + this.value + '&provCode=' + $('#province option:selected').val(),
  381.         success : function(data) {
  382.  
  383.             $('#tambol').find('option').remove().end();
  384.             $.each(data, function() {
  385.                 $('#tambol').append(new Option(this.tambolName, this.tambolCode));
  386.  
  387.                 <%
  388.                 if (request.getParameter("agentId") != null) {
  389.                 %>
  390.                    if(this.tambolCode=='${agentDetailBean.tambonId}'&&tambonChange){
  391.                        $('#tambol').val('${agentDetailBean.tambonId}');
  392.                        tambonChange=false;
  393.                      }
  394.                 <%
  395.                 } 
  396.                 %>
  397.             });
  398.             $('#tambol').change();
  399.  
  400.         },
  401.         error : function(xhr, ajaxOptions, thrownError) {
  402.             alert(xhr.status);
  403.             alert(thrownError);
  404.         }
  405.     });
  406.  
  407. });
  408.  
  409.  
  410. $('#province').on('change', function() {
  411.  
  412.     $.ajax({
  413.         type : "GET",
  414.         dataType : "json",
  415.         url : 'amphur-list?provCode=' + this.value,
  416.         success : function(data) {
  417.  
  418.             $('#amphur').find('option').remove().end();
  419.             $('#tambol').find('option').remove().end();
  420.  
  421.             $.each(data, function() {
  422.                 $('#amphur').append(new Option(this.amphurName, this.amphurCode));
  423.  
  424.  
  425.                 <%
  426.                 if (request.getParameter("agentId") != null) {
  427.                 %>
  428.                    if(this.amphurCode=='${agentDetailBean.amphurId}'&&hurChange){
  429.                        $('#amphur').val('${agentDetailBean.amphurId}');
  430.                        amphurChange=false;
  431.                      }
  432.                 <%
  433.                 } 
  434.                 %>
  435.                 
  436.             });
  437.  
  438.  
  439.  
  440.             
  441.             $('#amphur').change();
  442.         },
  443.         error : function(xhr, ajaxOptions, thrownError) {
  444.             alert(xhr.status);
  445.             alert(thrownError);
  446.         }
  447.     });
  448.  
  449. });
  450.  
  451.  
  452.  
  453. $('#prbTambonId').on('change', function() {
  454.     $.ajax({
  455.         type : "GET",
  456.         dataType : "json",
  457.         url : 'tambol?amphurCode=' + $('#prbAmphurId option:selected').val() + '&provCode=' + $('#prbProvinceId option:selected').val() + '&tambolCode=' + this.value,
  458.         success : function(data) {
  459.  
  460.              
  461.  
  462.         },
  463.         error : function(xhr, ajaxOptions, thrownError) {
  464.             alert(xhr.status);
  465.             alert(thrownError);
  466.         }
  467.     });
  468.  
  469. });
  470. var prbAmphurIdChange = true;
  471. var prbTambonIdChange = true;
  472. $('#prbAmphurId').on('change', function() {
  473.     $.ajax({
  474.         type : "GET",
  475.         dataType : "json",
  476.         url : 'tambol-list?amphurCode=' + this.value + '&provCode=' + $('#prbProvinceId option:selected').val(),
  477.         success : function(data) {
  478.  
  479.             $('#prbTambonId').find('option').remove().end();
  480.             $.each(data, function() {
  481.                 $('#prbTambonId').append(new Option(this.tambolName, this.tambolCode));
  482.  
  483.                 <%
  484.                 if (request.getParameter("agentId") != null) {
  485.                 %>
  486.                    if(this.tambolCode=='${agentDetailBean.prbTambonId}'&&prbTambonIdChange){
  487.                        $('#prbTambonId').val('${agentDetailBean.prbTambonId}');
  488.                        prbTambonIdChange=false;
  489.                      }
  490.                 <%
  491.                 } 
  492.                 %>
  493.                 
  494.             });
  495.             $('#prbTambonId').change();
  496.  
  497.         },
  498.         error : function(xhr, ajaxOptions, thrownError) {
  499.             alert(xhr.status);
  500.             alert(thrownError);
  501.         }
  502.     });
  503.  
  504. });
  505.  
  506.  
  507.  
  508. $('#prbProvinceId').on('change', function() {
  509.  
  510.     $.ajax({
  511.         type : "GET",
  512.         dataType : "json",
  513.         url : 'amphur-list?provCode=' + this.value,
  514.         success : function(data) {
  515.  
  516.             $('#prbAmphurId').find('option').remove().end();
  517.             $('#prbTambonId').find('option').remove().end();
  518.  
  519.             $.each(data, function() {
  520.                 $('#prbAmphurId').append(new Option(this.amphurName, this.amphurCode));
  521.  
  522.                 <%
  523.                 if (request.getParameter("agentId") != null) {
  524.                 %>
  525.                    if(this.amphurCode=='${agentDetailBean.prbAmphurId}'&&prbAmphurIdChange){
  526.                        $('#prbAmphurId').val('${agentDetailBean.prbAmphurId}');
  527.                        prbAmphurIdChange=false;
  528.                      
  529.                      }
  530.                 <%
  531.                 } 
  532.                 %>
  533.                 
  534.             });
  535.             $('#prbAmphurId').change();
  536.         },
  537.         error : function(xhr, ajaxOptions, thrownError) {
  538.             alert(xhr.status);
  539.             alert(thrownError);
  540.         }
  541.     });
  542.  
  543. });
  544.  
  545.  
  546.  
  547.  
  548. $('#province').change();
  549. $('#prbProvinceId').change();
  550.  
  551.  
  552.  
  553. $("#frmAgentDetailSetup").submit(function() {
  554.  
  555.  
  556.     var form = $(this);
  557.     $('input').each(function(i){
  558.         var self = $(this);
  559.         try{
  560.             var v = self.autoNumeric('get');
  561.             self.autoNumeric('destroy');
  562.             self.val(v);
  563.         }catch(err){
  564.             console.log("Not an autonumeric field: " + self.attr("name"));
  565.         }
  566.     });
  567.     
  568.     var url = "saveAgentDetail";  
  569.  
  570.     $.ajax({
  571.            type: "POST",
  572.            url: url,
  573.            data: $("#frmAgentDetailSetup").serialize(),  
  574.            success: function(data)
  575.            {
  576.  
  577.                $('#grid').trigger("reloadGrid", [{ page: 1 }]);
  578.                $('#tableFrm').dialog('close');
  579.            },
  580.            error: function (xhr, ajaxOptions, thrownError) {
  581.                var obj = JSON.parse( xhr.responseText);
  582.                alert(obj.errorMessages ) ;      
  583.              }
  584.          });
  585.  
  586.     return false;
  587.  
  588.     
  589. });
  590.  
  591.  
  592.  
  593.  
  594.     $("#prbProvinceId").select2({
  595.             width : 'resolve'
  596.         });
  597.         $("#prbAmphurId").select2({
  598.             width : 'resolve'
  599.         });
  600.         $("#prbTambonId").select2({
  601.             width : 'resolve'
  602.         });
  603.  
  604.         $("#province").select2({
  605.             width : 'resolve'
  606.         });
  607.         $("#amphur").select2({
  608.             width : 'resolve'
  609.         });
  610.         $("#tambol").select2({
  611.             width : 'resolve'
  612.         });
  613.  
  614.     });
  615. </script>
  616.