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

775 lines
35 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>TicketAdministration_Dealer\ticketAdministrationDealer.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: TicketAdministration_Dealer\ticketAdministrationDealer.js</h1>
<div class="file">
<pre class="code prettyprint linenums">
/*================================================================================================================\
+
+ Project : GoData-VECV
+ Filename : ticketAdministrationDealer.js
+ Module Name : Ticket
+ Purpose : For ticketing
+ Coded By : Parul Gupta
+
+================================================================================================================*/
/**
* For ticketing
* @module Ticket
*/
/**
* This class contains functionality of Ticket administration for Dealer and his vans.
* @class TicketForDealer
* @constructor
*/
//Global Variables
var activeRequest, xhr_getTicketHistory, xhr_getTicketHistoryInterval, xhr_getCloseTickerDetails, xhr_getOpenTicketDetails, xhr_showActivity,
xhr_showOpenActivity, xhr_addCustomer, xhr_addCustomerForExisting, xhr_getAllVans, xhr_addNewTicket;
var interval_id;
var ccplMap = null, markerImagePath = &quot;../../Scripts/map_api/icons/red_blank.png&quot;,
markerTransImgPath = &quot;../../Scripts/map_api/icons/red_blink.gif&quot;,
defaultLat = 26.912285124827,
defaultLng = 75.7873203125,
sourceMarker = &#x27;../../Scripts/map_api/icons/red_s.png&#x27;, destinationMarker = &#x27;../../Scripts/map_api/icons/red_d.png&#x27;;
var availableVansMarkers = &#x27;../../Content/css/images/avil-van.png&#x27;;
var unavailableVansMarkers = &#x27;../../Content/css/images/unavl-van.png&#x27;;
var dealerMarker = &#x27;../../Content/css/images/dealer-icon.png&#x27;;
var breakdownLocationLatLng = &quot;&quot;;
//initialize markers
var nearestVansDealersMarks = []; //array of nearest vans and dealers markers
var detailsListOfVanDealer = []; //array of objects of details of nearest vans and dealers
var vanDealerLatLngArr = []; //array of nearest vans and dealers lat lng
var ticketDetailsMarkerArray = [];
var _securityToken;
var _userId;
var marker, geoCoder, directionService;
var routeDirectionDisplay = &quot;&quot;;
var routeDirectionsService = new google.maps.DirectionsService();
var routeDistanceService = new google.maps.DistanceMatrixService();
var displayDisplay = &quot;&quot;;
var selectedTicket;
var assignedTo;
/**
* Load google map on page.
* @method initMap
* @for TicketForDealer
*/
function initMap(id) {
var mapOptions = {
center: new google.maps.LatLng(defaultLat, defaultLng),
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
ccplMap = new google.maps.Map(document.getElementById(id), mapOptions);
geoCoder = new google.maps.Geocoder();
}
/**
* Function call on click of Route label to show map
* @method onclickLabelRoute
* @for TicketForDealer
*/
function onclickLabelRoute() {
//on click of label route
$(&quot;#labelRoute&quot;).click(function () {
// add selected class
$(&#x27;#labelActivity&#x27;).removeClass(&quot;toolBtnActive&quot;);
$(&#x27;#labelRoute&#x27;).addClass(&quot;toolBtnActive&quot;);
$(&quot;#divMapContainer&quot;).show();
$(&quot;#divActivity&quot;).css(&#x27;display&#x27;, &#x27;none&#x27;);
});
}
/**
* Function call on click of Activity label to show ticket activity
* @method onclickLabelActivity
* @for TicketForDealer
*/
function onclickLabelActivity() {
//on click of label Activitys
$(&quot;#labelActivity&quot;).click(function () {
// add selected class
$(&#x27;#labelRoute&#x27;).removeClass(&quot;toolBtnActive&quot;);
$(&#x27;#labelActivity&#x27;).addClass(&quot;toolBtnActive&quot;);
$(&quot;#divActivity&quot;).css(&#x27;display&#x27;, &#x27;inline-block&#x27;);
$(&quot;#divActivity&quot;).addClass(&quot;withtoolbar&quot;);
$(&quot;#divMapContainer&quot;).hide();
var ticketId;
if ((document.getElementById(&#x27;tableTicketHistory&#x27;)) || (document.getElementById(&#x27;tableCloseTicketHistory&#x27;)) || ((document.getElementById(&#x27;tableTicketHistory&#x27;)) &amp;&amp; (document.getElementById(&#x27;tableCloseTicketHistory&#x27;)))) {
if (document.getElementById(&#x27;tableTicketHistory&#x27;)) {
if ($(&quot;#tableTicketHistory &gt; tbody &gt; tr&quot;).hasClass(&#x27;select&#x27;)) {
ticketId = $(&quot;#tableTicketHistory &gt; tbody &gt; tr.select&quot;)[0].id;
//enable ticket status dropdown list and remarks text box and update button for open tickets list
$(&quot;#ddTicketStatus, #textBoxDescription&quot;).attr(&quot;disabled&quot;, false);
$(&quot;#button_submit&quot;).show();
if (xhr_showOpenActivity &amp;&amp; xhr_showOpenActivity.readystate != 4) {
xhr_showOpenActivity.abort();
}
//get ticket activity details
xhr_showOpenActivity = $.ajax({
type: &quot;POST&quot;,
url: &quot;/TicketAdministration_Dealer/TicketAdministrationDealer_ShowTicketActivityOpenClose/&quot;,
data: { ticketId: ticketId, ticketStatus: &#x27;open&#x27; },
success: function (data) {
$(&quot;#divActivity&quot;).html(data);
$(&quot;#ddTicketStatus, #textBoxDescription&quot;).attr(&quot;disabled&quot;, false);
$(&quot;#button_submit&quot;).show();
},
error: function (data) { }
});
}
else {
ticketId = $(&quot;#tableCloseTicketHistory &gt; tbody &gt; tr.select&quot;)[0].id;
//disable ticket status dropdown list and remarks text box and update button for close tickets list
$(&quot;#ddTicketStatus, #textBoxDescription&quot;).attr(&quot;disabled&quot;, true);
$(&quot;#button_submit&quot;).hide();
//get ticket activity details
if (xhr_showActivity &amp;&amp; xhr_showActivity.readystate != 4) {
xhr_showActivity.abort();
}
xhr_showActivity = $.ajax({
type: &quot;POST&quot;,
url: &quot;/TicketAdministration_Dealer/TicketAdministrationDealer_ShowTicketActivityOpenClose/&quot;,
data: { ticketId: ticketId, ticketStatus: &#x27;close&#x27; },
success: function (data) {
$(&quot;#divActivity&quot;).html(data);
$(&quot;#ddTicketStatus, #textBoxDescription, #ddReasonForOpportunityLost&quot;).attr(&quot;disabled&quot;, true);
$(&quot;#button_submit&quot;).hide();
},
error: function (data) { }
});
}
} else {
ticketId = $(&quot;#tableCloseTicketHistory &gt; tbody &gt; tr.select&quot;)[0].id;
$(&quot;#ddTicketStatus, #textBoxDescription&quot;).attr(&quot;disabled&quot;, true);
$(&quot;#button_submit&quot;).hide();
//get ticket activity details
if (xhr_showActivity &amp;&amp; xhr_showActivity.readystate != 4) {
xhr_showActivity.abort();
}
xhr_showActivity = $.ajax({
type: &quot;POST&quot;,
url: &quot;/TicketAdministration_Dealer/TicketAdministrationDealer_ShowTicketActivityOpenClose/&quot;,
data: { ticketId: ticketId, ticketStatus: &#x27;close&#x27; },
success: function (data) {
$(&quot;#divActivity&quot;).html(data);
$(&quot;#ddTicketStatus, #textBoxDescription, #ddReasonForOpportunityLost&quot;).attr(&quot;disabled&quot;, true);
$(&quot;#button_submit&quot;).hide();
},
error: function (data) { }
});
}
}
});
}
/**
* Function to get open tickets history
* @method getOpenTicketsHistory
* @for TicketForDealer
*/
function getOpenTicketsHistory() {
$(&quot;#tableTicketHistory &gt; tbody &gt; tr&quot;).click(function (e) {
$(&quot;#div_loading&quot;).show();
$(&quot;#labelRoute&quot;).trigger(&#x27;click&#x27;);
$(&quot;#divActivity&quot;).html(&quot;&quot;);
//Remove Source Destination Direction Display if visible as well as Remove Previous Markers if any Present
if (displayDisplay) {
//Remove direction display
displayDisplay.setMap(null);
}
//Remove previous markers
removeTicketDetailsMarkerArray();
var ticketId = e.currentTarget.id;
var assignedVanDealerLatLng, breakdownLocationLatLng;
//remove select class
$(&quot;#tableCloseTicketHistory &gt; tbody &gt; tr.select &gt; td&quot;).removeClass(&quot;SelectRow&quot;);
$(&quot;#tableCloseTicketHistory &gt; tbody &gt; tr&quot;).removeClass(&quot;select&quot;);
$(&quot;#tableTicketHistory &gt; tbody &gt; tr.select &gt; td&quot;).removeClass(&quot;SelectRow&quot;);
$(&quot;#tableTicketHistory &gt; tbody &gt; tr&quot;).removeClass(&quot;select&quot;);
$(&quot;#tableTicketHistory &gt; tbody &gt; tr[id=&quot; + ticketId + &quot;]&quot;).addClass(&#x27;select&#x27;);
$(&quot;#tableTicketHistory &gt; tbody &gt; tr[id=&quot; + ticketId + &quot;].select &gt; td&quot;).addClass(&#x27;SelectRow&#x27;);
$(&quot;#divMap&quot;).css(&#x27;width&#x27;, &#x27;50%&#x27;);
$(&quot;#divMapContainer&quot;).addClass(&quot;withtoolbar&quot;);
$(&quot;#divMapContainer&quot;).addClass(&quot;MapBox&quot;);
$(&quot;#divTicketDetailTitle&quot;).css(&#x27;display&#x27;, &#x27;inline-block&#x27;);
if (xhr_getOpenTicketDetails &amp;&amp; xhr_getOpenTicketDetails.readystate != 4) {
xhr_getOpenTicketDetails.abort();
}
//get ticket details
xhr_getOpenTicketDetails = $.ajax({
type: &quot;POST&quot;,
url: &quot;/TicketAdministration_Dealer/TicketAdministrationDealer_GetTicketDetails/&quot;,
data: { ticketId: ticketId, ticketStatus: &#x27;open&#x27; },
success: function (data) {
//Remove Source Destination Direction Display if visible as well as Remove Previous Markers if any Present
if (displayDisplay) {
//Remove direction display
displayDisplay.setMap(null);
}
//Remove previous markers
removeTicketDetailsMarkerArray();
$(&quot;#divDetail&quot;).html(&#x27;&#x27;);
$(&quot;#divDetail&quot;).html(data);
if (ccplMap) {
if ($(&quot;#labelRoute&quot;).hasClass(&#x27;toolBtnActive&#x27;) == true) {
var vanLat = $(&quot;#AssignedVanDealerLat&quot;).val();
var vanLng = $(&quot;#AssignedVanDealerLng&quot;).val();
var breakdownLat = $(&quot;#BreakdownLat&quot;).val();
var breakdownLng = $(&quot;#BreakdownLng&quot;).val();
if ((vanLat != &quot;&quot; &amp;&amp; vanLat != null) &amp;&amp; (vanLng != &quot;&quot; &amp;&amp; vanLng != null) &amp;&amp; (breakdownLat != &quot;&quot; &amp;&amp; breakdownLat != null) &amp;&amp; (breakdownLng != &quot;&quot; &amp;&amp; breakdownLng != null)) {
assignedVanDealerLatLng = new google.maps.LatLng(vanLat, vanLng);
breakdownLocationLatLng = new google.maps.LatLng(breakdownLat, breakdownLng);
//Get address of the Lat Long click clicked
getReverseGeoCode(assignedVanDealerLatLng, function (data) {
//Here we got the address of the point clicked. Update this value to the form textbox.
var title = data;
//create marker at position
createMarkerVanDealer(assignedVanDealerLatLng, sourceMarker, title);
//Get address of the Lat Long click clicked
getReverseGeoCode(breakdownLocationLatLng, function (data) {
//Here we got the address of the point clicked. Update this value to the form textbox.
var title = data;
//create marker at position
createMarkerVanDealer(breakdownLocationLatLng, destinationMarker, title);
//calculate route
calcRoute(assignedVanDealerLatLng, breakdownLocationLatLng);
//get map bound
var _bounds = new google.maps.LatLngBounds();
for (var count = 0; count &lt; ticketDetailsMarkerArray.length; count++) {
_bounds.extend(ticketDetailsMarkerArray[count].position);
}
ccplMap.fitBounds(_bounds);
});
});
} else {
$(&quot;#div_loading&quot;).hide();
}
}
}
},
error: function (data) {
console.log(data);
}
});
});
}
/**
* Function to get close tickets history
* @method getCloseTicketsHistory
* @for TicketForDealer
*/
function getCloseTicketsHistory() {
$(&quot;#tableCloseTicketHistory &gt; tbody &gt; tr&quot;).click(function (e) {
$(&quot;#div_loading&quot;).show();
$(&quot;#labelRoute&quot;).trigger(&#x27;click&#x27;);
$(&quot;#divActivity&quot;).html(&quot;&quot;);
//Remove Source Destination Direction Display if visible as well as Remove Previous Markers if any Present
if (displayDisplay) {
//Remove direction display
displayDisplay.setMap(null);
}
//Remove previous markers
removeTicketDetailsMarkerArray();
var ticketId = e.currentTarget.id;
var assignedVanDealerLatLng, breakdownLocationLatLng;
//remove select class
$(&quot;#tableTicketHistory &gt; tbody &gt; tr.select &gt; td&quot;).removeClass(&quot;SelectRow&quot;);
$(&quot;#tableTicketHistory &gt; tbody &gt; tr&quot;).removeClass(&quot;select&quot;);
$(&quot;#tableCloseTicketHistory &gt; tbody &gt; tr.select &gt; td&quot;).removeClass(&quot;SelectRow&quot;);
$(&quot;#tableCloseTicketHistory &gt; tbody &gt; tr&quot;).removeClass(&quot;select&quot;);
$(&quot;#tableCloseTicketHistory &gt; tbody &gt; tr[id=&quot; + ticketId + &quot;]&quot;).addClass(&#x27;select&#x27;);
$(&quot;#tableCloseTicketHistory &gt; tbody &gt; tr[id=&quot; + ticketId + &quot;].select &gt; td&quot;).addClass(&#x27;SelectRow&#x27;);
$(&quot;#divMap&quot;).css(&#x27;width&#x27;, &#x27;50%&#x27;);
$(&quot;#divTicketDetailTitle&quot;).css(&#x27;display&#x27;, &#x27;inline-block&#x27;);
if (xhr_getCloseTickerDetails &amp;&amp; xhr_getCloseTickerDetails.readystate != 4) {
xhr_getCloseTickerDetails.abort();
}
xhr_getCloseTickerDetails = $.ajax({
type: &quot;POST&quot;,
url: &quot;/TicketAdministration_Dealer/TicketAdministrationDealer_GetTicketDetails/&quot;,
data: { ticketId: ticketId, ticketStatus: &#x27;close&#x27; },
success: function (data) {
//Remove Source Destination Direction Display if visible as well as Remove Previous Markers if any Present
if (displayDisplay) {
//Remove direction display
displayDisplay.setMap(null);
}
//Remove previous markers
removeTicketDetailsMarkerArray();
$(&quot;#divDetail&quot;).html(&#x27;&#x27;);
$(&quot;#divDetail&quot;).html(data);
if (ccplMap) {
if ($(&quot;#labelRoute&quot;).hasClass(&#x27;toolBtnActive&#x27;) == true) {
var vanLat = $(&quot;#AssignedVanDealerLat&quot;).val();
var vanLng = $(&quot;#AssignedVanDealerLng&quot;).val();
var breakdownLat = $(&quot;#BreakdownLat&quot;).val();
var breakdownLng = $(&quot;#BreakdownLng&quot;).val();
if ((vanLat != &quot;&quot; &amp;&amp; vanLat != null) &amp;&amp; (vanLng != &quot;&quot; &amp;&amp; vanLng != null) &amp;&amp; (breakdownLat != &quot;&quot; &amp;&amp; breakdownLat != null) &amp;&amp; (breakdownLng != &quot;&quot; &amp;&amp; breakdownLng != null)) {
assignedVanDealerLatLng = new google.maps.LatLng(vanLat, vanLng);
breakdownLocationLatLng = new google.maps.LatLng(breakdownLat, breakdownLng);
//Get address of the Lat Long click clicked
getReverseGeoCode(assignedVanDealerLatLng, function (data) {
//Here we got the address of the point clicked. Update this value to the form textbox.
var title = data;
//create marker at position
createMarkerVanDealer(assignedVanDealerLatLng, sourceMarker, title);
//Get address of the Lat Long click clicked
getReverseGeoCode(breakdownLocationLatLng, function (data) {
//Here we got the address of the point clicked. Update this value to the form textbox.
var title = data;
//create marker at position
createMarkerVanDealer(breakdownLocationLatLng, destinationMarker, title);
var _bounds = new google.maps.LatLngBounds();
// console.log(ticketDetailsMarkerArray);
for (var count = 0; count &lt; ticketDetailsMarkerArray.length; count++) {
_bounds.extend(ticketDetailsMarkerArray[count].position);
}
ccplMap.fitBounds(_bounds);
//calculate route
calcRoute(assignedVanDealerLatLng, breakdownLocationLatLng);
});
});
} else {
$(&quot;#div_loading&quot;).hide();
}
}
}
},
error: function (data) {
console.log(data);
}
});
});
}
/**
* This fn return selected tab id.
* @method getSelectedTab
* @for TicketForDealer
*/
function getSelectedTab() {
&#x27;use strict&#x27;;
var selectedTab;
selectedTab = $(&quot;.tabs&quot;).find(&#x27;ul &gt; li.ActiveTab&#x27;)[0].id;
return selectedTab;
}
/**
* This fn get history of ticket
* @method getTicketsHistory
* @param {string} controller Controller name
* @param {string} assignedToType Type to which, Ticket is assigned
* @param {string} divId HTML id of div
* @for TicketForDealer
*/
function getTicketsHistory(controller, assignedToType, divId) {
&#x27;use strict&#x27;;
// check request already exist or not.
if (xhr_getTicketHistory &amp;&amp; xhr_getTicketHistory.readystate != 4) {
xhr_getTicketHistory.abort();
}
xhr_getTicketHistory = $.post(&quot;/TicketAdministration_Dealer/&quot; + controller + &quot;/&quot;, { assignedToType: assignedToType }, function (data) {
$(&#x27;#divMyTickets, #divMyVansTickets&#x27;).html(&#x27;&#x27;);
$(&#x27;#&#x27; + divId).html(data);
$(&#x27;#&#x27; + divId).show();
if (!selectedTicket) {
if (document.getElementById(&#x27;tableTicketHistory&#x27;) != null) {
$(&quot;#tableTicketHistory &gt; tbody &gt; tr&quot;).first().trigger(&#x27;click&#x27;);
$(&quot;#li_Activity&quot;).show();
} else if (document.getElementById(&#x27;tableCloseTicketHistory&#x27;) != null) {
$(&quot;#tableCloseTicketHistory &gt; tbody &gt; tr&quot;).first().trigger(&#x27;click&#x27;);
$(&quot;#li_Activity&quot;).show();
} else {
$(&#x27;#&#x27; + divId).html(&quot;&lt;div&gt;&lt;span&gt;No open / close tickets are available !!&lt;/span&gt;&lt;/div&gt;&quot;)
$(&quot;#li_Activity&quot;).hide();
$(&quot;#divActivity&quot;).hide();
$(&quot;#labelRoute&quot;).trigger(&#x27;click&#x27;);
if (displayDisplay) {
//Remove direction display
displayDisplay.setMap(null);
//Remove previous markers
removeTicketDetailsMarkerArray();
}
$(&quot;#divDetail&quot;).html(&#x27;&#x27;);
}
}
else {
$(&quot;#tableTicketHistory &gt; tbody &gt; tr[id=&#x27;&quot; + selectedTicket + &quot;&#x27;]&quot;).trigger(&#x27;click&#x27;);
selectedTicket = &quot;&quot;;
}
});
}
/**
* This fn show ticket history
* @method showTicketHistory
* @for TicketForDealer
*/
function showTicketHistory() {
// get selected tab id.
var tabId;
tabId = getSelectedTab();
if (tabId == &quot;tabMyTickets&quot;) {
getTicketsHistory(&quot;TicketAdministrationDealer_GetTicketHistory&quot;, &quot;dealer&quot;, &quot;divMyTickets&quot;);
}
else {
getTicketsHistory(&quot;TicketAdministrationDealer_GetTicketHistory&quot;, &quot;van&quot;, &quot;divMyVansTickets&quot;);
}
}
/**
* Maintain tab functionality. show particular div based on the tab id.
* @method graphicalTabAction
* @for TicketForDealer
*/
function graphicalTabAction() {
&#x27;use strict&#x27;;
$(&quot;.divContent&quot;).hide();
$(&quot;#tabGroup li&quot;).removeClass(&quot;ActiveTab&quot;);
$(&#x27;#tabGroup li&#x27;).click(function (e) {
e.stopPropagation();
var target = $(this).attr(&quot;rel&quot;);
$(&quot;.divContent&quot;).hide();
$(&quot;#tabGroup li&quot;).removeClass(&quot;ActiveTab&quot;);
$(&quot;.divContent[rel=&#x27;&quot; + target + &quot;&#x27;]&quot;).show();
$(&quot;#tabGroup li[rel=&#x27;&quot; + target + &quot;&#x27;]&quot;).addClass(&quot;ActiveTab&quot;);
showTicketHistory();
});
}
/**
* Function to create markers on van&#x27;s / dealer&#x27;s location for ticket details
* @method createMarkerVanDealer
* @param {String} position Position of van / dealer
* @param {String} icon Icon of placed marker
* @param {String} title Title of placed marker
* @for TicketForDealer
*/
function createMarkerVanDealer(position, icon, title) {
//create a google marker with the given param
var vanDealerMarker = new google.maps.Marker({
position: position,
map: ccplMap,
icon: icon,
title: title
});
//push marker to marksArray
ticketDetailsMarkerArray.push(vanDealerMarker);
}
//------------------------------------------ calculate route -------------------------------------//
/**
* This fn removes all markers stored in ticketDetailsMarkerArray.
* @method removeTicketDetailsMarkerArray
* @for TicketForDealer
*/
function removeTicketDetailsMarkerArray() {
//loop through arary
for (var i = 0; i &lt; ticketDetailsMarkerArray.length; i++) {
//set marker map to null
ticketDetailsMarkerArray[i].setMap(null);
}
//empty array
ticketDetailsMarkerArray = [];
}
/**
* This fn calculates and draws the Route for the Ticket selected in the Ticket List using Google Direction API
* @method calcRoute
* @param {String} startLatLng Position of origin
* @param {String} endLatLng Position of destination
* @for TicketForDealer
*/
function calcRoute(startLatLng, endLatLng) {
var merkerIcon;
if (displayDisplay) {
//Remove direction display
displayDisplay.setMap(null);
}
var rendererOptions = {
map: ccplMap,
suppressMarkers: true,
polylineOptions: { strokeColor: &quot;#1b3f94&quot; }
}
displayDisplay = new google.maps.DirectionsRenderer(rendererOptions);
//Make request obj to Direction Service API with starting and end LatLng
var request = {
origin: startLatLng,
destination: endLatLng,
travelMode: google.maps.TravelMode.DRIVING
};
//call Direction Service API with the reuqest obj
routeDirectionsService.route(request, function (response, status) {
//if status was a success
if (status == google.maps.DirectionsStatus.OK) {
displayDisplay.setOptions({ preserveViewport: true });
//set Direction to the response
displayDisplay.setDirections(response);
var leg = response.routes[0].legs[0];
$(&quot;#div_loading&quot;).hide();
}
});
}
//-------------------------------------------- end routing ---------------------------------------//
//======================================================================GeoCoding Functions=============================================================================//
/**
* This function reverses the Lat Lng to Get the Approxmiate Address using the Google GeoCoding. Callback the result
* @method getReverseGeoCode
* @param {String} latLng lat lng of marker
* @param {String} callback function callback
* @for TicketForDealer
*/
function getReverseGeoCode(latLng, callback) {
// Get google map LatLng object with the latLng in params
var latlng = new google.maps.LatLng(latLng.lat(), latLng.lng());
//Use google geocode library to get results
geoCoder.geocode({ &#x27;latLng&#x27;: latlng }, function (results, status) {
//If status is Ok
if (status == google.maps.GeocoderStatus.OK) {
//Find most intensive search result and callback it
if (results[0]) {
callback(results[0].formatted_address);
//Else callback no result found
} else {
callback(&#x27;No results found&#x27;);
}
}
return false;
});
}
//========================== document ready function =========================//
$(document).ready(function () {
initMap(&quot;divMapContainer&quot;);
selectedTicket = getParameterByName(&quot;complaintNo&quot;);
assignedTo = getParameterByName(&quot;assignedTo&quot;);
graphicalTabAction();
if (!selectedTicket) {
$(&quot;#tabMyTickets&quot;).trigger(&#x27;click&#x27;);
}
else {
if (assignedTo == &quot;dealer&quot;) { $(&quot;#tabMyTickets&quot;).trigger(&#x27;click&#x27;); } else { $(&quot;#tabMyVansTickets&quot;).trigger(&#x27;click&#x27;); }
}
});
</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>