EOS/Scripts/out/files/Inventory_ManageOwner.js.html
Nidhi Bhargava f0c1ab20e1 code push
2025-09-04 16:25:07 +05:30

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&#x27;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 = &quot;&quot;;
var vDupMsgRegNo = &quot;&quot;;
var vDupMsgChasisNo = &quot;&quot;;
var vRegNoOnPageLoad = &quot;&quot;;
var vChasisNoOnPageLoad = &quot;&quot;;
var vCustMobileNoOnPageLoad = &quot;&quot;;
var vAddOrUpdate = true;
var vPrePageSize = 0;
var OwnerName;
var vRegNo = &quot;&quot;;
/**
* 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 = $(&quot;#gridOwnerList&quot;).data(&quot;kendoGrid&quot;);
/// click event on rows of grid.
$(grid.tbody).on(&quot;click&quot;, &quot;tr&quot;, function () {
// clicked row instance
row = $(this).closest(&quot;tr&quot;);
var custId;
custId = row[0].childNodes[0].innerHTML;
OwnerName = row[0].childNodes[2].innerHTML;
//Add button hide show
$(&quot;#btnAdd&quot;).show();
// ajax request to get Owner detail
if (activeRequest_OwnerDetails &amp;&amp; activeRequest_OwnerDetails.readystate != 4) {
activeRequest_OwnerDetails.abort();
}
$(&quot;#div_load&quot;).show();
activeRequest_OwnerDetails = $.ajax({
type: &quot;POST&quot;,
url: &quot;/Inventory/ManageOwner_GetOwnerDetails/&quot;,
data: { CustId: custId },
success: function (data) {
$(&quot;#divOwnerDetailPanel&quot;).html(&#x27;&#x27;);
$(&quot;#divOwnerDetailPanel&quot;).html(data);
LoadCityList(&#x27;#ddlOwnerState&#x27;, &#x27;#ddlOwnerCity&#x27;);
HideValidMsg();
//$(&#x27;#CustomerCustomerName&#x27;).attr(&#x27;readonly&#x27;, true);
$(&quot;#btnAdd&quot;).show();
$(&quot;#btnSaveOwner&quot;).prop(&#x27;value&#x27;, &#x27;Update&#x27;);
vCustMobileNoOnPageLoad = $(&quot;#CustomerMobileNumber1&quot;).val();
vOwnerMobileNoDup = 0;
$(&quot;#div_load&quot;).hide();
$(&quot;#btnDeleteOwner&quot;).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(&quot;kendoWindow&quot;);
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(&quot;kendoWindow&quot;).close();
}
/**
* Function to get Owner list.
* @method getOwnerList
* @for ManageOwner
*/
function getOwnerList() {
$(&quot;#spanState&quot;).hide();
stateVal = $(&quot;#stateCombobox&quot;).data(&quot;kendoComboBox&quot;).text();
var FilterVal = $(&quot;#srchText&quot;).val();
if (stateVal != &quot;&quot;) {
$.ajax({
type: &quot;POST&quot;,
url: &quot;/Inventory/ManageOwner_GetOwnerList/&quot;,
data: { state: stateVal, FilterVal: FilterVal },
success: function (data) {
//Bind html
$(&quot;#divOwnerList&quot;).html(data);
vPrePageSize = 0;
},
error: function (data) {
}
});
} else {
$(&quot;#spanState&quot;).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(&quot;#divAddCustDetl&quot;, &quot;Edit Vehicle Detail&quot;, &quot;833px&quot;, 385, 250);
// Get selected row
var dataItem = this.dataItem($(e.currentTarget).closest(&quot;tr&quot;));
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 &amp;&amp; activeRequest_Edit.readystate != 4) {
activeRequest_Edit.abort();
}
activeRequest_Edit = $.ajax({
type: &quot;GET&quot;,
url: &quot;/Inventory/ManageOwner_AddOrEditCustomer&quot;,
data: oOwner,
success: function (data) {
//open form in new dialog box
$(&quot;#divAddCustDetl&quot;).parent().addClass(&quot;responsive_popup&quot;) //addClass for respond the menu
$(&quot;#divAddCustDetl&quot;).html(&#x27;&#x27;);
$(&quot;#divAddCustDetl&quot;).html(data);
SetKendoWindowTitle(&quot;#divAddCustDetl&quot;, &quot;Edit Vehicle Detail&quot;);
//open form in new dialog box
$(&quot;#divAddCustDetl&quot;).data(&quot;kendoWindow&quot;).open();
//Show the textbox of Model No., Vechile Type, Driver Name and Driver City
$(&#x27;#CustomerState,#CustomerCity,#btnSaveVan&#x27;).show();
$(&#x27;#VechVechType,#VehicleModelNumber&#x27;).hide();
//Hide the drop down list of Model No., Vechile Type
//$(&#x27;#ddlVechileNo,#ddlVechileType,#btnSaveCust,#tdCustName,#tdCustName1,#trCustDetl2,#trCustDetl3,#trCustDetl4,#btnSaveVan,#btnCustReset&#x27;).hide();
$(&#x27;#btnSaveCust,#tdCustName,#tdCustName1,#trCustDetl2,#trCustDetl3,#trCustDetl4&#x27;).hide();
//Set the readonly textbox of vechile registration Number, Vechile Chasis No.,Vechile Model No and Vechile Type
//$(&quot;#VehicleRegistrationNumber,#VehicleNumberPlate,#VehicleModelNumber,#VechVechType&quot;).attr(&#x27;readonly&#x27;, 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 = $(&quot;#VehicleRegistrationNumber&quot;).cleanVal();
vChasisNoOnPageLoad = $(&quot;#VehicleNumberPlate&quot;).val();
$(&#x27;#VehicleInstallationDate&#x27;).attr(&#x27;disabled&#x27;);
LoadCityList(&quot;#ddlState&quot;, &quot;#ddlCity&quot;);
vAddOrUpdate = false;
$(&#x27;#VehicleRegistrationNumber,#VehicleNumberPlate&#x27;).attr(&#x27;readonly&#x27;, false);
$(&quot;#btnVechReset&quot;).show();
$(&quot;#btnCustReset&quot;).hide();
$(&quot;#btnSaveVan&quot;).prop(&#x27;value&#x27;, &#x27;Update&#x27;);
},
complete: function () {
vRegNo = $(&quot;#VehicleRegistrationNumber&quot;).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(&quot;#divAddCustDetl&quot;, &quot;Edit Driver Detail&quot;, &quot;833px&quot;, 385, 250);
// Get selected row
var dataItem = this.dataItem($(e.currentTarget).closest(&quot;tr&quot;));
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 &amp;&amp; activeRequest_Edit.readystate != 4) {
activeRequest_Edit.abort();
}
activeRequest_Edit = $.ajax({
type: &quot;GET&quot;,
url: &quot;/Inventory/ManageOwner_AddOrEditCustomer&quot;,
data: oOwner,
success: function (data) {
//open form in new dialog box
$(&quot;#divAddCustDetl&quot;).parent().addClass(&quot;responsive_popup&quot;) //addClass for respond the menu
$(&quot;#divAddCustDetl&quot;).html(&#x27;&#x27;);
$(&quot;#divAddCustDetl&quot;).html(data);
SetKendoWindowTitle(&quot;#divAddCustDetl&quot;, &quot;Edit Driver Detail&quot;);
//open form in new dialog box
$(&quot;#divAddCustDetl&quot;).data(&quot;kendoWindow&quot;).open();
$(&quot;#VehicleInstallationDate&quot;).val(dataItem.VehicleInstallationDate);
$(&#x27;#VehicleRegistrationNumber,#VehicleNumberPlate&#x27;).show();
if (oOwner.CustomerId == &quot;&quot;) {
//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.
//$(&#x27;#ddlVechileNo,#ddlVechileType,#VehicleRegistrationNumber,#VehicleNumberPlate&#x27;).show();
$(&#x27;#VehicleRegistrationNumber,#VehicleNumberPlate&#x27;).show();
//hide textbox of Vechile No.,Vechile Type
//$(&quot;#VehicleModelNumber,#VechVechType&quot;).hide();
}
else {
//hide dropdown of Vechile No.,Vechile Type
//$(&#x27;#ddlVechileNo,#ddlVechileType&#x27;).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.
//$(&quot;#VehicleRegistrationNumber,#VehicleNumberPlate,#VehicleModelNumber,#VechVechType&quot;).show().attr(&#x27;readonly&#x27;, true);
$(&quot;#VehicleRegistrationNumber,#VehicleNumberPlate&quot;).show();
}
$(&quot;#btnSaveVan,#ddlVechileNo,#ddlVechileType&quot;).hide();
//show textbox of Driver State, Driver city
$(&#x27;#CustomerState,#CustomerCity,#btnSaveCust,#tdCustName,#tdCustName1,#trCustDetl2,#trCustDetl3,#trCustDetl4,#btnSaveVan,#btnCustReset&#x27;).show();
LoadCityList(&quot;#ddlState&quot;, &quot;#ddlCity&quot;);
$(&#x27;#VehicleRegistrationNumber,#VehicleNumberPlate&#x27;).show().attr(&#x27;readonly&#x27;, true);
$(&quot;#ddlCity&quot;).val($(&quot;#CustomerCity&quot;).val());
$(&quot;#VechProduct&quot;).val(dataItem.CustomerVehicleModelTagging);
vRegNoOnPageLoad = $(&quot;#VehicleRegistrationNumber&quot;).cleanVal();
vChasisNoOnPageLoad = $(&quot;#VehicleNumberPlate&quot;).val();
vAddOrUpdate = false;
$(&quot;#btnSaveVan&quot;).prop(&#x27;value&#x27;, &#x27;Update&#x27;);
$(&quot;#btnSaveCust&quot;).hide();
$(&quot;#btnVechReset&quot;).hide();
$(&quot;#btnCustReset&quot;).show();
},
complete: function () {
var datepicker = $(&quot;#VehicleInstallationDate&quot;).data(&quot;kendoDatePicker&quot;);
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(&quot;tr&quot;));
var grid = $(&quot;#gridVechile&quot;).data(&quot;kendoGrid&quot;);
datasource = grid.dataSource;
if (datasource.total() &gt; 1) {
//jConfirm(&quot;Do you want to delete the Vehcile Of Reg. No. &lt;b&gt;&quot; + dataItem.VehicleRegistrationNumber + &#x27;&lt;/b&gt; ?&#x27;, &#x27;Delete&#x27;, function (result) {
jConfirm(MANAGE_FLEET_MESSAGES.confirmDeleteVehicle + &quot; &lt;b&gt;&quot; + dataItem.VehicleRegistrationNumber + &#x27;&lt;/b&gt; ?&#x27;, &#x27;Delete&#x27;, function (result) {
//again check whether user input is true
if (result) {
for (var i = 0; i &lt;= datasource.total() - 1; i++) {
var datasourceItem = datasource.at(i);
if (dataItem.VehicleRegistrationNumber === datasource.at(i).VehicleRegistrationNumber) {
datasourceItem.IsDealetedVehicle = true;
if (dataItem.VehicleId == &quot;&quot;) {
for (var j = 0; j &lt;= 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(&quot;tr&quot;)[$(e.currentTarget).closest(&quot;tr&quot;).index()]);
}
}
}
});
}
else {
//jAlert(&quot;Every Customer must have atleast one Vehicle&quot;);
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(&quot;tr&quot;));
var gridId = &quot;#gridCust_&quot; + dataItem.VehicleRegistrationNumber;
var grid = $(gridId).data(&quot;kendoGrid&quot;);
datasource = grid.dataSource;
if (datasource.total() &gt; 1) {
//jConfirm(&quot;Do you want to delete the Driver &quot; + dataItem.CustomerCustomerName + &#x27;&lt;/b&gt; ?&#x27;, &#x27;Delete&#x27;, function (result) {
jConfirm(MANAGE_FLEET_MESSAGES.confirmDeleteDealer + dataItem.CustomerCustomerName + &#x27;&lt;/b&gt; ?&#x27;, &#x27;Delete&#x27;, function (result) {
//again check whether user input is true
if (result) {
for (var i = 0; i &lt;= datasource.total() - 1; i++) {
var datasourceItem = datasource.at(i);
if (dataItem.CustomerId === datasource.at(i).CustomerId &amp;&amp; dataItem.CustomerCustomerName === datasource.at(i).CustomerCustomerName &amp;&amp;
dataItem.VehicleRegistrationNumber === datasource.at(i).VehicleRegistrationNumber &amp;&amp;
dataItem.CustomerState === datasource.at(i).CustomerState &amp;&amp;
dataItem.CustomerCity === datasource.at(i).CustomerCity &amp;&amp;
dataItem.CustomerAddress === datasource.at(i).CustomerAddress &amp;&amp;
dataItem.CustomerMobileNumber1 === datasource.at(i).CustomerMobileNumber1) {
datasourceItem.IsDeleted = true;
if (dataItem.CustomerId == &quot;&quot;) {
for (var j = 0; j &lt;= VechiledataSource.length - 1; j++) {
if (dataItem.CustomerId === VechiledataSource[j].CustomerId &amp;&amp; dataItem.CustomerCustomerName === VechiledataSource[j].CustomerCustomerName &amp;&amp;
dataItem.VehicleRegistrationNumber === VechiledataSource[j].VehicleRegistrationNumber &amp;&amp;
dataItem.CustomerState === VechiledataSource[j].CustomerState &amp;&amp;
dataItem.CustomerCity === VechiledataSource[j].CustomerCity &amp;&amp;
dataItem.CustomerAddress === VechiledataSource[j].CustomerAddress &amp;&amp;
dataItem.CustomerMobileNumber1 === VechiledataSource[j].CustomerMobileNumber1) {
VechiledataSource.splice(j, 1);
}
}
}
else {
VechiledataSource.push(datasource.at(i));
}
grid.removeRow(grid.tbody.find(&quot;tr&quot;)[$(e.currentTarget).closest(&quot;tr&quot;).index()]);
}
}
}
});
}
else {
//jAlert(&quot;Every Vehcile must have atleast one Driver&quot;);
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.
$(&#x27;.k-grid-Edit&#x27;).text(&quot;&quot;).removeClass(&quot;k-button k-button-icontext&quot;).html(&quot;&lt;span class=&#x27;k-icon k-edit&#x27;&gt;&lt;/span&gt;&quot;);
$(&#x27;.k-grid-Delete&#x27;).text(&quot;&quot;).removeClass(&quot;k-button k-button-icontext&quot;).html(&quot;&lt;span class=&#x27;k-icon k-delete&#x27;&gt;&lt;/span&gt;&quot;);
var dataItem = this.dataItem($(e.currentTarget).closest(&quot;tr&quot;));
// 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 &lt; data.length; i++) {
// if (data[i].VehicleId != &quot;&quot;) {
// $(&quot;#gridVechile&quot;).data(&quot;kendoGrid&quot;).tbody.find(&quot;tr[data-uid=&#x27;&quot; + data[i].uid + &quot;&#x27;]&quot;).find(&#x27;td&#x27;).find(&#x27;#cmdDelete&#x27;).find(&quot;span&quot;).removeClass(&quot;k-icon k-delete&quot;);
// }
// else {
// $(&quot;#gridVechile&quot;).data(&quot;kendoGrid&quot;).tbody.find(&quot;tr[data-uid=&#x27;&quot; + data[i].uid + &quot;&#x27;]&quot;).find(&#x27;td&#x27;).find(&#x27;#cmdVanLocation&#x27;).removeAttr(&quot;id&quot;);
// }
//}
// 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(&quot;tr&quot;));
var data = this.dataSource.view();
// Add Edit and delete icon.
console.log(data);
var gridId = &quot;#gridCust_&quot; + data[0].VehicleRegistrationNumber;
$(gridId).find(&#x27;.k-grid-Edit&#x27;).text(&quot;&quot;).removeClass(&quot;k-button k-button-icontext&quot;).html(&quot;&lt;span class=&#x27;k-icon k-edit&#x27;&gt;&lt;/span&gt;&quot;);
$(gridId).find(&#x27;.k-grid-Delete&#x27;).text(&quot;&quot;).removeClass(&quot;k-button k-button-icontext&quot;).html(&quot;&lt;span class=&#x27;k-icon k-delete&#x27;&gt;&lt;/span&gt;&quot;);
// 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 &lt; data.length; i++) {
// if (data[i].CustomerId != &quot;&quot; || typeof data[i].CustomerId == &quot;undefined&quot;) {
// var grid = $(gridId).data(&quot;kendoGrid&quot;);
// grid.tbody.find(&quot;tr[data-uid=&#x27;&quot; + data[i].uid + &quot;&#x27;]&quot;).find(&#x27;td&#x27;).find(&#x27;#cmdDeleteVech&#x27;).find(&quot;span&quot;).removeClass(&quot;k-icon k-delete&quot;);
// }
//}
// 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 = &quot;&quot;;
//Hide Vechile Detail Validation Message
HideVechileValidationMsg();
addKendoWindowToDiv(&quot;#divAddCustDetl&quot;, &quot;Add Vehicle Detail&quot;, &quot;833px&quot;, 385, 95);
// Ajax request
if (activeRequest &amp;&amp; activeRequest.readystate != 4) {
activeRequest.abort();
}
activeRequest = $.ajax({
type: &quot;POST&quot;,
url: &quot;/Inventory/ManageOwner_AddOrEditCustomer&quot;,
data: oOwner,
success: function (data) {
$(&quot;#divAddCustDetl&quot;).parent().addClass(&quot;responsive_popup&quot;) //addClass for respond the menu
$(&quot;#divAddCustDetl&quot;).html(&#x27;&#x27;);
$(&quot;#divAddCustDetl&quot;).html(data);
SetKendoWindowTitle(&quot;#divAddCustDetl&quot;, &quot;Add Vehicle Detail&quot;);
//open form in new dialog box
$(&quot;#divAddCustDetl&quot;).data(&quot;kendoWindow&quot;).open();
$(&#x27;#VehicleId&#x27;).val(&quot;&quot;);
//Show Controls
$(&quot;#btnSaveVan,#VehicleRegistrationNumber,#ddlVechileType,#ddlVechileNo,#ddlState,#ddlCity&quot;).show();
//$(&quot;#btnSaveVan,#VehicleRegistrationNumber,#ddlState,#ddlCity&quot;).show();
$(&quot;#VehicleModelNumber,#VechVechType&quot;).hide();
$(&quot;#btnSaveCust&quot;).hide();
$(&quot;#hdnCustId&quot;).val(&quot;&quot;);
$(&#x27;#VehicleInstallationDate&#x27;).attr(&#x27;disabled&#x27;);
$(&#x27;#VehicleRegistrationNumber,#VehicleNumberPlate&#x27;).attr(&#x27;readonly&#x27;, false);
vAddOrUpdate = true;
vVechileSelectedRow = undefined;
$(&quot;#btnVechReset&quot;).show();
$(&quot;#btnCustReset&quot;).hide();
$(&quot;#btnSaveVan&quot;).prop(&#x27;value&#x27;, &#x27;Save&#x27;);
},
complete: function () {
vRegNo = $(&quot;#VehicleRegistrationNumber&quot;).val();
},
error: function (data) {
}
});
}
/**
* This function create a popup for Add Driver Detail.
* @method AddCustDetl
* @for ManageOwner
*/
function AddCustDetl(e) {
addKendoWindowToDiv(&quot;#divAddCustDetl&quot;, &quot;Add Driver Detail&quot;, &quot;833px&quot;, 385, 95);
// Ajax request
if (activeRequest &amp;&amp; activeRequest.readystate != 4) {
activeRequest.abort();
}
var grid = $(&quot;#gridVechile&quot;).data(&quot;kendoGrid&quot;);
var dataItem = this.dataItem($(e.currentTarget).closest(&quot;tr&quot;));
var rowIndx = $(e.currentTarget).closest(&quot;tr&quot;).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: &quot;POST&quot;,
data: oOwner,
url: &quot;/Inventory/ManageOwner_AddOrEditCustomer&quot;,
success: function (data) {
$(&quot;#divAddCustDetl&quot;).parent().addClass(&quot;responsive_popup&quot;) //addClass for respond the menu
$(&quot;#divAddCustDetl&quot;).html(&#x27;&#x27;);
$(&quot;#divAddCustDetl&quot;).html(&#x27;&#x27;);
$(&quot;#divAddCustDetl&quot;).html(data);
SetKendoWindowTitle(&quot;#divAddCustDetl&quot;, &quot;Add Driver Detail&quot;);
//open form in new dialog box
$(&quot;#divAddCustDetl&quot;).data(&quot;kendoWindow&quot;).open();
$(&#x27;#VehicleId&#x27;).val(dataItem.VehicleId);
$(&quot;#btnSaveCust&quot;).show();
$(&quot;#btnSaveVan&quot;).hide();
$(&#x27;#VehicleRegistrationNumber,#VehicleNumberPlate&#x27;).show().attr(&#x27;readonly&#x27;, true);
$(&#x27;#ddlVechileNo,#ddlVechileType&#x27;).hide();
vSelectedRow = undefined;
vVechileSelectedRow = undefined;
$(&#x27;#ddlState&#x27;).show();
//$(&#x27;#VechState&#x27;).hide();
//$(&#x27;#VechCity&#x27;).hide();
$(&#x27;#ddlCity&#x27;).show();
grid = $(&quot;#gridVechile&quot;).data(&quot;kendoGrid&quot;);
grid.expandRow(grid.tbody.find(&quot;tr.k-master-row&quot;).eq(rowIndx));
$(&quot;#hdnCustId&quot;).val(&quot;&quot;);
vAddOrUpdate = true;
$(&quot;#btnVechReset&quot;).hide();
$(&quot;#btnCustReset&quot;).show();
$(&quot;#btnSaveCust&quot;).prop(&#x27;value&#x27;, &#x27;Save&#x27;);
},
complete: function () {
var datepicker = $(&quot;#VehicleInstallationDate&quot;).data(&quot;kendoDatePicker&quot;);
datepicker.enable(false);
vRegNoOnPageLoad = $(&#x27;#VehicleRegistrationNumber&#x27;).cleanVal();
vChasisNoOnPageLoad = $(&#x27;#VehicleNumberPlate&#x27;).val();
},
error: function (data) {
}
});
}
//function SetVehicleCOntrolDisabled() {
// var datepicker = $(&quot;#VehicleInstallationDate&quot;).data(&quot;kendoDatePicker&quot;);
// datepicker.enable(false);
//}
///**
//* Function to show Owner details.
//* @method showOwnerDetails
//* @for ManageOwner
//*/
//function showOwnerDetails() {
// //function call on click of user list table&#x27;s row
// $(&quot;#tableOwnerList tbody tr&quot;).click(function (e) {
// });
// //Trigger click event on first row of non-vecv owner list table
// $(&quot;#tableOwnerList tbody tr:first&quot;).trigger(&#x27;click&#x27;);
//}
/**
* 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(&#x27;option:selected&#x27;).text();
$(&quot;#stateName&quot;).val(selectedState);
var stateVal;
stateVal = $(ddlstateId).val();
if (stateVal != &quot;-Select-&quot;)
stateVal = $(ddlstateId).val();
else
stateVal = 0;
if (stateVal != &quot;&quot;) {
if (activeRequest_City &amp;&amp; activeRequest_City.readystate != 4) {
activeRequest_City.abort();
}
activeRequest_City = $.ajax({
type: &quot;GET&quot;,
url: &quot;/UserInventory/showCityStateWise/&quot;,
data: { stateVal: stateVal },
success: function (data) {
// empty City dropdown
$(ddlcustId).text(&quot;&quot;);
// by default add select text.
$(ddlcustId).append($(&#x27;&lt;option&gt;&lt;/option&gt;&#x27;).val(&quot;&quot;).html(&quot;-Select-&quot;));
// add data to dropdown.
if (data.list) {
for (var counter = 0; counter &lt; data.list.length; counter++) {
$(ddlcustId).append(
$(&#x27;&lt;option&gt;&lt;/option&gt;&#x27;).val(data.list[counter].Value).html(data.list[counter].Text));
}
}
if (ddlcustId == &quot;#ddlOwnerCity&quot;) {
$(ddlcustId).val($(&quot;#OwnerCityId&quot;).val());
}
if (ddlcustId == &quot;#ddlCity&quot;) {
$(ddlcustId).val($(&quot;#hdnCustCityIdNo&quot;).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(&quot;#divAddCustDetl&quot;, &quot;Add Driver Detail&quot;, &quot;833px&quot;, 385, 95);
// Ajax request
if (activeRequest &amp;&amp; activeRequest.readystate != 4) {
activeRequest.abort();
}
activeRequest = $.ajax({
type: &quot;POST&quot;,
url: &quot;/Inventory/ManageOwner_AddOrEditCustomer&quot;,
success: function (data) {
$(&quot;#divAddCustDetl&quot;).parent().addClass(&quot;responsive_popup&quot;); //addClass for respond the menu
$(&quot;#divAddCustDetl&quot;).html(&#x27;&#x27;);
$(&quot;#divAddCustDetl&quot;).html(&#x27;&#x27;);
$(&quot;#divAddCustDetl&quot;).html(data);
SetKendoWindowTitle(&quot;#divAddCustDetl&quot;, &quot;Add Driver Detail&quot;);
//open form in new dialog box
$(&quot;#divAddCustDetl&quot;).data(&quot;kendoWindow&quot;).open();
//$(&#x27;#btnSaveVan,#VehicleModelNumber,#VehicleType,#CustomerState,#CustomerCity&#x27;).hide();
$(&#x27;#btnSaveVan,#VehicleType,#CustomerState,#CustomerCity&#x27;).hide();
//$(&#x27;#btnSaveCust,#ddlVechileNo,#ddlVechileType,#ddlState,#ddlCity&#x27;).show();
$(&#x27;#btnSaveCust,#ddlState,#ddlCity&#x27;).show();
$(&#x27;#VehicleId&#x27;).val(&quot;&quot;);
$(&quot;#VehicleInstallationDate&quot;).attr(&#x27;readonly&#x27;, 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 = $(&quot;#CustomerCustomerName&quot;).val();
var VehicleRegistrationNumber = $(&quot;#VehicleRegistrationNumber&quot;).cleanVal();
var VehicleNumberPlate = $(&quot;#VehicleNumberPlate&quot;).val();
var VehicleModelNumber = $(&quot;#ddlVechileNo option:selected&quot;).val();
var VehicleType = $(&quot;#ddlVechileType option:selected&quot;).val();
var CustomerCustomerName = $(&quot;#VechCustName&quot;).val();
var CustomerMobileNumber1 = $(&quot;#VechileMobileNo&quot;).val();
var CustomerAddress = $(&quot;#VechileAddress&quot;).val();
var CustomerState = $(&quot;#ddlState option:selected&quot;).text();
var CustomerCity = $(&quot;#ddlCity option:selected&quot;).val();
var VehicleId = $(&quot;#VehicleId&quot;).val();
var CustomerEmailId = $(&quot;#txtCustomerEmailId&quot;).val();
var ProductVar = $(&quot;#VechProduct&quot;).val();
var vdataSourceLength = 0;
var vTotal = 0;
var VehicleInstallationDate = $(&quot;#VehicleInstallationDate&quot;).val();
var vCustId = $(&quot;#hdnCustId&quot;).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 = $(&quot;#gridVechile&quot;).data(&quot;kendoGrid&quot;);
datasourceCust = gridVechile.dataSource;
if (typeof (vVechileSelectedRow) == &quot;undefined&quot;) {
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 = &quot;#gridCust_&quot; + oOwner.VehicleRegistrationNumber;
var gridCust = $(gridId).data(&quot;kendoGrid&quot;);
var datasourceCust = new kendo.data.DataSource({
VehicleId: oOwner.VehicleId,
VehicleRegistrationNumber: oOwner.VehicleRegistrationNumber
});
AddInList();
$(gridId).kendoGrid({
dataSource: datasourceCust
});
vdataSourceLength = datasourceCust.total();
closeWindow(&#x27;#divAddCustDetl&#x27;);
gridVechile.expandRow(gridVechile.tbody.find(&quot;tr.k-master-row&quot;).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(&quot;VehicleId&quot;, oOwner.VehicleId);
vVechileSelectedRow.set(&quot;VehicleInstallationDate&quot;, oOwner.VehicleInstallationDate);
vVechileSelectedRow.set(&quot;VehicleNumberPlate&quot;, oOwner.VehicleNumberPlate);
vVechileSelectedRow.set(&quot;VehicleModelNumber&quot;, oOwner.VehicleModelNumber);
vVechileSelectedRow.set(&quot;VehicleType&quot;, oOwner.VehicleType);
vVechileSelectedRow.set(&quot;CustomerVehicleModelTagging&quot;, oOwner.CustomerVehicleModelTagging);
vVechileSelectedRow.set(&quot;CustomerCustomerName&quot;, oOwner.CustomerCustomerName);
vVechileSelectedRow.set(&quot;CustomerMobileNumber1&quot;, oOwner.CustomerMobileNumber1);
vVechileSelectedRow.set(&quot;CustomerAddress&quot;, oOwner.CustomerAddress);
vVechileSelectedRow.set(&quot;CustomerState&quot;, oOwner.CustomerState);
vVechileSelectedRow.set(&quot;CustomerCity&quot;, oOwner.CustomerCity);
vVechileSelectedRow.set(&quot;VehicleRegistrationNumber&quot;, oOwner.VehicleRegistrationNumber);
vVechileSelectedRow.set(&quot;CustomerEmailId&quot;, oOwner.CustomerEmailId);
vVechileSelectedRow.set(&quot;VehicleInstallationDate&quot;, oOwner.VehicleInstallationDate);
AddInList();
}
closeWindow(&quot;#divAddCustDetl&quot;);
}
}
/**
* 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 = $(&quot;#CustomerCustomerName&quot;).val();
var VehicleRegistrationNumber = $(&quot;#VehicleRegistrationNumber&quot;).cleanVal();
var VehicleNumberPlate = $(&quot;#VehicleNumberPlate&quot;).val();
var VehicleModelNumber = $(&quot;#ddlVechileNo option:selected&quot;).val();
var VehicleType = $(&quot;#ddlVechileType option:selected&quot;).val();
var CustomerCustomerName = $(&quot;#VechCustName&quot;).val();
var CustomerMobileNumber1 = $(&quot;#VechileMobileNo&quot;).val();
var CustomerAddress = $(&quot;#VechileAddress&quot;).val();
var CustomerState = $(&quot;#ddlState option:selected&quot;).text();
var CustomerCity = $(&quot;#ddlCity option:selected&quot;).val();
var VehicleId = $(&quot;#VehicleId&quot;).val();
var CustomerEmailId = $(&quot;#txtCustomerEmailId&quot;).val();
var vdataSourceLength = 0;
var VehicleInstallationDate = $(&quot;#VehicleInstallationDate&quot;).val();
var VechProduct = $(&quot;#VechProduct&quot;).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 = &quot;&quot;;
oOwner.CustomerEmailId = CustomerEmailId;
oOwner.VehicleInstallationDate = VehicleInstallationDate;
oOwner.CustomerVehicleModelTagging = VechProduct;
var datasource;
var gridId = &quot;#gridCust_&quot; + oOwner.VehicleRegistrationNumber;
var grid = $(gridId).data(&quot;kendoGrid&quot;);
if (grid != null)
datasource = grid.dataSource;
if (typeof (vVechileSelectedRow) == &quot;undefined&quot;) {
//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 = &quot;#gridCust_&quot; + oOwner.VehicleRegistrationNumber;
grid = $(gridId).data(&quot;kendoGrid&quot;);
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(&quot;VehicleId&quot;, oOwner.VehicleId);
vVechileSelectedRow.set(&quot;CustomerCustomerName&quot;, oOwner.CustomerCustomerName);
vVechileSelectedRow.set(&quot;CustomerMobileNumber1&quot;, oOwner.CustomerMobileNumber1);
vVechileSelectedRow.set(&quot;CustomerAddress&quot;, oOwner.CustomerAddress);
vVechileSelectedRow.set(&quot;CustomerState&quot;, oOwner.CustomerState);
vVechileSelectedRow.set(&quot;CustomerCity&quot;, oOwner.CustomerCity);
vVechileSelectedRow.set(&quot;VehicleRegistrationNumber&quot;, oOwner.VehicleRegistrationNumber);
vVechileSelectedRow.set(&quot;CustomerEmailId&quot;, oOwner.CustomerEmailId);
vVechileSelectedRow.set(&quot;VehicleInstallationDate&quot;, oOwner.VehicleInstallationDate);
vVechileSelectedRow.set(&quot;CustomerVehicleModelTagging&quot;, oOwner.CustomerVehicleModelTagging);
}
AddInList();
closeWindow(&quot;#divAddCustDetl&quot;);
}
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 = $(&#x27;#tableOwnerList tbody tr&#x27;);
var jThis;
if (keyCode != 8 &amp;&amp; keyCode != 46) {
$rows.each(function () {
jThis = $(this);
if (jThis.is(&#x27;:visible&#x27;)) {
var oLabel = jThis.find(&#x27;label&#x27;).text();
if (oLabel.length &gt; 0) {
if (oLabel.toLowerCase().indexOf(sValue.toLowerCase()) &gt;= 0) {
jThis.show();
} else {
jThis.hide();
}
}
}
});
}
else {
$rows.each(function () {
jThis = $(this);
var oLabel = jThis.find(&#x27;label&#x27;).text();
if (oLabel.length &gt; 0) {
if (oLabel.toLowerCase().indexOf(sValue.toLowerCase()) &gt;= 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 &amp;&amp; activeRequest_OwnerDetails.readystate != 4) {
activeRequest_OwnerDetails.abort();
}
activeRequest_OwnerDetails = $.ajax({
type: &quot;POST&quot;,
url: &quot;/Inventory/ManageOwner_GetOwnerDetails/&quot;,
data: { CustId: custId },
success: function (data) {
$(&quot;#divOwnerDetailPanel&quot;).html(&#x27;&#x27;);
$(&quot;#divOwnerDetailPanel&quot;).html(data);
//$(&#x27;#CustomerCustomerName&#x27;).attr(&#x27;readonly&#x27;, false);
$(&quot;#btnAdd&quot;).hide();
vCustMobileNoOnPageLoad = $(&quot;#CustomerMobileNumber1&quot;).val();
$(&quot;#VechCustName&quot;).attr(&#x27;readonly&#x27;, false);
vSelectedRow = undefined;
$(&quot;#btnDeleteOwner&quot;).hide();
$(&quot;#btnSaveOwner&quot;).prop(&#x27;value&#x27;, &#x27;Save&#x27;);
},
error: function (data) {
}
});
}
/**
* This function is used to Cancel the Operation.
* @method btnCancelAddUser
* @for ManageOwner
*/
function btnCancelAddUser() {
//$(&quot;#tableDealerList tbody tr.SelectedRow&quot;).trigger(&#x27;click&#x27;);
if (document.getElementById(&#x27;tableOwnerList&#x27;)) {
$(&quot;#tableOwnerList tbody tr.SelectedRow&quot;).trigger(&#x27;click&#x27;);
} else {
$(&quot;#divOwnerList&quot;).html(&quot;&quot;);
$(&quot;#btnAdd&quot;).show();
}
}
/**
* Bind textbox keyup event for searching.
* @event keyup
* @for ManageOwner
*/
$(&#x27;#txtSearchOwnerList&#x27;).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();
$(&quot;#btnDeleteOwner&quot;).hide();
$(&#x27;#srchText&#x27;).clearableTextField();
//Save The Owner Detail On Click Button
$(&#x27;#btnSaveOwner&#x27;).click(function () {
if (AllValid()) {
SaveRecord(false);
}
});
$(&quot;#btnDeleteOwner&quot;).click(function () {
//jConfirm(&quot;Do you want to delete the Customer &lt;b&gt;&quot; + OwnerName + &#x27;&lt;/b&gt; ?&#x27;, &#x27;Delete&#x27;, function (result) {
jConfirm(MANAGE_FLEET_MESSAGES.confirmDeleteCustomer + &quot; &lt;b&gt;&quot; + OwnerName + &#x27;&lt;/b&gt; ?&#x27;, &#x27;Delete&#x27;, 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) {
$(&quot;#div_load&quot;).show();
var vArrVechile = new Array();
var gridVechile = $(&quot;#gridVechile&quot;).data(&quot;kendoGrid&quot;);
var datasource = gridVechile.dataSource;
vdataSourceLength = gridVechile.dataSource.total();
var data = datasource.view();
var CustomerCustomerName = $(&quot;#CustomerCustomerName&quot;).val();
var CustomerMobileNumber1 = $(&quot;#CustomerMobileNumber1&quot;).val();
var CustomerAddress = $(&quot;#OwnerAddress&quot;).val();
var CustomerEmailId = $(&quot;#CustomerEmailId&quot;).val();
var vStateId = $(&quot;#ddlOwnerState option:selected&quot;).text();
var vCityId = $(&quot;#ddlOwnerCity option:selected&quot;).val();
var CustList = datasource.data();
var CustomerId = $(&quot;#hdnCustomerId&quot;).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: &#x27;application/json; charset=utf-8&#x27;,
dataType: &#x27;json&#x27;,
type: &#x27;POST&#x27;,
url: &#x27;/Inventory/ManageOwner_SaveOwner&#x27;,
data: JSON.stringify(OwnerData),
success: function (data) {
jAlert(data.message, &#x27;message&#x27;);
$(&#x27;#srchText&#x27;).val(&#x27;&#x27;);
$(&quot;#hdnCustomerId&quot;).val(data.Custid);
getOwnerList();
VechiledataSource = new Array();
$(&quot;#div_load&quot;).hide();
$(&quot;#btnDeleteOwner&quot;).hide();
$(&quot;#btnSaveOwner&quot;).prop(&#x27;value&#x27;, &#x27;Save&#x27;);
if (IsDeleted)
$(&quot;#btnAdd&quot;).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 = $(&quot;#VechCustName&quot;).val();
var CustomerMobileNumber1 = $(&quot;#VechileMobileNo&quot;).val();
var CustomerAddress = $(&quot;#VechileAddress&quot;).val();
var vStateId = $(&quot;#ddlState option:selected&quot;).text();
var vCityId = $(&quot;#ddlCity option:selected&quot;).val();
var VehicleRegistrationNumber = $(&quot;#VehicleRegistrationNumber&quot;).cleanVal();
var VehicleNumberPlate = $(&quot;#VehicleNumberPlate&quot;).val();
var VehicleModelNumber = $(&quot;#ddlVechileNo option:selected&quot;).val();
var VehicleType = $(&quot;#ddlVechileType option:selected&quot;).val();
var VehicleId = $(&quot;#VehicleId&quot;).val();
var CustomerId = $(&quot;#hdnCustId&quot;).val();
var vCustomerEmailId = $(&quot;#txtCustomerEmailId&quot;).val();
var ProductVar = $(&quot;#VechProduct&quot;).val();
var VehicleInstallationDate = $(&quot;#VehicleInstallationDate&quot;).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 &gt; 0) {
for (var i = 0; i &lt; 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 = $(&quot;#VehicleRegistrationNumber&quot;).cleanVal();
var VehicleNumberPlate = $(&quot;#VehicleNumberPlate&quot;).val();
var VehicleModelNumber = $(&quot;#ddlVechileNo option:selected&quot;).val();
var VehicleType = $(&quot;#ddlVechileType option:selected&quot;).val();
var CustomerCustomerName = $(&quot;#VechCustName&quot;).val();
var CustomerMobileNumber1 = $(&quot;#VechileMobileNo&quot;).val();
var CustomerAddress = $(&quot;#VechileAddress&quot;).val();
var vStateId = $(&quot;#ddlState option:selected&quot;).text();
var vCityId = $(&quot;#ddlCity option:selected&quot;).text();
var CustomerEmailId = $(&quot;#txtCustomerEmailId&quot;).val();
var VehicleInstallationDate = $(&quot;#VehicleInstallationDate&quot;).val();
if (VehicleRegistrationNumber == &quot;&quot;)
$(&quot;#spanVanRegNo&quot;).show();
else if (VehicleNumberPlate == &quot;&quot;)
$(&quot;#spanVanPlateNo&quot;).show();
else if (VehicleModelNumber == &quot;&quot; &amp;&amp; $(&quot;#VehicleModelNumber&quot;).val() == &quot;&quot;)
$(&quot;#spanVechModelNo&quot;).show();
else if (VehicleType == &quot;&quot;)
$(&quot;#spanVechType&quot;).show();
////else if (VehicleInstallationDate == &quot;&quot;)
//// $(&quot;#spanVehicleInstallationDate&quot;).show()
else if (CustomerCustomerName == &quot;&quot;)
$(&quot;#spanCustomerName&quot;).show();
else if (CustomerMobileNumber1 == &quot;&quot;) {
$(&quot;#spanCustomerMobileNo&quot;).text(&quot;*&quot;);
$(&quot;#spanCustomerMobileNo&quot;).show();
}
else if (CustomerMobileNumber1.length != 10) {
$(&quot;#spanCustomerMobileNo&quot;).text(&quot;Mobile No. should be 10 Characters in Length&quot;);
$(&quot;#spanCustomerMobileNo&quot;).show();
}
else if (CustomerAddress == &quot;&quot;)
$(&quot;#spanCustomerAddress&quot;).show();
else if (vStateId == &quot;-Select-&quot;)
$(&quot;#spanCustomerState&quot;).show();
else if (vCityId == &quot;-Select-&quot;)
$(&quot;#spanCustomerCity&quot;).show();
else if (vRegNoDup &gt; 0)
jAlert(vDupMsgRegNo, &#x27;message&#x27;);
else if (vChasisNoDup &gt; 0)
jAlert(vDupMsgChasisNo, &#x27;message&#x27;);
else if (CustomerEmailId != &quot;&quot;) {
if (validateEmail(CustomerEmailId)) {
vResult = true;
}
else {
$(&quot;#spanCustEmailId&quot;).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() {
$(&quot;#spanVanRegNo&quot;).hide();
$(&quot;#spanVanPlateNo&quot;).hide();
$(&quot;#spanVechModelNo&quot;).hide();
$(&quot;#spanVechType&quot;).hide();
$(&quot;#spanVechModelNo&quot;).hide();
$(&quot;#spanCustomerName&quot;).hide();
$(&quot;#spanCustomerMobileNo&quot;).hide();
$(&quot;#spanCustomerName&quot;).hide();
$(&quot;#spanCustomerAddress&quot;).hide();
$(&quot;#spanCustomerState&quot;).hide();
$(&quot;#spanCustomerEmailId&quot;).hide();
$(&quot;#spanVehicleInstallationDate&quot;).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 = $(&quot;#gridVechile&quot;).data(&quot;kendoGrid&quot;);
var datasource = grid.dataSource.data().length;
var OwnerName = $(&quot;#CustomerCustomerName&quot;).val();
var OwnerMobileNumber = $(&quot;#CustomerMobileNumber1&quot;).val();
var OwnerAddress = $(&quot;#OwnerAddress&quot;).val();
var CustomerEmailId = $(&quot;#CustomerEmailId&quot;).val();
var CustomerAddress = $(&quot;#VechileAddress&quot;).val();
var vStateId = $(&quot;#ddlOwnerState option:selected&quot;).text();
var vCityId = $(&quot;#ddlOwnerCity option:selected&quot;).text();
var vValidEmail = validateEmail(CustomerEmailId);
if (OwnerName == &quot;&quot;)
$(&quot;#spanOwnerName&quot;).show();
else if (OwnerMobileNumber == &quot;&quot;) {
$(&quot;#spanOwnerMobileNo&quot;).text(&quot;*&quot;);
$(&quot;#spanOwnerMobileNo&quot;).show();
}
else if (OwnerMobileNumber.length != 10) {
$(&quot;#spanOwnerMobileNo&quot;).text(&quot;Mobile No. should be of 10 characters.&quot;);
$(&quot;#spanOwnerMobileNo&quot;).show();
}
else if (OwnerAddress == &quot;&quot;)
$(&quot;#spanOwnerAddress&quot;).show();
else if (vStateId == &quot;-Select-&quot;)
$(&quot;#spanOwnerState&quot;).show();
else if (vCityId == &quot;-Select-&quot;)
$(&quot;#spanOwnerCity&quot;).show();
else if (datasource == 0)
//jAlert(&quot;Please enter Vechile detail&quot;, &#x27;message&#x27;);
jAlert(MANAGE_OWNER_MESSAGES.enterVehicleDetail, &#x27;message&#x27;);
else if (vOwnerMobileNoDup &gt; 0)
jAlert(vDupMsg, &#x27;message&#x27;);
else if (CustomerEmailId != &quot;&quot;) {
if (validateEmail(CustomerEmailId)) {
vResult = true;
}
else {
$(&quot;#spanOwnerEmailId&quot;).text(&quot;Please enter valid email&quot;);
$(&quot;#spanOwnerEmailId&quot;).show();
}
}
else
vResult = true;
return vResult;
}
/**
* This Function is used to hide the validation Message of owner Detail
* @method HideValidMsg
* @for ManageOwner
*/
function HideValidMsg() {
$(&quot;#spanOwnerName&quot;).hide();
$(&quot;#spanOwnerMobileNo&quot;).hide();
$(&quot;#spanCustomerAddress&quot;).hide();
$(&quot;#spanVechModelNo&quot;).hide();
$(&quot;#spanOwnerEmailId&quot;).hide();
$(&quot;#spanOwnerState&quot;).hide();
$(&quot;#spanOwnerCity&quot;).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 = &quot;&quot;;
var vCheckDup = false;
if (type == &quot;1&quot;) {
CustName = $(&quot;#VehicleRegistrationNumber&quot;).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 == &quot;2&quot;) {
CustName = $(&quot;#VehicleNumberPlate&quot;).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 == &quot;3&quot;) {
CustName = $(&quot;#CustomerMobileNumber1&quot;).val();
vOwnerMobileNoDup = 0;
//Check Driver Mobile No.
if (CustName != vCustMobileNoOnPageLoad) {
vCheckDup = true;
}
}
if (vCheckDup == true &amp;&amp; CustName != &quot;&quot;) {
$(&quot;#div_load&quot;).show();
$.ajax({
dataType: &#x27;json&#x27;,
type: &#x27;POST&#x27;,
url: &#x27;/Inventory/CheckForDuplication&#x27;,
data: { CustName: CustName, type: type },
success: function (data) {
if (data.success == false) {
jAlert(data.message, &#x27;message&#x27;);
if (type == &quot;1&quot;) {
vDupMsgRegNo = data.message;
//Set
vRegNoDup = data.count;
}
else if (type == &quot;2&quot;) {
vDupMsgChasisNo = data.message;
vChasisNoDup = data.count;
}
else if (type == &quot;3&quot;) {
vOwnerMobileNoDup = data.count;
vDupMsg = data.message;
}
}
else if (type == &quot;1&quot;)
vDupMsgRegNo = &quot;&quot;;
else if (type == &quot;2&quot;)
vDupMsgChasisNo = &quot;&quot;;
else if (type == &quot;3&quot;) {
vDupMsg = &quot;&quot;;
}
},
complete: function () {
$(&quot;#div_load&quot;).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 = $(&quot;#gridVechile&quot;).data(&quot;kendoGrid&quot;);
datasource = grid.dataSource;
var RegdNoList = datasource.data();
for (var i = 0; i &lt;= RegdNoList.length - 1; i++) {
if (RegdNoList[i].VehicleRegistrationNumber == vVechileRegdNo) {
vDupMsgRegNo = &quot;The Registration No. is already added by you&quot;;
jAlert(vDupMsgRegNo, &#x27;message&#x27;);
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 = $(&quot;#gridVechile&quot;).data(&quot;kendoGrid&quot;);
datasource = grid.dataSource;
var ChasisNoList = datasource.data();
for (var i = 0; i &lt;= ChasisNoList.length - 1; i++) {
if (ChasisNoList[i].VehicleNumberPlate == ChasisNo) {
vDupMsgChasisNo = &quot;The Chasis No. is already added by you&quot;;
jAlert(vDupMsgChasisNo, &#x27;message&#x27;);
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: &quot;POST&quot;,
url: WCFRESTURL.GetStateListIdWise,
data: { Token: SecurityToken, UtcMinutes: utcMinutes, UserId: UserId },
dataType: &quot;json&quot;,
success: function (data) {
//data.push({
// StateId: 0,
// StateAlias: &quot;-Select-&quot;
//});
data.sort(function SortState(a, b) { // non-anonymous as you ordered...
return b.StateAlias &lt; a.StateAlias ? 1 // if b should come earlier, push a to end
: b.StateAlias &gt; a.StateAlias ? -1 // if b should come later, push a to begin
: 0; // a and b are equal
});
$(&quot;#stateCombobox&quot;).kendoComboBox({
dataTextField: &quot;StateAlias&quot;,
dataValueField: &quot;StateId&quot;,
filter: &quot;contains&quot;,
dataSource: data
});
},
complete: function () {
//$(&quot;#stateCombobox&quot;).data(&#x27;kendoComboBox&#x27;).select(0);
},
error: function (jqXHR, textStatus, errorThrown) {
}
});
}
/**
//* This Function is used to Reset the Vechile Detail
//* @for ManageOwner
//*/
//function btnUndoVanDealerDetail() {
// if ($(&quot;#VehicleId&quot;).val() != &quot;&quot;) {
// $(&quot;#VehicleRegistrationNumber&quot;).val(vSelectedRow.VehicleRegistrationNumber);
// $(&quot;#VehicleNumberPlate&quot;).val(vSelectedRow.VehicleNumberPlate);
// $(&quot;#VechileAddress&quot;).val(vSelectedRow.CustomerAddress);
// $(&quot;#ddlState option&quot;).filter(function () {
// return this.text == vSelectedRow.CustomerState;
// }).attr(&#x27;selected&#x27;, true);
// $(&quot;#VehicleInstallationDate&quot;).val(vSelectedRow.VehicleInstallationDate);
// $(&#x27;#ddlState&#x27;).trigger(&#x27;change&#x27;);
// }
// else {
// $(&quot;#VechileMobileNo&quot;).val(&quot;&quot;);
// $(&quot;#txtCustomerEmailId&quot;).val(&quot;&quot;);
// $(&quot;#VechileAddress&quot;).val(&quot;&quot;);
// $(&quot;#ddlState option&quot;).filter(function () {
// return this.text == &#x27;-Select-&#x27;;
// }).attr(&#x27;selected&#x27;, true);
// $(&quot;#ddlCity option&quot;).filter(function () {
// return this.text == &#x27;-Select-&#x27;;
// }).attr(&#x27;selected&#x27;, true);
// }
// return false;
//}
/**
* This Function is used to Reset the Driver Detail
* @method btnUndoVanDealerDetail
* @for ManageOwner
*/
function btnUndoVanDealerDetail() {
if ($(&quot;#VehicleId&quot;).val() != &quot;&quot; || vSelectedRow.CustomerCustomerName != &quot;&quot;) {
$(&quot;#VechCustName&quot;).val(vSelectedRow.CustomerCustomerName);
$(&quot;#VechileMobileNo&quot;).val(vSelectedRow.CustomerMobileNumber1);
$(&quot;#txtCustomerEmailId&quot;).val(vSelectedRow.CustomerEmailId);
$(&quot;#VechileAddress&quot;).val(vSelectedRow.CustomerAddress);
$(&quot;#ddlState option&quot;).filter(function () {
return this.text == vSelectedRow.CustomerState;
}).attr(&#x27;selected&#x27;, true);
$(&quot;#VehicleInstallationDate&quot;).val(vSelectedRow.VehicleInstallationDate);
$(&#x27;#ddlState&#x27;).trigger(&#x27;change&#x27;);
}
else {
$(&quot;#VehicleRegistrationNumber&quot;).val(&quot;&quot;);
$(&quot;#VechCustName&quot;).val(&quot;&quot;);
$(&quot;#VechileMobileNo&quot;).val(&quot;&quot;);
$(&quot;#txtCustomerEmailId&quot;).val(&quot;&quot;);
$(&quot;#VechileAddress&quot;).val(&quot;&quot;);
$(&quot;#ddlState option&quot;).filter(function () {
return this.text == &#x27;-Select-&#x27;;
}).attr(&#x27;selected&#x27;, true);
$(&quot;#ddlCity option&quot;).filter(function () {
return this.text == &#x27;-Select-&#x27;;
}).attr(&#x27;selected&#x27;, true);
}
return false;
}
/**
* This Function is used to Reset the Driver Detail
* @method btnUndoVechDetail
* @for ManageOwner
*/
function btnUndoVechDetail() {
if ($(&quot;#VehicleId&quot;).val() != &quot;&quot; || vVechileSelectedRow.VehicleRegistrationNumber != &quot;&quot;) {
$(&quot;#VehicleRegistrationNumber&quot;).val(vRegNo);
$(&quot;#VehicleNumberPlate&quot;).val(vVechileSelectedRow.VehicleNumberPlate);
$(&quot;#ddlVechileNo option&quot;).filter(function () {
return this.text == vVechileSelectedRow.VehicleModelNumber;
}).attr(&#x27;selected&#x27;, true);
$(&quot;#ddlVechileType option&quot;).filter(function () {
return this.text == vVechileSelectedRow.VehicleType;
}).attr(&#x27;selected&#x27;, true);
$(&quot;#VehicleInstallationDate&quot;).val(vVechileSelectedRow.VehicleInstallationDate);
$(&#x27;#ddlVechileNo&#x27;).trigger(&#x27;change&#x27;);
}
else {
$(&quot;#VehicleRegistrationNumber&quot;).val(vRegNo);
$(&quot;#VehicleNumberPlate&quot;).val(&quot;&quot;);
$(&quot;#ddlVechileNo option&quot;).filter(function () {
return this.text == &#x27;-Select-&#x27;;
}).attr(&#x27;selected&#x27;, true);
$(&quot;#ddlVechileType option&quot;).filter(function () {
return this.text == &#x27;-Select-&#x27;;
}).attr(&#x27;selected&#x27;, true);
$(&quot;#VehicleInstallationDate&quot;).val(vVechileSelectedRow.VehicleInstallationDate);
$(&quot;#VechProduct&quot;).val(&quot;&quot;);
}
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 &gt; 31 &amp;&amp; (charCode &lt; 48 || charCode &gt; 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 = $(&quot;#ddlVechileNo&quot;).val();
$.getJSON(&quot;/Ticket_CustomerInventory/GetVehicleModelTaggingBasedOnModelNo/&quot;, { ModelTypeId: VModel }, function (result) {
if (result) {
var ModelType = result.VehicleModelTagging;
for (var count = 0; count &lt; ModelType.length; count++) {
$(&quot;#VechProduct&quot;).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 &gt; 0) {
$(this).bind(&#x27;keyup change paste cut&#x27;, onSomethingChanged);
for (var i = 0; i &lt; $(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 &gt; 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(&#x27;text_clear_button&#x27;)) {
// appends div
input.after(&quot;&lt;div class=&#x27;text_clear_button&#x27;&gt;&lt;/div&gt;&quot;);
var clear_button = input.next();
var w = clear_button.outerHeight(), h = clear_button.outerHeight();
input.css(&#x27;padding-right&#x27;, parseInt(input.css(&#x27;padding-right&#x27;)) + w + 1);
input.width(input.width() - w - 1);
var pos = input.position();
var style = {};
style[&#x27;left&#x27;] = pos.left + input.outerWidth(false) - (w + 2);
var offset = Math.round((input.outerHeight(true) - h) / 2.0);
style[&#x27;top&#x27;] = pos.top + offset;
clear_button.css(style);
clear_button.click(function () {
input.val(&#x27;&#x27;);
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(&#x27;text_clear_button&#x27;)) {
clear_button.remove();
var w = clear_button.width();
input.css(&#x27;padding-right&#x27;, parseInt(input.css(&#x27;padding-right&#x27;)) - 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>