index1.blade.php 6.1 KB

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