templates/abscence_sheet/new.html.twig line 1

Open in your IDE?
  1. {% extends 'layout/backEndLayout.html.twig' %}
  2. {% block content %}
  3. {% form_theme form 'bootstrap_4_layout.html.twig' %}
  4. <div class="col-12 jumbotron" >
  5. <div class="row mt-4 mx-auto box-shadow">
  6. <div class="card-header">
  7. <h3 class="my-0 text-center text-justify text-uppercase"> Nouvelle fiche d'abscences</h3>
  8. </div>
  9. <div class="mt-4 col-md-12 col-sm-12 table-responsive">
  10. <div class="row">
  11. <div class="col-3 table-responsive"></div>
  12. <div class="col-6 table-responsive">
  13. {{ form_start(form, {action: path('admin_abscences_sheet_create'),'attr': { 'class':'evaluation'} }) }}
  14. <p>
  15. {{ form_widget(form.sequence ,{'attr':{'class':'ChoiceSequence'} } ) }}
  16. </p>
  17. <p>
  18. {{ form_widget(form.classRoom,{'attr':{ 'name' :'ChoiceClassRoom'} }) }}
  19. </p>
  20. <div class="row">
  21. <div class="col-6">
  22. {{ form_widget(form.startDate,{'attr':{ 'name' :'StartDate'} }) }}
  23. </div>
  24. <div class="col-6">
  25. {{ form_widget(form.endDate,{'attr':{ 'name' :'EndDate'} }) }}
  26. </div>
  27. </div>
  28. </div>
  29. <div class="col-3 table-responsive"></div>
  30. </div>
  31. </div>
  32. <div id="ficheBodyStudents" class=" col-md-12 row">
  33. {% include "abscence_sheet/liststudents.html.twig" %}
  34. </div>
  35. </div>
  36. <div class="row mt-2 mx-auto">
  37. <div class=" col-3">
  38. </div>
  39. <div class=" col-3 mx-auto btn-group d-inline-flex p-2 bd-highlight">
  40. <button class="btn btn-danger" type="submit">
  41. <b>
  42. <i class="fa fa-balance-scale"></i>submit</b>
  43. </button>
  44. </div>
  45. <div class=" col-3 mx-auto btn-group d-inline-flex p-2 bd-highligh">
  46. <a class="btn btn-info" href="{{ path('admin_abscences_sheet_index') }}">
  47. <i class="fa fa-list"></i>
  48. {{ 'Back to the list'|trans({}, 'admin') }}
  49. </a>
  50. </div>
  51. <div class=" col-3">
  52. </div>
  53. </div>
  54. {{ form_end(form) }}
  55. </div>
  56. {% endblock %}
  57. {% block footer %}
  58. {{ parent() }}
  59. {% endblock %}
  60. {% block javascripts %}
  61. {{parent()}}
  62. <script type="text/javascript">
  63. var classRoom = $("#abscence_sheet_classRoom");
  64. var idClassRoom, idSequence=$("#abscence_sheet_sequence").val(), startDate, endDate;
  65. classRoom.change(function () {
  66. idClassRoom = $("#abscence_sheet_classRoom option:selected").val();
  67. $.ajax({
  68. type: "POST",
  69. url: "{{ path('admin_abscence_list_students') }}",
  70. data: {
  71. idClassRoom: idClassRoom
  72. },
  73. datatype: "json",
  74. success: function (data) {
  75. $("#ficheBodyStudents").html(data).show();
  76. }
  77. });
  78. });
  79. $("#abscence_sheet_sequence").change(function () {
  80. idSequence = $(this).val();
  81. });
  82. $("#abscence_sheet_startDate").change(function () {
  83. startDate = $(this).val();
  84. });
  85. $("#abscence_sheet_endDate").change(function () {
  86. endDate = $(this).val();
  87. });
  88. $(function () {
  89. $(document).on('submit', 'form', function (e) { // il est impératif de commencer avec cette méthode qui va empêcher le navigateur d'envoyer le formulaire lui-même
  90. e.preventDefault();
  91. console.log(idClassRoom, idSequence, startDate, endDate);
  92. var abscencesJson = [];
  93. if(startDate < endDate) {
  94. $("input[max=180]").each(function (index) {
  95. abscencesJson.push({"matricule": $(this).attr('id'), "weight": $(this).val(), "raison": $(this).parent().next().children().val()});
  96. });
  97. console.log(abscencesJson);
  98. postData = {
  99. "abscences": JSON.stringify(abscencesJson),
  100. "idRoom": idClassRoom,
  101. "idSequence": idSequence,
  102. "startDate": startDate,
  103. "endDate": endDate
  104. };
  105. if(abscencesJson.length>0){
  106. $.ajax({
  107. type: "POST",
  108. url: "{{ path('admin_abscences_sheet_create') }}",
  109. data: postData,
  110. datatype: "json",
  111. success: function (data) {
  112. alert("Enregistre avec succes.");
  113. },
  114. error: function (e) {
  115. console.log(e.message);
  116. alert("Echec.");
  117. }
  118. });
  119. } else {
  120. alert("Aucune abscence enregistree");
  121. }
  122. } else {
  123. alert("La date de debut doit etre anterieure a la date de fin");
  124. }
  125. });
  126. });
  127. </script>
  128. {% endblock javascripts %}