templates/workhour/pay.html.twig line 1

Open in your IDE?
  1. {% extends '@!EasyAdmin/page/content.html.twig' %}
  2. {% block page_content %}
  3. <div>
  4. <h2>{{worker}}</h2>
  5. <form method="post">
  6. <table class="table">
  7. {% set sum=0 %}
  8. {% set sumOther=0 %}
  9. <tr>
  10. <th>Kifizet</th>
  11. <th>Projekt</th>
  12. <th>Idő</th>
  13. <th>Egyéb költség</th>
  14. <th>Összesen</th>
  15. <th>Nap</th>
  16. <th>Létrehozva</th>
  17. </tr>
  18. {% for hour in hours %}
  19. <tr id="row-{{hour.id}}">
  20. {% if hour.isValidated %}
  21. <td><input type="checkbox" value="{{hour.id}}" checked="" name="workhours[]" class="hour-checkbox" onClick="check()"></td>
  22. {% else %}
  23. <td><input type="checkbox" value="{{hour.id}}" name="workhours[]" class="hour-checkbox" onClick="check()"></td>
  24. {% endif %}
  25. {% if hour.project %}
  26. {% if hour.project.customer %}
  27. <td>({{hour.project.customer.name}}) {{hour.project.name}} - {{hour.note|raw}}</td>
  28. {% else %}
  29. <td>{{hour.project.name}} - {{hour.note|raw}}</td>
  30. {% endif %}
  31. {% else %}
  32. <td>{{hour.note|raw}}</td>
  33. {% endif %}
  34. <td id="hour-{{hour.id}}">{{hour.hours}}</td>
  35. <td id="other-{{hour.id}}">{{hour.otherPrice}}</td>
  36. <td id="sum-{{hour.id}}">{{(hour.hours*worker.priceHour)+hour.otherPrice}}</td>
  37. <td>{{hour.day?hour.day.format('Y-m-d'):'-'}}</td>
  38. <td>{{hour.created.format('Y-m-d')}}</td>
  39. {% if hour.isValidated %}
  40. {% set sum = sum + hour.hours %}
  41. {% set sumOther = sumOther + (hour.otherPrice?hour.otherPrice:0) %}
  42. {% endif %}
  43. </tr>
  44. {% endfor %}
  45. <tfoot style="background-color: #fafafafa">
  46. <tr>
  47. <td colspan="2"><strong>Összesen</strong></td>
  48. <td id="sumHours" >{{sum}}</td>
  49. <td id="sumHours" >{{sum}}</td>
  50. <td></td>
  51. </tr>
  52. <tr>
  53. <td colspan="2"><strong>Órabér</strong></td>
  54. <td>{{worker.priceHour|format_currency('HUF',{fraction_digit: 0}, locale='hu')}}</td>
  55. <td><input type="number" name="priceHour" id="priceHour" value="{{worker.priceHour}}"></td>
  56. <td><input type="number" name="priceHour" id="priceHour" value="{{worker.priceHour}}"></td>
  57. </tr>
  58. <tr>
  59. <td colspan="2"><strong>Fizetendő óra</strong></td>
  60. <td id="sumHoursPrice">{{(sum*worker.priceHour)|format_currency('HUF',{fraction_digit: 0}, locale='hu')}}</td>
  61. <td colspan="2"><strong>Fizetendő óra</strong></td>
  62. <td id="sumHoursPrice">{{(sum*worker.priceHour)|format_currency('HUF',{fraction_digit: 0}, locale='hu')}}</td>
  63. <td></td>
  64. </tr>
  65. <tr>
  66. <td colspan="2"><strong>Egyéb költség</strong></td>
  67. <td id="sumOther">{{sumOther|format_currency('HUF',{fraction_digit: 0}, locale='hu')}}</td>
  68. <td id="sumOther">{{sumOther|format_currency('HUF',{fraction_digit: 0}, locale='hu')}}</td>
  69. <td></td>
  70. </tr>
  71. <tr>
  72. <td colspan="2"><strong>Teljes fizetendő összeg</strong></td>
  73. <td><strong id="sumTotalStrong">{{((sum*worker.priceHour)+sumOther)|format_currency('HUF',{fraction_digit: 0}, locale='hu')}}</strong></td>
  74. <td><input type="hidden" name="sumTotal" id="sumTotal" value="{{(sum*worker.priceHour)+sumOther}}"></td>
  75. </tr>
  76. </tfoot>
  77. </table>
  78. <input type="submit" name="submit" value="Fizetés" class="btn btn-info">
  79. </form>
  80. <script type="text/javascript">
  81. function check(){
  82. $('#sumTotal').val(0);
  83. var total = 0;
  84. var sumHours = 0;
  85. var sumHoursPrice = 0;
  86. var sumOther = 0;
  87. var priceHour = parseInt($('#priceHour').val())
  88. $('.hour-checkbox:checked').each(function(key,chk){
  89. var price = parseInt($('#sum-'+chk.value).html())
  90. var other = parseInt($('#other-'+chk.value).html())
  91. var hour = parseFloat($('#hour-'+chk.value).html())
  92. total = total + price;
  93. if(other > 0){
  94. sumOther = sumOther + other;
  95. }
  96. sumHours = sumHours + hour;
  97. sumHoursPrice = sumHoursPrice + (hour*priceHour);
  98. $('#sumTotalStrong').html(total);
  99. $('#sumOther').html(sumOther);
  100. $('#sumHours').html(sumHours);
  101. $('#sumHoursPrice').html(sumHoursPrice);
  102. })
  103. }
  104. </script>
  105. <script type="text/javascript">
  106. function check(){
  107. var sumTotal = document.getElementById('sumTotal')
  108. sumTotal.value = 0;
  109. var total = 0;
  110. var sumHours = 0;
  111. var sumHoursPrice = 0;
  112. var sumOther = 0;
  113. var priceHour = document.getElementById('priceHour')
  114. var priceHour = parseInt(priceHour.value)
  115. var checked = document.querySelectorAll('.hour-checkbox:checked')
  116. checked.forEach(function(chk, key){
  117. console.log(key, chk, chk.value)
  118. var price = parseInt(document.getElementById('sum-'+chk.value).innerHTML)
  119. var other = parseInt(document.getElementById('other-'+chk.value).innerHTML)
  120. var hour = parseFloat(document.getElementById('hour-'+chk.value).innerHTML)
  121. total = total + price;
  122. if(other > 0){
  123. sumOther = sumOther + other;
  124. }
  125. sumHours = sumHours + hour;
  126. sumHoursPrice = sumHoursPrice + (hour*priceHour);
  127. document.getElementById('sumTotalStrong').innerHTML = total;
  128. document.getElementById('sumOther').innerHTML = sumOther;
  129. document.getElementById('sumHours').innerHTML = sumHours;
  130. document.getElementById('sumHoursPrice').innerHTML = sumHoursPrice;
  131. })
  132. }
  133. </script>
  134. </div>
  135. {% endblock page_content %}