close #472 Fixed: If you create/edit invoice/bill then Validation return error missing items.
This commit is contained in:
		| @@ -59,9 +59,17 @@ | ||||
|                         </tr> | ||||
|                     </thead> | ||||
|                     <tbody> | ||||
|                         <?php $item_row = 0; ?> | ||||
|                         @include('expenses.bills.item') | ||||
|                         <?php $item_row++; ?> | ||||
|                         @php $item_row = 0; @endphp | ||||
|                         @if(old('item')) | ||||
|                             @foreach(old('item') as $old_item) | ||||
|                                 @php $item = (object) $old_item; @endphp | ||||
|                                 @include('expenses.bills.item') | ||||
|                                 @php $item_row++; @endphp | ||||
|                             @endforeach | ||||
|                         @else | ||||
|                             @include('expenses.bills.item') | ||||
|                         @endif | ||||
|                         @php $item_row++; @endphp | ||||
|                         @stack('add_item_td_start') | ||||
|                         <tr id="addItem"> | ||||
|                             <td class="text-center"><button type="button" id="button-add-item" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-xs btn-primary" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i></button></td> | ||||
| @@ -122,14 +130,14 @@ | ||||
|  | ||||
|         {{ Form::fileGroup('attachment', trans('general.attachment'),[]) }} | ||||
|  | ||||
|         {{ Form::hidden('vendor_name', '', ['id' => 'vendor_name']) }} | ||||
|         {{ Form::hidden('vendor_email', '', ['id' => 'vendor_email']) }} | ||||
|         {{ Form::hidden('vendor_tax_number', '', ['id' => 'vendor_tax_number']) }} | ||||
|         {{ Form::hidden('vendor_phone', '', ['id' => 'vendor_phone']) }} | ||||
|         {{ Form::hidden('vendor_address', '', ['id' => 'vendor_address']) }} | ||||
|         {{ Form::hidden('currency_rate', '', ['id' => 'currency_rate']) }} | ||||
|         {{ Form::hidden('bill_status_code', 'draft', ['id' => 'bill_status_code']) }} | ||||
|         {{ Form::hidden('amount', '0', ['id' => 'amount']) }} | ||||
|         {{ Form::hidden('vendor_name', old('vendor_name'), ['id' => 'vendor_name']) }} | ||||
|         {{ Form::hidden('vendor_email', old('vendor_email'), ['id' => 'vendor_email']) }} | ||||
|         {{ Form::hidden('vendor_tax_number', old('vendor_tax_number'), ['id' => 'vendor_tax_number']) }} | ||||
|         {{ Form::hidden('vendor_phone', old('vendor_phone'), ['id' => 'vendor_phone']) }} | ||||
|         {{ Form::hidden('vendor_address', old('vendor_address'), ['id' => 'vendor_address']) }} | ||||
|         {{ Form::hidden('currency_rate', old('currency_rate'), ['id' => 'currency_rate']) }} | ||||
|         {{ Form::hidden('bill_status_code', old('bill_status_code', 'draft'), ['id' => 'bill_status_code']) }} | ||||
|         {{ Form::hidden('amount', old('amount', '0'), ['id' => 'amount']) }} | ||||
|     </div> | ||||
|     <!-- /.box-body --> | ||||
|  | ||||
| @@ -162,7 +170,7 @@ | ||||
|  | ||||
|         $(document).on('click', '#button-add-item', function (e) { | ||||
|             var currency_code = $('#currency_code').val(); | ||||
|   | ||||
|  | ||||
|             $.ajax({ | ||||
|                 url: '{{ url("expenses/bills/addItem") }}', | ||||
|                 type: 'GET', | ||||
| @@ -415,6 +423,10 @@ | ||||
|                     } | ||||
|                 }); | ||||
|             }); | ||||
|  | ||||
|             @if(old('item')) | ||||
|                 totalItem(); | ||||
|             @endif | ||||
|         }); | ||||
|  | ||||
|         function totalItem() { | ||||
|   | ||||
| @@ -47,15 +47,23 @@ | ||||
|                             </tr> | ||||
|                         </thead> | ||||
|                         <tbody> | ||||
|                         <?php $item_row = 0; ?> | ||||
|                         @foreach($bill->items as $item) | ||||
|                             @include('expenses.bills.item') | ||||
|                             <?php $item_row++; ?> | ||||
|                         @endforeach | ||||
|                         @if (empty($bill->items)) | ||||
|                             @include('expenses.bills.item') | ||||
|                         @endif | ||||
|                             <?php $item_row++; ?> | ||||
|                             @php $item_row = 0; @endphp | ||||
|                             @if(old('item')) | ||||
|                                 @foreach(old('item') as $old_item) | ||||
|                                     @php $item = (object) $old_item; @endphp | ||||
|                                     @include('expenses.bills.item') | ||||
|                                     @php $item_row++; @endphp | ||||
|                                 @endforeach | ||||
|                             @else | ||||
|                                 @foreach($bill->items as $item) | ||||
|                                     @include('expenses.bills.item') | ||||
|                                     @php $item_row++; @endphp | ||||
|                                 @endforeach | ||||
|                                 @if (empty($bill->items)) | ||||
|                                     @include('expenses.bills.item') | ||||
|                                 @endif | ||||
|                             @endif | ||||
|                             @php $item_row++; @endphp | ||||
|                             @stack('add_item_td_start') | ||||
|                             <tr id="addItem"> | ||||
|                                 <td class="text-center"><button type="button" id="button-add-item" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-xs btn-primary" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i></button></td> | ||||
| @@ -104,14 +112,14 @@ | ||||
|  | ||||
|             {{ Form::fileGroup('attachment', trans('general.attachment'),[]) }} | ||||
|  | ||||
|             {{ Form::hidden('vendor_name', null, ['id' => 'vendor_name']) }} | ||||
|             {{ Form::hidden('vendor_email', null, ['id' => 'vendor_email']) }} | ||||
|             {{ Form::hidden('vendor_tax_number', null, ['id' => 'vendor_tax_number']) }} | ||||
|             {{ Form::hidden('vendor_phone', null, ['id' => 'vendor_phone']) }} | ||||
|             {{ Form::hidden('vendor_address', null, ['id' => 'vendor_address']) }} | ||||
|             {{ Form::hidden('currency_rate', null, ['id' => 'currency_rate']) }} | ||||
|             {{ Form::hidden('bill_status_code', null, ['id' => 'bill_status_code']) }} | ||||
|             {{ Form::hidden('amount', null, ['id' => 'amount']) }} | ||||
|             {{ Form::hidden('vendor_name', old('customer_name', null), ['id' => 'vendor_name']) }} | ||||
|             {{ Form::hidden('vendor_email', old('vendor_email', null), ['id' => 'vendor_email']) }} | ||||
|             {{ Form::hidden('vendor_tax_number', old('vendor_tax_number', null), ['id' => 'vendor_tax_number']) }} | ||||
|             {{ Form::hidden('vendor_phone', old('vendor_phone', null), ['id' => 'vendor_phone']) }} | ||||
|             {{ Form::hidden('vendor_address', old('vendor_address', null), ['id' => 'vendor_address']) }} | ||||
|             {{ Form::hidden('currency_rate', old('currency_rate', null), ['id' => 'currency_rate']) }} | ||||
|             {{ Form::hidden('bill_status_code', old('bill_status_code', null), ['id' => 'bill_status_code']) }} | ||||
|             {{ Form::hidden('amount', old('amount', null), ['id' => 'amount']) }} | ||||
|         </div> | ||||
|         <!-- /.box-body --> | ||||
|  | ||||
| @@ -423,6 +431,10 @@ | ||||
|                     } | ||||
|                 }); | ||||
|             }); | ||||
|  | ||||
|             @if(old('item')) | ||||
|                 totalItem(); | ||||
|             @endif | ||||
|         }); | ||||
|  | ||||
|         function totalItem() { | ||||
|   | ||||
| @@ -7,39 +7,43 @@ | ||||
|     </td> | ||||
|     @stack('actions_td_end') | ||||
|     @stack('name_td_start') | ||||
|     <td> | ||||
|     <td {!! $errors->has('item.' . $item_row . '.name') ? 'class="has-error"' : ''  !!}"> | ||||
|         @stack('name_input_start') | ||||
|         <input value="{{ empty($item) ? '' : $item->name }}" class="form-control typeahead" required="required" placeholder="{{ trans('general.form.enter', ['field' => trans_choice('invoices.item_name', 1)]) }}" name="item[{{ $item_row }}][name]" type="text" id="item-name-{{ $item_row }}" autocomplete="off"> | ||||
|         <input value="{{ empty($item) ? '' : $item->name }}" class="form-control typeahead" required="required" placeholder="{{ trans('general.form.enter', ['field' => trans_choice('bills.item_name', 1)]) }}" name="item[{{ $item_row }}][name]" type="text" id="item-name-{{ $item_row }}" autocomplete="off"> | ||||
|         <input value="{{ empty($item) ? '' : $item->item_id }}" name="item[{{ $item_row }}][item_id]" type="hidden" id="item-id-{{ $item_row }}"> | ||||
|         {!! $errors->first('item.' . $item_row . '.name', '<p class="help-block">:message</p>') !!} | ||||
|         @stack('name_input_end') | ||||
|     </td> | ||||
|     @stack('name_td_end') | ||||
|     @stack('quantity_td_start') | ||||
|     <td> | ||||
|     <td {{ $errors->has('item.' . $item_row . '.quantity') ? 'class="has-error"' : '' }}"> | ||||
|         @stack('quantity_input_start') | ||||
|         <input value="{{ empty($item) ? '' : $item->quantity }}" class="form-control text-center" required="required" name="item[{{ $item_row }}][quantity]" type="text" id="item-quantity-{{ $item_row }}"> | ||||
|         {!! $errors->first('item.' . $item_row . '.quantity', '<p class="help-block">:message</p>') !!} | ||||
|         @stack('quantity_input_end') | ||||
|     </td> | ||||
|     @stack('quantity_td_end') | ||||
|     @stack('price_td_start') | ||||
|     <td> | ||||
|     <td {{ $errors->has('item.' . $item_row . 'price') ? 'class="has-error"' : '' }}"> | ||||
|         @stack('price_input_start') | ||||
|         <input value="{{ empty($item) ? '' : $item->price }}" class="form-control text-right input-price" required="required" name="item[{{ $item_row }}][price]" type="text" id="item-price-{{ $item_row }}"> | ||||
|         <input value="{{ $currency->code }}" name="item[{{ $item_row }}][currency]" type="hidden" id="item-currency-{{ $item_row }}"> | ||||
|         {!! $errors->first('item.' . $item_row . 'price', '<p class="help-block">:message</p>') !!} | ||||
|         @stack('price_input_end') | ||||
|     </td> | ||||
|     @stack('price_td_end') | ||||
|     @stack('taxes_td_start') | ||||
|     <td> | ||||
|     <td {{ $errors->has('item.' . $item_row . '.tax_id') ? 'class="has-error"' : '' }}"> | ||||
|         @stack('tax_id_input_start') | ||||
|         {!! Form::select('item[' . $item_row . '][tax_id]', $taxes, empty($item) ? setting('general.default_tax') : $item->tax_id, ['id'=> 'item-tax-'. $item_row, 'class' => 'form-control tax-select2', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)])]) !!} | ||||
|         {!! $errors->first('item.' . $item_row . '.tax_id', '<p class="help-block">:message</p>') !!} | ||||
|         @stack('tax_id_input_end') | ||||
|     </td> | ||||
|     @stack('taxes_td_end') | ||||
|     @stack('total_td_start') | ||||
|     <td class="text-right" style="vertical-align: middle;"> | ||||
|         @stack('total_input_start') | ||||
|         @if (empty($item)) | ||||
|         @if (empty($item) || !isset($item->total)) | ||||
|         <span id="item-total-{{ $item_row }}">0</span> | ||||
|         @else | ||||
|         <span id="item-total-{{ $item_row }}">@money($item->total, $bill->currency_code, true)</span> | ||||
|   | ||||
| @@ -59,9 +59,17 @@ | ||||
|                         </tr> | ||||
|                     </thead> | ||||
|                     <tbody> | ||||
|                         <?php $item_row = 0; ?> | ||||
|                         @include('incomes.invoices.item') | ||||
|                         <?php $item_row++; ?> | ||||
|                         @php $item_row = 0; @endphp | ||||
|                         @if(old('item')) | ||||
|                             @foreach(old('item') as $old_item) | ||||
|                                 @php $item = (object) $old_item; @endphp | ||||
|                                 @include('incomes.invoices.item') | ||||
|                                 @php $item_row++; @endphp | ||||
|                             @endforeach | ||||
|                         @else | ||||
|                             @include('incomes.invoices.item') | ||||
|                         @endif | ||||
|                         @php $item_row++; @endphp | ||||
|                         @stack('add_item_td_start') | ||||
|                         <tr id="addItem"> | ||||
|                             <td class="text-center"><button type="button" id="button-add-item" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-xs btn-primary" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i></button></td> | ||||
| @@ -122,14 +130,14 @@ | ||||
|  | ||||
|         {{ Form::fileGroup('attachment', trans('general.attachment')) }} | ||||
|  | ||||
|         {{ Form::hidden('customer_name', '', ['id' => 'customer_name']) }} | ||||
|         {{ Form::hidden('customer_email', '', ['id' => 'customer_email']) }} | ||||
|         {{ Form::hidden('customer_tax_number', '', ['id' => 'customer_tax_number']) }} | ||||
|         {{ Form::hidden('customer_phone', '', ['id' => 'customer_phone']) }} | ||||
|         {{ Form::hidden('customer_address', '', ['id' => 'customer_address']) }} | ||||
|         {{ Form::hidden('currency_rate', '', ['id' => 'currency_rate']) }} | ||||
|         {{ Form::hidden('invoice_status_code', 'draft', ['id' => 'invoice_status_code']) }} | ||||
|         {{ Form::hidden('amount', '0', ['id' => 'amount']) }} | ||||
|         {{ Form::hidden('customer_name', old('customer_name'), ['id' => 'customer_name']) }} | ||||
|         {{ Form::hidden('customer_email', old('customer_email'), ['id' => 'customer_email']) }} | ||||
|         {{ Form::hidden('customer_tax_number', old('customer_tax_number'), ['id' => 'customer_tax_number']) }} | ||||
|         {{ Form::hidden('customer_phone', old('customer_phone'), ['id' => 'customer_phone']) }} | ||||
|         {{ Form::hidden('customer_address', old('customer_address'), ['id' => 'customer_address']) }} | ||||
|         {{ Form::hidden('currency_rate', old('currency_rate'), ['id' => 'currency_rate']) }} | ||||
|         {{ Form::hidden('invoice_status_code', old('invoice_status_code', 'draft'), ['id' => 'invoice_status_code']) }} | ||||
|         {{ Form::hidden('amount', old('amount', '0'), ['id' => 'amount']) }} | ||||
|     </div> | ||||
|     <!-- /.box-body --> | ||||
|  | ||||
| @@ -415,6 +423,10 @@ | ||||
|                     } | ||||
|                 }); | ||||
|             }); | ||||
|  | ||||
|             @if(old('item')) | ||||
|                 totalItem(); | ||||
|             @endif | ||||
|         }); | ||||
|  | ||||
|         function totalItem() { | ||||
|   | ||||
| @@ -47,15 +47,23 @@ | ||||
|                             </tr> | ||||
|                         </thead> | ||||
|                         <tbody> | ||||
|                         <?php $item_row = 0; ?> | ||||
|                         @foreach($invoice->items as $item) | ||||
|                             @include('incomes.invoices.item') | ||||
|                             <?php $item_row++; ?> | ||||
|                         @endforeach | ||||
|                         @if (empty($invoice->items)) | ||||
|                             @include('incomes.invoices.item') | ||||
|                         @endif | ||||
|                             <?php $item_row++; ?> | ||||
|                             @php $item_row = 0; @endphp | ||||
|                             @if(old('item')) | ||||
|                                 @foreach(old('item') as $old_item) | ||||
|                                     @php $item = (object) $old_item; @endphp | ||||
|                                     @include('incomes.invoices.item') | ||||
|                                     @php $item_row++; @endphp | ||||
|                                 @endforeach | ||||
|                             @else | ||||
|                                 @foreach($invoice->items as $item) | ||||
|                                     @include('incomes.invoices.item') | ||||
|                                     @php $item_row++; @endphp | ||||
|                                 @endforeach | ||||
|                                 @if (empty($invoice->items)) | ||||
|                                     @include('incomes.invoices.item') | ||||
|                                 @endif | ||||
|                             @endif | ||||
|                             @php $item_row++; @endphp | ||||
|                             @stack('add_item_td_start') | ||||
|                             <tr id="addItem"> | ||||
|                                 <td class="text-center"><button type="button" id="button-add-item" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-xs btn-primary" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i></button></td> | ||||
| @@ -104,14 +112,14 @@ | ||||
|  | ||||
|             {{ Form::fileGroup('attachment', trans('general.attachment')) }} | ||||
|  | ||||
|             {{ Form::hidden('customer_name', null, ['id' => 'customer_name']) }} | ||||
|             {{ Form::hidden('customer_email', null, ['id' => 'customer_email']) }} | ||||
|             {{ Form::hidden('customer_tax_number', null, ['id' => 'customer_tax_number']) }} | ||||
|             {{ Form::hidden('customer_phone', null, ['id' => 'customer_phone']) }} | ||||
|             {{ Form::hidden('customer_address', null, ['id' => 'customer_address']) }} | ||||
|             {{ Form::hidden('currency_rate', null, ['id' => 'currency_rate']) }} | ||||
|             {{ Form::hidden('invoice_status_code', null, ['id' => 'invoice_status_code']) }} | ||||
|             {{ Form::hidden('amount', null, ['id' => 'amount']) }} | ||||
|             {{ Form::hidden('customer_name', old('customer_name', null), ['id' => 'customer_name']) }} | ||||
|             {{ Form::hidden('customer_email', old('customer_email', null), ['id' => 'customer_email']) }} | ||||
|             {{ Form::hidden('customer_tax_number', old('customer_tax_number', null), ['id' => 'customer_tax_number']) }} | ||||
|             {{ Form::hidden('customer_phone', old('customer_phone', null), ['id' => 'customer_phone']) }} | ||||
|             {{ Form::hidden('customer_address', old('customer_address', null), ['id' => 'customer_address']) }} | ||||
|             {{ Form::hidden('currency_rate', old('currency_rate', null), ['id' => 'currency_rate']) }} | ||||
|             {{ Form::hidden('invoice_status_code', old('invoice_status_code', null), ['id' => 'invoice_status_code']) }} | ||||
|             {{ Form::hidden('amount', old('amount', null), ['id' => 'amount']) }} | ||||
|         </div> | ||||
|         <!-- /.box-body --> | ||||
|  | ||||
| @@ -423,6 +431,10 @@ | ||||
|                     } | ||||
|                 }); | ||||
|             }); | ||||
|  | ||||
|             @if(old('item')) | ||||
|                 totalItem(); | ||||
|             @endif | ||||
|         }); | ||||
|  | ||||
|         function totalItem() { | ||||
|   | ||||
| @@ -7,39 +7,43 @@ | ||||
|     </td> | ||||
|     @stack('actions_td_end') | ||||
|     @stack('name_td_start') | ||||
|     <td> | ||||
|     <td {!! $errors->has('item.' . $item_row . '.name') ? 'class="has-error"' : ''  !!}"> | ||||
|         @stack('name_input_start') | ||||
|         <input value="{{ empty($item) ? '' : $item->name }}" class="form-control typeahead" required="required" placeholder="{{ trans('general.form.enter', ['field' => trans_choice('invoices.item_name', 1)]) }}" name="item[{{ $item_row }}][name]" type="text" id="item-name-{{ $item_row }}" autocomplete="off"> | ||||
|         <input value="{{ empty($item) ? '' : $item->item_id }}" name="item[{{ $item_row }}][item_id]" type="hidden" id="item-id-{{ $item_row }}"> | ||||
|         {!! $errors->first('item.' . $item_row . '.name', '<p class="help-block">:message</p>') !!} | ||||
|         @stack('name_input_end') | ||||
|     </td> | ||||
|     @stack('name_td_end') | ||||
|     @stack('quantity_td_start') | ||||
|     <td> | ||||
|     <td {{ $errors->has('item.' . $item_row . '.quantity') ? 'class="has-error"' : '' }}"> | ||||
|         @stack('quantity_input_start') | ||||
|         <input value="{{ empty($item) ? '' : $item->quantity }}" class="form-control text-center" required="required" name="item[{{ $item_row }}][quantity]" type="text" id="item-quantity-{{ $item_row }}"> | ||||
|         {!! $errors->first('item.' . $item_row . '.quantity', '<p class="help-block">:message</p>') !!} | ||||
|         @stack('quantity_input_end') | ||||
|     </td> | ||||
|     @stack('quantity_td_end') | ||||
|     @stack('price_td_start') | ||||
|     <td> | ||||
|     <td {{ $errors->has('item.' . $item_row . 'price') ? 'class="has-error"' : '' }}"> | ||||
|         @stack('price_input_start') | ||||
|         <input value="{{ empty($item) ? '' : $item->price }}" class="form-control text-right input-price" required="required" name="item[{{ $item_row }}][price]" type="text" id="item-price-{{ $item_row }}"> | ||||
|         <input value="{{ $currency->code }}" name="item[{{ $item_row }}][currency]" type="hidden" id="item-currency-{{ $item_row }}"> | ||||
|         {!! $errors->first('item.' . $item_row . 'price', '<p class="help-block">:message</p>') !!} | ||||
|         @stack('price_input_end') | ||||
|     </td> | ||||
|     @stack('price_td_end') | ||||
|     @stack('taxes_td_start') | ||||
|     <td> | ||||
|     <td {{ $errors->has('item.' . $item_row . '.tax_id') ? 'class="has-error"' : '' }}"> | ||||
|         @stack('tax_id_input_start') | ||||
|         {!! Form::select('item[' . $item_row . '][tax_id]', $taxes, empty($item) ? setting('general.default_tax') : $item->tax_id, ['id'=> 'item-tax-'. $item_row, 'class' => 'form-control tax-select2', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)])]) !!} | ||||
|         {!! $errors->first('item.' . $item_row . '.tax_id', '<p class="help-block">:message</p>') !!} | ||||
|         @stack('tax_id_input_end') | ||||
|     </td> | ||||
|     @stack('taxes_td_end') | ||||
|     @stack('total_td_start') | ||||
|     <td class="text-right" style="vertical-align: middle;"> | ||||
|         @stack('total_input_start') | ||||
|         @if (empty($item)) | ||||
|         @if (empty($item) || !isset($item->total)) | ||||
|         <span id="item-total-{{ $item_row }}">0</span> | ||||
|         @else | ||||
|         <span id="item-total-{{ $item_row }}">@money($item->total, $invoice->currency_code, true)</span> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user