Blame view

resources/views/incomes/invoices/show.blade.php 20.5 KB
b7c7a5f6   Alexey Boroda   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
  @extends('layouts.admin')
  
  @section('title', trans_choice('general.invoices', 1) . ': ' . $invoice->invoice_number)
  
  @section('content')
      @if (($recurring = $invoice->recurring) && ($next = $recurring->next()))
          <div class="callout callout-info">
              <h4>{{ trans('recurring.recurring') }}</h4>
  
              <p>{{ trans('recurring.message', [
                      'type' => mb_strtolower(trans_choice('general.invoices', 1)),
                      'date' => $next->format($date_format)
                  ]) }}
              </p>
          </div>
      @endif
  
      <div class="box box-success">
          <section class="invoice">
              <div id="badge">
                  <div class="arrow-up"></div>
                  <div class="label {{ $invoice->status->label }}">{{ trans('invoices.status.' . $invoice->status->code) }}</div>
                  <div class="arrow-right"></div>
              </div>
  
              <div class="row invoice-header">
                  <div class="col-xs-7">
                      @if (setting('general.invoice_logo'))
                          <img src="{{ Storage::url(setting('general.invoice_logo')) }}" class="invoice-logo" />
                      @elseif (setting('general.company_logo'))
                          <img src="{{ Storage::url(setting('general.company_logo')) }}" class="invoice-logo" />
                      @else
                          <img src="{{ asset('public/img/company.png') }}" class="invoice-logo" />
                      @endif
                  </div>
                  <div class="col-xs-5 invoice-company">
                      <address>
                          <strong>{{ setting('general.company_name') }}</strong><br>
                          {!! nl2br(setting('general.company_address')) !!}<br>
                          @if (setting('general.company_tax_number'))
                          {{ trans('general.tax_number') }}: {{ setting('general.company_tax_number') }}<br>
                          @endif
                          <br>
                          @if (setting('general.company_phone'))
                          {{ setting('general.company_phone') }}<br>
                          @endif
                          {{ setting('general.company_email') }}
                      </address>
                  </div>
              </div>
  
              <div class="row">
                  <div class="col-xs-7">
                      {{ trans('invoices.bill_to') }}
                      <address>
                          <strong>{{ $invoice->customer_name }}</strong><br>
                          {!! nl2br($invoice->customer_address) !!}<br>
                          @if ($invoice->customer_tax_number)
                          {{ trans('general.tax_number') }}: {{ $invoice->customer_tax_number }}<br>
                          @endif
                          <br>
                          @if ($invoice->customer_phone)
                          {{ $invoice->customer_phone }}<br>
                          @endif
                          {{ $invoice->customer_email }}
                      </address>
                  </div>
                  <div class="col-xs-5">
                      <div class="table-responsive">
                          <table class="table no-border">
                              <tbody>
                                  <tr>
                                      <th>{{ trans('invoices.invoice_number') }}:</th>
                                      <td class="text-right">{{ $invoice->invoice_number }}</td>
                                  </tr>
                                  @if ($invoice->order_number)
                                  <tr>
                                      <th>{{ trans('invoices.order_number') }}:</th>
                                      <td class="text-right">{{ $invoice->order_number }}</td>
                                  </tr>
                                  @endif
                                  <tr>
                                      <th>{{ trans('invoices.invoice_date') }}:</th>
                                      <td class="text-right">{{ Date::parse($invoice->invoiced_at)->format($date_format) }}</td>
                                  </tr>
                                  <tr>
                                      <th>{{ trans('invoices.payment_due') }}:</th>
                                      <td class="text-right">{{ Date::parse($invoice->due_at)->format($date_format) }}</td>
                                  </tr>
                              </tbody>
                          </table>
                      </div>
                  </div>
              </div>
  
              <div class="row">
                  <div class="col-xs-12 table-responsive">
                      <table class="table table-striped">
                          <tbody>
                              <tr>
                                  <th>{{ trans_choice('general.items', 1) }}</th>
                                  <th class="text-center">{{ trans('invoices.quantity') }}</th>
                                  <th class="text-right">{{ trans('invoices.price') }}</th>
                                  <th class="text-right">{{ trans('invoices.total') }}</th>
                              </tr>
                              @foreach($invoice->items as $item)
                              <tr>
                                  <td>
                                      {{ $item->name }}
                                      @if ($item->sku)
                                          <br><small>{{ trans('items.sku') }}: {{ $item->sku }}</small>
                                      @endif
                                  </td>
                                  <td class="text-center">{{ $item->quantity }}</td>
                                  <td class="text-right">@money($item->price, $invoice->currency_code, true)</td>
                                  <td class="text-right">@money($item->total, $invoice->currency_code, true)</td>
                              </tr>
                              @endforeach
                          </tbody>
                      </table>
                  </div>
              </div>
  
              <div class="row">
                  <div class="col-xs-7">
                  @if ($invoice->notes)
                      <p class="lead">{{ trans_choice('general.notes', 2) }}</p>
  
                      <p class="text-muted well well-sm no-shadow" style="margin-top: 10px;">
                          {{ $invoice->notes }}
                      </p>
                  @endif
                  </div>
                  <div class="col-xs-5">
                      <div class="table-responsive">
                          <table class="table">
                              <tbody>
                                  @foreach ($invoice->totals as $total)
                                  @if ($total->code != 'total')
                                      <tr>
                                          <th>{{ trans($total->title) }}:</th>
                                          <td class="text-right">@money($total->amount, $invoice->currency_code, true)</td>
                                      </tr>
                                  @else
                                      @if ($invoice->paid)
                                          <tr class="text-success">
                                              <th>{{ trans('invoices.paid') }}:</th>
                                              <td class="text-right">- @money($invoice->paid, $invoice->currency_code, true)</td>
                                          </tr>
                                      @endif
                                      <tr>
                                          <th>{{ trans($total->name) }}:</th>
                                          <td class="text-right">@money($total->amount - $invoice->paid, $invoice->currency_code, true)</td>
                                      </tr>
                                  @endif
                                  @endforeach
                              </tbody>
                          </table>
                      </div>
                  </div>
              </div>
  
              <div class="box-footer row no-print">
                  <div class="col-md-12">
                      <a href="{{ url('incomes/invoices/' . $invoice->id . '/edit') }}" class="btn btn-default">
                          <i class="fa fa-pencil-square-o"></i>&nbsp; {{ trans('general.edit') }}
                      </a>
                      <a href="{{ url('incomes/invoices/' . $invoice->id . '/print') }}" target="_blank" class="btn btn-success">
                          <i class="fa fa-print"></i>&nbsp; {{ trans('general.print') }}
                      </a>
                      <div class="btn-group dropup">
                          <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><i class="fa fa-chevron-circle-up"></i>&nbsp; {{ trans('general.more_actions') }}</button>
                          <ul class="dropdown-menu" role="menu">
                              @if($invoice->status->code != 'paid')
                              @permission('update-incomes-invoices')
                              <li><a href="{{ url('incomes/invoices/' . $invoice->id . '/pay') }}">{{ trans('invoices.mark_paid') }}</a></li>
                              @endpermission
                              @if(empty($invoice->payments()->count()) || (!empty($invoice->payments()->count()) && $invoice->paid != $invoice->amount))
                              <li><a href="#" id="button-payment">{{ trans('invoices.add_payment') }}</a></li>
                              @endif
                              <li class="divider"></li>
                              @endif
                              @permission('update-incomes-invoices')
                              @if($invoice->invoice_status_code == 'draft')
                              <li><a href="{{ url('incomes/invoices/' . $invoice->id . '/sent') }}">{{ trans('invoices.mark_sent') }}</a></li>
                              @else
                              <li><a href="javascript:void(0);" class="disabled"><span class="text-disabled">{{ trans('invoices.mark_sent') }}</span></a></li>
                              @endif
                              @endpermission
                              @if($invoice->customer_email)
                              <li><a href="{{ url('incomes/invoices/' . $invoice->id . '/email') }}">{{ trans('invoices.send_mail') }}</a></li>
                              @else
                              <li><a href="javascript:void(0);" class="green-tooltip disabled" data-toggle="tooltip" data-placement="right" title="{{ trans('invoices.messages.email_required') }}"><span class="text-disabled">{{ trans('invoices.send_mail') }}</span></a></li>
                              @endif
                              <li class="divider"></li>
                              <li><a href="{{ url('incomes/invoices/' . $invoice->id . '/pdf') }}">{{ trans('invoices.download_pdf') }}</a></li>
                              <li class="divider"></li>
                              @permission('delete-incomes-invoices')
                              <li>{!! Form::deleteLink($invoice, 'incomes/invoices') !!}</li>
                              @endpermission
                          </ul>
                      </div>
  
                      @if($invoice->attachment)
                          <span class="attachment">
                              <a href="{{ url('uploads/' . $invoice->attachment->id . '/download') }}">
                                  <span id="download-attachment" class="text-primary">
                                      <i class="fa fa-file-{{ $invoice->attachment->aggregate_type }}-o"></i> {{ $invoice->attachment->basename }}
                                  </span>
                              </a>
                              {!! Form::open([
                                  'id' => 'attachment-' . $invoice->attachment->id,
                                  'method' => 'DELETE',
                                  'url' => [url('uploads/' . $invoice->attachment->id)],
                                  'style' => 'display:inline'
                              ]) !!}
                              <a id="remove-attachment" href="javascript:void();">
                                  <span class="text-danger"><i class="fa fa fa-times"></i></span>
                              </a>
                              {!! Form::close() !!}
                          </span>
                      @endif
                  </div>
              </div>
          </section>
      </div>
  
      <div class="row">
          <div class="col-xs-6">
              <div class="box box-default collapsed-box">
                  <div class="box-header with-border">
                      <h3 class="box-title">{{ trans('invoices.histories') }}</h3>
  
                      <div class="box-tools pull-right">
                          <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i></button>
                      </div>
                      <!-- /.box-tools -->
                  </div>
                  <div class="box-body">
                      <div class="table-responsive">
                          <table class="table">
                              <thead>
                              <tr>
                                  <th>{{ trans('general.date') }}</th>
                                  <th>{{ trans_choice('general.statuses', 1) }}</th>
                                  <th>{{ trans('general.description') }}</th>
                              </tr>
                              </thead>
                              <tbody>
                              @foreach($invoice->histories as $history)
                                  <tr>
                                      <td>{{ Date::parse($history->created_at)->format($date_format) }}</td>
                                      <td>{{ $history->status->name }}</td>
                                      <td>{{ $history->description }}</td>
                                  </tr>
                              @endforeach
                              </tbody>
                          </table>
                      </div>
                  </div>
              </div>
          </div>
  
          <div class="col-xs-6">
              <div class="box box-default collapsed-box">
                  <div class="box-header with-border">
                      <h3 class="box-title">{{ trans('invoices.payments') }}</h3>
  
                      <div class="box-tools pull-right">
                          <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i></button>
                      </div>
                      <!-- /.box-tools -->
                  </div>
                  <div class="box-body">
                      <div class="table-responsive">
                          <table class="table">
                              <thead>
                              <tr>
                                  <th>{{ trans('general.date') }}</th>
                                  <th>{{ trans('general.amount') }}</th>
                                  <th>{{ trans_choice('general.accounts', 1) }}</th>
                                  <th style="width: 15%;">{{ trans('general.actions') }}</th>
                              </tr>
                              </thead>
                              <tbody>
                              @foreach($invoice->payments as $payment)
                                  <tr>
                                      <td>{{ Date::parse($payment->paid_at)->format($date_format) }}</td>
                                      <td>@money($payment->amount, $payment->currency_code, true)</td>
                                      <td>{{ $payment->account->name }}</td>
                                      <td>
                                          <a href="{{ url('incomes/invoices/' . $payment->id . '') }}" class="btn btn-info btn-xs hidden"><i class="fa fa-eye" aria-hidden="true"></i> {{ trans('general.show') }}</a>
                                          <a href="{{ url('incomes/revenues/' . $payment->id . '/edit') }}" class="btn btn-primary btn-xs  hidden"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> {{ trans('general.edit') }}</a>
                                          {!! Form::open([
                                              'id' => 'invoice-payment-' . $payment->id,
                                              'method' => 'DELETE',
                                              'url' => ['incomes/invoices/payment', $payment->id],
                                              'style' => 'display:inline'
                                          ]) !!}
                                          {!! Form::button('<i class="fa fa-trash-o" aria-hidden="true"></i> ' . trans('general.delete'), array(
                                              'type'    => 'button',
                                              'class'   => 'btn btn-danger btn-xs',
                                              'title'   => trans('general.delete'),
                                              'onclick' => 'confirmDelete("' . '#invoice-payment-' . $payment->id . '", "' . trans_choice('general.payments', 2) . '", "' . trans('general.delete_confirm', ['name' => '<strong>' . Date::parse($payment->paid_at)->format($date_format) . ' - ' . money($payment->amount, $payment->currency_code, true) . ' - ' . $payment->account->name . '</strong>', 'type' => strtolower(trans_choice('general.revenues', 1))]) . '", "' . trans('general.cancel') . '", "' . trans('general.delete') . '")'
                                          )) !!}
                                          {!! Form::close() !!}
                                      </td>
                                  </tr>
                              @endforeach
                              </tbody>
                          </table>
                      </div>
                  </div>
              </div>
          </div>
      </div>
  @endsection
  
  @push('js')
      <script src="{{ asset('vendor/almasaeed2010/adminlte/plugins/datepicker/bootstrap-datepicker.js') }}"></script>
      <script src="{{ asset('public/js/bootstrap-fancyfile.js') }}"></script>
  @endpush
  
  @push('css')
      <link rel="stylesheet" href="{{ asset('vendor/almasaeed2010/adminlte/plugins/datepicker/datepicker3.css') }}">
      <link rel="stylesheet" href="{{ asset('public/css/bootstrap-fancyfile.css') }}">
  @endpush
  
  @push('scripts')
      <script type="text/javascript">
          $(document).ready(function(){
              $(document).on('click', '#button-email', function (e) {
                  $('#email-modal').remove();
  
                  var html = '<div class="modal fade" id="email-modal" tabindex="-1" role="dialog" aria-labelledby="emailModalLabel">';
                  html += '   <div class="modal-dialog" role="document">';
                  html += '       <div class="modal-content">';
                  html += '           <div class="modal-header">';
                  html += '               <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
                  html += '               <h4 class="modal-title" id="emailModalLabel">Overflowing text</h4>';
                  html += '           </div>';
                  html += '           <div class="modal-body">';
                  html += '              {{ trans('general.na') }}';
                  html += '           </div>';
                  html += '           <div class="modal-footer">';
                  html += '               <button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('general.cancel') }}</button>';
                  html += '               <button type="button" class="btn btn-success">Save changes</button>';
                  html += '           </div>';
                  html += '       </div>';
                  html += '   </div>';
                  html += '</div>';
  
                  $('body').append(html);
  
                  $('#email-modal').modal('show');
              });
  
              @if($invoice->attachment)
              $(document).on('click', '#remove-attachment', function (e) {
                  confirmDelete("#attachment-{!! $invoice->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $invoice->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete')  !!}");
              });
              @endif
          });
  
          $(document).on('click', '#button-payment', function (e) {
              $('#modal-add-payment').remove();
  
              $.ajax({
                  url: '{{ url("modals/invoices/" . $invoice->id . "/payment/create") }}',
                  type: 'GET',
                  dataType: 'JSON',
                  success: function(json) {
                      if (json['success']) {
                          $('body').append(json['html']);
                      }
                  }
              });
          });
      </script>
  @endpush