_CraftEmployeePartial.cshtml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. @{
  7. <text>
  8. function recalculateEmployeeValue_@id () {
  9. $.ajax({
  10. method: "POST",
  11. url: "@Url.Action("CalculateEmployeeValue", "Craft")",
  12. data: {
  13. EmployeeId: $("select[name='CraftEmployees[@id].EmployeeId']").val(),
  14. AmountText: $("input[name='CraftEmployees[@id].AmountText']").val()
  15. },
  16. success: function (data) {
  17. $("input[name='CraftEmployees[@id].Value']").val(data);
  18. calculateEmployeeAggregation();
  19. },
  20. error: function (msg) {
  21. }
  22. });
  23. }
  24. </text>
  25. }
  26. </script>
  27. <div class="row align-items-start">
  28. <input type="hidden" asp-for="Index" name="CraftEmployees[@id].Index" />
  29. <input type="hidden" asp-for="DictIdentifier" name="CraftEmployees[@id].DictIdentifier" value="@id" />
  30. <div class="form-group col-md-4">
  31. @if (Model == null || (Model != null && (!Model.Index.HasValue || Model.Index == 0)))
  32. {
  33. <label asp-for="EmployeeId" class="control-label"></label>
  34. }
  35. <select asp-items='(IEnumerable<SelectListItem>)ViewData["AvailableEmployees"]'
  36. asp-for="EmployeeId" name="CraftEmployees[@id].EmployeeId" class="form-control"
  37. onchange="calculateEmployeeAggregation(); recalculateEmployeeValue_@id ();">
  38. </select>
  39. @Html.ValidationMessage(String.Format("CraftEmployees[{0}].EmployeeId", id), new { @class = "text-danger" })
  40. </div>
  41. <div class="form-group col-md-2">
  42. @if (Model == null || (Model != null && (!Model.Index.HasValue || Model.Index == 0)))
  43. {
  44. <label asp-for="Amount" class="control-label"></label>
  45. }
  46. <div class="input-group">
  47. <div class="input-group-prepend">
  48. <span class="input-group-text">Std.</span>
  49. </div>
  50. @*<span class="input-group-prepend">
  51. <button type="button" class="quantity-left-minus btn btn-danger btn-number" data-field="">
  52. <span class="fas fa-minus"></span>
  53. </button>
  54. </span>*@
  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. @*<span class="input-group-append">
  60. <button type="button" class="quantity-left-minus btn btn-success btn-number" data-field="">
  61. <span class="fas fa-plus"></span>
  62. </button>
  63. </span>*@
  64. </div>
  65. @Html.ValidationMessage(String.Format("CraftEmployees[{0}].AmountText", id), new { @class = "text-danger" })
  66. </div>
  67. <div class="form-group col-md-2">
  68. @if (Model == null || (Model != null && (!Model.Index.HasValue || Model.Index == 0)))
  69. {
  70. <label asp-for="Value" class="control-label"></label>
  71. }
  72. <div class="input-group">
  73. <div class="input-group-prepend">
  74. <span class="input-group-text">@CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol</span>
  75. </div>
  76. <input asp-for="Value" name="CraftEmployees[@id].Value" type="number" min="0.00" class="form-control"
  77. data-aggregation="employeeValue"
  78. onchange="calculateEmployeeAggregation();" />
  79. </div>
  80. @Html.ValidationMessage(String.Format("CraftEmployees[{0}].Value", id), new { @class = "text-danger" })
  81. </div>
  82. <div class="form-group col-md-3">
  83. @if (Model == null || (Model != null && (!Model.Index.HasValue || Model.Index == 0)))
  84. {
  85. <label asp-for="Comment" class="control-label"></label>
  86. }
  87. <input asp-for="Comment" name="CraftEmployees[@id].Comment" class="form-control" />
  88. @Html.ValidationMessage(String.Format("CraftEmployees[{0}].Comment", id), new { @class = "text-danger" })
  89. </div>
  90. <div class="form-group col-md-1 pl-1">
  91. @if (Model != null && Model.Index > 0)
  92. {
  93. <button type="button" class="btn btn-danger" aria-label="Entfernen"
  94. onclick="$(this).closest('.row').remove(); calculateEmployeeAggregation();">
  95. <span class="fas fa-trash"></span>
  96. </button>
  97. }
  98. </div>
  99. </div>