index.blade.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. @extends('layouts.master')
  2. @section('content')
  3. <!-- DataTables -->
  4. <link rel="stylesheet" href="{{ asset('/assets/') }}/css/dataTables.bootstrap.min.css">
  5. <script src="{{ asset('/assets/') }}/js/jquery.dataTables.min.js"></script>
  6. <script src="{{ asset('/assets/') }}/js/dataTables.bootstrap.min.js"></script>
  7. <div class="panel panel-default">
  8. <!-- Default panel contents -->
  9. <div class="panel-heading">{{ $title }}</div>
  10. <div class="panel-body">
  11. @if(\Auth::user()->utype==1)
  12. <a href="{{ url('invoice/new') }}" class="btn btn-sm btn-info pull-right"><i class="fa fa-plus"></i> New Invoice</a> <br><br>
  13. @endif
  14. <div class="clearfix"></div>
  15. <table class="table table-bordered table-striped" id="example">
  16. <thead>
  17. <tr>
  18. <th>Invoice Code</th>
  19. @if(\Auth::user()->utype!=3)
  20. <th>Vendor</th>
  21. @endif
  22. <th>Service</th>
  23. <th>Date</th>
  24. <th>Due Date</th>
  25. <th>Amount</th>
  26. <th>Status</th>
  27. <th>Attachment</th>
  28. <th>Action</th>
  29. </tr>
  30. </thead>
  31. <tbody>
  32. @if($invoices)
  33. @foreach($invoices as $row)
  34. <tr>
  35. <td>{{ $row->invoice_code }}</td>
  36. @if(\Auth::user()->utype!=3)
  37. <td>{{ $row->company?$row->company->name:'' }}</td>
  38. @endif
  39. <td>
  40. @if($row->items)
  41. @foreach($row->items as $itm)
  42. {{ $itm->service?$itm->service->name:'' }} <br>
  43. @endforeach
  44. @endif
  45. </td>
  46. <td>{{ date('d M, Y',strtotime($row->invoice_date)) }}</td>
  47. <td>{{ date('d M, Y',strtotime($row->due_date)) }}</td>
  48. <?php
  49. $total=$row->items?$row->items->sum('payable_amount'):0;;
  50. $total1=$row->items?$row->items->sum('payable_amount'):0;
  51. $total2=$row->items?$row->items->sum('payable_amount'):0;
  52. $total_vat=($total1*$row->vat)/100;
  53. $total_tax=($total2*$row->tax)/100;
  54. $payable=$total+$total_vat+$total_tax;;
  55. $paid=$row->items?$row->items->sum('paid_amount'):0;
  56. $due=$payable-$paid;
  57. ?>
  58. <td>{{ $payable }}</td>
  59. <td>
  60. @if($row->status==0)
  61. <span class='label label-danger'>Due</span>
  62. @elseif($row->status==1)
  63. <span class='label label-success'>Paid</span>
  64. @endif
  65. </td>
  66. <td>
  67. @if(!empty($row->attachment))
  68. <a href="assets/invoice/{{ $row->attachment }}" title='Download attachment' target="_blank" class='btn btn-block btn-default btn-xs'><i class="fa fa-cloud-download"></i> Download</a>
  69. @else
  70. No Attachment
  71. @endif
  72. </td>
  73. <td>
  74. <a href="{{ url('invoice/show/') }}/{{ $row->id }}" data-toggle='modal' data-target='#modalPreview' class='btn btn-default btn-sm'><i class="fa fa-eye"></i></a>
  75. {{-- $itm->service?$itm->service->account_id:0 ; --}}
  76. <?php
  77. $service_account_id= 0 ;
  78. $client_id=$row->client?$row->client->id:0;
  79. ?>
  80. @if(\Auth::user()->utype==1)
  81. <a href="" class='btn btn-default btn-sm'><i class="fa fa-edit"></i></a>
  82. <a href="" class='btn btn-default btn-sm'><i class="fa fa-trash-o"></i></a>
  83. <a title='Update Payment' href="" data-client="{{ $client_id }}" data-acc_id="{{ $service_account_id }}" data-id='{{ $row->id }}' data-amount='{{ $payable }}' class='btn btn-default btn-sm btn_payment'><i class="fa fa-money"></i></a>
  84. @endif
  85. </td>
  86. </tr>
  87. @endforeach
  88. @endif
  89. </tbody>
  90. </table>
  91. </div>
  92. </div>
  93. <div class="modal fade" id="modalPreview">
  94. <div class="modal-dialog" style='width: 70%;'>
  95. </div>
  96. </div>
  97. <div class="modal fade" id="modalPayment">
  98. <div class="modal-dialog modal-xs">
  99. <div class="modal-content">
  100. <form action="{{ url('invoice/pay') }}" method="POST" role="form">
  101. <div class="modal-header">
  102. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  103. <h4 class="modal-title">Payment</h4>
  104. </div>
  105. <div class="modal-body">
  106. {{ csrf_field() }}
  107. <input type="hidden" name="id">
  108. <input type="hidden" name="amount">
  109. <input type="hidden" name="acc_id">
  110. <input type="hidden" name="client">
  111. <div class="form-group">
  112. <label for="mode_of_payment">Mode Of Payment</label>
  113. <select name="mode_of_payment" id="mode_of_payment" class="form-control">
  114. <option value="">Select Mode Of Payment</option>
  115. @if($account_types)
  116. @foreach($account_types as $type)
  117. <option value="{{ $type->id }}">{{ $type->name }}</option>
  118. @endforeach
  119. @endif
  120. </select>
  121. </div>
  122. <div class="form-group">
  123. <label for="description">Description</label>
  124. <textarea class="form-control" name="description" id="description" placeholder="Description"></textarea>
  125. </div>
  126. </div>
  127. <div class="modal-footer">
  128. <button type="submit" class="btn btn-primary">Confirm Payment</button>
  129. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  130. </div>
  131. </form>
  132. </div>
  133. </div>
  134. </div>
  135. @stop
  136. @section('style')
  137. <style>
  138. .modal-dialog {
  139. width: 70% !important;
  140. height: 70% !important;
  141. }
  142. .modal-content {
  143. height: auto;
  144. min-height: 70% !important;
  145. border-radius: 0;
  146. }
  147. </style>
  148. @stop
  149. @section('script')
  150. <script type="text/javascript">
  151. $(document).ready(function() {
  152. $('body').on('hidden.bs.modal', '.modal', function () {
  153. $(this).removeData('bs.modal');
  154. });
  155. var table=$("#example").DataTable({
  156. "searching": true,
  157. "lengthChange": true,
  158. "ordering": false,
  159. stateSave: true
  160. });
  161. $('.btn_payment').click(function(e){
  162. e.preventDefault();
  163. var conf=confirm('Are you sure to pay ??');
  164. if(conf)
  165. {
  166. /*var id=$(this).data('id');
  167. var amount=$(this).data('amount');
  168. var token='{{ csrf_token() }}';
  169. $.ajax({
  170. url: '{{ url('invoice/pay') }}',
  171. type: 'POST',
  172. data: {id: id,amount:amount,_token:token}
  173. })
  174. .done(function(res) {
  175. location.href="{{ url('invoice') }}";
  176. });*/
  177. var id=$(this).data('id');
  178. var amount=$(this).data('amount');
  179. var acc_id=$(this).data('acc_id');
  180. var client=$(this).data('client');
  181. $('#modalPayment').find('input[name="id"]').val(id);
  182. $('#modalPayment').find('input[name="amount"]').val(amount);
  183. $('#modalPayment').find('input[name="acc_id"]').val(acc_id);
  184. $('#modalPayment').find('input[name="client"]').val(client);
  185. $('#modalPayment').modal('show');
  186. }
  187. });
  188. });
  189. </script>
  190. @stop