Blame view

resources/views/expenses/payments/create.blade.php 9.23 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
  @extends('layouts.admin')
  
  @section('title', trans('general.title.new', ['type' => trans_choice('general.payments', 1)]))
  
  @section('content')
      <!-- Default box -->
      <div class="box box-success">
          {!! Form::open(['url' => 'expenses/payments', 'files' => true, 'role' => 'form']) !!}
  
          <div class="box-body">
              {{ Form::textGroup('paid_at', trans('general.date'), 'calendar',['id' => 'paid_at', 'class' => 'form-control', 'required' => 'required', 'data-inputmask' => '\'alias\': \'yyyy-mm-dd\'', 'data-mask' => '', 'autocomplete' => 'off'], Date::now()->toDateString()) }}
  
              {!! Form::hidden('currency_code', $account_currency_code, ['id' => 'currency_code', 'class' => 'form-control', 'required' => 'required']) !!}
              {!! Form::hidden('currency_rate', '', ['id' => 'currency_rate']) !!}
  
              {{ Form::textGroup('amount', trans('general.amount'), 'money', ['required' => 'required', 'autofocus' => 'autofocus']) }}
  
              @stack('account_id_input_start')
              <div class="form-group col-md-6 form-small">
                  {!! Form::label('account_id', trans_choice('general.accounts', 1), ['class' => 'control-label']) !!}
                  <div class="input-group">
                      <div class="input-group-addon"><i class="fa fa-university"></i></div>
                      {!! Form::select('account_id', $accounts, setting('general.default_account'), array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.accounts', 1)])])) !!}
                      <div class="input-group-append">
                          {!! Form::text('currency', $account_currency_code, ['id' => 'currency', 'class' => 'form-control', 'required' => 'required', 'disabled' => 'disabled']) !!}
                      </div>
                  </div>
              </div>
              @stack('account_id_input_end')
  
              @stack('vendor_id_input_start')
              <div class="form-group col-md-6">
                  {!! Form::label('vendor_id', trans_choice('general.vendors', 1), ['class' => 'control-label']) !!}
                  <div class="input-group">
                      <div class="input-group-addon"><i class="fa fa-user"></i></div>
                      {!! Form::select('vendor_id', $vendors, null, array_merge(['id' => 'vendor_id', 'class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.vendors', 1)])])) !!}
                      <span class="input-group-btn">
                      <button type="button" id="button-vendor" class="btn btn-default btn-icon"><i class="fa fa-plus"></i></button>
                  </span>
                  </div>
              </div>
              @stack('vendor_id_input_end')
  
              {{ Form::textareaGroup('description', trans('general.description')) }}
  
              @stack('category_id_input_start')
              <div class="form-group col-md-6 required {{ $errors->has('category_id') ? 'has-error' : ''}}">
                  {!! Form::label('category_id', trans_choice('general.categories', 1), ['class' => 'control-label']) !!}
                  <div class="input-group">
                      <div class="input-group-addon"><i class="fa fa-folder-open-o"></i></div>
                      {!! Form::select('category_id', $categories, null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.categories', 1)])])) !!}
                      <div class="input-group-btn">
                          <button type="button" id="button-category" class="btn btn-default btn-icon"><i class="fa fa-plus"></i></button>
                      </div>
                  </div>
                  {!! $errors->first('category_id', '<p class="help-block">:message</p>') !!}
              </div>
              @stack('category_id_input_end')
  
              {{ Form::recurring('create') }}
  
              {{ Form::selectGroup('payment_method', trans_choice('general.payment_methods', 1), 'credit-card', $payment_methods, setting('general.default_payment_method')) }}
  
              {{ Form::textGroup('reference', trans('general.reference'), 'file-text-o',[]) }}
  
              {{ Form::fileGroup('attachment', trans('general.attachment')) }}
          </div>
          <!-- /.box-body -->
  
          <div class="box-footer">
              {{ Form::saveButtons('expenses/payments') }}
          </div>
          <!-- /.box-footer -->
  
          {!! Form::close() !!}
      </div>
  @endsection
  
  @push('js')
      <script src="{{ asset('vendor/almasaeed2010/adminlte/plugins/datepicker/bootstrap-datepicker.js') }}"></script>
      <script src="{{ asset('vendor/almasaeed2010/adminlte/plugins/datepicker/locales/bootstrap-datepicker.' . language()->getShortCode() . '.js') }}"></script>
      <script src="{{ asset('public/js/bootstrap-fancyfile.js') }}"></script>
      <script src="{{ asset('vendor/almasaeed2010/adminlte/plugins/colorpicker/bootstrap-colorpicker.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') }}">
      <link rel="stylesheet" href="{{ asset('vendor/almasaeed2010/adminlte/plugins/colorpicker/bootstrap-colorpicker.css') }}">
  @endpush
  
  @push('scripts')
      <script type="text/javascript">
          $(document).ready(function(){
              $("#amount").maskMoney({
                  thousands : '{{ $currency->thousands_separator }}',
                  decimal : '{{ $currency->decimal_mark }}',
                  precision : {{ $currency->precision }},
                  allowZero : true,
                  @if($currency->symbol_first)
                  prefix : '{{ $currency->symbol }}'
                  @else
                  suffix : '{{ $currency->symbol }}'
                  @endif
              });
  
              $('#amount').trigger('focus');
  
              $('#account_id').trigger('change');
  
              //Date picker
              $('#paid_at').datepicker({
                  format: 'yyyy-mm-dd',
                  weekStart: 1,
                  autoclose: true,
                  language: '{{ language()->getShortCode() }}'
              });
  
              $("#account_id").select2({
                  placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.accounts', 1)]) }}"
              });
  
              $("#category_id").select2({
                  placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.categories', 1)]) }}"
              });
  
              $("#vendor_id").select2({
                  placeholder: {
                      id: '-1', // the value of the option
                      text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.vendors', 1)]) }}"
                  }
              });
  
              $("#payment_method").select2({
                  placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.payment_methods', 1)]) }}"
              });
  
              $('#attachment').fancyfile({
                  text  : '{{ trans('general.form.select.file') }}',
                  style : 'btn-default',
                  placeholder : '{{ trans('general.form.no_file_selected') }}'
              });
          });
  
          $(document).on('change', '#account_id', function (e) {
              $.ajax({
                  url: '{{ url("banking/accounts/currency") }}',
                  type: 'GET',
                  dataType: 'JSON',
                  data: 'account_id=' + $(this).val(),
                  success: function(data) {
                      $('#currency').val(data.currency_code);
  
                      $('#currency_code').val(data.currency_code);
                      $('#currency_rate').val(data.currency_rate);
  
                      amount = $('#amount').maskMoney('unmasked')[0];
  
                      $("#amount").maskMoney({
                          thousands : data.thousands_separator,
                          decimal : data.decimal_mark,
                          precision : data.precision,
                          allowZero : true,
                          prefix : (data.symbol_first) ? data.symbol : '',
                          suffix : (data.symbol_first) ? '' : data.symbol
                      });
  
                      $('#amount').val(amount);
  
                      $('#amount').trigger('focus');
                  }
              });
          });
  
          $(document).on('click', '#button-vendor', function (e) {
              $('#modal-create-vendor').remove();
  
              $.ajax({
                  url: '{{ url("modals/vendors/create") }}',
                  type: 'GET',
                  dataType: 'JSON',
                  success: function(json) {
                      if (json['success']) {
                          $('body').append(json['html']);
                      }
                  }
              });
          });
  
          $(document).on('click', '#button-category', function (e) {
              $('#modal-create-category').remove();
  
              $.ajax({
                  url: '{{ url("modals/categories/create") }}',
                  type: 'GET',
                  dataType: 'JSON',
                  data: {type: 'expense'},
                  success: function(json) {
                      if (json['success']) {
                          $('body').append(json['html']);
                      }
                  }
              });
          });
      </script>
  @endpush