index.blade.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. @extends('layouts.master')
  2. @section('content')
  3. <section class="content">
  4. <div class="row">
  5. <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
  6. <div class="panel panel-primary">
  7. <div class="panel-heading">
  8. <h3 class="panel-title">Journal</h3>
  9. </div>
  10. <div class="panel-body" style='min-height: 350px;'>
  11. @include('layouts.message')
  12. <a href="{{ url('account/journal/new') }}" class="btn btn-primary pull-right"><i class="fa fa-plus"></i> Add Expense</a>
  13. <a href="{{ url('account/revenue') }}" class="btn btn-success pull-right" style='margin-right: 10px;'>
  14. <i class="fa fa-plus"></i> Add Revenue</a>
  15. <br><br>
  16. <table class="table table-striped table-bordered">
  17. <thead>
  18. <tr>
  19. <th>Sl.</th>
  20. <th>Purpose</th>
  21. <th>Description</th>
  22. <th>Requested At</th>
  23. <th>Request By</th>
  24. <th>Due Date</th>
  25. <th>Amount</th>
  26. <th>Approval Status</th>
  27. </tr>
  28. </thead>
  29. <tbody>
  30. <?php $indx=1; ?>
  31. @foreach($approved_funds as $fund)
  32. <tr>
  33. <td>{{ $indx }}</td>
  34. <td>{{ $fund->acc_head?$fund->acc_head->name:'' }}</td>
  35. <td>{{ $fund->description }}</td>
  36. <td>{{ date('d M, Y',strtotime($fund->created_at)) }}</td>
  37. <td>{{ $fund->user?$fund->user->name:'' }}</td>
  38. <td>{{ date('Y M, Y',strtotime($fund->due_date)) }}</td>
  39. <td style='text-align: right;'>{{ $fund->amount }}</td>
  40. <td width="13%">
  41. <a href="{{ url('account/journal/payment') }}/{{ $fund->id }}" class="btn btn-info btn-xs">
  42. Make Payment
  43. </a>
  44. </td>
  45. </tr>
  46. <?php $indx++; ?>
  47. @endforeach
  48. </tbody>
  49. </table>
  50. <table class="table table-striped table-bordered hide">
  51. <thead>
  52. <tr>
  53. <th>Sl.</th>
  54. <th>Account Head</th>
  55. <th style='text-align: right'>Balance(Tk.)</th>
  56. <th width="20%">Approval Status</th>
  57. <th width="20%">Payment</th>
  58. </tr>
  59. </thead>
  60. <tbody>
  61. <?php $summery=0; ?>
  62. @if($journals)
  63. <?php $indx=1; ?>
  64. @foreach($journals as $journal)
  65. <?php
  66. $balance=$journal->debit-$journal->credit;
  67. $summery+=$balance;
  68. ?>
  69. @if($balance>0)
  70. <tr>
  71. <td>{{ $indx }}</td>
  72. <td><a data-toggle='modal' data-target='#modalJournalDetails' href="{{ url('account/journal/details') }}/{{ $journal->debit_account }}">{{ $journal->name }}</a></td>
  73. <td style='text-align: right;'>{{ $balance }}</td>
  74. <td width="20%">
  75. <?php
  76. $app_remarks=App\Models\JournalComment::where('approaval_status',1)->where('debit_account',$journal->debit_account)->first();
  77. ?>
  78. <label class="checkbox">
  79. @if(!$app_remarks)
  80. @if(\Auth::user()->id==2)
  81. <input type="checkbox" class="ck_approaval" data-balance='{{ $balance }}' data-debit_account='{{ $journal->debit_account }}' value="1">
  82. @endif
  83. <span>Not Approved</span>
  84. @else
  85. <span>{{ $app_remarks->approaval_status?'Approaved':'Not Approaved' }}</span>
  86. @endif
  87. </label>
  88. </td>
  89. <td>
  90. @if($app_remarks)
  91. <a href="{{ url('account/journal/payment') }}/{{ $journal->debit_account }}" class="btn btn-info btn-xs">
  92. Make Payment
  93. </a>
  94. @else
  95. <span class="label label-danger">Need Approval</span>
  96. @endif
  97. </td>
  98. </tr>
  99. <?php $indx++; ?>
  100. @endif
  101. @endforeach
  102. @endif
  103. </tbody>
  104. <tfoot>
  105. <tr>
  106. <th></th>
  107. <th></th>
  108. <th style='text-align: right;'>{{ $summery }}</th>
  109. <th></th>
  110. <th></th>
  111. </tr>
  112. </tfoot>
  113. </table>
  114. @if(!$funds->isEmpty())
  115. <h3>Fund Requests</h3>
  116. <table class="table table-bordered table-striped">
  117. <thead>
  118. <tr>
  119. <th>Sl.</th>
  120. <th>Purpose</th>
  121. <th>Description</th>
  122. <th>Requested At</th>
  123. <th>Requested By</th>
  124. <th>Due Date</th>
  125. <th style='text-align: right;'>Amount</th>
  126. <th>Approval Status</th>
  127. </tr>
  128. </thead>
  129. <tbody>
  130. <?php $indx=1; ?>
  131. @foreach($funds as $fund)
  132. <tr>
  133. <td>{{ $indx }}</td>
  134. <td>{{ $fund->acc_head?$fund->acc_head->name:'' }}</td>
  135. <td>{{ $fund->description }}</td>
  136. <td>{{ date('d M, Y',strtotime($fund->created_at)) }}</td>
  137. <td>{{ $fund->user?$fund->user->name:'' }}</td>
  138. <td>{{ date('Y M, Y',strtotime($fund->due_date)) }}</td>
  139. <td style='text-align: right;'>{{ $fund->amount }}</td>
  140. <td width="13%">
  141. <div class="btn-group">
  142. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-cog"></i>
  143. Action <span class="caret"></span>
  144. </button>
  145. <ul class="dropdown-menu">
  146. <li><a class='btnReqApprove' data-id='{{ $fund->id }}' data-purpose='{{ $fund->purpose }}' data-description='{{ $fund->description }}' data-amount='{{ $fund->amount }}' href="#">Approve</a></li>
  147. <li><a class='btnReqRevoke' data-id='{{ $fund->id }}' href="#">Revoke</a></li>
  148. </ul>
  149. </div>
  150. </td>
  151. </tr>
  152. <?php $indx++; ?>
  153. @endforeach
  154. </tbody>
  155. </table>
  156. @endif
  157. </div>
  158. </div>
  159. </div>
  160. </div>
  161. </section>
  162. <div class="modal fade" id="modalJournalDetails">
  163. </div>
  164. <div class="modal fade" id="appModal">
  165. <div class="modal-dialog modal-sm">
  166. <div class="modal-content">
  167. <div class="modal-header">
  168. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  169. <h4 class="modal-title">Payment Approval</h4>
  170. </div>
  171. <div class="modal-body">
  172. <input type="hidden" name="debit_account_id" value="0">
  173. <div class="form-group">
  174. <input type="text" onkeypress="return checkNumber(event)" class="form-control" name="modalAmount" id="modalAmount" placeholder="Amount" value="0">
  175. </div>
  176. <div class="form-group">
  177. <textarea name="modalRemarks" id="modalRemarks" class='form-control' placeholder="Remarks"></textarea>
  178. </div>
  179. </div>
  180. <div class="modal-footer">
  181. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  182. <button type="button" id='btnApproave' class="btn btn-primary">Save changes</button>
  183. </div>
  184. </div>
  185. </div>
  186. </div>
  187. @stop
  188. @section('style')
  189. <style>
  190. #modalJournalDetails .modal-dialog {width:75%;}
  191. @media screen and (min-width: 768px) {
  192. #modalJournalDetails .modal-dialog {width:900px;}
  193. }
  194. </style>
  195. @stop
  196. @section('script')
  197. <script type="text/javascript">
  198. $(document).ready(function() {
  199. $('.ck_approaval').click(function(){
  200. var that=$(this);
  201. var status=$(this).is(':checked')?1:0;
  202. if(status==1)
  203. {
  204. $('#appModal').modal('toggle');
  205. $('#appModal').find("input[name='debit_account_id']").val($(this).data('debit_account'));
  206. $('#appModal').find("#modalAmount").val($(this).data('balance'));
  207. }
  208. });
  209. $('#btnApproave').click(function(){
  210. var status=1;
  211. var debit_acc_id=$("input[name='debit_account_id']").val();
  212. var debit_amount=$('#modalAmount').val();
  213. var remarks=$('#modalRemarks').val();
  214. var token='{{ csrf_token() }}';
  215. $.ajax({
  216. url: '{{ url("account/journal/change_approaval_status") }}',
  217. type: 'POST',
  218. dataType:'JSON',
  219. data: {debit_account: debit_acc_id,status:status,amount:debit_amount,remarks:remarks,_token:token}
  220. })
  221. .done(function(res) {
  222. if(res.ok)
  223. {
  224. window.location.href='{{ url('account/journal') }}';
  225. }
  226. });
  227. });
  228. $('body').on('hide.bs.modal', '.modal', function () {
  229. $(this).removeData('bs.modal');
  230. });
  231. /**
  232. * approve fund request
  233. */
  234. $('.btnReqApprove').click(function(e){
  235. e.preventDefault();
  236. var id=$(this).data('id');
  237. var purpose=$(this).data('purpose');
  238. var description=$(this).data('description');
  239. var amount=$(this).data('amount');
  240. var token='{{ csrf_token() }}';
  241. $.ajax({
  242. url: '{{ url('account/fund/approval_status') }}',
  243. type: 'POST',
  244. data: {id: id,purpose:purpose,description:description,amount:amount,status:1,_token:token}
  245. })
  246. .done(function(res) {
  247. alert('Fund request approved successfully !');
  248. location.href='{{ url('account/journal') }}';
  249. });
  250. });//end approve fund request
  251. /**
  252. * remoke fund request
  253. */
  254. $('.btnReqRevoke').click(function(e){
  255. e.preventDefault();
  256. var id=$(this).data('id');
  257. var token='{{ csrf_token() }}';
  258. $.ajax({
  259. url: '{{ url('account/fund/approval_status') }}',
  260. type: 'POST',
  261. data: {id: id,status:2,_token:token}
  262. })
  263. .done(function(res) {
  264. alert('Fund request revoked successfully !');
  265. location.href='{{ url('account/journal') }}';
  266. });
  267. });//end remoke fund request
  268. });
  269. function checkNumber(evt)
  270. {
  271. var charCode = (evt.which) ? evt.which : evt.keyCode;
  272. if (charCode != 46 && charCode > 31
  273. && (charCode < 48 || charCode > 57))
  274. {
  275. alert('Invalid amount !!');
  276. return false;
  277. }
  278. return true;
  279. }
  280. </script>
  281. @stop