Advertisement
Guest User

Untitled

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