1959 lines
80 KiB
HTML
1959 lines
80 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Inventory\ManageOwner.js</title>
|
|
<link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
|
|
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
|
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
|
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
|
|
<script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
|
|
</head>
|
|
<body class="yui3-skin-sam">
|
|
|
|
<div id="doc">
|
|
<div id="hd" class="yui3-g header">
|
|
<div class="yui3-u-3-4">
|
|
|
|
<h1><img src="../assets/css/logo.png" title=""></h1>
|
|
|
|
</div>
|
|
<div class="yui3-u-1-4 version">
|
|
<em>API Docs for: </em>
|
|
</div>
|
|
</div>
|
|
<div id="bd" class="yui3-g">
|
|
|
|
<div class="yui3-u-1-4">
|
|
<div id="docs-sidebar" class="sidebar apidocs">
|
|
<div id="api-list">
|
|
<h2 class="off-left">APIs</h2>
|
|
<div id="api-tabview" class="tabview">
|
|
<ul class="tabs">
|
|
<li><a href="#api-classes">Classes</a></li>
|
|
<li><a href="#api-modules">Modules</a></li>
|
|
</ul>
|
|
|
|
<div id="api-tabview-filter">
|
|
<input type="search" id="api-filter" placeholder="Type to filter APIs">
|
|
</div>
|
|
|
|
<div id="api-tabview-panel">
|
|
<ul id="api-classes" class="apis classes">
|
|
|
|
<li><a href="../classes/CallFeedbackRating.html">CallFeedbackRating</a></li>
|
|
|
|
<li><a href="../classes/CloseTicketReport.html">CloseTicketReport</a></li>
|
|
|
|
<li><a href="../classes/ConsolidatedReport.html">ConsolidatedReport</a></li>
|
|
|
|
<li><a href="../classes/CustomerReport.html">CustomerReport</a></li>
|
|
|
|
<li><a href="../classes/DealerWiseCallDetails.html">DealerWiseCallDetails</a></li>
|
|
|
|
<li><a href="../classes/DeclinedCalls.html">DeclinedCalls</a></li>
|
|
|
|
<li><a href="../classes/DropDownData.html">DropDownData</a></li>
|
|
|
|
<li><a href="../classes/EicherPromise.html">EicherPromise</a></li>
|
|
|
|
<li><a href="../classes/EosCallCount.html">EosCallCount</a></li>
|
|
|
|
<li><a href="../classes/GeoAnalysis.html">GeoAnalysis</a></li>
|
|
|
|
<li><a href="../classes/HdBusLmdContrCallFeedbackRatingibution.html">HdBusLmdContrCallFeedbackRatingibution</a></li>
|
|
|
|
<li><a href="../classes/HdBusLmdContribution.html">HdBusLmdContribution</a></li>
|
|
|
|
<li><a href="../classes/HistoryTracking.html">HistoryTracking</a></li>
|
|
|
|
<li><a href="../classes/LiveTracking.html">LiveTracking</a></li>
|
|
|
|
<li><a href="../classes/ManageEscalation.html">ManageEscalation</a></li>
|
|
|
|
<li><a href="../classes/ManageFleet.html">ManageFleet</a></li>
|
|
|
|
<li><a href="../classes/ManageFleet_Detail.html">ManageFleet_Detail</a></li>
|
|
|
|
<li><a href="../classes/ManageFleet_details.html">ManageFleet_details</a></li>
|
|
|
|
<li><a href="../classes/ManageOwner.html">ManageOwner</a></li>
|
|
|
|
<li><a href="../classes/ManageReason.html">ManageReason</a></li>
|
|
|
|
<li><a href="../classes/ManageVechile.html">ManageVechile</a></li>
|
|
|
|
<li><a href="../classes/ManageVehicle.html">ManageVehicle</a></li>
|
|
|
|
<li><a href="../classes/NonVecvUserManagement.html">NonVecvUserManagement</a></li>
|
|
|
|
<li><a href="../classes/Notifications.html">Notifications</a></li>
|
|
|
|
<li><a href="../classes/OpenTicketReport.html">OpenTicketReport</a></li>
|
|
|
|
<li><a href="../classes/OrganizationChart.html">OrganizationChart</a></li>
|
|
|
|
<li><a href="../classes/PositioningTool.html">PositioningTool</a></li>
|
|
|
|
<li><a href="../classes/PositioningTool_Report.html">PositioningTool_Report</a></li>
|
|
|
|
<li><a href="../classes/ReasonForClosure.html">ReasonForClosure</a></li>
|
|
|
|
<li><a href="../classes/Report.html">Report</a></li>
|
|
|
|
<li><a href="../classes/ShowDealerMap.html">ShowDealerMap</a></li>
|
|
|
|
<li><a href="../classes/TicketAdministration.html">TicketAdministration</a></li>
|
|
|
|
<li><a href="../classes/TicketAdministration_FullDetail.html">TicketAdministration_FullDetail</a></li>
|
|
|
|
<li><a href="../classes/TicketFeedback.html">TicketFeedback</a></li>
|
|
|
|
<li><a href="../classes/TicketForDealer.html">TicketForDealer</a></li>
|
|
|
|
<li><a href="../classes/TicketForDealer_FullDetails.html">TicketForDealer_FullDetails</a></li>
|
|
|
|
<li><a href="../classes/TicketReassign.html">TicketReassign</a></li>
|
|
|
|
<li><a href="../classes/TileDashboard.html">TileDashboard</a></li>
|
|
|
|
<li><a href="../classes/TimeSlotClosure.html">TimeSlotClosure</a></li>
|
|
|
|
<li><a href="../classes/TollFreeAndOpportunityLoss.html">TollFreeAndOpportunityLoss</a></li>
|
|
|
|
<li><a href="../classes/VanCoverageDesigner.html">VanCoverageDesigner</a></li>
|
|
|
|
<li><a href="../classes/VecvUserManagement.html">VecvUserManagement</a></li>
|
|
|
|
</ul>
|
|
|
|
<ul id="api-modules" class="apis modules">
|
|
|
|
<li><a href="../modules/Dashboard.html">Dashboard</a></li>
|
|
|
|
<li><a href="../modules/DropDownData.html">DropDownData</a></li>
|
|
|
|
<li><a href="../modules/Geo.html">Geo</a></li>
|
|
|
|
<li><a href="../modules/Inventory.html">Inventory</a></li>
|
|
|
|
<li><a href="../modules/Notifications.html">Notifications</a></li>
|
|
|
|
<li><a href="../modules/ReportModule.html">ReportModule</a></li>
|
|
|
|
<li><a href="../modules/Ticket.html">Ticket</a></li>
|
|
|
|
<li><a href="../modules/TrackingModule.html">TrackingModule</a></li>
|
|
|
|
<li><a href="../modules/UserManagement.html">UserManagement</a></li>
|
|
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="yui3-u-3-4">
|
|
<div id="api-options">
|
|
Show:
|
|
<label for="api-show-inherited">
|
|
<input type="checkbox" id="api-show-inherited" checked>
|
|
Inherited
|
|
</label>
|
|
|
|
<label for="api-show-protected">
|
|
<input type="checkbox" id="api-show-protected">
|
|
Protected
|
|
</label>
|
|
|
|
<label for="api-show-private">
|
|
<input type="checkbox" id="api-show-private">
|
|
Private
|
|
</label>
|
|
<label for="api-show-deprecated">
|
|
<input type="checkbox" id="api-show-deprecated">
|
|
Deprecated
|
|
</label>
|
|
|
|
</div>
|
|
|
|
|
|
<div class="apidocs">
|
|
<div id="docs-main">
|
|
<div class="content">
|
|
<h1 class="file-heading">File: Inventory\ManageOwner.js</h1>
|
|
|
|
<div class="file">
|
|
<pre class="code prettyprint linenums">
|
|
/*================================================================================================================\
|
|
+
|
|
+ Project : GoData-VECV
|
|
+ Filename : ManageOwner.js
|
|
+ Module Name : ManageOwner
|
|
+ Purpose : For Eicher Manage Owner
|
|
+ Coded By : Gourav Jhangikhel
|
|
+
|
|
+================================================================================================================*/
|
|
|
|
/**
|
|
* To manage Owner
|
|
* @module Inventory
|
|
*/
|
|
|
|
|
|
/**
|
|
* To perform CRUD On Manage Owner.
|
|
* @class ManageOwner
|
|
* @constructor
|
|
*/
|
|
|
|
|
|
/**
|
|
* Global References: To store Ajax Request's XHR object.
|
|
* @for ManageOwner
|
|
*/
|
|
|
|
|
|
var VechiledataSource = new Array();
|
|
//Global variables
|
|
var activeRequest, activeRequest_City, activeRequest_Edit, activeRequest_del, activeRequest_OwnerDetails, activeRequest_export, vSelectedRow;
|
|
var vVechileSelectedRow;
|
|
|
|
var vRegNoDup = 0;
|
|
var vChasisNoDup = 0;
|
|
var vOwnerMobileNoDup = 0;
|
|
var vDupMsg = "";
|
|
|
|
var vDupMsgRegNo = "";
|
|
var vDupMsgChasisNo = "";
|
|
|
|
var vRegNoOnPageLoad = "";
|
|
var vChasisNoOnPageLoad = "";
|
|
var vCustMobileNoOnPageLoad = "";
|
|
var vAddOrUpdate = true;
|
|
var vPrePageSize = 0;
|
|
var OwnerName;
|
|
|
|
var vRegNo = "";
|
|
/**
|
|
* Function to Add Kendo Window.
|
|
* @method addKendoWindowToDiv
|
|
* @param {String} divId Id of Kendo Window
|
|
* @param {String} titleText Title Of Kendo Window
|
|
* @param {String} width width Of Kendo Window
|
|
* @param {String} left left Of Kendo Window
|
|
* @param {String} top top Of Kendo Window
|
|
* @for ManageOwner
|
|
*/
|
|
|
|
|
|
function addKendoWindowToDiv(divId, titleText, width, left, top) {
|
|
$(divId).kendoWindow({
|
|
width: width,
|
|
title: titleText,
|
|
modal: true,
|
|
resizable: false,
|
|
draggable: true,
|
|
position: {
|
|
top: top,
|
|
left: left
|
|
},
|
|
close: SetDupValueFalse()
|
|
});
|
|
}
|
|
|
|
|
|
/**
|
|
* Function to Get The Call When the Kendo Grid Row is Selected.
|
|
* @method RowSelected
|
|
* @for ManageOwner
|
|
*/
|
|
function RowSelected() {
|
|
grid = $("#gridOwnerList").data("kendoGrid");
|
|
|
|
/// click event on rows of grid.
|
|
$(grid.tbody).on("click", "tr", function () {
|
|
// clicked row instance
|
|
row = $(this).closest("tr");
|
|
var custId;
|
|
custId = row[0].childNodes[0].innerHTML;
|
|
OwnerName = row[0].childNodes[2].innerHTML;
|
|
|
|
//Add button hide show
|
|
$("#btnAdd").show();
|
|
|
|
// ajax request to get Owner detail
|
|
if (activeRequest_OwnerDetails && activeRequest_OwnerDetails.readystate != 4) {
|
|
activeRequest_OwnerDetails.abort();
|
|
}
|
|
$("#div_load").show();
|
|
activeRequest_OwnerDetails = $.ajax({
|
|
type: "POST",
|
|
url: "/Inventory/ManageOwner_GetOwnerDetails/",
|
|
data: { CustId: custId },
|
|
success: function (data) {
|
|
$("#divOwnerDetailPanel").html('');
|
|
$("#divOwnerDetailPanel").html(data);
|
|
|
|
LoadCityList('#ddlOwnerState', '#ddlOwnerCity');
|
|
HideValidMsg();
|
|
//$('#CustomerCustomerName').attr('readonly', true);
|
|
$("#btnAdd").show();
|
|
$("#btnSaveOwner").prop('value', 'Update');
|
|
vCustMobileNoOnPageLoad = $("#CustomerMobileNumber1").val();
|
|
vOwnerMobileNoDup = 0;
|
|
$("#div_load").hide();
|
|
$("#btnDeleteOwner").show();
|
|
|
|
},
|
|
error: function (data) {
|
|
|
|
}
|
|
});
|
|
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Function to Set Kendo Window Title.
|
|
* @method SetKendoWindowTitle
|
|
* @param {String} divId Id of Kendo Window
|
|
* @param {String} titleText Title Of Kendo Window
|
|
* @for ManageOwner
|
|
*/
|
|
function SetKendoWindowTitle(divId, titleText) {
|
|
var dialog = $(divId).data("kendoWindow");
|
|
dialog.title(titleText);
|
|
}
|
|
|
|
/**
|
|
* Function to Close the kendo Window.
|
|
* @method closeWindow
|
|
* @param {String} divId Id of Kendo Window
|
|
* @for ManageOwner
|
|
*/
|
|
function closeWindow(divId) {
|
|
$(divId).data("kendoWindow").close();
|
|
}
|
|
|
|
/**
|
|
* Function to get Owner list.
|
|
* @method getOwnerList
|
|
* @for ManageOwner
|
|
*/
|
|
function getOwnerList() {
|
|
$("#spanState").hide();
|
|
stateVal = $("#stateCombobox").data("kendoComboBox").text();
|
|
var FilterVal = $("#srchText").val();
|
|
if (stateVal != "") {
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "/Inventory/ManageOwner_GetOwnerList/",
|
|
data: { state: stateVal, FilterVal: FilterVal },
|
|
success: function (data) {
|
|
//Bind html
|
|
$("#divOwnerList").html(data);
|
|
vPrePageSize = 0;
|
|
},
|
|
error: function (data) {
|
|
|
|
}
|
|
});
|
|
} else {
|
|
$("#spanState").show();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Function To Edit Vechile Detail
|
|
* @method editVechile
|
|
* @param {Object} e Contains Information about selected Row of Kendo Grid
|
|
* @for ManageOwner
|
|
*/
|
|
|
|
function editVechile(e) {
|
|
addKendoWindowToDiv("#divAddCustDetl", "Edit Vehicle Detail", "833px", 385, 250);
|
|
// Get selected row
|
|
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
|
|
vVechileSelectedRow = dataItem;
|
|
// Set Vechile model
|
|
oOwner = {};
|
|
oOwner.VehicleId = dataItem.VehicleId;
|
|
oOwner.VehicleRegistrationNumber = dataItem.VehicleRegistrationNumber;
|
|
oOwner.VehicleNumberPlate = dataItem.VehicleNumberPlate;
|
|
oOwner.VehicleModelNumber = dataItem.VehicleModelNumber;
|
|
oOwner.CustomerMobileNumber1 = dataItem.CustomerMobileNumber1;
|
|
oOwner.VehicleType = dataItem.VehicleType;
|
|
oOwner.CustomerCustomerName = dataItem.CustomerCustomerName;
|
|
oOwner.CustomerAddress = dataItem.CustomerAddress;
|
|
oOwner.CustomerState = dataItem.CustomerState;
|
|
oOwner.CustomerCity = dataItem.CustomerCity;
|
|
oOwner.CustomerId = dataItem.CustomerId;
|
|
oOwner.CustomerVehicleModelTagging = dataItem.CustomerVehicleModelTagging;
|
|
oOwner.VehicleInstallationDate = dataItem.VehicleInstallationDate;
|
|
//// Ajax request for edit ; if exist then kill it.
|
|
if (activeRequest_Edit && activeRequest_Edit.readystate != 4) {
|
|
activeRequest_Edit.abort();
|
|
}
|
|
activeRequest_Edit = $.ajax({
|
|
type: "GET",
|
|
url: "/Inventory/ManageOwner_AddOrEditCustomer",
|
|
data: oOwner,
|
|
success: function (data) {
|
|
//open form in new dialog box
|
|
$("#divAddCustDetl").parent().addClass("responsive_popup") //addClass for respond the menu
|
|
$("#divAddCustDetl").html('');
|
|
$("#divAddCustDetl").html(data);
|
|
SetKendoWindowTitle("#divAddCustDetl", "Edit Vehicle Detail");
|
|
//open form in new dialog box
|
|
$("#divAddCustDetl").data("kendoWindow").open();
|
|
//Show the textbox of Model No., Vechile Type, Driver Name and Driver City
|
|
$('#CustomerState,#CustomerCity,#btnSaveVan').show();
|
|
$('#VechVechType,#VehicleModelNumber').hide();
|
|
//Hide the drop down list of Model No., Vechile Type
|
|
//$('#ddlVechileNo,#ddlVechileType,#btnSaveCust,#tdCustName,#tdCustName1,#trCustDetl2,#trCustDetl3,#trCustDetl4,#btnSaveVan,#btnCustReset').hide();
|
|
$('#btnSaveCust,#tdCustName,#tdCustName1,#trCustDetl2,#trCustDetl3,#trCustDetl4').hide();
|
|
//Set the readonly textbox of vechile registration Number, Vechile Chasis No.,Vechile Model No and Vechile Type
|
|
//$("#VehicleRegistrationNumber,#VehicleNumberPlate,#VehicleModelNumber,#VechVechType").attr('readonly', true);
|
|
//Get Value Registration and chasis No. On Page Load so that it used to check whether Chasis or/And
|
|
//Registration No are duplicate
|
|
vRegNoOnPageLoad = $("#VehicleRegistrationNumber").cleanVal();
|
|
vChasisNoOnPageLoad = $("#VehicleNumberPlate").val();
|
|
$('#VehicleInstallationDate').attr('disabled');
|
|
LoadCityList("#ddlState", "#ddlCity");
|
|
vAddOrUpdate = false;
|
|
$('#VehicleRegistrationNumber,#VehicleNumberPlate').attr('readonly', false);
|
|
$("#btnVechReset").show();
|
|
$("#btnCustReset").hide();
|
|
$("#btnSaveVan").prop('value', 'Update');
|
|
},
|
|
complete: function () {
|
|
vRegNo = $("#VehicleRegistrationNumber").val();
|
|
},
|
|
error: function (data) {
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Function To Edit Driver Detail
|
|
* @method editCust
|
|
* @param {Object} e Contains Information about selected Row of Kendo Grid
|
|
* @for ManageOwner
|
|
*/
|
|
function editCust(e) {
|
|
|
|
addKendoWindowToDiv("#divAddCustDetl", "Edit Driver Detail", "833px", 385, 250);
|
|
// Get selected row
|
|
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
|
|
vSelectedRow = dataItem;
|
|
vVechileSelectedRow = dataItem;
|
|
//Add Or Edit Driver model
|
|
oOwner = {};
|
|
oOwner.VehicleId = dataItem.VehicleId;
|
|
oOwner.VehicleRegistrationNumber = dataItem.VehicleRegistrationNumber;
|
|
oOwner.VehicleNumberPlate = dataItem.VehicleNumberPlate;
|
|
oOwner.VehicleModelNumber = dataItem.VehicleModelNumber;
|
|
oOwner.CustomerMobileNumber1 = dataItem.CustomerMobileNumber1;
|
|
oOwner.VehicleType = dataItem.VehicleType;
|
|
oOwner.CustomerCustomerName = dataItem.CustomerCustomerName;
|
|
oOwner.CustomerAddress = dataItem.CustomerAddress;
|
|
oOwner.CustomerState = dataItem.CustomerState;
|
|
oOwner.CustomerCity = dataItem.CustomerCity;
|
|
oOwner.CustomerEmailId = dataItem.CustomerEmailId;
|
|
oOwner.CustomerId = dataItem.CustomerId;
|
|
oOwner.CustomerVehicleModelTagging = dataItem.CustomerVehicleModelTagging;
|
|
//// Ajax request for edit ; if exist then kill it.
|
|
if (activeRequest_Edit && activeRequest_Edit.readystate != 4) {
|
|
activeRequest_Edit.abort();
|
|
}
|
|
activeRequest_Edit = $.ajax({
|
|
type: "GET",
|
|
url: "/Inventory/ManageOwner_AddOrEditCustomer",
|
|
data: oOwner,
|
|
success: function (data) {
|
|
//open form in new dialog box
|
|
$("#divAddCustDetl").parent().addClass("responsive_popup") //addClass for respond the menu
|
|
$("#divAddCustDetl").html('');
|
|
$("#divAddCustDetl").html(data);
|
|
SetKendoWindowTitle("#divAddCustDetl", "Edit Driver Detail");
|
|
//open form in new dialog box
|
|
$("#divAddCustDetl").data("kendoWindow").open();
|
|
$("#VehicleInstallationDate").val(dataItem.VehicleInstallationDate);
|
|
$('#VehicleRegistrationNumber,#VehicleNumberPlate').show();
|
|
if (oOwner.CustomerId == "") {
|
|
//if the Driver is newly Added then we will show dropdown of Vechile No.,Vechile Type,
|
|
//and textboxes of Vechile registration No and Vechile Chasis No.
|
|
//$('#ddlVechileNo,#ddlVechileType,#VehicleRegistrationNumber,#VehicleNumberPlate').show();
|
|
$('#VehicleRegistrationNumber,#VehicleNumberPlate').show();
|
|
//hide textbox of Vechile No.,Vechile Type
|
|
//$("#VehicleModelNumber,#VechVechType").hide();
|
|
}
|
|
else {
|
|
//hide dropdown of Vechile No.,Vechile Type
|
|
//$('#ddlVechileNo,#ddlVechileType').hide();
|
|
//if the Driver is already Added then we will show textbox of Vechile No.,Vechile Type,
|
|
//Vechile registration No and Vechile Chasis No and set it to non-editable.
|
|
//$("#VehicleRegistrationNumber,#VehicleNumberPlate,#VehicleModelNumber,#VechVechType").show().attr('readonly', true);
|
|
$("#VehicleRegistrationNumber,#VehicleNumberPlate").show();
|
|
}
|
|
$("#btnSaveVan,#ddlVechileNo,#ddlVechileType").hide();
|
|
//show textbox of Driver State, Driver city
|
|
$('#CustomerState,#CustomerCity,#btnSaveCust,#tdCustName,#tdCustName1,#trCustDetl2,#trCustDetl3,#trCustDetl4,#btnSaveVan,#btnCustReset').show();
|
|
|
|
LoadCityList("#ddlState", "#ddlCity");
|
|
$('#VehicleRegistrationNumber,#VehicleNumberPlate').show().attr('readonly', true);
|
|
$("#ddlCity").val($("#CustomerCity").val());
|
|
$("#VechProduct").val(dataItem.CustomerVehicleModelTagging);
|
|
vRegNoOnPageLoad = $("#VehicleRegistrationNumber").cleanVal();
|
|
vChasisNoOnPageLoad = $("#VehicleNumberPlate").val();
|
|
vAddOrUpdate = false;
|
|
$("#btnSaveVan").prop('value', 'Update');
|
|
$("#btnSaveCust").hide();
|
|
$("#btnVechReset").hide();
|
|
$("#btnCustReset").show();
|
|
},
|
|
complete: function () {
|
|
var datepicker = $("#VehicleInstallationDate").data("kendoDatePicker");
|
|
datepicker.enable(false);
|
|
},
|
|
error: function (data) {
|
|
|
|
}
|
|
});
|
|
return false;
|
|
// Create Reason model
|
|
}
|
|
|
|
/**
|
|
* Function To Delete the selected Row in vechile grid
|
|
* @method DeleteVechile
|
|
* @param {Object} e Contains Information about selected Row of Kendo Grid
|
|
* @for ManageOwner
|
|
*/
|
|
function DeleteVechile(e) {
|
|
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
|
|
var grid = $("#gridVechile").data("kendoGrid");
|
|
datasource = grid.dataSource;
|
|
if (datasource.total() > 1) {
|
|
//jConfirm("Do you want to delete the Vehcile Of Reg. No. <b>" + dataItem.VehicleRegistrationNumber + '</b> ?', 'Delete', function (result) {
|
|
jConfirm(MANAGE_FLEET_MESSAGES.confirmDeleteVehicle + " <b>" + dataItem.VehicleRegistrationNumber + '</b> ?', 'Delete', function (result) {
|
|
//again check whether user input is true
|
|
if (result) {
|
|
for (var i = 0; i <= datasource.total() - 1; i++) {
|
|
var datasourceItem = datasource.at(i);
|
|
if (dataItem.VehicleRegistrationNumber === datasource.at(i).VehicleRegistrationNumber) {
|
|
datasourceItem.IsDealetedVehicle = true;
|
|
if (dataItem.VehicleId == "") {
|
|
for (var j = 0; j <= VechiledataSource.length - 1; j++) {
|
|
if (dataItem.VehicleId == VechiledataSource[j].VehicleId) {
|
|
VechiledataSource.splice(j, 1);
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
VechiledataSource.push(datasource.at(i));
|
|
}
|
|
grid.removeRow(grid.tbody.find("tr")[$(e.currentTarget).closest("tr").index()]);
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
});
|
|
}
|
|
else {
|
|
//jAlert("Every Customer must have atleast one Vehicle");
|
|
jAlert(MANAGE_OWNER_MESSAGES.vehicleRequiredForCustomer);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Function To Delete the selected Row in Driver grid
|
|
* @method DeleteCust
|
|
* @param {Object} e Contains Information about selected Row of Kendo Grid
|
|
* @for ManageOwner
|
|
*/
|
|
|
|
function DeleteCust(e) {
|
|
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
|
|
var gridId = "#gridCust_" + dataItem.VehicleRegistrationNumber;
|
|
var grid = $(gridId).data("kendoGrid");
|
|
|
|
datasource = grid.dataSource;
|
|
if (datasource.total() > 1) {
|
|
//jConfirm("Do you want to delete the Driver " + dataItem.CustomerCustomerName + '</b> ?', 'Delete', function (result) {
|
|
jConfirm(MANAGE_FLEET_MESSAGES.confirmDeleteDealer + dataItem.CustomerCustomerName + '</b> ?', 'Delete', function (result) {
|
|
//again check whether user input is true
|
|
if (result) {
|
|
for (var i = 0; i <= datasource.total() - 1; i++) {
|
|
var datasourceItem = datasource.at(i);
|
|
if (dataItem.CustomerId === datasource.at(i).CustomerId && dataItem.CustomerCustomerName === datasource.at(i).CustomerCustomerName &&
|
|
dataItem.VehicleRegistrationNumber === datasource.at(i).VehicleRegistrationNumber &&
|
|
dataItem.CustomerState === datasource.at(i).CustomerState &&
|
|
dataItem.CustomerCity === datasource.at(i).CustomerCity &&
|
|
dataItem.CustomerAddress === datasource.at(i).CustomerAddress &&
|
|
dataItem.CustomerMobileNumber1 === datasource.at(i).CustomerMobileNumber1) {
|
|
datasourceItem.IsDeleted = true;
|
|
if (dataItem.CustomerId == "") {
|
|
for (var j = 0; j <= VechiledataSource.length - 1; j++) {
|
|
if (dataItem.CustomerId === VechiledataSource[j].CustomerId && dataItem.CustomerCustomerName === VechiledataSource[j].CustomerCustomerName &&
|
|
dataItem.VehicleRegistrationNumber === VechiledataSource[j].VehicleRegistrationNumber &&
|
|
dataItem.CustomerState === VechiledataSource[j].CustomerState &&
|
|
dataItem.CustomerCity === VechiledataSource[j].CustomerCity &&
|
|
dataItem.CustomerAddress === VechiledataSource[j].CustomerAddress &&
|
|
dataItem.CustomerMobileNumber1 === VechiledataSource[j].CustomerMobileNumber1) {
|
|
VechiledataSource.splice(j, 1);
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
VechiledataSource.push(datasource.at(i));
|
|
}
|
|
grid.removeRow(grid.tbody.find("tr")[$(e.currentTarget).closest("tr").index()]);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
else {
|
|
//jAlert("Every Vehcile must have atleast one Driver");
|
|
jAlert(MANAGE_OWNER_MESSAGES.driverRequiredForVehicle);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
/**
|
|
* Function of Binding Of Grid And set Delete Button In Vechile Grid.
|
|
* @method onRowBoundVechile
|
|
* @param {Object} e Contains Complete kendo grid property
|
|
* @for ManageOwner
|
|
*/
|
|
|
|
function onRowBoundVechile(e) {
|
|
// Add Edit and delete icon.
|
|
$('.k-grid-Edit').text("").removeClass("k-button k-button-icontext").html("<span class='k-icon k-edit'></span>");
|
|
$('.k-grid-Delete').text("").removeClass("k-button k-button-icontext").html("<span class='k-icon k-delete'></span>");
|
|
|
|
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
|
|
// called common file function to show title on mouse hover.
|
|
addTitleAttribute();
|
|
// called common file function to show title on mouse hover.
|
|
addTitleAttribute();
|
|
// severity functionality
|
|
var data = this.dataSource.view();
|
|
// Show Delete button in Grid if We add New Row And Hide Delete button in grid if Row is Already Inserted
|
|
|
|
//for (var i = 0; i < data.length; i++) {
|
|
// if (data[i].VehicleId != "") {
|
|
// $("#gridVechile").data("kendoGrid").tbody.find("tr[data-uid='" + data[i].uid + "']").find('td').find('#cmdDelete').find("span").removeClass("k-icon k-delete");
|
|
// }
|
|
// else {
|
|
// $("#gridVechile").data("kendoGrid").tbody.find("tr[data-uid='" + data[i].uid + "']").find('td').find('#cmdVanLocation').removeAttr("id");
|
|
// }
|
|
//}
|
|
|
|
// show no data available message when grid has no data.
|
|
//displayNoResultManageFleet(e)
|
|
}
|
|
/**
|
|
* Function of Binding Of Grid And set Delete Button In Driver Grid.
|
|
* @method onRowBoundCust
|
|
* @param {Object} e Contains Complete kendo grid property
|
|
* @for ManageOwner
|
|
*/
|
|
|
|
function onRowBoundCust(e) {
|
|
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
|
|
var data = this.dataSource.view();
|
|
// Add Edit and delete icon.
|
|
console.log(data);
|
|
var gridId = "#gridCust_" + data[0].VehicleRegistrationNumber;
|
|
$(gridId).find('.k-grid-Edit').text("").removeClass("k-button k-button-icontext").html("<span class='k-icon k-edit'></span>");
|
|
$(gridId).find('.k-grid-Delete').text("").removeClass("k-button k-button-icontext").html("<span class='k-icon k-delete'></span>");
|
|
|
|
// called common file function to show title on mouse hover.
|
|
addTitleAttribute();
|
|
// severity functionality
|
|
|
|
// Show Delete button in Grid if We add New Row And Hide Delete button in grid if Row is Already Inserted
|
|
//for (var i = 0; i < data.length; i++) {
|
|
// if (data[i].CustomerId != "" || typeof data[i].CustomerId == "undefined") {
|
|
// var grid = $(gridId).data("kendoGrid");
|
|
// grid.tbody.find("tr[data-uid='" + data[i].uid + "']").find('td').find('#cmdDeleteVech').find("span").removeClass("k-icon k-delete");
|
|
// }
|
|
//}
|
|
// show no data available message when grid has no data.
|
|
}
|
|
|
|
/**
|
|
* This function create a popup for Add Vechile Detail.
|
|
* @method AddVechileDetl
|
|
* @for ManageOwner
|
|
*/
|
|
function AddVechileDetl() {
|
|
oOwner = {};
|
|
|
|
oOwner.CustomerId = "";
|
|
|
|
//Hide Vechile Detail Validation Message
|
|
HideVechileValidationMsg();
|
|
addKendoWindowToDiv("#divAddCustDetl", "Add Vehicle Detail", "833px", 385, 95);
|
|
// Ajax request
|
|
if (activeRequest && activeRequest.readystate != 4) {
|
|
activeRequest.abort();
|
|
}
|
|
activeRequest = $.ajax({
|
|
type: "POST",
|
|
url: "/Inventory/ManageOwner_AddOrEditCustomer",
|
|
data: oOwner,
|
|
success: function (data) {
|
|
$("#divAddCustDetl").parent().addClass("responsive_popup") //addClass for respond the menu
|
|
$("#divAddCustDetl").html('');
|
|
$("#divAddCustDetl").html(data);
|
|
SetKendoWindowTitle("#divAddCustDetl", "Add Vehicle Detail");
|
|
//open form in new dialog box
|
|
$("#divAddCustDetl").data("kendoWindow").open();
|
|
$('#VehicleId').val("");
|
|
//Show Controls
|
|
$("#btnSaveVan,#VehicleRegistrationNumber,#ddlVechileType,#ddlVechileNo,#ddlState,#ddlCity").show();
|
|
//$("#btnSaveVan,#VehicleRegistrationNumber,#ddlState,#ddlCity").show();
|
|
$("#VehicleModelNumber,#VechVechType").hide();
|
|
$("#btnSaveCust").hide();
|
|
$("#hdnCustId").val("");
|
|
$('#VehicleInstallationDate').attr('disabled');
|
|
$('#VehicleRegistrationNumber,#VehicleNumberPlate').attr('readonly', false);
|
|
vAddOrUpdate = true;
|
|
vVechileSelectedRow = undefined;
|
|
$("#btnVechReset").show();
|
|
$("#btnCustReset").hide();
|
|
$("#btnSaveVan").prop('value', 'Save');
|
|
},
|
|
complete: function () {
|
|
vRegNo = $("#VehicleRegistrationNumber").val();
|
|
},
|
|
error: function (data) {
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* This function create a popup for Add Driver Detail.
|
|
* @method AddCustDetl
|
|
* @for ManageOwner
|
|
*/
|
|
function AddCustDetl(e) {
|
|
addKendoWindowToDiv("#divAddCustDetl", "Add Driver Detail", "833px", 385, 95);
|
|
// Ajax request
|
|
if (activeRequest && activeRequest.readystate != 4) {
|
|
activeRequest.abort();
|
|
}
|
|
var grid = $("#gridVechile").data("kendoGrid");
|
|
|
|
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
|
|
var rowIndx = $(e.currentTarget).closest("tr").index();
|
|
|
|
vSelectedRow = dataItem;
|
|
// Add or Edit Driver model
|
|
oOwner = {};
|
|
oOwner.VehicleId = dataItem.VehicleId;
|
|
oOwner.VehicleRegistrationNumber = dataItem.VehicleRegistrationNumber;
|
|
oOwner.VehicleNumberPlate = dataItem.VehicleNumberPlate;
|
|
oOwner.VehicleModelNumber = dataItem.VehicleModelNumber;
|
|
oOwner.VehicleType = dataItem.VehicleType;
|
|
oOwner.CustomerVehicleModelTagging = dataItem.CustomerVehicleModelTagging;
|
|
oOwner.VehicleInstallationDate = dataItem.VehicleInstallationDate;
|
|
|
|
activeRequest = $.ajax({
|
|
type: "POST",
|
|
data: oOwner,
|
|
url: "/Inventory/ManageOwner_AddOrEditCustomer",
|
|
success: function (data) {
|
|
$("#divAddCustDetl").parent().addClass("responsive_popup") //addClass for respond the menu
|
|
$("#divAddCustDetl").html('');
|
|
$("#divAddCustDetl").html('');
|
|
$("#divAddCustDetl").html(data);
|
|
SetKendoWindowTitle("#divAddCustDetl", "Add Driver Detail");
|
|
//open form in new dialog box
|
|
$("#divAddCustDetl").data("kendoWindow").open();
|
|
$('#VehicleId').val(dataItem.VehicleId);
|
|
$("#btnSaveCust").show();
|
|
$("#btnSaveVan").hide();
|
|
$('#VehicleRegistrationNumber,#VehicleNumberPlate').show().attr('readonly', true);
|
|
$('#ddlVechileNo,#ddlVechileType').hide();
|
|
vSelectedRow = undefined;
|
|
vVechileSelectedRow = undefined;
|
|
$('#ddlState').show();
|
|
//$('#VechState').hide();
|
|
//$('#VechCity').hide();
|
|
$('#ddlCity').show();
|
|
grid = $("#gridVechile").data("kendoGrid");
|
|
|
|
grid.expandRow(grid.tbody.find("tr.k-master-row").eq(rowIndx));
|
|
$("#hdnCustId").val("");
|
|
vAddOrUpdate = true;
|
|
$("#btnVechReset").hide();
|
|
$("#btnCustReset").show();
|
|
$("#btnSaveCust").prop('value', 'Save');
|
|
},
|
|
complete: function () {
|
|
var datepicker = $("#VehicleInstallationDate").data("kendoDatePicker");
|
|
datepicker.enable(false);
|
|
vRegNoOnPageLoad = $('#VehicleRegistrationNumber').cleanVal();
|
|
vChasisNoOnPageLoad = $('#VehicleNumberPlate').val();
|
|
},
|
|
error: function (data) {
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
//function SetVehicleCOntrolDisabled() {
|
|
// var datepicker = $("#VehicleInstallationDate").data("kendoDatePicker");
|
|
// datepicker.enable(false);
|
|
|
|
//}
|
|
///**
|
|
//* Function to show Owner details.
|
|
//* @method showOwnerDetails
|
|
//* @for ManageOwner
|
|
//*/
|
|
//function showOwnerDetails() {
|
|
|
|
// //function call on click of user list table's row
|
|
// $("#tableOwnerList tbody tr").click(function (e) {
|
|
|
|
|
|
// });
|
|
|
|
// //Trigger click event on first row of non-vecv owner list table
|
|
// $("#tableOwnerList tbody tr:first").trigger('click');
|
|
//}
|
|
|
|
/**
|
|
* Function to load city list state wise.
|
|
* @method LoadCityList
|
|
* @param {String} stateId selected state id
|
|
* @for ManageOwner
|
|
*/
|
|
function LoadCityList(ddlstateId, ddlcustId) {
|
|
var selectedState = $(ddlstateId).find('option:selected').text();
|
|
$("#stateName").val(selectedState);
|
|
var stateVal;
|
|
stateVal = $(ddlstateId).val();
|
|
if (stateVal != "-Select-")
|
|
stateVal = $(ddlstateId).val();
|
|
else
|
|
stateVal = 0;
|
|
|
|
if (stateVal != "") {
|
|
|
|
if (activeRequest_City && activeRequest_City.readystate != 4) {
|
|
activeRequest_City.abort();
|
|
}
|
|
activeRequest_City = $.ajax({
|
|
type: "GET",
|
|
url: "/UserInventory/showCityStateWise/",
|
|
data: { stateVal: stateVal },
|
|
success: function (data) {
|
|
// empty City dropdown
|
|
$(ddlcustId).text("");
|
|
// by default add select text.
|
|
$(ddlcustId).append($('<option></option>').val("").html("-Select-"));
|
|
// add data to dropdown.
|
|
if (data.list) {
|
|
for (var counter = 0; counter < data.list.length; counter++) {
|
|
$(ddlcustId).append(
|
|
$('<option></option>').val(data.list[counter].Value).html(data.list[counter].Text));
|
|
}
|
|
}
|
|
if (ddlcustId == "#ddlOwnerCity") {
|
|
$(ddlcustId).val($("#OwnerCityId").val());
|
|
}
|
|
if (ddlcustId == "#ddlCity") {
|
|
$(ddlcustId).val($("#hdnCustCityIdNo").val());
|
|
}
|
|
|
|
},
|
|
error: function (data) {
|
|
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Function to Show the Detail in pop up on Add Csutomer Button Click in Kendo grid.
|
|
* @method AddCustomer
|
|
* @param {Object} e Contains Complete Row Detail Of Kendo grid.
|
|
* @for ManageOwner
|
|
*/
|
|
|
|
function AddCustomer(e) {
|
|
addKendoWindowToDiv("#divAddCustDetl", "Add Driver Detail", "833px", 385, 95);
|
|
// Ajax request
|
|
if (activeRequest && activeRequest.readystate != 4) {
|
|
activeRequest.abort();
|
|
}
|
|
|
|
activeRequest = $.ajax({
|
|
type: "POST",
|
|
url: "/Inventory/ManageOwner_AddOrEditCustomer",
|
|
success: function (data) {
|
|
$("#divAddCustDetl").parent().addClass("responsive_popup"); //addClass for respond the menu
|
|
$("#divAddCustDetl").html('');
|
|
$("#divAddCustDetl").html('');
|
|
$("#divAddCustDetl").html(data);
|
|
SetKendoWindowTitle("#divAddCustDetl", "Add Driver Detail");
|
|
//open form in new dialog box
|
|
$("#divAddCustDetl").data("kendoWindow").open();
|
|
|
|
//$('#btnSaveVan,#VehicleModelNumber,#VehicleType,#CustomerState,#CustomerCity').hide();
|
|
$('#btnSaveVan,#VehicleType,#CustomerState,#CustomerCity').hide();
|
|
//$('#btnSaveCust,#ddlVechileNo,#ddlVechileType,#ddlState,#ddlCity').show();
|
|
$('#btnSaveCust,#ddlState,#ddlCity').show();
|
|
$('#VehicleId').val("");
|
|
$("#VehicleInstallationDate").attr('readonly', true);
|
|
vAddOrUpdate = true;
|
|
},
|
|
error: function (data) {
|
|
|
|
}
|
|
});
|
|
}
|
|
/**
|
|
* Function used to save or update (in case of newly added Vechile) the Vechile Including its Driver in grid.
|
|
* @method btnSaveVechileCust
|
|
* @for ManageOwner
|
|
*/
|
|
function btnSaveVechileCust() {
|
|
if (CheckVechileValidation()) {
|
|
var CustomerCustomerName = $("#CustomerCustomerName").val();
|
|
var VehicleRegistrationNumber = $("#VehicleRegistrationNumber").cleanVal();
|
|
var VehicleNumberPlate = $("#VehicleNumberPlate").val();
|
|
var VehicleModelNumber = $("#ddlVechileNo option:selected").val();
|
|
var VehicleType = $("#ddlVechileType option:selected").val();
|
|
var CustomerCustomerName = $("#VechCustName").val();
|
|
var CustomerMobileNumber1 = $("#VechileMobileNo").val();
|
|
var CustomerAddress = $("#VechileAddress").val();
|
|
var CustomerState = $("#ddlState option:selected").text();
|
|
var CustomerCity = $("#ddlCity option:selected").val();
|
|
var VehicleId = $("#VehicleId").val();
|
|
var CustomerEmailId = $("#txtCustomerEmailId").val();
|
|
var ProductVar = $("#VechProduct").val();
|
|
var vdataSourceLength = 0;
|
|
var vTotal = 0;
|
|
var VehicleInstallationDate = $("#VehicleInstallationDate").val();
|
|
var vCustId = $("#hdnCustId").val();
|
|
|
|
oOwner = {};
|
|
oOwner.VehicleId = VehicleId;
|
|
oOwner.CustomerCustomerName = CustomerCustomerName;
|
|
oOwner.VehicleRegistrationNumber = VehicleRegistrationNumber;
|
|
oOwner.VehicleNumberPlate = VehicleNumberPlate;
|
|
oOwner.VehicleModelNumber = VehicleModelNumber;
|
|
oOwner.VehicleType = VehicleType;
|
|
oOwner.CustomerMobileNumber1 = CustomerMobileNumber1;
|
|
oOwner.CustomerAddress = CustomerAddress;
|
|
oOwner.CustomerState = CustomerState;
|
|
oOwner.CustomerCity = CustomerCity;
|
|
oOwner.CustomerId = vCustId;
|
|
oOwner.CustomerEmailId = CustomerEmailId;
|
|
oOwner.CustomerVehicleModelTagging = ProductVar;
|
|
oOwner.VehicleInstallationDate = VehicleInstallationDate;
|
|
var datasourceOwner;
|
|
var datasourceVechile;
|
|
|
|
var gridVechile = $("#gridVechile").data("kendoGrid");
|
|
datasourceCust = gridVechile.dataSource;
|
|
|
|
if (typeof (vVechileSelectedRow) == "undefined") {
|
|
vTotal = datasourceCust.total();
|
|
//If New vechile is added then we add it in Datasource and Also in Array
|
|
//So that array is used to added the newly data
|
|
datasourceCust.add({
|
|
VehicleId: oOwner.VehicleId, CustomerId: oOwner.CustomerId, VehicleRegistrationNumber: oOwner.VehicleRegistrationNumber,
|
|
VehicleNumberPlate: oOwner.VehicleNumberPlate, VehicleModelNumber: oOwner.VehicleModelNumber,
|
|
VehicleType: oOwner.VehicleType, CustomerId: oOwner.CustomerId, CustomerCustomerName: oOwner.CustomerCustomerName,
|
|
CustomerAddress: oOwner.CustomerAddress, CustomerState: oOwner.CustomerState, CustomerMobileNumber1: oOwner.CustomerMobileNumber1,
|
|
CustomerCity: oOwner.CustomerCity, CustomerEmailId: oOwner.CustomerEmailId, CustomerVehicleModelTagging: oOwner.CustomerVehicleModelTagging,
|
|
VehicleInstallationDate: oOwner.VehicleInstallationDate
|
|
});
|
|
|
|
var gridId = "#gridCust_" + oOwner.VehicleRegistrationNumber;
|
|
var gridCust = $(gridId).data("kendoGrid");
|
|
|
|
var datasourceCust = new kendo.data.DataSource({
|
|
VehicleId: oOwner.VehicleId,
|
|
VehicleRegistrationNumber: oOwner.VehicleRegistrationNumber
|
|
});
|
|
|
|
AddInList();
|
|
|
|
$(gridId).kendoGrid({
|
|
dataSource: datasourceCust
|
|
});
|
|
|
|
vdataSourceLength = datasourceCust.total();
|
|
closeWindow('#divAddCustDetl');
|
|
gridVechile.expandRow(gridVechile.tbody.find("tr.k-master-row").eq(vTotal));
|
|
}
|
|
else {
|
|
//If we update the vechile is then we update it in Datasource and Also in Array
|
|
//So that array is used to Updated the previously data
|
|
vVechileSelectedRow.set("VehicleId", oOwner.VehicleId);
|
|
vVechileSelectedRow.set("VehicleInstallationDate", oOwner.VehicleInstallationDate);
|
|
vVechileSelectedRow.set("VehicleNumberPlate", oOwner.VehicleNumberPlate);
|
|
vVechileSelectedRow.set("VehicleModelNumber", oOwner.VehicleModelNumber);
|
|
vVechileSelectedRow.set("VehicleType", oOwner.VehicleType);
|
|
vVechileSelectedRow.set("CustomerVehicleModelTagging", oOwner.CustomerVehicleModelTagging);
|
|
vVechileSelectedRow.set("CustomerCustomerName", oOwner.CustomerCustomerName);
|
|
vVechileSelectedRow.set("CustomerMobileNumber1", oOwner.CustomerMobileNumber1);
|
|
vVechileSelectedRow.set("CustomerAddress", oOwner.CustomerAddress);
|
|
vVechileSelectedRow.set("CustomerState", oOwner.CustomerState);
|
|
vVechileSelectedRow.set("CustomerCity", oOwner.CustomerCity);
|
|
vVechileSelectedRow.set("VehicleRegistrationNumber", oOwner.VehicleRegistrationNumber);
|
|
vVechileSelectedRow.set("CustomerEmailId", oOwner.CustomerEmailId);
|
|
vVechileSelectedRow.set("VehicleInstallationDate", oOwner.VehicleInstallationDate);
|
|
AddInList();
|
|
}
|
|
closeWindow("#divAddCustDetl");
|
|
}
|
|
}
|
|
/**
|
|
* Function used to save or update (in case of newly added Driver) the Driver in grid.
|
|
* @method btnSaveCustDetail
|
|
* @for ManageOwner
|
|
*/
|
|
function btnSaveCustDetail() {
|
|
if (CheckVechileValidation()) {
|
|
var CustomerCustomerName = $("#CustomerCustomerName").val();
|
|
var VehicleRegistrationNumber = $("#VehicleRegistrationNumber").cleanVal();
|
|
var VehicleNumberPlate = $("#VehicleNumberPlate").val();
|
|
var VehicleModelNumber = $("#ddlVechileNo option:selected").val();
|
|
var VehicleType = $("#ddlVechileType option:selected").val();
|
|
var CustomerCustomerName = $("#VechCustName").val();
|
|
var CustomerMobileNumber1 = $("#VechileMobileNo").val();
|
|
var CustomerAddress = $("#VechileAddress").val();
|
|
var CustomerState = $("#ddlState option:selected").text();
|
|
var CustomerCity = $("#ddlCity option:selected").val();
|
|
var VehicleId = $("#VehicleId").val();
|
|
var CustomerEmailId = $("#txtCustomerEmailId").val();
|
|
var vdataSourceLength = 0;
|
|
var VehicleInstallationDate = $("#VehicleInstallationDate").val();
|
|
var VechProduct = $("#VechProduct").val();
|
|
|
|
oOwner = {};
|
|
oOwner.VehicleId = VehicleId;
|
|
oOwner.CustomerCustomerName = CustomerCustomerName;
|
|
oOwner.VehicleRegistrationNumber = VehicleRegistrationNumber;
|
|
oOwner.VehicleNumberPlate = VehicleNumberPlate;
|
|
oOwner.VehicleModelNumber = VehicleModelNumber;
|
|
oOwner.VehicleType = VehicleType;
|
|
oOwner.CustomerMobileNumber1 = CustomerMobileNumber1;
|
|
oOwner.CustomerAddress = CustomerAddress;
|
|
oOwner.CustomerState = CustomerState;
|
|
oOwner.CustomerCity = CustomerCity;
|
|
oOwner.CustomerId = "";
|
|
oOwner.CustomerEmailId = CustomerEmailId;
|
|
oOwner.VehicleInstallationDate = VehicleInstallationDate;
|
|
oOwner.CustomerVehicleModelTagging = VechProduct;
|
|
|
|
var datasource;
|
|
var gridId = "#gridCust_" + oOwner.VehicleRegistrationNumber;
|
|
var grid = $(gridId).data("kendoGrid");
|
|
|
|
if (grid != null)
|
|
datasource = grid.dataSource;
|
|
|
|
if (typeof (vVechileSelectedRow) == "undefined") {
|
|
//If New Driver is added then we add it in Datasource and Also in Array
|
|
//So that array is used to added the newly data
|
|
var gridId = "#gridCust_" + oOwner.VehicleRegistrationNumber;
|
|
grid = $(gridId).data("kendoGrid");
|
|
datasource = grid.dataSource;
|
|
datasource.add({
|
|
VehicleId: oOwner.VehicleId, VehicleRegistrationNumber: oOwner.VehicleRegistrationNumber,
|
|
VehicleNumberPlate: oOwner.VehicleNumberPlate, VehicleModelNumber: oOwner.VehicleModelNumber,
|
|
VehicleType: oOwner.VehicleType, CustomerCustomerName: oOwner.CustomerCustomerName,
|
|
CustomerAddress: oOwner.CustomerAddress, CustomerState: oOwner.CustomerState,
|
|
CustomerMobileNumber1: oOwner.CustomerMobileNumber1, CustomerCity: oOwner.CustomerCity,
|
|
CustomerId: oOwner.CustomerId, CustomerEmailId: oOwner.CustomerEmailId,
|
|
VehicleInstallationDate: oOwner.VehicleInstallationDate,CustomerVehicleModelTagging : oOwner.CustomerVehicleModelTagging
|
|
});
|
|
}
|
|
else {
|
|
//If we update the Driver is then we update it in Datasource and Also in Array
|
|
//So that array is used to Updated the previously data
|
|
vVechileSelectedRow.set("VehicleId", oOwner.VehicleId);
|
|
vVechileSelectedRow.set("CustomerCustomerName", oOwner.CustomerCustomerName);
|
|
vVechileSelectedRow.set("CustomerMobileNumber1", oOwner.CustomerMobileNumber1);
|
|
vVechileSelectedRow.set("CustomerAddress", oOwner.CustomerAddress);
|
|
vVechileSelectedRow.set("CustomerState", oOwner.CustomerState);
|
|
vVechileSelectedRow.set("CustomerCity", oOwner.CustomerCity);
|
|
vVechileSelectedRow.set("VehicleRegistrationNumber", oOwner.VehicleRegistrationNumber);
|
|
vVechileSelectedRow.set("CustomerEmailId", oOwner.CustomerEmailId);
|
|
vVechileSelectedRow.set("VehicleInstallationDate", oOwner.VehicleInstallationDate);
|
|
vVechileSelectedRow.set("CustomerVehicleModelTagging", oOwner.CustomerVehicleModelTagging);
|
|
}
|
|
AddInList();
|
|
closeWindow("#divAddCustDetl");
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* This function is used to Search the data In Owner List
|
|
* @method initSearch
|
|
* @keyCode {string} The Key code which is pressed by user.
|
|
* @sValue {string} The Value Enter in Textbox.
|
|
* @for ManageOwner
|
|
*/
|
|
function initSearch(keyCode, sValue) {
|
|
var $rows = $('#tableOwnerList tbody tr');
|
|
var jThis;
|
|
if (keyCode != 8 && keyCode != 46) {
|
|
$rows.each(function () {
|
|
jThis = $(this);
|
|
if (jThis.is(':visible')) {
|
|
var oLabel = jThis.find('label').text();
|
|
if (oLabel.length > 0) {
|
|
if (oLabel.toLowerCase().indexOf(sValue.toLowerCase()) >= 0) {
|
|
jThis.show();
|
|
} else {
|
|
jThis.hide();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
else {
|
|
$rows.each(function () {
|
|
jThis = $(this);
|
|
var oLabel = jThis.find('label').text();
|
|
if (oLabel.length > 0) {
|
|
if (oLabel.toLowerCase().indexOf(sValue.toLowerCase()) >= 0) {
|
|
jThis.show();
|
|
} else {
|
|
jThis.hide();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* This function is used to Add the New Owner.
|
|
* @method btnAddOwnerDetail
|
|
* @for ManageOwner
|
|
*/
|
|
function btnAddOwnerDetail() {
|
|
custId = 0;
|
|
if (activeRequest_OwnerDetails && activeRequest_OwnerDetails.readystate != 4) {
|
|
activeRequest_OwnerDetails.abort();
|
|
}
|
|
activeRequest_OwnerDetails = $.ajax({
|
|
type: "POST",
|
|
url: "/Inventory/ManageOwner_GetOwnerDetails/",
|
|
data: { CustId: custId },
|
|
success: function (data) {
|
|
$("#divOwnerDetailPanel").html('');
|
|
$("#divOwnerDetailPanel").html(data);
|
|
//$('#CustomerCustomerName').attr('readonly', false);
|
|
$("#btnAdd").hide();
|
|
vCustMobileNoOnPageLoad = $("#CustomerMobileNumber1").val();
|
|
$("#VechCustName").attr('readonly', false);
|
|
vSelectedRow = undefined;
|
|
$("#btnDeleteOwner").hide();
|
|
$("#btnSaveOwner").prop('value', 'Save');
|
|
|
|
},
|
|
error: function (data) {
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* This function is used to Cancel the Operation.
|
|
* @method btnCancelAddUser
|
|
* @for ManageOwner
|
|
*/
|
|
|
|
function btnCancelAddUser() {
|
|
//$("#tableDealerList tbody tr.SelectedRow").trigger('click');
|
|
if (document.getElementById('tableOwnerList')) {
|
|
$("#tableOwnerList tbody tr.SelectedRow").trigger('click');
|
|
} else {
|
|
$("#divOwnerList").html("");
|
|
$("#btnAdd").show();
|
|
}
|
|
}
|
|
/**
|
|
* Bind textbox keyup event for searching.
|
|
* @event keyup
|
|
* @for ManageOwner
|
|
*/
|
|
$('#txtSearchOwnerList').keyup(function (event) {
|
|
var sValue = $.trim($(this).val());
|
|
initSearch(event.keyCode, sValue);
|
|
}).keydown(function () { }).focus(function () { $(this).select(); });
|
|
|
|
//------------------------------------ document ready function --------------------------------------//
|
|
$(document).ready(function () {
|
|
//get owner list after DOM is ready
|
|
loadStateChoices();
|
|
$("#btnDeleteOwner").hide();
|
|
$('#srchText').clearableTextField();
|
|
//Save The Owner Detail On Click Button
|
|
$('#btnSaveOwner').click(function () {
|
|
if (AllValid()) {
|
|
SaveRecord(false);
|
|
}
|
|
});
|
|
|
|
$("#btnDeleteOwner").click(function () {
|
|
//jConfirm("Do you want to delete the Customer <b>" + OwnerName + '</b> ?', 'Delete', function (result) {
|
|
jConfirm(MANAGE_FLEET_MESSAGES.confirmDeleteCustomer + " <b>" + OwnerName + '</b> ?', 'Delete', function (result) {
|
|
//again check whether user input is true
|
|
if (result) {
|
|
SaveRecord(true);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
/**
|
|
* This Function is used to save the record of owner.
|
|
* @method SaveRecord
|
|
* @for ManageOwner
|
|
*/
|
|
|
|
function SaveRecord(IsDeleted) {
|
|
$("#div_load").show();
|
|
var vArrVechile = new Array();
|
|
var gridVechile = $("#gridVechile").data("kendoGrid");
|
|
var datasource = gridVechile.dataSource;
|
|
vdataSourceLength = gridVechile.dataSource.total();
|
|
var data = datasource.view();
|
|
|
|
var CustomerCustomerName = $("#CustomerCustomerName").val();
|
|
var CustomerMobileNumber1 = $("#CustomerMobileNumber1").val();
|
|
var CustomerAddress = $("#OwnerAddress").val();
|
|
var CustomerEmailId = $("#CustomerEmailId").val();
|
|
var vStateId = $("#ddlOwnerState option:selected").text();
|
|
var vCityId = $("#ddlOwnerCity option:selected").val();
|
|
var CustList = datasource.data();
|
|
var CustomerId = $("#hdnCustomerId").val();
|
|
|
|
var OwnerData = {
|
|
CustomerCustomerName: CustomerCustomerName,
|
|
CustomerMobileNumber1: CustomerMobileNumber1,
|
|
CustomerAddress: CustomerAddress,
|
|
CustomerEmailId: CustomerEmailId,
|
|
plsVechileList: VechiledataSource, // The VechiledataSource is used the save or update the information of Vechile and Driver
|
|
CustomerState: vStateId,
|
|
CustomerCity: vCityId,
|
|
CustomerId: CustomerId,
|
|
IsDeleted: IsDeleted
|
|
};
|
|
$.ajax({
|
|
contentType: 'application/json; charset=utf-8',
|
|
dataType: 'json',
|
|
type: 'POST',
|
|
url: '/Inventory/ManageOwner_SaveOwner',
|
|
data: JSON.stringify(OwnerData),
|
|
success: function (data) {
|
|
jAlert(data.message, 'message');
|
|
$('#srchText').val('');
|
|
$("#hdnCustomerId").val(data.Custid);
|
|
getOwnerList();
|
|
VechiledataSource = new Array();
|
|
$("#div_load").hide();
|
|
$("#btnDeleteOwner").hide();
|
|
$("#btnSaveOwner").prop('value', 'Save');
|
|
if (IsDeleted)
|
|
$("#btnAdd").click();
|
|
},
|
|
failure: function (response) {
|
|
|
|
}
|
|
});
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* This Function is used to save or update the record of Vechile and Driver.
|
|
* @method AddInList
|
|
* @for ManageOwner
|
|
*/
|
|
|
|
function AddInList() {
|
|
var vOwner;
|
|
var CustomerCustomerName = $("#VechCustName").val();
|
|
var CustomerMobileNumber1 = $("#VechileMobileNo").val();
|
|
var CustomerAddress = $("#VechileAddress").val();
|
|
var vStateId = $("#ddlState option:selected").text();
|
|
var vCityId = $("#ddlCity option:selected").val();
|
|
var VehicleRegistrationNumber = $("#VehicleRegistrationNumber").cleanVal();
|
|
var VehicleNumberPlate = $("#VehicleNumberPlate").val();
|
|
var VehicleModelNumber = $("#ddlVechileNo option:selected").val();
|
|
var VehicleType = $("#ddlVechileType option:selected").val();
|
|
var VehicleId = $("#VehicleId").val();
|
|
var CustomerId = $("#hdnCustId").val();
|
|
var vCustomerEmailId = $("#txtCustomerEmailId").val();
|
|
var ProductVar = $("#VechProduct").val();
|
|
var VehicleInstallationDate = $("#VehicleInstallationDate").val();
|
|
//Used to check whether Registration No is Exist In array or Not
|
|
//If Registration No. Exist in VechiledataSource Array then we will update the Vechile Detail
|
|
//Else we will Add the Vechile Detail
|
|
if (vAddOrUpdate == false) {
|
|
if (VechiledataSource.length > 0) {
|
|
for (var i = 0; i < VechiledataSource.length; i++) {
|
|
if (VechiledataSource[i].VehicleRegistrationNumber == VehicleRegistrationNumber) {
|
|
VechiledataSource[i].VehicleId = VehicleId;
|
|
VechiledataSource[i].CustomerId = CustomerId;
|
|
VechiledataSource[i].CustomerCustomerName = CustomerCustomerName;
|
|
VechiledataSource[i].CustomerMobileNumber1 = CustomerMobileNumber1;
|
|
VechiledataSource[i].CustomerAddress = CustomerAddress;
|
|
VechiledataSource[i].CustomerState = vStateId;
|
|
VechiledataSource[i].CustomerCity = vCityId;
|
|
VechiledataSource[i].VehicleRegistrationNumber = VehicleRegistrationNumber;
|
|
VechiledataSource[i].VehicleNumberPlate = VehicleNumberPlate;
|
|
VechiledataSource[i].VehicleModelNumber = VehicleModelNumber;
|
|
VechiledataSource[i].VehicleType = VehicleType;
|
|
VechiledataSource[i].CustomerEmailId = vCustomerEmailId;
|
|
VechiledataSource[i].CustomerVehicleModelTagging = ProductVar;
|
|
VechiledataSource[i].IsDeleted = false;
|
|
VechiledataSource[i].VehicleInstallationDate = VehicleInstallationDate;
|
|
break;
|
|
}
|
|
else {
|
|
vAddOrUpdate = true;
|
|
}
|
|
}
|
|
|
|
}
|
|
else {
|
|
vAddOrUpdate = true;
|
|
}
|
|
}
|
|
|
|
if (vAddOrUpdate == true) {
|
|
|
|
var OwnerData = {
|
|
VehicleId: VehicleId,
|
|
CustomerId: CustomerId,
|
|
CustomerCustomerName: CustomerCustomerName,
|
|
CustomerMobileNumber1: CustomerMobileNumber1,
|
|
CustomerAddress: CustomerAddress,
|
|
CustomerState: vStateId,
|
|
CustomerCity: vCityId,
|
|
VehicleRegistrationNumber: VehicleRegistrationNumber,
|
|
VehicleNumberPlate: VehicleNumberPlate,
|
|
VehicleModelNumber: VehicleModelNumber,
|
|
VehicleType: VehicleType,
|
|
CustomerEmailId: vCustomerEmailId,
|
|
CustomerVehicleModelTagging: ProductVar,
|
|
IsDeleted: false,
|
|
VehicleInstallationDate: VehicleInstallationDate
|
|
};
|
|
|
|
VechiledataSource.push(OwnerData);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* This Function is used to Check the validation for Add or Updating Vechile and Driver Detail
|
|
* @method CheckVechileValidation
|
|
* @for ManageOwner
|
|
*/
|
|
function CheckVechileValidation() {
|
|
HideVechileValidationMsg();
|
|
|
|
var vResult = false;
|
|
|
|
var VehicleRegistrationNumber = $("#VehicleRegistrationNumber").cleanVal();
|
|
var VehicleNumberPlate = $("#VehicleNumberPlate").val();
|
|
var VehicleModelNumber = $("#ddlVechileNo option:selected").val();
|
|
var VehicleType = $("#ddlVechileType option:selected").val();
|
|
var CustomerCustomerName = $("#VechCustName").val();
|
|
var CustomerMobileNumber1 = $("#VechileMobileNo").val();
|
|
var CustomerAddress = $("#VechileAddress").val();
|
|
var vStateId = $("#ddlState option:selected").text();
|
|
var vCityId = $("#ddlCity option:selected").text();
|
|
var CustomerEmailId = $("#txtCustomerEmailId").val();
|
|
var VehicleInstallationDate = $("#VehicleInstallationDate").val();
|
|
if (VehicleRegistrationNumber == "")
|
|
$("#spanVanRegNo").show();
|
|
else if (VehicleNumberPlate == "")
|
|
$("#spanVanPlateNo").show();
|
|
else if (VehicleModelNumber == "" && $("#VehicleModelNumber").val() == "")
|
|
$("#spanVechModelNo").show();
|
|
else if (VehicleType == "")
|
|
$("#spanVechType").show();
|
|
////else if (VehicleInstallationDate == "")
|
|
//// $("#spanVehicleInstallationDate").show()
|
|
else if (CustomerCustomerName == "")
|
|
$("#spanCustomerName").show();
|
|
else if (CustomerMobileNumber1 == "") {
|
|
$("#spanCustomerMobileNo").text("*");
|
|
$("#spanCustomerMobileNo").show();
|
|
}
|
|
else if (CustomerMobileNumber1.length != 10) {
|
|
$("#spanCustomerMobileNo").text("Mobile No. should be 10 Characters in Length");
|
|
$("#spanCustomerMobileNo").show();
|
|
}
|
|
else if (CustomerAddress == "")
|
|
$("#spanCustomerAddress").show();
|
|
else if (vStateId == "-Select-")
|
|
$("#spanCustomerState").show();
|
|
else if (vCityId == "-Select-")
|
|
$("#spanCustomerCity").show();
|
|
else if (vRegNoDup > 0)
|
|
jAlert(vDupMsgRegNo, 'message');
|
|
else if (vChasisNoDup > 0)
|
|
jAlert(vDupMsgChasisNo, 'message');
|
|
else if (CustomerEmailId != "") {
|
|
if (validateEmail(CustomerEmailId)) {
|
|
vResult = true;
|
|
}
|
|
else {
|
|
$("#spanCustEmailId").show();
|
|
}
|
|
}
|
|
else
|
|
vResult = true;
|
|
|
|
return vResult;
|
|
}
|
|
|
|
/**
|
|
* This Function is used to Hide the validation message for Add or Updating Vechile and Driver Detail
|
|
* @method HideVechileValidationMsg
|
|
* @for ManageOwner
|
|
*/
|
|
function HideVechileValidationMsg() {
|
|
$("#spanVanRegNo").hide();
|
|
$("#spanVanPlateNo").hide();
|
|
$("#spanVechModelNo").hide();
|
|
$("#spanVechType").hide();
|
|
$("#spanVechModelNo").hide();
|
|
$("#spanCustomerName").hide();
|
|
$("#spanCustomerMobileNo").hide();
|
|
$("#spanCustomerName").hide();
|
|
$("#spanCustomerAddress").hide();
|
|
$("#spanCustomerState").hide();
|
|
$("#spanCustomerEmailId").hide();
|
|
$("#spanVehicleInstallationDate").hide();
|
|
}
|
|
|
|
/**
|
|
* This Function is used to Check the validation for Add or Updating Owner Detail
|
|
* @method AllValid
|
|
* @for ManageOwner
|
|
*/
|
|
|
|
function AllValid() {
|
|
HideValidMsg();
|
|
|
|
var vResult = false;
|
|
var grid = $("#gridVechile").data("kendoGrid");
|
|
var datasource = grid.dataSource.data().length;
|
|
var OwnerName = $("#CustomerCustomerName").val();
|
|
var OwnerMobileNumber = $("#CustomerMobileNumber1").val();
|
|
var OwnerAddress = $("#OwnerAddress").val();
|
|
var CustomerEmailId = $("#CustomerEmailId").val();
|
|
var CustomerAddress = $("#VechileAddress").val();
|
|
var vStateId = $("#ddlOwnerState option:selected").text();
|
|
var vCityId = $("#ddlOwnerCity option:selected").text();
|
|
var vValidEmail = validateEmail(CustomerEmailId);
|
|
|
|
if (OwnerName == "")
|
|
$("#spanOwnerName").show();
|
|
else if (OwnerMobileNumber == "") {
|
|
$("#spanOwnerMobileNo").text("*");
|
|
$("#spanOwnerMobileNo").show();
|
|
}
|
|
else if (OwnerMobileNumber.length != 10) {
|
|
$("#spanOwnerMobileNo").text("Mobile No. should be of 10 characters.");
|
|
$("#spanOwnerMobileNo").show();
|
|
}
|
|
else if (OwnerAddress == "")
|
|
$("#spanOwnerAddress").show();
|
|
else if (vStateId == "-Select-")
|
|
$("#spanOwnerState").show();
|
|
else if (vCityId == "-Select-")
|
|
$("#spanOwnerCity").show();
|
|
else if (datasource == 0)
|
|
//jAlert("Please enter Vechile detail", 'message');
|
|
jAlert(MANAGE_OWNER_MESSAGES.enterVehicleDetail, 'message');
|
|
else if (vOwnerMobileNoDup > 0)
|
|
jAlert(vDupMsg, 'message');
|
|
else if (CustomerEmailId != "") {
|
|
if (validateEmail(CustomerEmailId)) {
|
|
vResult = true;
|
|
}
|
|
else {
|
|
$("#spanOwnerEmailId").text("Please enter valid email");
|
|
$("#spanOwnerEmailId").show();
|
|
}
|
|
}
|
|
else
|
|
vResult = true;
|
|
|
|
return vResult;
|
|
}
|
|
/**
|
|
* This Function is used to hide the validation Message of owner Detail
|
|
* @method HideValidMsg
|
|
* @for ManageOwner
|
|
*/
|
|
|
|
function HideValidMsg() {
|
|
$("#spanOwnerName").hide();
|
|
$("#spanOwnerMobileNo").hide();
|
|
$("#spanCustomerAddress").hide();
|
|
$("#spanVechModelNo").hide();
|
|
$("#spanOwnerEmailId").hide();
|
|
$("#spanOwnerState").hide();
|
|
$("#spanOwnerCity").hide();
|
|
|
|
}
|
|
/**
|
|
* This Function is used to Validate the Email Id
|
|
* @param {String} email text of Email
|
|
* @method validateEmail
|
|
* @for ManageOwner
|
|
*/
|
|
|
|
function validateEmail(email) {
|
|
var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
|
|
return re.test(email);
|
|
}
|
|
|
|
/**
|
|
* This Function is used to intialize the vRegNoDup and vChasisNoDup so that it should be check on blur or on save in button click in Vechile and Driver
|
|
* @method SetDupValueFalse
|
|
* @for ManageOwner
|
|
*/
|
|
function SetDupValueFalse() {
|
|
vRegNoDup = 0;
|
|
vChasisNoDup = 0;
|
|
}
|
|
/**
|
|
* This Function is used to check whether Vechile Registration No., Vechile Chasis No. or Owner Mobile No is already Added or available in DB.
|
|
* @method CheckDUP
|
|
* @param {string} type = 1(For Vechile Registration No.),type = 2(For Vechile Chasis No.),type = 3 (for Owner Mobile No.)
|
|
* @for ManageOwner
|
|
*/
|
|
|
|
function CheckDUP(type) {
|
|
var CustName = "";
|
|
var vCheckDup = false;
|
|
if (type == "1") {
|
|
CustName = $("#VehicleRegistrationNumber").cleanVal();
|
|
vRegNoDup = 0;
|
|
//Check Vechile Registration No.
|
|
//Is it Come same as on Form Load
|
|
//IF it change then we Check in Grid
|
|
if (CustName != vRegNoOnPageLoad) {
|
|
vCheckDup = CheckRegNoInGrid(CustName);
|
|
}
|
|
}
|
|
else if (type == "2") {
|
|
CustName = $("#VehicleNumberPlate").val();
|
|
vChasisNoDup = 0;
|
|
//Check Vechile Chasis No.
|
|
//Is it Come same as on Form Load
|
|
//IF it change then we Check in Grid
|
|
if (CustName != vChasisNoOnPageLoad) {
|
|
vCheckDup = CheckChasisNoInGrid(CustName);
|
|
}
|
|
}
|
|
else if (type == "3") {
|
|
CustName = $("#CustomerMobileNumber1").val();
|
|
vOwnerMobileNoDup = 0;
|
|
//Check Driver Mobile No.
|
|
if (CustName != vCustMobileNoOnPageLoad) {
|
|
vCheckDup = true;
|
|
}
|
|
}
|
|
if (vCheckDup == true && CustName != "") {
|
|
$("#div_load").show();
|
|
$.ajax({
|
|
dataType: 'json',
|
|
type: 'POST',
|
|
url: '/Inventory/CheckForDuplication',
|
|
data: { CustName: CustName, type: type },
|
|
success: function (data) {
|
|
if (data.success == false) {
|
|
jAlert(data.message, 'message');
|
|
if (type == "1") {
|
|
vDupMsgRegNo = data.message;
|
|
//Set
|
|
vRegNoDup = data.count;
|
|
}
|
|
else if (type == "2") {
|
|
vDupMsgChasisNo = data.message;
|
|
vChasisNoDup = data.count;
|
|
}
|
|
else if (type == "3") {
|
|
vOwnerMobileNoDup = data.count;
|
|
vDupMsg = data.message;
|
|
}
|
|
}
|
|
else if (type == "1")
|
|
vDupMsgRegNo = "";
|
|
else if (type == "2")
|
|
vDupMsgChasisNo = "";
|
|
else if (type == "3") {
|
|
vDupMsg = "";
|
|
}
|
|
},
|
|
complete: function () {
|
|
$("#div_load").hide();
|
|
},
|
|
failure: function (response) {
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
return false;
|
|
}
|
|
/**
|
|
* This Function is used to check whether Reg. No. is exist in grid or not.
|
|
* @method CheckRegNoInGrid
|
|
* @param {string} vVechileRegdNo Vechile Registration No.
|
|
* @for ManageOwner
|
|
*/
|
|
function CheckRegNoInGrid(vVechileRegdNo) {
|
|
var grid = $("#gridVechile").data("kendoGrid");
|
|
datasource = grid.dataSource;
|
|
var RegdNoList = datasource.data();
|
|
|
|
for (var i = 0; i <= RegdNoList.length - 1; i++) {
|
|
if (RegdNoList[i].VehicleRegistrationNumber == vVechileRegdNo) {
|
|
vDupMsgRegNo = "The Registration No. is already added by you";
|
|
jAlert(vDupMsgRegNo, 'message');
|
|
vRegNoDup = 1;
|
|
return false;
|
|
}
|
|
}
|
|
vRegNoDup = 0;
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* This Function is used to check whether Chasis no is exist in grid or not
|
|
* @method CheckChasisNoInGrid
|
|
* @param {string} ChasisNo Vechile ChasisNo No.
|
|
* @for ManageOwner
|
|
*/
|
|
function CheckChasisNoInGrid(ChasisNo) {
|
|
var grid = $("#gridVechile").data("kendoGrid");
|
|
datasource = grid.dataSource;
|
|
var ChasisNoList = datasource.data();
|
|
|
|
for (var i = 0; i <= ChasisNoList.length - 1; i++) {
|
|
if (ChasisNoList[i].VehicleNumberPlate == ChasisNo) {
|
|
vDupMsgChasisNo = "The Chasis No. is already added by you";
|
|
jAlert(vDupMsgChasisNo, 'message');
|
|
vChasisNoDup = 1;
|
|
return false;
|
|
}
|
|
}
|
|
vChasisNoDup = 0;
|
|
return true;
|
|
}
|
|
/**
|
|
* This Function is used to Get The Load State
|
|
* @method loadStateChoices
|
|
* @for ManageOwner
|
|
*/
|
|
function loadStateChoices() {
|
|
SecurityToken = securityToken;
|
|
utcMinutes = parseInt(UtcMinutes, 10);
|
|
UserId = userId;
|
|
$.ajax({
|
|
type: "POST",
|
|
url: WCFRESTURL.GetStateListIdWise,
|
|
data: { Token: SecurityToken, UtcMinutes: utcMinutes, UserId: UserId },
|
|
dataType: "json",
|
|
success: function (data) {
|
|
|
|
//data.push({
|
|
// StateId: 0,
|
|
// StateAlias: "-Select-"
|
|
//});
|
|
data.sort(function SortState(a, b) { // non-anonymous as you ordered...
|
|
return b.StateAlias < a.StateAlias ? 1 // if b should come earlier, push a to end
|
|
: b.StateAlias > a.StateAlias ? -1 // if b should come later, push a to begin
|
|
: 0; // a and b are equal
|
|
});
|
|
|
|
$("#stateCombobox").kendoComboBox({
|
|
dataTextField: "StateAlias",
|
|
dataValueField: "StateId",
|
|
filter: "contains",
|
|
dataSource: data
|
|
});
|
|
|
|
},
|
|
complete: function () {
|
|
//$("#stateCombobox").data('kendoComboBox').select(0);
|
|
},
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
/**
|
|
//* This Function is used to Reset the Vechile Detail
|
|
//* @for ManageOwner
|
|
//*/
|
|
//function btnUndoVanDealerDetail() {
|
|
// if ($("#VehicleId").val() != "") {
|
|
// $("#VehicleRegistrationNumber").val(vSelectedRow.VehicleRegistrationNumber);
|
|
// $("#VehicleNumberPlate").val(vSelectedRow.VehicleNumberPlate);
|
|
// $("#VechileAddress").val(vSelectedRow.CustomerAddress);
|
|
// $("#ddlState option").filter(function () {
|
|
// return this.text == vSelectedRow.CustomerState;
|
|
// }).attr('selected', true);
|
|
// $("#VehicleInstallationDate").val(vSelectedRow.VehicleInstallationDate);
|
|
// $('#ddlState').trigger('change');
|
|
// }
|
|
// else {
|
|
// $("#VechileMobileNo").val("");
|
|
// $("#txtCustomerEmailId").val("");
|
|
// $("#VechileAddress").val("");
|
|
// $("#ddlState option").filter(function () {
|
|
// return this.text == '-Select-';
|
|
// }).attr('selected', true);
|
|
// $("#ddlCity option").filter(function () {
|
|
// return this.text == '-Select-';
|
|
// }).attr('selected', true);
|
|
// }
|
|
// return false;
|
|
//}
|
|
|
|
|
|
/**
|
|
* This Function is used to Reset the Driver Detail
|
|
* @method btnUndoVanDealerDetail
|
|
* @for ManageOwner
|
|
*/
|
|
function btnUndoVanDealerDetail() {
|
|
if ($("#VehicleId").val() != "" || vSelectedRow.CustomerCustomerName != "") {
|
|
$("#VechCustName").val(vSelectedRow.CustomerCustomerName);
|
|
$("#VechileMobileNo").val(vSelectedRow.CustomerMobileNumber1);
|
|
$("#txtCustomerEmailId").val(vSelectedRow.CustomerEmailId);
|
|
$("#VechileAddress").val(vSelectedRow.CustomerAddress);
|
|
$("#ddlState option").filter(function () {
|
|
return this.text == vSelectedRow.CustomerState;
|
|
}).attr('selected', true);
|
|
$("#VehicleInstallationDate").val(vSelectedRow.VehicleInstallationDate);
|
|
$('#ddlState').trigger('change');
|
|
}
|
|
else {
|
|
$("#VehicleRegistrationNumber").val("");
|
|
$("#VechCustName").val("");
|
|
$("#VechileMobileNo").val("");
|
|
$("#txtCustomerEmailId").val("");
|
|
$("#VechileAddress").val("");
|
|
$("#ddlState option").filter(function () {
|
|
return this.text == '-Select-';
|
|
}).attr('selected', true);
|
|
$("#ddlCity option").filter(function () {
|
|
return this.text == '-Select-';
|
|
}).attr('selected', true);
|
|
}
|
|
return false;
|
|
}
|
|
/**
|
|
* This Function is used to Reset the Driver Detail
|
|
* @method btnUndoVechDetail
|
|
* @for ManageOwner
|
|
*/
|
|
function btnUndoVechDetail() {
|
|
|
|
if ($("#VehicleId").val() != "" || vVechileSelectedRow.VehicleRegistrationNumber != "") {
|
|
$("#VehicleRegistrationNumber").val(vRegNo);
|
|
$("#VehicleNumberPlate").val(vVechileSelectedRow.VehicleNumberPlate);
|
|
$("#ddlVechileNo option").filter(function () {
|
|
return this.text == vVechileSelectedRow.VehicleModelNumber;
|
|
}).attr('selected', true);
|
|
$("#ddlVechileType option").filter(function () {
|
|
return this.text == vVechileSelectedRow.VehicleType;
|
|
}).attr('selected', true);
|
|
$("#VehicleInstallationDate").val(vVechileSelectedRow.VehicleInstallationDate);
|
|
$('#ddlVechileNo').trigger('change');
|
|
}
|
|
else {
|
|
$("#VehicleRegistrationNumber").val(vRegNo);
|
|
$("#VehicleNumberPlate").val("");
|
|
$("#ddlVechileNo option").filter(function () {
|
|
return this.text == '-Select-';
|
|
}).attr('selected', true);
|
|
$("#ddlVechileType option").filter(function () {
|
|
return this.text == '-Select-';
|
|
}).attr('selected', true);
|
|
$("#VehicleInstallationDate").val(vVechileSelectedRow.VehicleInstallationDate);
|
|
$("#VechProduct").val("");
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* This function is Used to Check Whether the keypress No is Entered or Not.
|
|
* @method isNumber
|
|
* @param {Object} e Get Event Detail
|
|
* @param {Object} t Get Textbox Detail
|
|
* @for ManageOwner
|
|
*/
|
|
|
|
|
|
function isNumber(e, t) {
|
|
try {
|
|
if (window.event) {
|
|
var charCode = window.event.keyCode;
|
|
}
|
|
else if (e) {
|
|
var charCode = e.which;
|
|
}
|
|
else { return true; }
|
|
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
catch (err) {
|
|
alert(err.Description);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* This Function is used to get the product Varient based on Model No.
|
|
* @method GetProductVar
|
|
* @for ManageOwner
|
|
*/
|
|
function GetProductVar() {
|
|
var VModel = $("#ddlVechileNo").val();
|
|
$.getJSON("/Ticket_CustomerInventory/GetVehicleModelTaggingBasedOnModelNo/", { ModelTypeId: VModel }, function (result) {
|
|
if (result) {
|
|
var ModelType = result.VehicleModelTagging;
|
|
for (var count = 0; count < ModelType.length; count++) {
|
|
$("#VechProduct").val(ModelType[0].VehicleTypeTagging);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
|
|
(function ($) {
|
|
/**
|
|
* This Function is used to check whether Cut, Copy, Paste operation is Performed on.
|
|
* @for ManageOwner
|
|
*/
|
|
$.fn.clearableTextField = function () {
|
|
if ($(this).length > 0) {
|
|
$(this).bind('keyup change paste cut', onSomethingChanged);
|
|
|
|
for (var i = 0; i < $(this).length; i++) {
|
|
trigger($($(this)[i]));
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* On Cut, Copy, Paste This Function will Call.
|
|
* @for ManageOwner
|
|
*/
|
|
function onSomethingChanged() {
|
|
trigger($(this));
|
|
}
|
|
/**
|
|
* This function is used to check Add or Remove the Clear Button.
|
|
* @for ManageOwner
|
|
*/
|
|
function trigger(input) {
|
|
if (input.val().length > 0) {
|
|
add_clear_button(input);
|
|
} else {
|
|
remove_clear_button(input);
|
|
}
|
|
}
|
|
/**
|
|
* This function is used to Add the Clear Button.
|
|
* @for ManageOwner
|
|
*/
|
|
function add_clear_button(input) {
|
|
if (!input.next().hasClass('text_clear_button')) {
|
|
// appends div
|
|
input.after("<div class='text_clear_button'></div>");
|
|
|
|
var clear_button = input.next();
|
|
var w = clear_button.outerHeight(), h = clear_button.outerHeight();
|
|
|
|
input.css('padding-right', parseInt(input.css('padding-right')) + w + 1);
|
|
input.width(input.width() - w - 1);
|
|
|
|
var pos = input.position();
|
|
var style = {};
|
|
style['left'] = pos.left + input.outerWidth(false) - (w + 2);
|
|
var offset = Math.round((input.outerHeight(true) - h) / 2.0);
|
|
style['top'] = pos.top + offset;
|
|
|
|
clear_button.css(style);
|
|
|
|
clear_button.click(function () {
|
|
input.val('');
|
|
trigger(input);
|
|
});
|
|
}
|
|
}
|
|
/**
|
|
* This function is used to Remove the Clear Button.
|
|
* @for ManageOwner
|
|
*/
|
|
function remove_clear_button(input) {
|
|
var clear_button = input.next();
|
|
|
|
if (clear_button.hasClass('text_clear_button')) {
|
|
clear_button.remove();
|
|
var w = clear_button.width();
|
|
|
|
input.css('padding-right', parseInt(input.css('padding-right')) - w - 1);
|
|
input.width(input.width() + w + 1);
|
|
}
|
|
}
|
|
|
|
})(jQuery);
|
|
|
|
</pre>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
|
<script>prettyPrint();</script>
|
|
<script src="../assets/js/yui-prettify.js"></script>
|
|
<script src="../assets/../api.js"></script>
|
|
<script src="../assets/js/api-filter.js"></script>
|
|
<script src="../assets/js/api-list.js"></script>
|
|
<script src="../assets/js/api-search.js"></script>
|
|
<script src="../assets/js/apidocs.js"></script>
|
|
</body>
|
|
</html>
|