Guest User

Untitled

a guest
Feb 9th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.27 KB | None | 0 0
  1. @using System.Web.Mvc.Html
  2. @using Worx24Ticketing;
  3. @using System.Text.RegularExpressions;
  4. @using System.Web.Helpers;
  5. @model Ticket
  6. @{
  7. ViewBag.Title = "New Ticket";
  8. Layout = "~/Views/Shared/_Layout.cshtml";
  9. }
  10. <h2 style="float: left;">
  11. <a href="@Url.Action("index", "ticketing")">
  12. <img style="width: 80px; padding-right: 20px;"
  13. src="../../Content/Images/icon_ticket.png" /></a>Modify Ticket
  14. </h2>
  15.  
  16. <div id="savingWrapper" style="line-height: 8em; float: left; padding-left: 50px;">
  17. <span style="display: none; font-size: 17px;" id="saving">
  18. <img src="~/Content/Images/loading.gif" />
  19. Saving ...</span>
  20. </div>
  21. <div class="clear"></div>
  22. <span id="priorityContainer" style="padding-left: 15px; font-size: 12px; font-weight: bold;">Priority</span>
  23. <span id="updateDetails" style="padding-left: 15px;"> </span>
  24. <br />
  25. <br />
  26. <div class="clear"></div>
  27. <div id="scheduleService">
  28. <a href="#myModal" role="button" style="float: left; margin-bottom: 15px; color: white; margin-left: 15px; text-decoration: none;" class="btn btn-danger" data-toggle="modal">Schedule Service</a>
  29. <a onclick="return confirm('This action is irreversible, are you sure you want to close this ticket?')" style="margin-bottom: 15px; color: white; margin-left: 15px; text-decoration: none;" href="@Url.Action("closeticket", "ticketing", new { id = Model.TicketId })" class="btn btn-danger">Close Ticket</a>
  30. </div>
  31. <div class="buttonContainer">
  32. <div class="btn-group" style="float: left; text-decoration: none;">
  33. <a class="btn btn-danger dropdown-toggle" style="text-decoration: none; color: #ffffff" data-toggle="dropdown" href="#">Priority
  34. <span class="caret"></span>
  35. </a>
  36. <ul class="dropdown-menu">
  37. <li><a href="#" id="highPriority" onclick="setTicketPriority(3)" style="font-weight: bold; color: red">High</a></li>
  38. <li><a href="#" id="mediumPriority" onclick="setTicketPriority(2)" style="font-weight: bold; color: orange">Medium</a></li>
  39. <li><a href="#" id="lowPriority" onclick="setTicketPriority(1)" style="font-weight: bold; color: green">Low</a></li>
  40. <li class="divider"></li>
  41. <li><a href="#" id="noPriority" onclick="setTicketPriority(0)" style="font-weight: bold; color: black">None</a></li>
  42. </ul>
  43. </div>
  44. </div>
  45. <div class="buttonContainer">
  46. <div class="btn-group" style="float: left;">
  47. <a class="btn btn-danger dropdown-toggle" style="text-decoration: none; color: #ffffff" data-toggle="dropdown" href="#">E-Mail Customer
  48. <span class="caret"></span>
  49. </a>
  50. <ul class="dropdown-menu">
  51. @{
  52. var pattern = @"([a-zA-Z0-9_\-])([a-zA-Z0-9_\-\.]*)@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])";
  53. var PrimaryContactEmail = Regex.Match(@Model.PrimaryContact, pattern);
  54. var mailtoFormatter = String.Empty;
  55.  
  56. var multipleContacts = Regex.Matches(Model.PrimaryContact, pattern);
  57.  
  58. if (multipleContacts != null)
  59. {
  60. var mailtoString = String.Empty;
  61. foreach (var match in multipleContacts)
  62. {
  63. mailtoString += match + ";";
  64. }
  65.  
  66. mailtoFormatter = String.Format("mailto:{0}?subject={1}&body={2}", mailtoString, "Test", "Test");
  67. }
  68.  
  69.  
  70. }
  71. <li><a href="@mailtoFormatter">Service Scheduled</a></li>
  72. <li><a href="@mailtoFormatter">Ticket Assigned</a></li>
  73. <li><a href="@mailtoFormatter">Ticket Complete</a></li>
  74. </ul>
  75. </div>
  76. </div>
  77.  
  78. <div class="clear"></div>
  79. @using (Html.BeginForm("modifyticket", "ticketing", FormMethod.Post, new { id = "modifyTicket" }))
  80. {
  81. @Html.HiddenFor(model => model.TicketId)
  82. @Html.HiddenFor(model => model.CreatedDate)
  83. @Html.HiddenFor(model => model.CreatedBy)
  84. @Html.HiddenFor(model => model.SalesEmpId)
  85. @Html.HiddenFor(model => model.LocationId)
  86. @Html.HiddenFor(model => model.IsComplete)
  87. @Html.HiddenFor(model => model.LastUpdate)
  88. @Html.HiddenFor(model => model.LastUpdate)
  89. @Html.HiddenFor(model => model.CompletedDate)
  90. @Html.HiddenFor(model => model.Priority)
  91. <div id="newTicketWrapper">
  92. <table class="newTicket">
  93. <tbody>
  94. <tr>
  95. <td class="newticketHeading">
  96. @Html.Label("Ticket Type:")
  97. </td>
  98. <td class="newticketInputs">
  99. @Html.DropDownListFor(model => model.TicketTypeId, (IEnumerable<SelectListItem>)ViewBag.TicketTypes)
  100. @Html.ValidationMessageFor(model => model.TicketTypeId)
  101. </td>
  102. </tr>
  103. <tr>
  104. <td class="newticketHeading">
  105. @Html.Label("Company:")
  106. </td>
  107. <td class="newticketInputs">
  108. @Html.TextBox("ClientName", null, new { placeholder = "Select a company..." })
  109. @Html.HiddenFor(model => model.ClientId)
  110. <br />
  111. @Html.ValidationMessage("ClientName", "Please specify a company for this ticket.")
  112. </td>
  113. </tr>
  114. <tr>
  115. <td class="newticketHeading">
  116. @Html.Label("Location(s):")
  117. <label for="AllLocations" style="font-size: 9px; display: block;">
  118. Type "all" for all locations</label>
  119. </td>
  120. <td class="newticketInputs">
  121. @Html.HiddenFor(model => model.LocationId, new { placeholder = "Select a location from the dropdown." })
  122. @Html.TextBox("LocationName", "", new { @class = "LocationName required" })
  123.  
  124. <button href="#newAffected" role="button" style="float: right; height: 38px; text-decoration: none;" class="btn" data-toggle="modal">+</button>
  125. <div id="affectedLocWrapper"></div>
  126. <br />
  127. @Html.ValidationMessageFor(model => model.LocationId)
  128. </td>
  129. </tr>
  130. <tr>
  131. <td class="newticketHeading">
  132. @Html.Label("Service / Unit Type:")
  133. </td>
  134. <td class="newticketInputs">
  135. @Html.DropDownListFor(model => model.UnitTypeId, (IEnumerable<SelectListItem>)ViewBag.UnitTypes)
  136. <br />
  137. @Html.ValidationMessageFor(model => model.UnitTypeId)
  138. </td>
  139. </tr>
  140. <tr>
  141. <td class="newticketHeading">
  142. @Html.Label("Summary:")
  143. </td>
  144. <td class="newticketInputs">
  145. @Html.TextBoxFor(model => model.Title, new { placeholder = "Short summary of the problem..." })
  146. <br />
  147. @Html.ValidationMessageFor(model => model.Title)
  148. </td>
  149. </tr>
  150. <tr>
  151. <td class="newticketHeading">
  152. @Html.Label("Client Contact:")
  153. </td>
  154. <td class="newticketInputs">
  155. @Html.TextAreaFor(model => model.PrimaryContact)
  156. @* I think its something like this, because remember these objects will be injected into the dom upon a click.*@
  157. <br />
  158. @Html.ValidationMessageFor(model => model.PrimaryContact)
  159. </td>
  160. </tr>
  161. <tr>
  162. <td class="newticketHeading">
  163. @Html.Label("CSR:")
  164. </td>
  165. <td class="newticketInputs">
  166. @Html.TextBox("CSR", "", new { disabled = "true", placeholder = "Name of CSR" })
  167. @Html.HiddenFor(model => model.CsrEmpId)
  168. <br />
  169. @Html.ValidationMessageFor(model => model.CsrEmpId)
  170. </td>
  171. </tr>
  172. <tr>
  173. <td class="newticketHeading">
  174. @Html.Label("Assigned To:")
  175. </td>
  176. <td class="newticketInputs">
  177. @Html.DropDownListFor(model => model.AssignedTo, Util.TicketAssignees(), "Unassigned - Queue")
  178. </td>
  179. </tr>
  180. <tr>
  181. <td class="newticketHeading">
  182. @Html.Label("Ticket Status:")
  183. </td>
  184. <td class="newticketInputs">
  185. @Html.DropDownListFor(model => model.TicketStateId, (IEnumerable<SelectListItem>)ViewBag.TicketStates)
  186. <br />
  187. @Html.ValidationMessageFor(model => model.TicketStateId)
  188. </td>
  189. </tr>
  190. <tr>
  191. <td class="newticketHeading">@Html.Label("Ticket Attachements:")</td>
  192. <td class="newticketInputs">
  193. <div id="file-uploader" style="float: left; clear: both;">
  194. <noscript>
  195. <p>
  196. Please enable JavaScript to use file uploader.
  197. </p>
  198. <!-- or put a simple form for upload here -->
  199. </noscript>
  200. </div>
  201. <a id="viewAttachments" href="#ticketAttachments" role="button" style="float: left; margin-bottom: 15px; color: white; margin-left: 15px; text-decoration: none;" class="btn btn-danger" data-toggle="modal">View All</a>
  202. <div id="uploader1Preview" style="margin-top: 10px; width: 300px;">
  203. </div>
  204. </td>
  205. </tr>
  206. </tbody>
  207. </table>
  208. </div>
  209.  
  210. <div id="rightContainer">
  211. <table class="newTicketAdditional">
  212. <tbody>
  213. <tr>
  214. <td class="newticketHeadingAlt">
  215. @Html.Label("Description:")
  216. </td>
  217. <td class="newticketInputs">
  218. @Html.TextAreaFor(model => model.Description, new { placeholder = "Description of the problem...", @style = "height: 275px;" })
  219. <br />
  220. @Html.ValidationMessageFor(model => model.Description)
  221. </td>
  222. </tr>
  223. </tbody>
  224. </table>
  225. <h4>Notifications</h4>
  226. <p>Send email notifications to the below recipients on ticket creation, updates or changes. <span style="color: red;">NOTE: Notification of new tickets will automatically be sent to Support.</span></p>
  227. <table class="newTicketAdditional">
  228. <tbody>
  229. <tr>
  230. <td class="newticketHeadingAlt">
  231. @Html.Label("Recipients:")
  232. </td>
  233. <td class="newticketInputs">
  234. @Html.TextBoxFor(model => model.NotifyList, new { @class = "tags", value = "Email Address", style = "" })
  235.  
  236. <br />
  237. @Html.ValidationMessageFor(model => model.NotifyList)
  238. </td>
  239. </tr>
  240. </tbody>
  241. </table>
  242. <br />
  243. <div id="ccSales">
  244. <label class="checkbox">
  245. <input id="ccSalesmen" name="ccSalesmen" type="checkbox">
  246. Notify Salesmen? If so, which?
  247. </label>
  248. <br />
  249. @Html.DropDownList("salesmenDd", Util.SalesmenOfClient(Model.ClientId), "-- Select --")
  250. </div>
  251. </div>
  252. }
  253.  
  254.  
  255. <div class="clear"></div>
  256. <br />
  257. <div id="serviceDates">
  258. <h2>Scheduled Service Details</h2>
  259.  
  260. <div id="ajaxUpdateWrapper-services">
  261. </div>
  262. </div>
  263.  
  264. <div id="notesWrapper">
  265. <h2>Comments</h2>
  266. </div>
  267.  
  268. @using (Html.BeginForm(string.Empty, string.Empty, FormMethod.Post, new { id = "newServiceFrm" }))
  269. {
  270. <div style="display: none; width: 675px;" class="modal fade in" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  271. <div class="modal-header">
  272. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  273. <h3 id="myModalLabel">Schedule Service</h3>
  274. </div>
  275. <div class="modal-body">
  276. <table class="newTicketAdditional" style="width: auto;">
  277. <tbody>
  278. <tr>
  279. @Html.HiddenFor(model => model.TicketId)
  280. <td class="newticketHeadingAlt" style="width: 150px; text-align: left;">
  281. @Html.Label("Service Date:")
  282. </td>
  283. <td class="newticketInputs">
  284. @Html.TextBoxFor(model => model.TicketAppointment.InstallDate, new { @class = "datepicker required", style = "width: 250px;" })
  285. @Html.ValidationMessageFor(model => model.TicketAppointment.InstallDate)
  286. </td>
  287. </tr>
  288. <tr>
  289. <td class="newticketHeadingAlt" style="width: 150px; text-align: left;">
  290. @Html.Label("Company:")
  291. </td>
  292. <td class="newticketInputs">
  293. @Html.TextBoxFor(model => model.TicketAppointment.Installer, new { @style = "width: 250px;", @class = "required" })
  294. @Html.ValidationMessageFor(model => model.TicketAppointment.Installer)
  295. </td>
  296. </tr>
  297. <tr>
  298. <td class="newticketHeadingAlt" style="width: 150px; text-align: left;">
  299. @Html.Label("Installer Contact:")
  300. </td>
  301. <td class="newticketInputs">
  302. @Html.TextBoxFor(model => model.TicketAppointment.InstallerContactInfo, new { @style = "width: 450px;", @class = "required" })
  303. @Html.ValidationMessageFor(model => model.TicketAppointment.InstallerContactInfo)
  304. </td>
  305. </tr>
  306. <tr>
  307. <td class="newticketHeadingAlt" style="width: 150px; text-align: left;">
  308. @Html.Label("Notes:")
  309. </td>
  310. <td class="newticketInputs">
  311. @Html.TextAreaFor(model => model.TicketAppointment.InstallNotes, new { @style = "width: 450px;", @class = "required" })
  312. @Html.ValidationMessageFor(model => model.TicketAppointment.InstallNotes)
  313. </td>
  314. </tr>
  315. <tr id="inventoryWrapper">
  316. <td class="newticketHeadingAlt" style="width: 150px; text-align: left;">
  317. @Html.Label("Units Required:")
  318. <br />
  319. @Html.Label("Units Shipped:")
  320. </td>
  321. <td class="newticketInputs">
  322. @Html.TextBoxFor(model => model.TicketAppointment.UnitsRequired, new { @style = "width: 60px;", placeholder = "amount", @class = "required" })@Html.ValidationMessageFor(model => model.TicketAppointment.UnitsRequired)
  323. <br />
  324. @Html.TextBoxFor(model => model.TicketAppointment.UnitsShipped, new { @style = "width: 60px;", placeholder = "amount", @class = "required" })@Html.ValidationMessageFor(model => model.TicketAppointment.UnitsShipped)
  325. </td>
  326. </tr>
  327. </tbody>
  328. </table>
  329. </div>
  330. <div class="modal-footer">
  331. <input type="submit" id="newServiceDate" class="btn btn-primary" aria-hidden="true" value="Create" />
  332. <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Close</button>
  333. </div>
  334. </div>
  335. }
  336.  
  337. @using (Html.BeginForm(string.Empty, string.Empty, FormMethod.Post, new { id = "newAffectedLocationFrm" }))
  338. {
  339. <div style="display: none; width: 675px;" class="modal fade in" id="newAffected" tabindex="-1" role="dialog" aria-labelledby="myModalLabel3" aria-hidden="true">
  340. <div class="modal-header">
  341. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  342. <h3 id="myModalLabel3">Schedule Service</h3>
  343. </div>
  344. <div class="modal-body">
  345. <table class="newTicketAdditional" style="width: auto;">
  346. <tbody>
  347. <tr>
  348. @Html.HiddenFor(model => model.TicketId)
  349. <td class="newticketHeadingAlt" style="width: 150px; text-align: left;">
  350. @Html.Label("Location Name:")
  351. </td>
  352. <td class="newticketInputs">
  353. @Html.TextBoxFor(model => model.AffectedLocation.Name, new { @class = "LocationName1 required", style = "width: 250px;" })
  354. @Html.HiddenFor(model => model.AffectedLocation.LocationId)
  355. @Html.ValidationMessageFor(model => model.AffectedLocation.Name)
  356. </td>
  357. </tr>
  358. </tbody>
  359. </table>
  360. </div>
  361. <div class="modal-footer">
  362. <input type="submit" id="newAffectedSubmit" class="btn btn-primary" aria-hidden="true" value="Create" />
  363. <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Close</button>
  364. </div>
  365. </div>
  366.  
  367.  
  368.  
  369. <div style="display: none; width: 675px;" class="modal fade in" id="ticketAttachments" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  370. <div class="modal-header">
  371. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  372. <h3 id="myModalLabel1">Ticket Attachments</h3>
  373. </div>
  374. <div id="ticketAttachmentContainer" class="modal-body">
  375. @Html.Action("getticketattachments", "ticketing", new { id = @Model.TicketId })
  376. </div>
  377. <div class="modal-footer">
  378. <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Close</button>
  379. </div>
  380. </div>
  381.  
  382. @section Scripts
  383. {
  384.  
  385. @Scripts.Render("~/bundles/jqueryval")
  386. <script src="~/Scripts/moment.js"></script>
  387. <script type="text/javascript">
  388. $(document).ready(function() {
  389. // Client AutoComplete based on entered text.
  390. $("#ClientName").autocomplete({
  391. source: function(request, response) {
  392. $.ajax({
  393. url: "/AutoComplete/ClientName",
  394. type: "POST",
  395. dataType: "json",
  396. data: "{ 'data': '" + request.term + "' }",
  397. contentType: "application/json; charset=utf-8",
  398. success: function(data) {
  399. response($.map(data, function(item) {
  400.  
  401. return {
  402. value: item.ClientId,
  403. label: item.Name
  404. };
  405. }));
  406. }
  407. });
  408. },
  409. minLength: 3,
  410. delay: 5,
  411. select: function(event, ui) {
  412. displayItem("ClientId", "ClientName", ui.item);
  413. // Populate CSR for Client when a clientId is in our "ClientID" Hidden Field -
  414. // This implies that a company has been selected and would be valid for us to
  415. // grab CSR at this point. Will be a jQuery onChange event.
  416. $.ajax({
  417. url: "/AutoComplete/ClientsCSR",
  418. type: "GET",
  419. data: { clientId: ui.item.value },
  420. contentType: "application/json; charset=utf-8",
  421. success: function(data) {
  422. if (data != null) {
  423. $("#CSR").attr({ value: data[1] });
  424. $("#CsrEmpId").attr({ value: data[0] });
  425.  
  426. } else {
  427. alert('There is no CSR for this company!');
  428. }
  429. }
  430. });
  431. return false;
  432. }
  433. });
  434.  
  435. // When user focuses on location name we need to ensure that there is a
  436. // clientId to validate against so we can pull locations on that Id.
  437. $(".LocationName").focus(function() {
  438. if ($("#ClientId").val() == '') {
  439. alert('Please select a company!');
  440. $("#ClientName").focus();
  441. }
  442. });
  443.  
  444. // Setup autocomplete options for easy rebinding.
  445. var autocomp_opt = {
  446. source: function(request, response) {
  447. $.ajax({
  448. url: "/AutoComplete/ClientLocations",
  449. type: "POST",
  450. dataType: "json",
  451. data: "{ 'data': '" + request.term + "','clientId': '" + $("#ClientId").val() + "'}",
  452. contentType: "application/json; charset=utf-8",
  453. success: function(data) {
  454. response($.map(data, function(item) {
  455. return {
  456. value: item.LocationId,
  457. label: item.Name
  458. };
  459. }));
  460. }
  461. });
  462. },
  463. minLength: 1,
  464. delay: 5,
  465. select: function(event, ui) {
  466. var id = this.id;
  467.  
  468. displayItem("LocationId", id, ui.item);
  469.  
  470. return false;
  471. }
  472. };
  473.  
  474. // Autocomplete settings for our AffectedLocations.
  475. var autocomp_opt_alt = {
  476. source: function(request, response) {
  477. $.ajax({
  478. url: "/AutoComplete/ClientLocations",
  479. type: "POST",
  480. dataType: "json",
  481. data: "{ 'data': '" + request.term + "','clientId': '" + $("#ClientId").val() + "'}",
  482. contentType: "application/json; charset=utf-8",
  483. success: function(data) {
  484. response($.map(data, function(item) {
  485. return {
  486. value: item.LocationId,
  487. label: item.Name
  488. };
  489. }));
  490. }
  491. });
  492. },
  493. minLength: 1,
  494. delay: 5,
  495. select: function(event, ui) {
  496. //console.log(this.id);
  497. //console.log(ui);
  498.  
  499. var id = this.id;
  500.  
  501. displayItem("AffectedLocation_LocationId", id, ui.item);
  502.  
  503. return false;
  504. }
  505. };
  506. // Location AutoComplete based on ClientId.
  507. $(".LocationName").autocomplete(autocomp_opt);
  508. $(".LocationName1").autocomplete(autocomp_opt_alt);
  509.  
  510. //Function to write the entries into the text box
  511.  
  512. function displayItem(hidden, target, dataObject) {
  513. console.log($('#' + hidden.toString() + ''));
  514. if (target != "") {
  515. $("#" + target).attr({ value: dataObject.label });
  516. }
  517. if (hidden != null) {
  518. //console.log(hidden);
  519. $("#" + hidden).attr({ value: dataObject.value });
  520. }
  521. }
  522.  
  523. // Hardcoding a value of '0' to our default "Unassigned - Queue" option.
  524. $("#AssignedTo").find("option:contains('Unassigned - Queue')").attr('value', '0');
  525. $('#NotifyList').tagsInput({ width: 'auto' });
  526. $("#AssignedTo").change(function() {
  527. if ($(this).val() > 0) {
  528. $("#TicketStateId").val('2');
  529. } else {
  530. $("#TicketStateId").val('0');
  531. }
  532. });
  533.  
  534. // Using jQuery to redisplay the location name and client name in the autocomplete fields as these are not model binded to elements.
  535. if ($("#LocationId").val() > 0) {
  536. var location = "@ViewBag.Location";
  537. $("#LocationName").attr({ value: location });
  538. } else if ($("#LocationId").val() === "-1") {
  539. $("#LocationName").attr({ value: "All" });
  540. }
  541.  
  542. // Populate CSR Name from hidden input value.
  543. if ($("#CsrEmpId").val() > 0) {
  544. $("#CSR").attr({ value: "@ViewBag.Csr" });
  545. }
  546.  
  547. // Populate Priority of ticket.
  548. var priorityHidden = $("#Priority");
  549.  
  550. var currentPriority = priorityHidden.val();
  551. setTicketPriority(currentPriority);
  552.  
  553. // Autocheck "Send to Salesmen" when a salesmen is selected.
  554. $("#salesmenDd").change(function() {
  555. if ($("#salesmenDd option:selected").val() === "") {
  556. $("#ccSalesmen").removeAttr('checked');
  557. } else {
  558. $("#ccSalesmen").attr('checked', 'checked');
  559. }
  560. });
  561.  
  562. // Observe this form for changes as it will be posted to the server for modification
  563. // This Observe will change the class of any changed element and append "changed" to it.
  564. // This will then change the background of the box indicating a changed field for agents.
  565.  
  566. // Remvoved formObserve as our ticket Enviornment is updated on blur(focus out) of elements.
  567. // $('#modifyTicket').FormObserve();
  568.  
  569. $("#TicketTypeId").change(function() {
  570. if ($(this).val() == 1 || $(this).val() == 2 || $(this).val() == 3 || $(this).val() == 4 || $(this).val() == 5 || $(this).val() == 6 || $(this).val() == 7 || $(this).val() == 8) {
  571. $("#scheduleService").slideDown('slow');
  572. if ($(this).val() == 2 || $(this).val() == 6) {
  573. $("#inventoryWrapper").slideDown('slow');
  574. } else {
  575. $("#inventoryWrapper").slideUp('slow');
  576. }
  577. } else {
  578. $("#scheduleService").slideUp('slow');
  579. }
  580. });
  581.  
  582. // Display the Schedule Service feature as well as Inventory control for VXP
  583. // based on what the ticket type selected is.
  584. if ($("#TicketTypeId").val() == 1 || $("#TicketTypeId").val() == 2 || $("#TicketTypeId").val() == 3 || $("#TicketTypeId").val() == 4 || $("#TicketTypeId").val() == 5 || $("#TicketTypeId").val() == 6 || $("#TicketTypeId").val() == 7 || $("#TicketTypeId").val() == 8) {
  585. $("#scheduleService").slideDown('slow');
  586. if ($("#TicketTypeId").val() == 2 || $("#TicketTypeId").val() == 6) {
  587. $("#inventoryWrapper").slideDown('slow');
  588. } else {
  589. $("#inventoryWrapper").slideUp('slow');
  590. }
  591. } else {
  592. $("#scheduleService").slideUp('slow');
  593. }
  594.  
  595. // Initiallize datepicker
  596. $('.datepicker').datepicker({ dateFormat: "yy-mm-dd" });
  597.  
  598. //$("#formSubmit").click(function() {
  599. // $("#modifyTicket").FormObserve_save();
  600. //});
  601.  
  602. // Get all service dates and populate our ajaxWrapper-services
  603. $.ajax({
  604. url: "/ticketing/ticketservicedates",
  605. type: "GET",
  606. data: { ticketId: @Model.TicketId, cache: Math.random() },
  607. success: function(result) {
  608. $("#ajaxUpdateWrapper-services").html('');
  609. $("#ajaxUpdateWrapper-services").append(result);
  610. }
  611. });
  612.  
  613. // When user clicks create in 'Schedule Service (button)' -- Insert new record and then repopulate the data on the page.
  614. $('#newServiceFrm').submit(function(e) {
  615. e.preventDefault();
  616. var $form = $(this);
  617.  
  618. // check if the input is valid
  619. if (!$form.valid()) return false;
  620.  
  621. $.ajax({
  622. type: 'POST',
  623. url: "/ticketing/scheduleservice",
  624. data: $form.serialize(),
  625. success: function(response) {
  626. $.ajax({
  627. url: "/ticketing/ticketservicedates",
  628. type: "GET",
  629. data: { ticketId: @Model.TicketId, cache: Math.random() },
  630. success: function(result) {
  631. $("#ajaxUpdateWrapper-services").html('');
  632. $("#ajaxUpdateWrapper-services").append(result);
  633. }
  634. });
  635. $("#newServiceFrm :input[type=text]").val('');
  636. $("#TicketAppointment_InstallNotes").val('');
  637. }
  638. });
  639. });
  640. // Load up affected locations on DOM Ready.
  641. $.ajax({
  642. url: "/ticketing/GetAffectedLocations",
  643. type: "GET",
  644. data: { ticketId: @Model.TicketId, cache: Math.random() },
  645. success: function(result) {
  646. $("#affectedLocWrapper").html('');
  647. $("#affectedLocWrapper").append(result);
  648. }
  649. });
  650.  
  651. // When a new location is added via modal we will insert it and then refresh the div
  652. // that holds each location.
  653. $('#newAffectedLocationFrm').submit(function(e) {
  654. e.preventDefault();
  655. var $form = $(this);
  656.  
  657. // check if the input is valid
  658. if (!$form.valid()) return false;
  659.  
  660. $.ajax({
  661. type: 'POST',
  662. url: "/ticketing/NewAffectedLocation",
  663. data: $form.serialize(),
  664. success: function(response) {
  665. $.ajax({
  666. url: "/ticketing/GetAffectedLocations",
  667. type: "GET",
  668. data: { ticketId: @Model.TicketId, cache: Math.random() },
  669. success: function(result) {
  670. $("#affectedLocWrapper").html('');
  671. $("#affectedLocWrapper").append(result);
  672. }
  673. });
  674. $("#newServiceFrm :input[type=text]").val('');
  675. $("#TicketAppointment_InstallNotes").val('');
  676. }
  677. });
  678. });
  679.  
  680. // This will create autocomplete on our partial box for adding affected locations.
  681. $('.LocationName').live('keyup.autocomplete', function() {
  682. $(".LocationName").autocomplete(autocomp_opt);
  683. });
  684.  
  685. setInterval(function() {
  686. $.ajax({
  687. type: 'POST',
  688. url: "/ticketing/TicketUpdateTicks",
  689. data: { ticketId: @Model.TicketId },
  690. success: function(response) {
  691. console.log(response);
  692. var formattedEditDate = new Date(parseInt(response.LastUpdate.substring(6, response.LastUpdate.length - 2), 10));
  693. var momentTime = moment(formattedEditDate);
  694. var timeAgoFromCurrent = moment(momentTime, "YYYYMMDD").fromNow();
  695.  
  696. $("#updateDetails").html(
  697. '<strong>Last update by:</strong> ' + response.LastEditedBy + ' <strong>' + timeAgoFromCurrent + '</strong>');
  698. }
  699. });
  700. }, 3000);
  701.  
  702. // Going to use the jquery blur event to save the form on blur of an element.
  703. $("#modifyTicket").on("blur", "input, textarea, select", function () {
  704. var $form = $("#modifyTicket");
  705. $("#saving").fadeIn('fast');
  706. $.ajax({
  707. type: 'POST',
  708. url: "/ticketing/ModifyTicket",
  709. data: $form.serialize(),
  710. success: function(response) {
  711. //console.log(response);
  712. $("#saving").fadeOut('slow');
  713. $("#updateDetails").html('');
  714.  
  715. var formattedEditDate = new Date(parseInt(response.LastUpdate.substring(6, response.LastUpdate.length - 2), 10));
  716. var momentTime = moment(formattedEditDate);
  717. var timeAgoFromCurrent = moment(momentTime, "YYYYMMDD").fromNow();
  718.  
  719. $("#updateDetails").html(
  720. '<strong>Last update by:</strong> ' + response.LastEditedBy + ' <strong>' + timeAgoFromCurrent + '</strong>');
  721. }
  722. });
  723. });
  724. });
  725. </script>
  726.  
  727. }
  728.  
  729. <script src="~/Scripts/fileuploader.js"></script>
  730. @*// File uploader javascript *@
  731. <script type="text/javascript">
  732. function getUrl(action, controller) {
  733. var protocol = window.location.protocol;
  734. var host = window.location.host;
  735.  
  736. var url = (protocol + '//' + host + '/');
  737.  
  738. if ((controller != null && controller != 'undefined') && (action != null && action != 'undefined'))
  739. url += controller + '/' + action;
  740.  
  741. return url;
  742. }
  743.  
  744. function createUploader() {
  745. var uploader = new qq.FileUploader({
  746. element: document.getElementById('file-uploader'),
  747. allowedExtensions: ['png', 'jpeg', 'jpg', 'gif', 'bmp'], // File Type restrictions
  748. action: '@Url.Action("uploadattachment", "ticketing")',
  749. params: { ticketId: @Model.TicketId },
  750. debug: true,
  751. onComplete: function (id, fileName, responseJSON) {
  752. if (responseJSON.success == true) {
  753. $("span.qq-upload-failed-text").html("<span style='color: green'>Success!</span>");
  754.  
  755. $.ajax({
  756. url: "/ticketing/getticketattachments",
  757. type: "GET",
  758. data: { id: @Model.TicketId, cache: Math.random() },
  759. success: function (result) {
  760. $("#ticketAttachmentContainer").html('');
  761. $("#ticketAttachmentContainer").append(result);
  762. }
  763. });
  764. }
  765. else {
  766. $("span.qq-upload-failed-text").html("<span style='color: white'>Failed!</span>"); }
  767. // Get the preview container
  768. var $previewContainer = jQuery('#uploader1Preview');
  769. // Create the preview img element
  770. var $preview = jQuery('<img />');
  771.  
  772. // Hide the preview and set it's size
  773. $preview.css({ display: 'none', width: '90%', height: '200px' });
  774. // Make sure the preview's container is empty
  775. $previewContainer.html('');
  776. // Append the preview to the container
  777. $previewContainer.append($preview);
  778.  
  779. setInterval(function () {
  780. clearPreviewContainer();
  781. }, 2000);
  782.  
  783. function clearPreviewContainer()
  784. {
  785. $(".qq-upload-list").html('');
  786. }
  787.  
  788. }
  789. });
  790. }
  791.  
  792. // create uploader as soon as the DOM is ready
  793. window.onload = createUploader;
  794.  
  795. // Setting ticket priority level and changing background color to indicate current priority.
  796. function setTicketPriority(level) {
  797. var priorityHidden = $("#Priority");
  798.  
  799. priorityHidden.attr({ value: level });
  800.  
  801. var currentPriority = priorityHidden.val();
  802.  
  803. switch(currentPriority) {
  804. case "3":
  805. $("#highPriority").css("background-color", "rgba(223, 223 , 223, 0.9)").css('border-left', '5px solid red');
  806. $("#mediumPriority").css("background-color", "").css('border-left', '');
  807. $("#lowPriority").css("background-color", "").css('border-left', '');
  808. $("#noPriority").css("background-color", "").css('border-left', '');
  809. $("#priorityContainer").html('Priority: <span class="label label-important">High</span>');
  810. break;
  811. case "2":
  812. $("#mediumPriority").css("background-color", "rgba(223, 223 , 223, 0.9)").css('border-left', '5px solid orange');
  813. $("#highPriority").css("background-color", "").css('border-left', '');
  814. $("#lowPriority").css("background-color", "").css('border-left', '');
  815. $("#noPriority").css("background-color", "").css('border-left', '');
  816. $("#priorityContainer").html('Priority: <span class="label label-warning">Medium</span>');
  817. break;
  818. case "1":
  819. $("#lowPriority").css("background-color", "rgba(223, 223 , 223, 0.9)").css('border-left', '5px solid green');
  820. $("#highPriority").css("background-color", "").css('border-left', '');
  821. $("#mediumPriority").css("background-color", "").css('border-left', '');
  822. $("#noPriority").css("background-color", "").css('border-left', '');
  823. $("#priorityContainer").html('Priority: <span class="label label-success">Low</span>');
  824. break;
  825. case "0":
  826. $("#noPriority").css("background-color", "rgba(223, 223 , 223, 0.9)").css('border-left', '5px solid black');
  827. $("#highPriority").css("background-color", "").css('border-left', '');
  828. $("#mediumPriority").css("background-color", "").css('border-left', '');
  829. $("#lowPriority").css("background-color", "").css('border-left', '');
  830. $("#priorityContainer").html('Priority: <span class="label label-inverse">None</span>');
  831. break;
  832. }
  833. }
  834.  
  835.  
  836. </script>
  837. }
Add Comment
Please, Sign In to add comment