refs #1147 Bill item create inline feature.

This commit is contained in:
Cüneyt Şentürk
2020-01-21 17:17:05 +03:00
parent a8522812b2
commit 650f7f1273
6 changed files with 55 additions and 55 deletions

View File

@ -90,7 +90,7 @@ class Bills extends Controller
$currency = Currency::where('code', setting('default.currency'))->first(); $currency = Currency::where('code', setting('default.currency'))->first();
$items = Item::enabled()->orderBy('name')->pluck('name', 'id'); $items = Item::enabled()->orderBy('name')->get();
$taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id'); $taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id');
@ -184,7 +184,7 @@ class Bills extends Controller
$currency = Currency::where('code', $bill->currency_code)->first(); $currency = Currency::where('code', $bill->currency_code)->first();
$items = Item::enabled()->orderBy('name')->pluck('name', 'id'); $items = Item::enabled()->orderBy('name')->get();
$taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id'); $taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id');
@ -225,7 +225,7 @@ class Bills extends Controller
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param $id * @param $bill
* *
* @return Response * @return Response
*/ */

View File

@ -16,8 +16,10 @@ import Form from './../../plugins/form';
import Error from './../../plugins/error'; import Error from './../../plugins/error';
import BulkAction from './../../plugins/bulk-action'; import BulkAction from './../../plugins/bulk-action';
import { Link } from 'element-ui';
// plugin setup // plugin setup
Vue.use(DashboardPlugin); Vue.use(DashboardPlugin, Link);
const app = new Vue({ const app = new Vue({
el: '#app', el: '#app',
@ -179,9 +181,8 @@ const app = new Vue({
this.form.items[index].name = item.name; this.form.items[index].name = item.name;
this.form.items[index].price = (item.purchase_price).toFixed(2); this.form.items[index].price = (item.purchase_price).toFixed(2);
this.form.items[index].quantity = 1; this.form.items[index].quantity = 1;
this.form.items[index].tax_id = [item.tax_id.toString()];
this.form.items[index].total = item.total; this.form.items[index].total = item.total;
this.form.items[index].show = false;
}, },
onDeleteItem(index) { onDeleteItem(index) {

View File

@ -99,7 +99,7 @@
<i class="fa fa-percent"></i> <i class="fa fa-percent"></i>
</span> </span>
</div> </div>
{!! Form::number('pre_discount', null, ['id' => 'pre-discount', 'class' => 'form-control text-right']) !!} {!! Form::number('pre_discount', null, ['id' => 'pre-discount', 'class' => 'form-control']) !!}
</div> </div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">

View File

@ -191,7 +191,7 @@
@push('scripts_start') @push('scripts_start')
<script type="text/javascript"> <script type="text/javascript">
var bill_items = {!! json_encode($bill->items()->select(['item_id', 'name', 'quantity', 'price', 'total', 'tax'])->get()) !!}; var bill_items = {!! json_encode($bill->items()->get()) !!};
</script> </script>
<script src="{{ asset('public/js/purchases/bills.js?v=' . version('short')) }}"></script> <script src="{{ asset('public/js/purchases/bills.js?v=' . version('short')) }}"></script>

View File

@ -16,38 +16,35 @@
@stack('name_td_start') @stack('name_td_start')
<td class="col-md-3 border-right-0 border-bottom-0"> <td class="col-md-3 border-right-0 border-bottom-0">
@stack('name_input_start') @stack('name_input_start')
<input class="form-control" <akaunting-select-remote
:form-classes="[{'has-error': form.errors.get('name') }]"
:placeholder="'{{ trans('general.type_item_name') }}'"
:name="'item_id'"
:options="{{ json_encode($items) }}"
:value="'{{ old('item_id', '') }}'"
:add-new="{{ json_encode([
'status' => true,
'text' => trans('general.form.add_new', ['field' => '']),
'path' => route('modals.items.store'),
'type' => 'inline',
'field' => 'name',
])}}"
@interface="row.item_id = $event"
@label="row.name = $event"
@option="onSelectItem($event, index)"
:remote-action="'{{ route('items.autocomplete') }}'"
:remote-type="'bill'"
:currency-code="form.currency_code"
:form-error="form.errors.get('name')"
:loading-text="'{{ trans('general.loading') }}'"
:no-data-text="'{{ trans('general.no_data') }}'"
:no-matching-data-text="'{{ trans('general.no_matching_data') }}'"
></akaunting-select-remote>
<input type="hidden"
data-item="name" data-item="name"
required="required"
name="items[][name]"
v-model="row.name" v-model="row.name"
@input="onGetItem($event, index)" @input="onCalculateTotal"
type="text" name="item[][name]">
autocomplete="off">
<div class="dropdown-menu item-show dropdown-menu-center" ref="menu" :class="[{show: row.show}]">
<div class="list-group list-group-flush">
<a class="list-group-item list-group-item-action" v-for="(item, item_index) in items" @click="onSelectItem(item, index)">
<div class="row align-items-center">
<div class="col ml--2">
<div class="d-flex justify-content-between align-items-center">
<div>
<div class="name" v-text="item.name"></div>
</div>
</div>
</div>
</div>
</a>
</div>
</div>
<input name="items[][show]"
value="false"
v-model="row.show"
data-item="show"
type="hidden">
<input name="items[][item_id]"
v-model="row.item_id"
data-item="item_id"
type="hidden">
{!! $errors->first('item.name', '<p class="help-block">:message</p>') !!} {!! $errors->first('item.name', '<p class="help-block">:message</p>') !!}
@stack('name_input_end') @stack('name_input_end')
</td> </td>
@ -73,8 +70,8 @@
<td class="col-md-2 border-right-0 border-bottom-0"> <td class="col-md-2 border-right-0 border-bottom-0">
@stack('price_input_start') @stack('price_input_start')
<input class="form-control text-right input-price" <input class="form-control text-right input-price"
required="required"
autocomplete="off" autocomplete="off"
required="required"
data-item="price" data-item="price"
v-model.lazy="row.price" v-model.lazy="row.price"
v-money="money" v-money="money"
@ -98,7 +95,9 @@
'data-item' => 'tax_id', 'data-item' => 'tax_id',
'v-model' => 'row.tax_id', 'v-model' => 'row.tax_id',
'change' => 'onCalculateTotal', 'change' => 'onCalculateTotal',
'class' => 'form-control' 'class' => 'form-control',
'collapse' => 'false',
'path' => route('modals.taxes.create')
], 'mb-0 select-tax') }} ], 'mb-0 select-tax') }}
@stack('tax_id_input_end') @stack('tax_id_input_end')
</td> </td>

View File

@ -193,7 +193,7 @@
@push('scripts_start') @push('scripts_start')
<script type="text/javascript"> <script type="text/javascript">
var invoice_items = {!! json_encode($invoice->items()->select(['item_id', 'name', 'quantity', 'price', 'total', 'tax'])->get()) !!}; var invoice_items = {!! json_encode($invoice->items()->get()) !!};
</script> </script>
<script src="{{ asset('public/js/sales/invoices.js?v=' . version('short')) }}"></script> <script src="{{ asset('public/js/sales/invoices.js?v=' . version('short')) }}"></script>