_CraftEmployeePartial.cshtml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. Amount: $("input[name='CraftEmployees[@id].Amount']").val().replace('.', ',')
  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. <input name="CraftEmployees[@id].Amount" type="number" min="0.00" step="0.50" class="form-control"
  51. id="CraftEmployees[@id].Amount" data-aggregation="employeeAmount"
  52. value="@(Model == null ? "0,00" : Model.Amount.ToString("G29"))"
  53. onchange="calculateEmployeeAggregation(); recalculateEmployeeValue_@id ();" />
  54. </div>
  55. @Html.ValidationMessage(String.Format("CraftEmployees[{0}].Amount", id), new { @class = "text-danger" })
  56. </div>
  57. <div class="form-group col-md-2">
  58. @if (Model == null || (Model != null && (!Model.Index.HasValue || Model.Index == 0)))
  59. {
  60. <label asp-for="Value" class="control-label"></label>
  61. }
  62. <div class="input-group">
  63. <div class="input-group-prepend">
  64. <span class="input-group-text">€</span>
  65. </div>
  66. <input asp-for="Value" name="CraftEmployees[@id].Value" type="number" min="0.00" class="form-control"
  67. data-aggregation="employeeValue"
  68. onchange="calculateEmployeeAggregation();" />
  69. </div>
  70. @Html.ValidationMessage(String.Format("CraftEmployees[{0}].Value", id), new { @class = "text-danger" })
  71. </div>
  72. <div class="form-group col-md-3">
  73. @if (Model == null || (Model != null && (!Model.Index.HasValue || Model.Index == 0)))
  74. {
  75. <label asp-for="Comment" class="control-label"></label>
  76. }
  77. <input asp-for="Comment" name="CraftEmployees[@id].Comment" class="form-control" />
  78. @Html.ValidationMessage(String.Format("CraftEmployees[{0}].Comment", id), new { @class = "text-danger" })
  79. </div>
  80. <div class="form-group col-md-1 pl-1">
  81. @if (Model != null && Model.Index > 0)
  82. {
  83. <button type="button" class="btn btn-danger" aria-label="Entfernen"
  84. onclick="$(this).closest('.row').remove(); calculateEmployeeAggregation();">
  85. <span class="fas fa-trash"></span>
  86. </button>
  87. }
  88. </div>
  89. </div>