_CraftEmployeePartial.cshtml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. @model GreenTree.Strohrmann.ERP.Web.Models.Business.CraftEmployeeModel
  2. @{
  3. var id = Model != null && !String.IsNullOrEmpty(Model.DictIdentifier) ? Model.DictIdentifier : Html.RandomId();
  4. }
  5. <script type="text/javascript">
  6. $(document).ready(function () {
  7. setTimeout(function () {
  8. $("input").restrictInput();
  9. }, 500);
  10. });
  11. @{
  12. <text>
  13. function recalculateEmployeeValue_@id () {
  14. $.ajax({
  15. method: "POST",
  16. url: "@Url.Action("CalculateEmployeeValue", "Craft")",
  17. data: {
  18. EmployeeId: $("select[name='CraftEmployees[@id].EmployeeId']").val(),
  19. AmountText: $("input[name='CraftEmployees[@id].AmountText']").val()
  20. },
  21. success: function (data) {
  22. $("input[name='CraftEmployees[@id].Value']").val(data);
  23. calculateEmployeeAggregation();
  24. },
  25. error: function (msg) {
  26. }
  27. });
  28. }
  29. </text>
  30. }
  31. </script>
  32. <div class="row align-items-start">
  33. <input type="hidden" asp-for="Index" name="CraftEmployees[@id].Index" />
  34. <input type="hidden" asp-for="DictIdentifier" name="CraftEmployees[@id].DictIdentifier" value="@id" />
  35. <div class="form-group col-md-4">
  36. @if (Model == null || (Model != null && (!Model.Index.HasValue || Model.Index == 0)))
  37. {
  38. <label asp-for="EmployeeId" class="control-label"></label>
  39. }
  40. <select asp-items='(IEnumerable<SelectListItem>)ViewData["AvailableEmployees"]'
  41. asp-for="EmployeeId" name="CraftEmployees[@id].EmployeeId" class="form-control"
  42. onchange="calculateEmployeeAggregation(); recalculateEmployeeValue_@id ();">
  43. </select>
  44. @Html.ValidationMessage(String.Format("CraftEmployees[{0}].EmployeeId", id), new { @class = "text-danger" })
  45. </div>
  46. <div class="form-group col-md-2">
  47. @if (Model == null || (Model != null && (!Model.Index.HasValue || Model.Index == 0)))
  48. {
  49. <label asp-for="Amount" class="control-label"></label>
  50. }
  51. <div class="input-group">
  52. <div class="input-group-prepend">
  53. <span class="input-group-text">Std.</span>
  54. </div>
  55. <input name="CraftEmployees[@id].AmountText" type="text" class="form-control"
  56. id="CraftEmployees[@id].AmountText" data-aggregation="employeeAmount" data-restriction="numberOnly"
  57. value="@(Model == null ? 0.00f : Model.Amount)"
  58. onchange="calculateEmployeeAggregation(); recalculateEmployeeValue_@id ();" />
  59. </div>
  60. @Html.ValidationMessage(String.Format("CraftEmployees[{0}].AmountText", id), new { @class = "text-danger" })
  61. </div>
  62. <div class="form-group col-md-2">
  63. @if (Model == null || (Model != null && (!Model.Index.HasValue || Model.Index == 0)))
  64. {
  65. <label asp-for="Value" class="control-label"></label>
  66. }
  67. <div class="input-group">
  68. <div class="input-group-prepend">
  69. <span class="input-group-text">€</span>
  70. </div>
  71. <input asp-for="Value" name="CraftEmployees[@id].Value" type="number" min="0.00" class="form-control"
  72. data-aggregation="employeeValue"
  73. onchange="calculateEmployeeAggregation();" />
  74. </div>
  75. @Html.ValidationMessage(String.Format("CraftEmployees[{0}].Value", id), new { @class = "text-danger" })
  76. </div>
  77. <div class="form-group col-md-3">
  78. @if (Model == null || (Model != null && (!Model.Index.HasValue || Model.Index == 0)))
  79. {
  80. <label asp-for="Comment" class="control-label"></label>
  81. }
  82. <input asp-for="Comment" name="CraftEmployees[@id].Comment" class="form-control" />
  83. @Html.ValidationMessage(String.Format("CraftEmployees[{0}].Comment", id), new { @class = "text-danger" })
  84. </div>
  85. <div class="form-group col-md-1 pl-1">
  86. @if (Model != null && Model.Index > 0)
  87. {
  88. <button type="button" class="btn btn-danger" aria-label="Entfernen"
  89. onclick="$(this).closest('.row').remove(); calculateEmployeeAggregation();">
  90. <span class="fas fa-trash"></span>
  91. </button>
  92. }
  93. </div>
  94. </div>