(function(s, u) {
s.add({
getPolicyReport: function(filters,success,error) {
u.post(this.host + "/api/policy/report", filters, success, error);
},
getPolUdwReport: function(filters, success, error) {
u.post(this.host + "/api/policy/underwriting", filters, success, error);
},
processPolicy: function(data, success, error) {
u.post(this.host + "/api/policy/process", data, success, error);
},
flagPolicy: function(json, success, error) {
u.post(this.host + `/api/policy/flag/${json.flag}/${json.user}`, json.policyIds, success, error);
},
searchFlagPolicy: function(filters, success, error) {
u.post(this.host + "/api/policy/flag/search", filters, success, error);
},
searchOv2Logs: function(filters, success, error) {
u.post(this.host + "/api/ov2/report", filters, success, error);
},
postOv2: function(policyId, success, error) {
u.get(this.host + `/api/ov2/post/${policyId}`, success, error);
},
postOv2Renewal: function (policyId, success, error) {
u.get(this.host + `/api/ov2/renew/${policyId}`, success, error);
}
});
})(window.service, window.utility);
(function ($, s, u, $scope) {
$(function() {
u.set_datepicker(".date");
$scope.renderStatus = (record) => {
switch (record.IsSuccessful) {
case true:
return '
Success
';
case false:
return 'Failed
';
}
};
$scope.renderActions = (record) => {
switch (record.IsSuccessful) {
case true:
return '';
case false:
return '';
}
};
$scope.search_grid = u.default_grid("#grdSearchResults",
"#grdSearchResultsPager",
"Policy Processing List",
[
"Status", "Actions", "Transaction Date", "OV2 Policy No.", "TransactionType", "Product Name", "Risk Name", "Siba Policy Number", "Customer Name",
"Premium", "Branch", "Registration No.", "Policy Start Date", "Policy End Date", "Captured By", "Intermediary", "Intermediary Email",
"Intermediary Phone", "Make", "Model", "Body Type", "Chassis", "Cc",
"Manufacture Year", "Sticker", "Seats", "Tppd", "Transaction ID",
"API Response"
],
[
{ name: "status", index: "status", template: $scope.renderStatus },
{ name: "actions", index: "actions", template: $scope.renderActions },
{ name: "Date", index: "Date" },
{ name: "Ov2PolicyNumber", index: "Ov2PolicyNumber" },
{ name: "TransactionType", index: "TransactionType" },
{ name: "Product", index: "Product" },
{ name: "Risk", index: "Risk" },
{ name: "PolicyNo", index: "PolicyNo" },
{ name: "Customer", index: "Customer" },
{ name: "Premium", index: "Premium" },
{ name: "Branch", index: "Branch" },
{ name: "RegistrationNumber", index: "RegistrationNumber" },
{ name: "StartDate", index: "StartDate" },
{ name: "EndDate", index: "EndDate" },
{ name: "CreatedBy", index: "CreatedBy" },
{ name: "Intermediary", index: "Intermediary" },
{ name: "IntermediaryEmail", index: "IntermediaryEmail" },
{ name: "IntermediaryPhone", index: "IntermediaryPhone" },
{ name: "Make", index: "Make" },
{ name: "Model", index: "Model" },
{ name: "BodyType", index: "BodyType" },
{ name: "Chassis", index: "Chassis" },
{ name: "Cc", index: "Cc" },
{ name: "ManufactureYear", index: "ManufactureYear" },
{ name: "Sticker", index: "Sticker" },
{ name: "Seats", index: "Seats" },
{ name: "Tppd", index: "Tppd" },
{ name: "TransactionId", index: "TransactionId" },
{ name: "LogMessage", index: "LogMessage" }
],
function(rowId) {
$scope.selectedRecord = u.getRow(rowId, $scope.search_grid);
});
$("#reset").click(function () {
u.modal_confirmation("Are you sure you want to reset the page?", function (e) {
u.hide_confirm();
u.clear_grid_data($scope.search_grid);
//u.form_reset("#filterForm");
$("#FROM").val("");
$("#TO").val("");
$("#QUERY").val("");
u.growl_success("Page reset successfully");
});
});
$("#fetch").click(function() {
if (!u.form_validation("#filterForm")) return u.growl_warning("All fields marked red are required");
s.searchOv2Logs(u.parse_form("#filterForm"), function(response) {
if (!response.state)
return u.growl_error(response.message);
u.clear_grid_data($scope.search_grid);
if (response.data.length <= 0) return u.growl_info("No data found for the specified filters");
u.bigDataPopulate($scope.search_grid, response.data);
});
});
$("body").delegate(".post-policy", "click", function() {
if ($scope.selectedRecord) {
if ($scope.selectedRecord.TransactionType === "NEW BUSINESS") {
u.modal_confirmation(`Are you sure you want to post this ${$scope.selectedRecord.Product} ${$scope.selectedRecord.Risk} policy for ${$scope.selectedRecord.Customer} to OV2?`,
function () {
s.postOv2($scope.selectedRecord.PolicyId, function (response) {
u.hide_confirm();
if (!response.state) return u.growl_error(response.message);
u.growl_success(response.message);
$("#fetch").trigger("click");
});
});
}
if ($scope.selectedRecord.TransactionType === "RENEWAL") {
u.modal_confirmation(`Are you sure you want to post the renewal for this ${$scope.selectedRecord.Product} ${$scope.selectedRecord.Risk} policy for ${$scope.selectedRecord.Customer} to OV2?`,
function () {
s.postOv2Renewal($scope.selectedRecord.PolicyId, function (response) {
u.hide_confirm();
if (!response.state) return u.growl_error(response.message);
u.growl_success(response.message);
$("#fetch").trigger("click");
});
});
}
}
});
});
})(window.jQuery, window.service, window.utility, {});