home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
61.19.244.139
/
61.19.244.139.zip
/
61.19.244.139
/
2015-03-02
/
views
/
entry-policy-add.jsp
< prev
next >
Wrap
Text File
|
2015-03-02
|
63KB
|
1,366 lines
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<div class="widget-content">
<div class="widget-box">
<form:form class="form-horizontal well" method="post" action="savePolicy" modelAttribute="policyBean" id="frmPolicy">
<fieldset>
<div class="box-tab">
<div class="tabbable">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#tab1"><i class="black-icons blocks_images"></i>กรมธรรม์</a></li>
<li><a data-toggle="tab" href="#tab2"><i class="black-icons abacus"></i> ผู้เอาประกันภัย</a></li>
<li><a data-toggle="tab" href="#tab3"><i class="black-icons abacus"></i> รายละเอียดรถ</a></li>
<li><a data-toggle="tab" href="#tab4"><i class="black-icons abacus"></i> ความคุ้มครอง</a></li>
<li><a data-toggle="tab" href="#tab5"><i class="black-icons abacus"></i>ผู้ขับขี่</a></li>
<li><a data-toggle="tab" href="#tab6"><i class="black-icons abacus"></i> เบี้ยประกันภัย</a></li>
<!-- <li><a data-toggle="tab" href="#tab7"><i class="black-icons abacus"></i>เอกสารแนบ</a></li> -->
</ul>
<div class="tab-content">
<div id="tab1" class="tab-pane active">
<div class=" row-fluid">
<div class="widget-box">
<div class="control-group">
<label class="control-label" for="packageCode">PACKAGE</label>
<div class="controls">
<form:select path="packageCode" id="packageCode">
<form:options items="${packageList}" itemValue="packageCode" itemLabel="packageCode" />
</form:select>
<form:input id="packageDesc" path="packageDesc" class="input-xxlarge" readonly="true"/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="packageCode">หมายเลขกรมธรรม์</label>
<div class="controls">
<form:input path="policyNo" class="input-medium" readonly="true"/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="beginDate">วันที่เริ่มต้น</label>
<div class="controls">
<form:input path="beginDate" class="input-small" />
วันที่สิ้นสุด
<form:input path="endDate" class="input-small" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="issueDate">วันที่ ทำสัญญา</label>
<div class="controls">
<form:input path="agreeDate" class="input-small" />
วันที่ออกเอกสาร :
<form:input path="issueDate" class="input-small" />
</div>
</div>
<div class="control-group">
<label class="control-label" for=" "></label>
<div class="controls">
<form:radiobutton path="premCal" value="A" id="premCalA" />
Annual (เต็มปี)
<form:radiobutton path="premCal" value="P" id="premCalP" />
Pro-Rata (นับวัน)
<form:radiobutton path="premCal" value="S" id="premCalS" />
Short Rate (ระยะสั้น)
</div>
</div>
</div>
</div>
</div>
<div id="tab2" class="tab-pane ">
<div class=" row-fluid">
<div class="control-group">
<label class="control-label" for="packageCode"> ประเภทบัตรสำคัญ</label>
<div class="controls">
<form:radiobutton path="insureType" value="P" id="insureTypeP" />
บุคคลธรรมดา
<form:radiobutton path="insureType" value="C" id="insureTypeC" />
นิติบุคคล
<form:radiobutton path="insureType" value="O" id="insureTypeO" />
อื่นๆ
<form:input path="regId" class="input-small" id="regId" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="packageCode"> </label>
<div class="controls">
<form:radiobutton path="brnFlag" value="Y" id="branchMain" />
สำนักงานใหญ่
<form:radiobutton path="brnFlag" value="N" id="branch" />
สาขา :
<form:input path="brnDesc" class="input-xlarge" id="branchDesc" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="insureTitle"> ชื่อ-สกุล</label>
<div class="controls">
<form:select path="insureTitle" id="insureTitle" cssClass="input-small" >
<form:options items="${titles}" itemLabel="refDesc1" itemValue="refCode" />
</form:select>
<form:input path="insureName" class="input-xxlarge" maxlength="200" />
</div>
</div>
<div class="control-group">
<label class="control-label" for=""> ที่อยู่</label>
<div class="controls">
<form:input path="address" class="input-xxlarge" maxlength="200" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="insureTitle"> จังหวัด</label>
<div class="controls">
<form:select path="province" id="province" class="input-medium">
<form:options items="${provinceList}" itemLabel="provName" itemValue="provCode" />
</form:select>
อำเภอ/เขต
<form:select path="amphur" id="amphur" class="input-medium"></form:select>
ตำบล/แขวง
<form:select path="tambol" id="tambol" class="input-medium"></form:select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="insureTitle"> รหัสไปรษณีย์</label>
<div class="controls">
<form:input path="zipcode" class="input-medium" id="zipcode" maxlength="5" />
อาชีพ
<form:select path="occuCode" id="occuCode">
<form:options items="${occuCodeList}" itemLabel="refDesc1" itemValue="refCode" />
</form:select>
</div>
</div>
ที่อยู่หน้าใบเสร็จ <input type="checkbox" id="reciptionName"/> เหมือนผู้เอาประกัน
<div class="control-group">
<label class="control-label" for=""> ชื่อ-นามสกุล</label>
<div class="controls">
<form:input path="receiptName" id="receiptName" class="input-xxlarge" maxlength="200" />
</div>
</div>
<div class="control-group">
<label class="control-label" for=""> ที่อยู่</label>
<div class="controls">
<form:input path="receiptAddress1" id="receiptAddress1" class="input-xxlarge" maxlength="200" />
</div>
</div>
<div class="control-group">
<label class="control-label" for=""> </label>
<div class="controls">
<form:input path="receiptAddress2" id="receiptAddress2" class="input-xxlarge" maxlength="200" />
</div>
</div>
<div class="control-group">
<label class="control-label" for=""> ผู้รับผลประโยชน์</label>
<div class="controls">
<form:input path="beneficiaryName" class="input-xxlarge" />
</div>
</div>
</div>
</div>
<div id="tab3" class="tab-pane ">
<div class=" row-fluid">
<div class="control-group">
<label class="control-label" for=""> ยี่ห้อรถยนต์</label>
<div class="controls">
<form:select path="vehBrand" class="input-medium" id="vehBrand" />
ประเภท MV /การใช้รถ
<form:select path="vehCode" class="input-medium" id="vehSize" />
</div>
</div>
<div class="control-group">
<label class="control-label" for=""> รุ่นรถยนต์</label>
<div class="controls">
<form:select path="vehBrandmodel" class="input-medium" id="vehBrandmodel" />
สีรถ
<form:input path="vehColor" class="input-medium" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="">ทะเบียนรถ</label>
<div class="controls">
<form:input path="vehLicense" class="input-medium" />
จังหวัดทะเบียนรถ
<form:select path="vehLicenseProv" class="input-medium">
<form:options items="${ provinceList}" itemLabel="provName" itemValue="provCode" />
</form:select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="packageCode">เลขตัวถัง</label>
<div class="controls">
<form:input path="vehChassis" class="input-large" maxlength="35" onblur="this.value=this.value.toUpperCase()"/>
เลขเครื่องยนต์
<form:input path="vehMachine" class="input-large" maxlength="35" onblur="this.value=this.value.toUpperCase()"/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">แบบตัวถัง</label>
<div class="controls">
<form:select path="vehChassisModel" id="vehChassisModel">
<form:options items="${chassisModelList}" itemLabel="vehmDesc" itemValue="vehmType" />
</form:select>
CC:
<form:input path="vehCc" class="input-mini autoInt" maxlength="5"/>
/ ที่นั่ง:
<form:input path="vehSeat" class="input-mini autoInt" maxlength="3"/>
/ น้ำหนัก:
<form:input path="vehWeigth" class="input-mini autoInt" maxlength="5"/>
ตัน
</div>
</div>
<div class="control-group">
<label class="control-label" for="">ปีที่จดทะเบียน</label>
<div class="controls">
<form:input path="vehYrreg" class="input-small autoInt" maxlength="4" />
ปีที่ผลิต
<form:input path="vehYrprod" class="input-small autoInt" maxlength="4" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="">รายการตกแต่งเพิ่มเติม</label>
<div class="controls">
<form:input path="vehOption" class="input-xxlarge" />
</div>
</div>
</div>
</div>
<div id="tab4" class="tab-pane ">
<div class=" row-fluid">
ตารางความคุ้มครอง
<div role="grid" class="dataTables_wrapper">
<div class="table_top clearfix"></div>
<div class="table_content">
<table class="data-tbl-striped table table-striped table-bordered dataTable">
<thead>
<tr role="row">
<th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" style="width: 100px;">ความคุ้มครอง</th>
<th class=" " role="columnheader" rowspan="1" colspan="1" style="width: 87px;">เบี้ยประกันทั้งกรมธรรม์</th>
<th class=" " role="columnheader" rowspan="1" colspan="1" style="width: 87px;">ทุนประกันภัยต่อครั้ง</th>
<th class=" " role="columnheader" rowspan="1" colspan="1" style="width: 87px;">ทุนประกันภัยต่อคน</th>
<th class=" " role="columnheader" rowspan="1" colspan="1" style="width: 53px;">จำนวนคน</th>
<th class=" " role="columnheader" rowspan="1" colspan="1" style="width: 152px;">Deduct</th>
</tr>
</thead>
<tbody role="alert" aria-live="polite" aria-relevant="all" id="coverContent">
<!--content-->
</tbody>
</table>
</div>
</div>
</div>
</div>
<div id="tab5" class="tab-pane ">
<div class=" row-fluid">
คนขับคนที่ 1
<div class="control-group">
<label class="control-label" for=""> ชื่อ-นามสกุล</label>
<div class="controls">
<form:select path="driver1Title" cssClass="input-small driverT" id="driver1Title">
<form:options items="${titles}" itemLabel="refDesc1" itemValue="refCode" />
</form:select>
<form:input path="driver1Name" class="input-xxlarge driverT" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="">เพศ</label>
<div class="controls">
<form:radiobutton path="driver1Sex" value="M" class=" driverT" />
ชาย
<form:radiobutton path="driver1Sex" value="F" class=" driverT" />
หญิง อาชีพ
<form:select path="driver1OccuCode" id="driver1OccuCode" class=" driverT">
<form:options items="${occuCodeList}" itemLabel="refDesc1" itemValue="refCode" />
</form:select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">วันเกิด</label>
<div class="controls">
<form:input path="driver1DateofBirth" class="input-large driverT" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="">หมายเลขใบขับขี่:</label>
<div class="controls">
<form:input path="driver1LicenseNo" class="input-large driverT" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="">หมายเลขบัตรประชาชน:</label>
<div class="controls">
<form:input path="driver1RegId" class="input-large driverT" maxlength="20"/>
</div>
</div>
คนขับคนที่ 2
<div class="control-group">
<label class="control-label" for=""> ชื่อ-นามสกุล</label>
<div class="controls">
<form:select path="driver2Title" cssClass="input-small driverT" id="driver2Title">
<form:options items="${titles}" itemLabel="refDesc1" itemValue="refCode" />
</form:select>
<form:input path="driver2Name" class="input-xxlarge driverT" maxlength="200"/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">เพศ</label>
<div class="controls">
<form:radiobutton path="driver2Sex" value="M" class="driverT" />
ชาย
<form:radiobutton path="driver2Sex" value="F" class="driverT" />
หญิง อาชีพ
<form:select path="driver2OccuCode" id="driver2OccuCode" class="driverT">
<form:options items="${occuCodeList}" itemLabel="refDesc1" itemValue="refCode" />
</form:select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">วันเกิด</label>
<div class="controls">
<form:input path="driver2DateofBirth" class="input-large driverT" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="">หมายเลขใบขับขี่:</label>
<div class="controls">
<form:input path="driver2LicenseNo" class="input-large driverT" maxlength="20"/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">หมายเลขบัตรประชาชน:</label>
<div class="controls">
<form:input path="driver2RegId" class="input-large driverT" maxlength="20"/>
</div>
</div>
</div>
</div>
<div id="tab6" class="tab-pane ">
<div class=" row-fluid">
<div class="control-group">
<label class="control-label" for=""> เบี้ยประกันภัยเต็มปี</label>
<div class="controls">
<form:input path="annualPrem" class=" autoNumber" id="annualPrem" readonly="true"/>
</div>
</div>
<div class="control-group">
<label class="control-label" for=""> เบี้ยประกันสุทธิ</label>
<div class="controls">
<form:input path="netPremium" class="input-small autoNumber" id="netPremium" readonly="true"/>
เบี้ยประกันภัยรวม
<form:input path="totalPremium" class="input-small autoNumber" id="totalPremium" readonly="true" />
</div>
</div>
<div class="control-group">
<label class="control-label" for=""> อากร</label>
<div class="controls">
<form:input path="feeAmt" class="input-small autoNumber" id="feeAmt" readonly="true"/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="">VAT</label>
<div class="controls">
<form:input path="vatAmt" class="input-small autoNumber" id="vatAmt" readonly="true" />
</div>
</div>
</div>
</div>
<!-- <div id="tab7" class="tab-pane ">
<div class=" row-fluid">
<div class="control-group">
<label class="control-label">File input</label>
<div class="controls">
ประเภทเอกสารแนบ <select name="" id="">
<option>เอกสารตรวจสภาพรถยนต์</option>
<option>รูปถ่าย</option>
<option>อื่นๆ</option>
</select> <input class="input-file" type="file">
</div>
</div>
</div>
</div>
-->
</div>
</div>
</div>
<!-- end tab -->
</fieldset>
<button class="btn btn-success" name="saveBtn" id="saveBtn">บันทึกกรมธรรม์</button>
<a class="btn" id="cancelBtn" onClick="$('#tableFrm').dialog('close');">ยกเลิก/ปิด</a>
</form:form>
</div>
</div>
<script>
$(function () {
var vehBrandmodel;
var vehBrand;
var packageCode;
var vatRate = ${vatRate};
var feeRate = ${feeRate} / 100;
function check_idcard(idcard) {
if (idcard.value == "") {
return false;
}
if (idcard.length != 13) {
return false;
}
var num = str_split(idcard); // function เพิ่มเติม
var sum = 0;
var total = 0;
var digi = 13;
for (i = 0; i < 12; i++) {
sum = sum + (num[i] * digi);
digi--;
}
total = ((11 - (sum % 11)) % 10);
if (total == num[12]) { //alert('รหัสหมายเลขประจำตัวประชาชนถูกต้อง');
return true;
} else { //alert('รหัสหมายเลขประจำตัวประชาชนไม่ถูกต้อง');
return false;
}
}
function checkID(id) {
if (id.length != 13)
return false;
for (i = 0, sum = 0; i < 12; i++)
sum += parseFloat(id.charAt(i)) * (13 - i);
if ((11 - sum % 11) % 10 != parseFloat(id.charAt(12)))
return false;
return true;
}
// $("#issueDate").datepicker({dateFormat: 'dd/mm/yy', minDate: new Date()});
// $("#agreeDate").datepicker({dateFormat: 'dd/mm/yy', minDate: new Date()});
$('#issueDate').datepicker('setDate', new Date());
$('#agreeDate').datepicker('setDate', new Date());
$("#issueDate").prop('readonly', true);
$("#agreeDate").prop('readonly', true);
// $('#issueDate').datepicker('disable');
// $('#agreeDate').datepicker('disable');
function daysInYear() {
var dateNow = new Date();
var year = dateNow.getYear();
year = year + 1;
if (year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)) {
// Leap year
return 366;
} else {
// Not a leap year
return 365;
}
}
$('#beginDate').datepicker({dateFormat: 'dd/mm/yy', minDate: new Date(), onSelect: function (selectedDate) {
$("#endDate").datepicker("option", "minDate", selectedDate);
if ($('#premCalA').prop('checked')) {
$('#endDate').prop('readonly', true);
var enddate = $('#beginDate').datepicker('getDate', '+1y');
enddate.setDate(enddate.getDate() + daysInYear());
$('#endDate').datepicker('setDate', enddate);
// $('#endDate').datepicker("destroy");;
} else {
$('#endDate').prop('readonly', false);
/* $('#endDate').datepicker({
dateFormat : 'dd/mm/yy',
onSelect : function(selectedDate) {
$("#beginDate").datepicker("option", "maxDate", selectedDate);
}
}); */
}
$("input[name=premCal]:radio").change();
}
});
$('#endDate').datepicker({
dateFormat: 'dd/mm/yy',
onSelect: function (selectedDate) {
$("#beginDate").datepicker("option", "maxDate", selectedDate);
$("input[name=premCal]:radio").change();
}
});
//$('#beginDate').datepicker( { dateFormat: 'dd/MM/yyyy' });
//$("#beginDate").datepicker("setDate", new Date());
//$('#endDate').datepicker({ dateFormat: 'dd/mm/yyyy' });
//$('#issueDate').datepicker( { dateFormat: 'dd/mm/yyyy' });
//$('#agreeDate').datepicker({ dateFormat: 'dd/mm/yyyy' });
$('#beginDate').change(function () {
var date1 = $('#beginDate').datepicker('getDate');
var date = new Date(Date.parse(date1));
date.setFullYear(date.getFullYear() + 1);
var newDate = date.toDateString();
newDate = new Date(Date.parse(newDate));
$('#date2').datepicker('setDate', newDate);
})
$('#beginDate').on('change', function () {
});
$("#regId").blur(function () {
// alert($('input[name=insureType]:checked').val().)
if ($('input[name=insureType]:checked').val() == 'P' && !check_idcard(this.value)) {
// if (!check_idcard(this.value)) {
alert('หมายเลขบัตรไม่ถูกต้องกรุณาตรวจสอบอีกครั้ง');
$("#regId").focus();
}
});
$('#tambol').on('change', function () {
if (this.value != '99') {
$.ajax({
type: "GET",
dataType: "json",
url: 'tambol?amphurCode=' + $('#amphur option:selected').val() + '&provCode=' + $('#province option:selected').val() + '&tambolCode=' + this.value,
success: function (data) {
$('#zipcode').val(data.tabolZipcode);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
}
});
$('#amphur').on('change', function () {
$.ajax({
type: "GET",
dataType: "json",
url: 'tambol-list?amphurCode=' + this.value + '&provCode=' + $('#province option:selected').val(),
success: function (data) {
$('#tambol').find('option').remove().end();
$('#tambol').append(new Option('-- ไม่ระบุ --', '99'));
$.each(data, function () {
$('#tambol').append(new Option(this.tambolName, this.tambolCode));
});
$('#tambol').change();
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
});
$('#province').on('change', function () {
$.ajax({
type: "GET",
dataType: "json",
url: 'amphur-list?provCode=' + this.value,
success: function (data) {
$('#amphur').find('option').remove().end();
$('#tambol').find('option').remove().end();
$('#amphur').append(new Option('-- ไม่ระบุ --', '99'));
$.each(data, function () {
$('#amphur').append(new Option(this.amphurName, this.amphurCode));
});
$('#amphur').change();
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
});
// mv
$('#vehChassisModel').on('change', function () {
// alert(this.value);
});
$('#vehBrand').on('change', function () {
$('#vehBrandmodel').find('option').remove().end();
if (packageCode.allBrand != 'Y') {
$.each(vehBrandmodel, function () {
if ($('#vehBrand option:selected').val() == this.brand) {
$('#vehBrandmodel').append(new Option(this.model, this.model));
}
});
} else {
$.each(vehBrandmodel, function () {
if ($('#vehBrand option:selected').val() == this.brandId) {
$('#vehBrandmodel').append(new Option(this.modelName, this.modelName));
}
});
}
});
$('#packageCode').on('change', function () {
$.ajax({
type: "GET",
dataType: "json",
url: 'get-packageH-detail?packageCode=' + encodeURIComponent(this.value),
success: function (data) {
packageCode = data;
$("#packageDesc").val(packageCode.packageDesc);
//brand Model
// data.totalPremium;
$('#vehBrand').find('option').remove().end();
vehBrandmodel = data.brandmodels;
vehBrand = {};
if (data.allBrand != 'Y') {
$.each(vehBrandmodel, function () {
if (!(this.brand in vehBrand)) {
$('#vehBrand').append(new Option(this.brand, this.brand));
vehBrand[this.brand] = this.brand;
}
});
} else {
$.ajax({
type: "GET",
dataType: "json",
url: 'vehBrandmodel-list',
success: function (data2) {
vehBrandmodel = data2;
$.each(data2, function () {
if (!(this.brandId in vehBrand)) {
$('#vehBrand').append(new Option(this.brandId, this.brandId));
vehBrand[this.brandId] = this.brandId;
}
});
$('#vehBrand').change();
}
});
}
//vehSize
$('#vehSize').find('option').remove().end();
var vv = '';
if (data.allVehCode != 'Y') {
$.each(data.vehSizeBeans, function () {
$('#vehSize').append(new Option(this.vehSizeDesc, this.vehSize + "|" + this.vehCode));
if (vv == '') {
vv = this.vehSize + "|" + this.vehCode;
}
});
} else {
$.ajax({
type: "GET",
dataType: "json",
url: 'veh-size-list',
success: function (data2) {
vehBrandmodel = data2;
$.each(data2, function () {
$('#vehSize').append(new Option(this.vehSizeDesc, this.vehSize + "|" + this.vehCode));
if (vv == '') {
vv = this.vehSize + "|" + this.vehCode;
}
});
}
});
}
if (vv != '') {
$.ajax({
type: "GET",
dataType: "json",
url: 'veh-model-list?vehmCode=' + vv,
success: function (data) {
$('#vehChassisModel').find('option').remove().end();
$.each(data, function () {
$('#vehChassisModel').append(new Option(this.vehmDesc, this.vehmType));
});
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
}
//cover Table
coverages = data.coverages;
var coveragesTable = '';
$.each(coverages, function () {
coveragesTable += '<tr class="odd">';
coveragesTable += '<td class="span4">' + this.covCode + ':' + this.covName;
coveragesTable += '</td>';
coveragesTable += '<td class=" "> ';
if (!this.enableSumOfPol) {
coveragesTable += '-';
} else {
coveragesTable += this.sumOfPol.toLocaleString();
}
coveragesTable += '</td>';
coveragesTable += '<td class="center ">';
if (!this.enableSumOfTimes) {
coveragesTable += '-';
} else {
coveragesTable += this.sumOfTimes.toLocaleString();
}
coveragesTable += '</td>';
coveragesTable += '<td class="center ">';
if (!this.enableSumOfPerson) {
coveragesTable += '-';
} else {
coveragesTable += this.sumOfPerson.toLocaleString();
}
coveragesTable += '</td>';
coveragesTable += '<td class="center ">';
if (!this.enableNoPerson) {
coveragesTable += '-';
} else {
coveragesTable += this.noPerson.toLocaleString();
}
coveragesTable += '</td>';
coveragesTable += '<td class="center ">';
if (!this.enableDeduct) {
coveragesTable += '-';
} else {
coveragesTable += this.deduct.toLocaleString();
}
coveragesTable += '</td>';
coveragesTable += '</tr>';
});
$('#coverContent').html("");
$(coveragesTable).appendTo('#coverContent');
//end cover table;
//driver tab
$(".driverT").prop('disabled', !(data.drivrers == 'Y'));
if (data.annualFlag == 'Y') {
$('#premCalA').prop('checked', true);
$('#premCalP').prop('disabled', true);
$('#premCalS').prop('disabled', true);
var enddate = $('#beginDate').datepicker('getDate', '+1y');
enddate.setDate(enddate.getDate() + daysInYear());
$('#endDate').datepicker('setDate', enddate);
$("#endDate").prop('readonly', true);
$('#endDate').datepicker('disable');
} else {
//$("input[type=radio]").attr('disabled', false);
$('#premCalP').prop('disabled', !(data.prorata == 'Y'));
$('#premCalS').prop('disabled', !(data.shortrate == 'Y'));
$("#endDate").prop('readonly', false);
$('#endDate').datepicker('enable');
}
if (data.insureType == 'Y') {
$('#insureTypeP').prop('checked', true);
$('#insureTypeO').prop('disabled', true);
$('#insureTypeC').prop('disabled', true);
$('#branchMain').prop('disabled', true);
$('#branch').prop('disabled', true);
} else {
// $('#insureTypeP').prop('checked', true);
$('#insureTypeO').prop('disabled', false);
$('#insureTypeC').prop('disabled', false);
$('#branchMain').prop('disabled', false);
$('#branch').prop('disabled', false);
}
// data.allVehCode;
// data.allBrand;
// data.allGroup;
// data.prorata;
// data.shortrate;
// ;
$('#vehBrand').change();
//premium
$("input[name=premCal]:radio").change();
/* if ($('#premCalA').prop('checked')) {
$('#annualPrem').val(data.totalPremium);
$('#netPremium').val(data.netPremium);
$('#totalPremium').val(data.totalPremium);
$('#feeAmt').val(data.fee);
$('#vatAmt').val(data.vatAmt);
} else if ($('#premCalP').prop('checked')) {
var netPremium = data.netPremium;
var bDate = ('#beginDate').datepicker("getDate") ;
var eDate = ('#endDate').datepicker("getDate");
//alert((eDate- bDate) /( 86400 * 1000));
$('#annualPrem').val(data.totalPremium);
$('#netPremium').val(data.netPremium);
$('#totalPremium').val(data.totalPremium);
$('#feeAmt').val(data.fee);
$('#vatAmt').val(data.vatAmt);
} else if ($('#premCalS').prop('checked')) {
$('#annualPrem').val(data.totalPremium);
$('#netPremium').val(data.netPremium);
$('#totalPremium').val(data.totalPremium);
$('#feeAmt').val(data.fee);
$('#vatAmt').val(data.vatAmt);
}
*/
$('.autoNumber').autoNumeric('init', {
aSep: ',',
aDec: '.',
vMin: '0.00',
vMax: '1000000000.00'
});
//documents
if (data.loadDoc != 'Y') {
//disable loaddocs
}
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
});
$('#branchMain').on('change', function () {
$('#branchDesc').val('');
});
$('#insureTypeP').on('change', function () {
$.ajax({
type: "GET",
dataType: "json",
url: 'title-list?type=P',
success: function (data) {
$('#insureTitle').find('option').remove().end();
$.each(data, function () {
$('#insureTitle').append(new Option(this.refDesc1, this.refCode));
});
;
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
$('#branchMain').prop('disabled', true);
$('#branch').prop('disabled', true);
});
$('#insureTypeC').on('change', function () {
$.ajax({
type: "GET",
dataType: "json",
url: 'title-list?type=C',
success: function (data) {
$('#insureTitle').find('option').remove().end();
$.each(data, function () {
$('#insureTitle').append(new Option(this.refDesc1, this.refCode));
});
;
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
$('#branch').prop('disabled', false);
$('#branchMain').prop('disabled', false);
$('#branchMain').prop('checked', true);
});
$('#insureTypeO').on('change', function () {
$.ajax({
type: "GET",
dataType: "json",
url: 'title-list?type=O',
success: function (data) {
$('#insureTitle').find('option').remove().end();
$.each(data, function () {
$('#insureTitle').append(new Option(this.refDesc1, this.refCode));
});
;
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
$('#branchMain').prop('disabled', false);
$('#branch').prop('disabled', false);
});
$('#reciptionName').on('change', function () {
var addressCopy = '';
if ($('#reciptionName').prop('checked')) {
$('#receiptName').val($('#insureTitle option:selected').text() + " " + $('#insureName').val());
$('#receiptAddress1').val($('#address').val());
if ($('#province option:selected').text() == 'กรุงเทพมหานคร') {
if ($('#tambol option:selected').text() != '-- ไม่ระบุ --') {
addressCopy += 'แขวง' + $('#tambol option:selected').text();
}
if ($('#amphur option:selected').text() != '-- ไม่ระบุ --') {
addressCopy += ' เขต' + $('#amphur option:selected').text();
}
addressCopy += ' ' + $('#province option:selected').text();
addressCopy += ' ' + $('#zipcode').val();
$('#receiptAddress2').val(addressCopy);
// $('#receiptAddress2').val(" แขวง" + $('#tambol option:selected').text() + " เขต" + $('#amphur option:selected').text() + " " + $('#province option:selected').text());
} else {
if ($('#tambol option:selected').text() != '-- ไม่ระบุ --') {
addressCopy += 'ตำบล' + $('#tambol option:selected').text();
}
if ($('#amphur option:selected').text() != '-- ไม่ระบุ --') {
addressCopy += ' อำเภอ' + $('#amphur option:selected').text();
}
addressCopy += ' จังหวัด' + $('#province option:selected').text();
addressCopy += ' ' + $('#zipcode').val();
$('#receiptAddress2').val(addressCopy);
// $('#receiptAddress2').val(" ตำบล" + $('#tambol option:selected').text() + " อำเภอ" + $('#amphur option:selected').text() + " จังหวัด" + $('#province option:selected').text());
}
$('#receiptName').prop('readonly', true);
$('#receiptAddress1').prop('readonly', true);
$('#receiptAddress2').prop('readonly', true);
} else {
/* $('#receiptName').val('');
$('#receiptAddress1').val('');
$('#receiptAddress2').val(''); */
$('#receiptName').prop('readonly', false);
$('#receiptAddress1').prop('readonly', false);
$('#receiptAddress2').prop('readonly', false);
}
});
$("input[name=premCal]:radio").change(function () {
var netPremium = packageCode.netPremium;
var freeAmt = packageCode.fee;
var vatAmt = packageCode.vatAmt;
var totalPremium = packageCode.totalPremium;
var annualPrem = packageCode.totalPremium; // เบี้ยทั้งเบี้ย
var bDate = $('#beginDate').datepicker("getDate");
var eDate = $('#endDate').datepicker("getDate");
var difDate;
if ($("input[name=premCal]:checked").val() != 'A') {
if ($("input[name=premCal]:checked").val() == 'P') {
difDate = (eDate - bDate) / (86400 * 1000);
netPremium = difDate * netPremium / 365;
} else if ($("input[name=premCal]:checked").val() == 'S') {
difDate = 1 + (eDate - bDate) / (86400 * 1000);
$.ajax({
type: "GET",
dataType: "json",
url: 'get-short-rate?days=' + difDate,
success: function (moShtRntBean) {
netPremium = netPremium * moShtRntBean.srShtPercent / 100;
}
});
}
var f = (netPremium * feeRate);
freeAmt = Math.ceil(f);
vatAmt = inprecise_round(((parseFloat(netPremium) + parseInt(freeAmt)) * vatRate) / 100, 2);
totalPremium = parseFloat(netPremium) + parseFloat(freeAmt) + parseFloat(vatAmt);
}
$('#annualPrem').val(annualPrem);
$('#netPremium').val(netPremium);
$("#feeAmt").val(freeAmt);
$("#vatAmt").val(vatAmt);
$("#totalPremium").val(totalPremium);
});
function inprecise_round(value, decPlaces) {
return Math.round(value * Math.pow(10, decPlaces)) / Math.pow(10, decPlaces);
}
$('#province').change();
$('#packageCode').change();
$('#vehSize').on('change', function () {
$.ajax({
type: "GET",
dataType: "json",
url: 'veh-model-list?vehmCode=' + this.value,
success: function (data) {
$('#vehChassisModel').find('option').remove().end();
$.each(data, function () {
$('#vehChassisModel').append(new Option(this.vehmDesc, this.vehmType));
});
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
});
$("#packageCode").select2({
width: 'resolve'
});
$("#driver1OccuCode").select2({
width: 'resolve'
});
$("#driver2OccuCode").select2({
width: 'resolve'
});
$("#driver1Title").select2({
width: 'resolve'
});
$("#driver2Title").select2({
width: 'resolve'
});
$("#occuCode").select2({
width: 'resolve'
});
$("#insureTitle").select2({
width: 'resolve'
});
$("#province").select2({
width: 'resolve'
});
$("#amphur").select2({
width: 'resolve'
});
$("#tambol").select2({
width: 'resolve'
});
$('#driver1DateofBirth').datepicker({
dateFormat: 'dd/mm/yy',
minDate: new Date()
});
$('driver2DateofBirth').datepicker({
dateFormat: 'dd/mm/yy',
minDate: new Date()
});
$('.autoInt').autoNumeric('init', {
aSep: '',
aPad: false,
vMin: '0',
vMax: '99999'
});
//$("#frmPolicy").preventDoubleSubmission();
<%if (request.getParameter("policyNo") == null) {%>
<%} else {%>
$('#amphur option:selected').val('${policyBean.tambol}');
//$('#amphur').change();
$('#tambol option:selected').val('${policyBean.amphur}');
$('#vehBrand option:selected').val('${policyBean.vehBrand}');
//$('#vehBrand').change();
$('#vehBrandmodel option:selected').val('${policyBean.vehBrandmodel}');
//$('#vehBrandmodel').change();
//$('#vehSize option:selected').val('${policyBean.vehSize}|${policyBean.vehCode}');
<%}%>
$("#frmPolicy").submit(function () {
$('#saveBtn').click(function () {
return false;
});
var form = $(this);
$('input').each(function (i) {
var self = $(this);
try {
var v = self.autoNumeric('get');
self.autoNumeric('destroy');
self.val(v);
} catch (err) {
console.log("Not an autonumeric field: " + self.attr("name"));
}
});
//$("saveBtn").prop('disabled', true);
var url = "savePolicy";
$.ajax({
type: "POST",
url: url,
data: $("#frmPolicy").serialize(),
success: function (data) {
$('#grid').trigger("reloadGrid", [{
page: 1
}]);
//$('#tableFrm').dialog('close');
$("#saveBtn").unbind();
$('#saveBtn').click(function () {
return true;
});
updateCreditMenu();
$('#tableFrm').dialog('close');
},
error: function (xhr, ajaxOptions, thrownError) {
var obj = JSON.parse(xhr.responseText);
alert(obj.errorMessages);
$("#saveBtn").unbind();
$('#saveBtn').click(function () {
return true;
});
}
});
return false;
});
});
</script>