PageRenderTime 25ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/resources/views/application/recertification/pdh.blade.php

https://bitbucket.org/mproctor-artba/sctpp
PHP | 349 lines | 286 code | 59 blank | 4 comment | 30 complexity | af16742511ee2988d1eca32297737989 MD5 | raw file
  1. @extends('layouts.app')
  2. @section('css')
  3. <link rel="stylesheet" type="text/css" href="/assets/plugins/dropify/dropify.min.css">
  4. <link rel="stylesheet" type="text/css" href="https://l-lin.github.io/font-awesome-animation/dist/font-awesome-animation.min.css">
  5. <style type="text/css">
  6. form .card-header{
  7. min-height: 70px;
  8. }
  9. .form-row{
  10. margin-bottom: 10px;
  11. }
  12. .pull-right{
  13. position: inherit;
  14. right:0;
  15. top:0;
  16. }
  17. #pdh{
  18. margin-top:10px;
  19. }
  20. .pdhTitle{
  21. margin: 0;
  22. margin-top: 10px;
  23. margin-bottom: -29px;
  24. }
  25. .pdhTitle a{
  26. padding-left: 10px;
  27. }
  28. .card .card-header a.collapsed:before {
  29. /* symbol for "opening" panels */
  30. content: "\f054"; /* adjust as needed, taken from bootstrap.css */
  31. font-family: FontAwesome !important;
  32. font-style: normal;
  33. font-weight: normal;
  34. text-decoration: inherit;
  35. float: left; /* adjust as needed */
  36. color: grey; /* adjust as needed */
  37. }
  38. .card-header a.text-dark:before {
  39. /* symbol for "collapsed" panels */
  40. font-family: FontAwesome !important;
  41. content: "\f077"; /* adjust as needed, taken from bootstrap.css */
  42. }
  43. .dropdown.bootstrap-select{
  44. max-width: 200px;
  45. float:right;
  46. margin-right: 20px;
  47. }
  48. .dropdown-menu.show{
  49. max-height: 200px;
  50. overflow-y: auto;
  51. min-width: inherit !important;
  52. max-width: 240px !important;
  53. }
  54. .req0{
  55. padding: .5rem .75rem;
  56. }
  57. .req0:before{
  58. font-family: FontAwesome !important;
  59. content: "\f054";
  60. }
  61. .activityTitle{
  62. font-size: 22px;
  63. }
  64. .condensed-list{
  65. list-style: none;
  66. padding-left: 0;
  67. }
  68. .progress .bg-success{
  69. background-color: #2bbbad !important;
  70. }
  71. </style>
  72. <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  73. @endsection
  74. @section('content')
  75. <div class="row">
  76. <div class="col-lg-12">
  77. <div class="card">
  78. <div class="card-body">
  79. <div class="row">
  80. <div class="col-md-12">
  81. <div class="progress progress-xxl">
  82. <div id="req0-progress" class="progress-bar bg-info" role="progressbar" style="" aria-valuenow="38" aria-valuemin="0" aria-valuemax="100"></div>
  83. </div>
  84. <label><strong>Total Progress:</strong> <span id="totalHours">0/30</span> Hours</label>
  85. </div>
  86. </div>
  87. <div class="row">
  88. <div class="col-md-12">
  89. <ul class="condensed-list">
  90. <li></li>
  91. <li>All hours must be submitted no later than @php $days = Auth::user()->certificate->daysToRecertify() - 15; @endphp {{ date('m-d-Y', strtotime("+$days days")) }}</li>
  92. </ul>
  93. </div>
  94. <div class="col-md-1">
  95. <button type="button" class="clone btn btn-info" style="cursor: pointer;">Add New</button>
  96. </div>
  97. <div class="col-md-2">
  98. <a href="https://sctpp.org/wp-content/uploads/2019/04/Recertification-PDH-Requirements.pdf" target="_blank" class="btn btn-dark" alt="PDH Submission Guide">PDH Submission Guide</a>
  99. </div>
  100. @if(Auth::user()->pdhs->sum('hours') >= 30)
  101. <div class="col-md-2">
  102. <div class="btn-group">
  103. <a href="{{ route('recertify-submit') }}" class="btn btn-primary waves-effect waves-light">Ready for Submission <span class="btn-label btn-label-right"><i class="fa fa-arrow-right"></i></span></a>
  104. </div>
  105. </div>
  106. @endif
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. <div class="row">
  113. <div class="col-lg-12">
  114. @CSRF
  115. <div id="pdh">
  116. @foreach($pdhs as $pdh)
  117. @include('layouts.pdh', $pdh)
  118. @endforeach
  119. @if(empty($pdh))
  120. @include('layouts.pdh')
  121. @endif
  122. </div>
  123. </div>
  124. </div>
  125. @endsection
  126. @section('js')
  127. <script type="text/javascript" src="/assets/plugins/dropify/dropify.min.js"></script>
  128. <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  129. <script>
  130. var regex = /^(.+?)(\d+)$/i;
  131. var cloneIndex = $(".clonedInput").length;
  132. $.ajaxSetup({
  133. headers: {
  134. 'X-CSRF-TOKEN': "{{ csrf_token() }}"
  135. }
  136. });
  137. function clone(){
  138. $.get("{{ route('getPDHForm') }}", function(data, status){
  139. $("#pdh").append(data);
  140. $('.dropify').dropify({
  141. allowedFiles: 'pdf'
  142. });
  143. });
  144. }
  145. function remove(pdhID){
  146. if(confirm("Are you sure you want to remove this record?")){
  147. $.ajax({
  148. type: "GET",
  149. url: "{{ route('removePDHform') }}/" + pdhID,
  150. });
  151. sumPDH();
  152. }
  153. }
  154. $("button.clone").on("click", clone);
  155. $("body").on("click", ".remove", function(){
  156. var pdhID = $(this).attr("data-pdhid");
  157. remove(pdhID);
  158. $(this).parent().parent().remove();
  159. });
  160. $("body").on("keyup", ".activityName", function(){
  161. var activityTitle = $(this).parent().parent().parent().parent().parent().parent().parent().parent().parent().find(".activityTitle");
  162. activityTitle.text($(this).val());
  163. });
  164. $("body").on("change", "select", function(){
  165. sumPDH();
  166. });
  167. function sumPDH(){
  168. var i;
  169. var progress = parseInt(0);
  170. var progressBar = [];
  171. var hours = parseInt(0);
  172. var category = "";
  173. // ad hoc to finish asap
  174. var progressA = parseInt(0);
  175. var progressB = parseInt(0);
  176. var progressC = parseInt(0);
  177. var progressD = parseInt(0);
  178. var progressE = parseInt(0);
  179. $(".req0 option:selected").each(function(){
  180. var father = $(this).parent().parent().parent().parent().parent().parent().parent().parent().parent();
  181. hours = parseInt($(this).val());
  182. if(!isNaN(hours)){
  183. progress += hours
  184. } else {
  185. hours = 0;
  186. }
  187. father.find(".currentHours").text(hours);
  188. });
  189. $('#req0-progress').css('width',((progress/30) * 100) + "%");
  190. $("#totalHours").text(progress + "/30");
  191. $("#page-title").text("Manage PDHs for Recertification");
  192. $("title").text("SCTPP | PDH Submission Form");
  193. if((progress/30 * 100) >= 100){
  194. $("#req0-progress").addClass("bg-success");
  195. }
  196. }
  197. $(".dropify").dropify({messages:{default:"Drag and drop a file here or click",replace:"Drag and drop or click to replace",remove:"Remove",error:"Please select another file"},error:{fileSize:"The file size is too big (2MB max)"}});
  198. $("body").on("change", ".required", function(){
  199. var father = $(this).parent().parent().parent().parent().parent().parent().parent().parent().parent();
  200. var requiredFields = father.find(".pre-validated").find(".required");
  201. var errors = 0;
  202. $(requiredFields).each(function(){
  203. if($(this).val() == "" || $(this).hasClass("validateDate") && validateDate($(this).val())){
  204. completed = false;
  205. $(this).addClass("parsley-error");
  206. if($(this).hasClass("dropify")){
  207. $(this).parent().parent().parent().find(".dropify-wrapper").addClass("parsley-error");
  208. }
  209. $(this).closest(".card").addClass("parsley-error");
  210. errors++;
  211. } else {
  212. $(this).removeClass("parsley-error");
  213. if($(this).hasClass("dropify")){
  214. $(this).parent().parent().parent().find(".dropify-wrapper").removeClass("parsley-error");
  215. }
  216. }
  217. });
  218. if(errors == 0){
  219. $(this).closest(".card").removeClass("parsley-error");
  220. }
  221. });
  222. $("body").on("click", "button.savePDH", function(){
  223. var formID = $(this).attr("data-form");
  224. var formdata = new FormData($("#pdhForm-" + formID)[0]);
  225. var errors = 0;
  226. var completed = true;
  227. var requiredFields = $("#pdhForm-" + formID).find(".required");
  228. $(requiredFields).each(function(){
  229. if($(this).val() == "" || $(this).hasClass("validateDate") && validateDate($(this).val())){
  230. completed = false;
  231. $(this).addClass("parsley-error");
  232. if($(this).hasClass("dropify")){
  233. $(this).parent().parent().parent().find(".dropify-wrapper").addClass("parsley-error");
  234. }
  235. $(this).closest(".card").addClass("parsley-error");
  236. errors++;
  237. } else {
  238. $(this).removeClass("parsley-error");
  239. if($(this).hasClass("dropify")){
  240. $(this).parent().parent().parent().find(".dropify-wrapper").removeClass("parsley-error");
  241. }
  242. }
  243. });
  244. if(errors == 0){
  245. $(this).closest(".card").removeClass("parsley-error");
  246. }
  247. $("#pdhForm-" + formID).addClass("pre-validated");
  248. if(completed == false){
  249. $.Notification.notify('error','bottom right', 'Missing Required Fields', 'Please correct the highlighted fields and try again.');
  250. var headerText = $("#pdhForm-" + formID).find("a.text-dark").text();
  251. $("#pdhForm-" + formID).find("a.text-dark").html('<i title="Pending Review" class="fa fa-warning text-danger"></i><span class="activityTitle">' + headerText + '</span>');
  252. } else {
  253. $.ajax({
  254. type: "POST",
  255. url: "{{ route('savePDHform') }}",
  256. data: formdata,
  257. cache: false,
  258. processData: false,
  259. contentType: false,
  260. success: function(data) { // je récupère la réponse du fichier PHP
  261. if(data == 200){
  262. $.Notification.notify('success','bottom right', 'PDH Uploaded', 'Your submission has been saved successfully!');
  263. var headerText = $("#pdhForm-" + formID).find("a.text-dark").text();
  264. $("#pdhForm-" + formID).find("a.text-dark").html('<i title="Pending Review" class="fa fa-clock-o text-info"></i><span class="activityTitle">' + headerText + '</span>');
  265. } else {
  266. $.Notification.notify('error','bottom right', 'Error!', 'We could not process your upload at this time. Please check all inputs and try again.');
  267. var headerText = $("#pdhForm-" + formID).find("a.text-dark").text();
  268. $("#pdhForm-" + formID).find("a.text-dark").html('<i title="Pending Review" class="fa fa-warning text-danger"></i><span class="activityTitle">' + headerText + '</span>');
  269. }
  270. }
  271. });
  272. }
  273. });
  274. function validateDate(date){
  275. var re = new RegExp("/^\d{1,2}\/\d{1,2}\/\d{4}$/");
  276. console.log(date);
  277. if (re.test(date)) {
  278. console.log(date);
  279. console.log("haha");
  280. return true;
  281. }
  282. console.log("nope");
  283. return false;
  284. }
  285. setTimeout(sumPDH, 200);
  286. $('body').on('focus',".datepicker", function(){
  287. $(this).datepicker();
  288. });
  289. </script>
  290. @endsection