Advertisement
Guest User

Untitled

a guest
Aug 21st, 2015
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.93 KB | None | 0 0
  1. @using Keoghs.Tracker
  2. @using Keoghs.Tracker.Data.Domain.ReferenceValues
  3. @using Keoghs.Tracker.Web.Controls
  4. @using Keoghs.Tracker.Web.UI.Extensions
  5. @model Keoghs.Tracker.Web.UI.Controllers.Instruction.InstructionViewModel
  6. @{ var chrome = new HtmlModalChromeParams()
  7. .WithTitle("ADD / MAINTAIN INSTRUCTION")
  8. .WithButton("Cancel", "button-cancel", "red")
  9. .WithButton("OK", "button-ok", "green")
  10. .WithOuterChromeCss("small");
  11. }
  12.  
  13. @using (Html.ModalChrome(chrome))
  14. {
  15.  
  16. using (Html.BeginForm("AddMaintainInstruction", "Instruction", FormMethod.Post, new { id = "addMaintainInstructionForm" }))
  17. {
  18.  
  19. @Html.HiddenFor(model => model.MatterId)
  20. @Html.HiddenFor(model => model.IsEdit)
  21. @Html.HiddenFor(model => model.SystemSuggestedPriority)
  22. @Html.HiddenFor(model => model.MatterRef)
  23. @Html.HiddenFor(model => model.DuplicateSearchId)
  24. if (!Model.FileMigrationReasonId.HasValue)
  25. {
  26. @Html.HiddenFor(model => model.FileMigrationReasonId)
  27. @Html.HiddenFor(model => model.OtherReason)
  28. }
  29. <div class="grid">
  30. @Html.ValidationSummary(true)
  31. @Html.Toasts("toaster")
  32. <div class="row">
  33. <div class="span3">
  34. @Html.Label("Instructing Client", new { @class = "form-required" })
  35. </div>
  36. <div class="span6">
  37. @Html.TextBoxFor(model => model.ClientName, "")
  38. <br />
  39. @Html.ValidationMessageFor(model => model.ClientName)
  40. @Html.HiddenFor(model => model.ClientAndBrandIds)
  41. </div>
  42. </div>
  43.  
  44. <div class="row">
  45. <div class="span3">
  46. @Html.LabelFor(model => model.Division, new { @class = "form-required" })
  47. </div>
  48. <div class="span6">
  49. @Html.RadioButtonFor(model => model.Division, 1)CFS
  50. @Html.RadioButtonFor(model => model.Division, 2)CMS
  51. @Html.RadioButtonFor(model => model.Division, 3)TCS
  52. @Html.ValidationMessageFor(model => model.Division)
  53. </div>
  54. </div>
  55.  
  56. <div class="row">
  57. <div class="span3">
  58. @Html.LabelFor(model => model.ProductNameId, new { @class = "form-required" })
  59. <img src="../../Scripts/styles/images/icons/info_transparent_icon.png" title="Only select if the matter belongs to a specific product which attracts a different fee to other areas of work. This field is used to identify the appropriate Client Number to assign the record in Elite." class="information right" />
  60. </div>
  61. <div class="span6 fill-control">
  62. @Html.DropDownListFor(model => model.ProductNameId, Model.ProductNameList, @Settings.Mvc.DropDownDefaultSelectPrompt)
  63. @Html.ValidationMessageFor(model => model.ProductNameId)
  64. </div>
  65. </div>
  66.  
  67. <div class="row">
  68. @* <div class="span3">
  69. @Html.Label("Work Types", new { @class = "form-required" })
  70. <img src="../../Scripts/styles/images/icons/info_transparent_icon.png" title="These fields are used to identify the charging rate to apply to the record in Elite. In some cases, it is also used to identify the Client Number to assign the record in Elite." class="information right" />
  71. </div>*@
  72. <div class="span9">
  73. @Html.HiddenFor(model => model.WorkTypeId)
  74. @Html.PartialFor(model => model.WorkTypeViewModel, "TreeDataMenu")
  75. @Html.ValidationMessageFor(model => model.WorkTypeId)
  76. </div>
  77. </div>
  78.  
  79. <div class="row">
  80. <div class="span3">
  81. @Html.LabelFor(model => model.IsDelegatedAuthority, new { @class = "form-required" })
  82. <img src="../../Scripts/styles/images/icons/info_transparent_icon.png" title="This field is used to assign the appropriate charging rate in Elite." class="information right" />
  83. </div>
  84. <div class="span6">
  85. @Html.RadioButtonFor(model => model.IsDelegatedAuthority, true)DA
  86. @Html.RadioButtonFor(model => model.IsDelegatedAuthority, false)NDA
  87. @Html.ValidationMessageFor(model => model.IsDelegatedAuthority)
  88. </div>
  89. </div>
  90.  
  91. <div class="row">
  92. <div class="span3">
  93. @Html.LabelFor(model => model.EstimatedValue)
  94. </div>
  95. <div class="span6">
  96. @Html.DropDownListFor(model => model.EstimatedValue, Model.EstimatedValuesList, @Settings.Mvc.DropDownDefaultSelectPrompt)
  97. </div>
  98. </div>
  99.  
  100. <div class="row">
  101.  
  102. <div class="span3">
  103. <div style="height: 25px">@Html.LabelFor(model => model.InstructionReceivedDateTime, new { @class = "form-required" })</div>
  104. @Html.Label("Time", new { @class = "form-required" })
  105. </div>
  106. <div class="span6">
  107. @Html.HiddenFor(model => model.InstructionReceivedDateTime)
  108. @Html.ValidationMessageFor(model => model.InstructionReceivedDateTime)
  109. </div>
  110. </div>
  111.  
  112. <div class="row">
  113. <div class="span3">
  114. @Html.Label("Client File Received same as Instruction Received?")
  115. </div>
  116. <div class="span6">
  117. @Html.CheckBoxFor(model => model.ClientFileReceivedIsEqualInstructionReceived, new { @class = "chkBox" })
  118. </div>
  119. </div>
  120.  
  121. <div class="row">
  122. <div class="span3">
  123. <div style="height: 25px">@Html.LabelFor(model => model.ClientFileReceivedDateTime)</div>
  124. @Html.Label("Time")
  125. </div>
  126. <div class="span6">
  127. @Html.HiddenFor(model => model.ClientFileReceivedDateTime)
  128. @Html.ValidationMessageFor(model => model.ClientFileReceivedDateTime)
  129. </div>
  130. </div>
  131.  
  132.  
  133. <div class="row">
  134. <div class="span3">
  135. @Html.LabelFor(model => model.WasNomination)
  136. </div>
  137. <div class="span6">
  138. @Html.CheckBoxFor(model => model.WasNomination)
  139. </div>
  140. </div>
  141.  
  142. <div class="row">
  143. <div class="span3">
  144. @Html.LabelFor(model => model.CriticalDate)
  145. </div>
  146. <div class="span6">
  147. @Html.HiddenFor(model => model.CriticalDate)
  148. <br />
  149. @Html.ValidationMessageFor(model => model.CriticalDate)
  150. </div>
  151. </div>
  152. <div class="row priority-logic">
  153. <div class="span3">
  154. @Html.LabelFor(model => model.Priority)
  155. </div>
  156. <div class="span6">
  157. @Html.RadioButtonFor(model => model.Priority, InstructionPriorities.High)High
  158. @Html.RadioButtonFor(model => model.Priority, InstructionPriorities.Medium)Medium
  159. @Html.RadioButtonFor(model => model.Priority, InstructionPriorities.Standard)Standard
  160. <div id="priorityUserOverride"><i class="x-small icon-magenta-alert cursor_auto"></i>User Override</div>
  161. </div>
  162.  
  163. </div>
  164.  
  165.  
  166.  
  167.  
  168. @if (Model.FileMigrationReasonId.HasValue)
  169. {
  170. <div class="row">
  171. <div class="span3">
  172. @Html.Label("Migration Reason", new { @class = "form-required" })
  173. </div>
  174. <div class="span6">
  175. @Html.DropDownListFor(model => Model.FileMigrationReasonId, Model.MigrationReasons)
  176. @Html.ValidationMessageFor(model => Model.FileMigrationReasonId)
  177. </div>
  178. </div>
  179. <div class="row" id="divOtherReason">
  180. <div class="span3">
  181. @Html.Label("Other Reason", new { @class = "form-required" })
  182. </div>
  183. <div class="span6">
  184. @Html.TextBoxFor(model => Model.OtherReason, new { @class = "dirtyTrackable" })
  185. @Html.ValidationMessageFor(model => Model.OtherReason)
  186. </div>
  187. </div>
  188. }
  189. </div>
  190. }
  191. }
  192.  
  193. <script type="text/javascript" src="~/Scripts/models/matter.js"></script>
  194. <script type="text/javascript">
  195. $(document).ready(function () {
  196. //attachStandardFormEvents();
  197. document.isDirty = false;
  198.  
  199. // Hook up toast container
  200. $("#toaster").toast();
  201.  
  202. setInstructionControls($("#FileMigrationReasonId").val());
  203.  
  204. $("#FileMigrationReasonId").change(function () {
  205. var value = $("#FileMigrationReasonId").val();
  206. setInstructionControls(value);
  207. });
  208.  
  209. $("SELECT, INPUT").change(function () {
  210. document.isDirty = true;
  211. });
  212.  
  213. if ('@Model.IsEdit' == 'True') {
  214. $('input[name=Division]').attr("disabled", true);
  215. $("#ClientName").attr("readonly", true);
  216. }
  217.  
  218. $("input[name='Division']:radio").change(function() {
  219.  
  220. var divId = $("input[name='Division']:checked").val();
  221.  
  222. clearWorkTypeDropDownLists();
  223.  
  224. if (divId == '@Divisions.CFS' || divId == '@Divisions.CMS' || divId == '@Divisions.TCS') {
  225.  
  226. var formData = { divisionId: divId };
  227. ajax.getResponse("/api/ProductNames/GetProductNames", formData, function(list) {
  228. var listItems = "";
  229.  
  230. for (var i = 0; i < list.length; i++) {
  231. listItems += "<option value='" + list[i].Value + "' selected='" + list[i].Selected + "'>" + list[i].Text + "</option>";
  232. }
  233.  
  234. $("#ProductNameId").html(listItems);
  235.  
  236. $("#ProductNameId").prepend("<option value=''>Select...</option>");
  237.  
  238. if (list.length > 1)
  239. $("#ProductNameId").val('');
  240.  
  241. });
  242. } else {
  243. $("#ProductNameId").empty();
  244. $("#ProductNameId").prepend("<option value=''>Select...</option>");
  245. }
  246. });
  247.  
  248. $("#button-cancel").click(function (e) {
  249. if (document.isDirty) {
  250. $("#toaster").toastConfirm('@Settings.Mvc.ToastConfirmation',
  251. ["No", "Yes"],
  252. function (result) {
  253. if (result == "No") {
  254. return;
  255. }
  256. if (result == "Yes") {
  257. document.isDirty = false;
  258. e.preventDefault();
  259. e.stopPropagation();
  260. xdomain.hostMessage({ type: "xdomain.closeModal" });
  261. }
  262. ;
  263. });
  264. } else {
  265. e.preventDefault();
  266. e.stopPropagation();
  267. xdomain.hostMessage({ type: "xdomain.closeModal" });
  268. }
  269. });
  270.  
  271. $("#ClientName").watermark("Search Client");
  272. if ($.browser.mozilla) {
  273.  
  274. $('#InstructionReceivedDateTime').dateandtime({ includeTime: true, watermark: "DD / MM / YYYY", dateAttributes: "class='priorityChecker'", timeAttributes: "class='priorityChecker'" });
  275. $('#ClientFileReceivedDateTime').dateandtime({ includeTime: true, watermark: "DD / MM / YYYY", dateAttributes: "class='dateDirty'", timeAttributes: "class='dateDirty'" });
  276. $('#CriticalDate').dateandtime({ includeTime: false, watermark: "DD / MM / YYYY", dateAttributes: "class='priorityChecker'", timeAttributes: "Class='priorityChecker'" });
  277. }
  278. $("#ClientName").autocomplete({ minChars: 2, url: "/api/ClientAutoComplete/Search", hiddenFieldId: "ClientAndBrandIds" });
  279.  
  280. $("#ClientName").blur(function () {
  281. var defaults = {
  282. minChars: 3,
  283. url: '',
  284. hiddenFieldId: ''
  285. };
  286.  
  287. var settings = $.extend(defaults, { minChars: 2, url: "/api/ClientAutoComplete/Search", hiddenFieldId: "ClientAndBrandIds" });
  288.  
  289. var searchText;
  290. if ($("#ClientName").val().indexOf('-') != -1) {
  291. searchText = $("#ClientName").val().split('-')[1].trim() != '' ? $("#ClientName").val().split('-')[1].trim() : $("#ClientName").val().split('-')[0].trim();
  292. }
  293. else {
  294. searchText = $("#ClientName").val().trim();
  295. }
  296. $.get("/api/ClientAutoComplete/Search", { searchData: searchText }, function (data) {
  297. var item = data[0];
  298. $("input[id='" + settings.hiddenFieldId + "']").val(item.Id);
  299. $("#ClientName").val(item.SelectedDisplayString);
  300. $("input#selectedClientId").val(item.Id).trigger('change');
  301. });
  302. });
  303.  
  304. $("#ClientName").bind('keyup change', function () {
  305.  
  306. if ($(this).val() == '' || $(this).val() == null) {
  307. $("input#selectedClientId").val('').trigger('change');
  308. }
  309. });
  310.  
  311. $('#ClientFileReceivedIsEqualInstructionReceived').change(function () {
  312.  
  313. if (this.checked) {
  314. var time = $("#@Html.IdFor(m => m.InstructionReceivedDateTime)TimeInput").val();
  315. $("#@Html.IdFor(m => m.ClientFileReceivedDateTime)TimeInput").removeClass('watermark').val(time);
  316.  
  317. var date = $("#@Html.IdFor(m => m.InstructionReceivedDateTime)DateInput").val();
  318. $("#@Html.IdFor(m => m.ClientFileReceivedDateTime)DateInput").removeClass('watermark').val(date).trigger('change');
  319. } else {
  320. $("#@Html.IdFor(m => m.ClientFileReceivedDateTime)DateInput").val("").trigger('change');
  321. $("#@Html.IdFor(m => m.ClientFileReceivedDateTime)TimeInput").val("").trigger('change');
  322. }
  323. });
  324.  
  325.  
  326. $('#ProductNameId').change(function () {
  327. // The following method is in the WorkType component
  328. workTypeProductChangeTrigger($("#ProductNameId").val());
  329.  
  330. var productName = $("#@Html.IdFor(m => m.ProductNameId)").val();
  331.  
  332. if (productName != "") {
  333. GetproductDefaults(productName);
  334. } else {
  335. $("#@Html.IdFor(m => m.EstimatedValue)").val("Select...");
  336.  
  337. var newIsDelegatedAuthority = $("#@Html.IdFor(m => m.IsDelegatedAuthority)").val();
  338. $("input:radio[name='IsDelegatedAuthority'][value='" + newIsDelegatedAuthority + "']").prop('checked', false);
  339. }
  340. });
  341.  
  342. $("#button-ok").click(function () {
  343. $("input.watermark").val('');
  344. consolidateWorkTypeId();
  345. $("#addMaintainInstructionForm").submit();
  346. });
  347.  
  348. $(".dateDirty").change(function (event) {
  349. document.isDirty = true;
  350. });
  351.  
  352. $(".priorityChecker").change(function (event) {
  353. document.isDirty = true;
  354. setPriority();
  355. });
  356.  
  357. setPriorityOverideLabel($("input:radio[name='Priority']:checked").val());
  358.  
  359. $("#menuButton").click(function () {
  360. document.isDirty = true;
  361. });
  362.  
  363. $('#ClientFileReceivedDateTimeDateInput').change(function () {
  364. var timeLabel = $('label[for="Time2"]');
  365.  
  366. if ($(this).val() != '') {
  367. timeLabel.addClass("form-required");
  368. }
  369. else
  370. timeLabel.removeClass("form-required");
  371. });
  372. });
  373.  
  374.  
  375.  
  376. function GetproductDefaults(prodNameId) {
  377. $.get("/api/ProductNames/GetProductNameValues", { productNameId: prodNameId }, function (result) {
  378.  
  379. $("#@Html.IdFor(m => m.IsDelegatedAuthority)").val(result.DefaultIsAuthority);
  380. $("input:radio[name='IsDelegatedAuthority'][value='" + result.DefaultIsAuthority + "']").prop('checked', true);
  381. $("#@Html.IdFor(m => m.EstimatedValue)").val(result.DefaultEstimatedValue);
  382.  
  383. resolveDelegatedAuthority(result.DefaultIsAuthority);
  384.  
  385. $("#@Html.IdFor(m => m.WorkTypeId)").val(result.DefaultWorkTypeId);
  386. });
  387. }
  388.  
  389. function resolveDelegatedAuthority(val) {
  390. var authority = null;
  391.  
  392. if (val === true || val === 'True') {
  393. authority = true;
  394. $("input:radio[name='IsDelegatedAuthority']")[0].checked = true;
  395. $("input:radio[name='IsDelegatedAuthority']")[1].checked = false;
  396. }
  397. else if (val === false || val === 'False') {
  398. authority = false;
  399. $("input:radio[name='IsDelegatedAuthority']")[0].checked = false;
  400. $("input:radio[name='IsDelegatedAuthority']")[1].checked = true;
  401. } else {
  402. $("input:radio[name='IsDelegatedAuthority']")[0].checked = false;
  403. $("input:radio[name='IsDelegatedAuthority']")[1].checked = f;alse;
  404. }
  405. $("input:radio[name='IsDelegatedAuthority']").val(authority);
  406. }
  407.  
  408. $("input:radio[name='IsDelegatedAuthority']").click(function () {
  409. var authority = null;
  410. if ($("input:radio[name='IsDelegatedAuthority']")[0].checked) {
  411. authority = true;
  412. $("input:radio[name='IsDelegatedAuthority']")[1].checked = false;
  413. }
  414. if ($('input[name=IsDelegatedAuthority]')[1].checked) {
  415. authority = false;
  416. $("input:radio[name='IsDelegatedAuthority']")[0].checked = false;
  417. }
  418.  
  419. $("input:radio[name='IsDelegatedAuthority']").val(authority);
  420. });
  421.  
  422.  
  423. function setInstructionControls(value) {
  424.  
  425. if (value == '@FileMigrationReasons.Other') {
  426. $("#divOtherReason").removeClass('hidden');
  427. } else {
  428. $("#divOtherReason").addClass('hidden');
  429. }
  430. }
  431.  
  432. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement