PageRenderTime 66ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/resources/views/user/attendance.blade.php

https://bitbucket.org/inets_company/erb_payment
PHP | 322 lines | 294 code | 25 blank | 3 comment | 33 complexity | fdeab5967d834587e968d68bbb109503 MD5 | raw file
Possible License(s): Apache-2.0
  1. @extends('layouts.app')
  2. @section('content')
  3. <!-- page start-->
  4. <?php
  5. $date = request('date') == null ? date('Y-m-d') : request('date');
  6. ?>
  7. <div class="row">
  8. <div class="col-sm-12">
  9. <section class="panel">
  10. <header class="panel-heading">
  11. Attendances
  12. </header>
  13. <div class="row">
  14. <div class="col-md-3">
  15. <div class="mini-stat clearfix">
  16. <span class="mini-stat-icon orange"><i class="fa fa-gavel"></i></span>
  17. <div class="mini-stat-info">
  18. <span><?= \App\Model\User::count() ?></span>
  19. Total Participants
  20. </div>
  21. </div>
  22. </div>
  23. <div class="col-md-3">
  24. <div class="mini-stat clearfix">
  25. <span class="mini-stat-icon tar"><i class="fa fa-tag"></i></span>
  26. <div class="mini-stat-info">
  27. <span id="att_count"><?= \App\Model\Attendance::where('date', $date)->where('present', 1)->count() ?></span>
  28. <?= date('Y M d', strtotime($date)) ?> Attendance
  29. </div>
  30. </div>
  31. </div>
  32. <div class="col-md-3">
  33. <div class="mini-stat clearfix">
  34. <span class="">Barcode Attendance</span>
  35. <div class="mini-stat-info">
  36. <input type="text" autofocus="true" class="form-control" id="add_attendance"/>
  37. </div>
  38. <span id="attendance_search_loader"></span>
  39. </div>
  40. </div>
  41. </div>
  42. <div class="panel-body">
  43. <?php
  44. $dates = DB::select('select distinct created_at::date from attendances');
  45. ?>
  46. <div class="row">
  47. <div class="form-group ">
  48. <label for="number" class="control-label col-lg-3 text-right">Dates</label>
  49. <div class="col-lg-6">
  50. <select class="form-control" id="sort_user" name="date">
  51. <option value="<?= date('Y-m-d') ?>" <?= date('Y-m-d') == $date ? 'selected' : '' ?>>Today</option>
  52. <?php
  53. foreach ($dates as $att) {
  54. $at_date = date('Y-m-d', (strtotime($att->created_at)));
  55. ?>
  56. <option value="<?= $at_date ?>" <?= $at_date == $date ? 'selected' : '' ?>><?= $at_date?></option>
  57. <?php } ?>
  58. </select>
  59. </div>
  60. </div>
  61. </div>
  62. <br/>
  63. <section class="panel">
  64. <header class="panel-heading tab-bg-dark-navy-blue ">
  65. <ul class="nav nav-tabs">
  66. <li class="active">
  67. <a data-toggle="tab" href="#home">Users</a>
  68. </li>
  69. <li class="">
  70. <a data-toggle="tab" href="#about">Attendance</a>
  71. </li>
  72. </li>
  73. </ul>
  74. </header>
  75. <div class="panel-body">
  76. <div class="tab-content">
  77. <div id="home" class="tab-pane active">
  78. <section id="unseen">
  79. <table class="table table-bordered table-striped table-condensed dataTable">
  80. <thead>
  81. <tr>
  82. <th>#</th>
  83. <th>Name</th>
  84. <th class="numeric">Phone</th>
  85. <th class="numeric">Email</th>
  86. <th class="numeric">Type</th>
  87. <th class="numeric">Employer</th>
  88. <th class="numeric">Specialization</th>
  89. <th class="numeric col-sm-1">Action</th>
  90. <th><input type="checkbox" name="all" id="toggle_all"/><span id="search_status_loader"></span></th>
  91. </tr>
  92. </thead>
  93. <tbody>
  94. <?php
  95. $i = 1;
  96. ?>
  97. @foreach($applicants as $applicant)
  98. <tr id="row<?= $applicant->id ?>">
  99. <td>{{$i}}</td>
  100. <td>{{$applicant->name}}</td>
  101. <td class="numeric">{{$applicant->phone}}</td>
  102. <td class="numeric">{{$applicant->email}}</td>
  103. <td>{{$applicant->userType->name}}</td>
  104. <td>{{$applicant->employer->name}}</td>
  105. <td>{{$applicant->profession->name}}</td>
  106. <td>
  107. <a href="<?= url('user/profile/' . $applicant->id) ?>" class="btn btn-xs btn-primary">View</a> &nbsp; &nbsp;
  108. </td>
  109. <td>
  110. <?php
  111. $method = "";
  112. $att = $applicant->attendance()->where('date', $date)->first();
  113. if (count($att) == 1 && $att->present == 1) {
  114. $method = "checked";
  115. }
  116. ?>
  117. <input type="checkbox" <?= $method ?> class="check" name="select[]" value="<?= $applicant->id ?>"/>
  118. <span id="search_status_loader<?= $applicant->id ?>"></span>
  119. </td>
  120. </tr>
  121. <?php $i++; ?>
  122. @endforeach
  123. </tbody>
  124. </table>
  125. <?php //$applicants->appends(Illuminate\Support\Facades\Input::except('page'))->links() ?>
  126. </section>
  127. </div>
  128. <div id="about" class="tab-pane">
  129. <section id="unseen">
  130. <table class="table table-bordered table-striped table-condensed dataTable">
  131. <thead>
  132. <tr>
  133. <th>#</th>
  134. <th>Name</th>
  135. <th class="numeric">Phone</th>
  136. <th class="numeric">Email</th>
  137. <th class="numeric">Type</th>
  138. <th class="numeric">Employer</th>
  139. <th class="numeric">Specialization</th>
  140. <th class="numeric col-sm-1">Action</th>
  141. <th><input type="checkbox" name="all" id="toggle_all"/><span id="search_status_loader"></span></th>
  142. </tr>
  143. </thead>
  144. <tbody>
  145. <?php
  146. $i = 1;
  147. ?>
  148. @foreach($applicants as $applicant)
  149. <?php
  150. $method = "";
  151. $attend = $applicant->attendance()->where('date', $date)->first();
  152. if (count($attend) == 1 && $attend->present == 1) {
  153. $method = "checked";
  154. ?>
  155. <tr id="row<?= $applicant->id ?>">
  156. <td>{{$i}}</td>
  157. <td>{{$applicant->name}}</td>
  158. <td class="numeric">{{$applicant->phone}}</td>
  159. <td class="numeric">{{$applicant->email}}</td>
  160. <td>{{$applicant->userType->name}}</td>
  161. <td>{{$applicant->employer->name}}</td>
  162. <td>{{$applicant->profession->name}}</td>
  163. <td>
  164. <a href="<?= url('user/profile/' . $applicant->id) ?>" class="btn btn-xs btn-primary">View</a> &nbsp; &nbsp;
  165. </td>
  166. <td>
  167. <input type="checkbox" <?= $method ?> class="check" name="select[]" value="<?= $applicant->id ?>"/>
  168. <span id="search_status_loader<?= $applicant->id ?>"></span>
  169. </td>
  170. </tr>
  171. <?php $i++;
  172. }
  173. ?>
  174. @endforeach
  175. </tbody>
  176. </table>
  177. <?php //$applicants->appends(Illuminate\Support\Facades\Input::except('page'))->links() ?>
  178. </section>
  179. </div>
  180. </div>
  181. </div>
  182. </section>
  183. </div>
  184. </section>
  185. </div>
  186. </div>
  187. <!-- page end-->
  188. <script type="text/javascript">
  189. let data = ''
  190. window.onload = function () {
  191. window.document.body.addEventListener('keydown', function (event) {
  192. if (event.keyCode == 13 || event.keyCode == 16 || event.keyCode == 17) {
  193. event.preventDefault();
  194. return;
  195. }
  196. if (event.ctrlKey) {
  197. event.preventDefault();
  198. return;
  199. }
  200. data += event.key;
  201. console.log(data);
  202. });
  203. }
  204. $('#add_attendance').keyup(function (e) {
  205. // e.preventDefault();
  206. if (e.which == 17 || e.which == 74 || e.which == 16) {
  207. e.preventDefault();
  208. } else {
  209. console.log(e.which);
  210. }
  211. if (e.keyCode == 13 || e.which == 16) {
  212. var pasteData = $(this).val();
  213. var att_count = parseInt($('#att_count').text());
  214. $.ajax({
  215. type: 'GET',
  216. url: "<?= url('user/barcodeAttendance') ?>",
  217. data: {
  218. "s": pasteData,
  219. 'date': '<?= $date ?>'
  220. },
  221. dataType: "html ",
  222. beforeSend: function (xhr) {
  223. $('#attendance_search_loader').html('<a href="#/refresh"><i class="fa fa-spinner"></i> </a>');
  224. },
  225. complete: function (xhr, status) {
  226. // $('#attendance_search_loader').html('<span class="label label-success">' + status + '</span>');
  227. $('#add_attendance').val('');
  228. },
  229. success: function (data) {
  230. if (data == '<span class="label label-success">success</span>') {
  231. $('#att_count').html(att_count + 1);
  232. }
  233. $('#attendance_search_loader').html('' + data + '');
  234. }
  235. });
  236. }
  237. });
  238. sort_user = function () {
  239. $('#sort_user').change(function () {
  240. var type = $(this).val();
  241. window.location.href = '<?= url()->current() ?>/?date=' + type;
  242. });
  243. }
  244. search_checked = function () {
  245. $('.check').click(function () {
  246. var value = $(this).val();
  247. var status = $(this).is(':checked');
  248. $.ajax({
  249. type: 'GET',
  250. url: "<?= url('user/addAttendance') ?>",
  251. data: {
  252. "user_id": value, 'status': status, 'user': 'attendance', 'date': '<?= $date ?>'
  253. },
  254. dataType: "html",
  255. beforeSend: function (xhr) {
  256. $('#search_status_loader' + value).html('<a href="#/refresh"><i class="fa fa-spinner"></i> </a>');
  257. },
  258. complete: function (xhr, status) {
  259. $('#search_status_loader' + value).html('<span class="label label-success">' + status + '</span>');
  260. },
  261. success: function (data) {
  262. //$('#search_status').html(data.message).removeClass().addClass('alert ' + data.alert_status);
  263. }
  264. });
  265. });
  266. }
  267. toggle_all = function () {
  268. $('#toggle_all').click(function () {
  269. var status = $(this).is(':checked');
  270. if ($("#toggle_all").prop('checked')) {
  271. $('.check').prop("checked", true);
  272. } else {
  273. $('.check').prop("checked", false);
  274. }
  275. $.ajax({
  276. type: 'GET',
  277. url: "<?= url('user/addBulkAttendance') ?>",
  278. data: {
  279. "type": '<?= request('type') ?>', 'status': status, 'user': 'attendance', 'date': '<?= $date ?>'
  280. },
  281. dataType: "html",
  282. beforeSend: function (xhr) {
  283. $('#search_status_loader').html('<a href="#/refresh"><i class="fa fa-spinner"></i> </a>');
  284. },
  285. complete: function (xhr, status) {
  286. $('#search_status_loader').html('<span class="label label-success">' + status + '</span>');
  287. },
  288. success: function (data) {
  289. }
  290. });
  291. });
  292. };
  293. $(document).ready(toggle_all);
  294. $(document).ready(search_checked);
  295. $(document).ready(sort_user);
  296. </script>
  297. @endsection