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

@ -32,7 +32,7 @@
<div class="col-md-12 mb-4"> <div class="col-md-12 mb-4">
{!! Form::label('items', trans_choice('general.items', 2), ['class' => 'form-control-label']) !!} {!! Form::label('items', trans_choice('general.items', 2), ['class' => 'form-control-label']) !!}
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-bordered" id="items"> <table class="table table-bordered" id="items">
<thead class="thead-light"> <thead class="thead-light">
<tr class="row"> <tr class="row">
@stack('actions_th_start') @stack('actions_th_start')
@ -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">
@ -109,18 +109,18 @@
</div> </div>
</div> </div>
</div> </div>
<div class="discount card-footer"> <div class="discount card-footer">
<div class="row text-center"> <div class="row text-center">
<div class="col-md-12"> <div class="col-md-12">
<a href="javascript:void(0)" @click="discount = false" class="btn btn-icon btn-outline-secondary"> <a href="javascript:void(0)" @click="discount = false" class="btn btn-icon btn-outline-secondary">
<span class="btn-inner--icon"><i class="fas fa-times"></i></span> <span class="btn-inner--icon"><i class="fas fa-times"></i></span>
<span class="btn-inner--text">{{ trans('general.cancel') }}</span> <span class="btn-inner--text">{{ trans('general.cancel') }}</span>
</a> </a>
{!! Form::button('<span class="fa fa-save"></span> &nbsp;' . trans('general.save'), ['type' => 'button', 'id' => 'save-discount', '@click' => 'onAddDiscount', 'class' => 'btn btn-success']) !!} {!! Form::button('<span class="fa fa-save"></span> &nbsp;' . trans('general.save'), ['type' => 'button', 'id' => 'save-discount', '@click' => 'onAddDiscount', 'class' => 'btn btn-success']) !!}
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
<el-link class="cursor-pointer text-info" slot="reference" type="primary" v-if="!totals.discount_text">{{ trans('invoices.add_discount') }}</el-link> <el-link class="cursor-pointer text-info" slot="reference" type="primary" v-if="!totals.discount_text">{{ trans('invoices.add_discount') }}</el-link>
<el-link slot="reference" type="primary" v-if="totals.discount_text" v-html="totals.discount_text"></el-link> <el-link slot="reference" type="primary" v-if="totals.discount_text" v-html="totals.discount_text"></el-link>
</el-popover> </el-popover>

View File

@ -113,7 +113,7 @@
<div class="discount card-footer"> <div class="discount card-footer">
<div class="row text-center"> <div class="row text-center">
<div class="col-md-12"> <div class="col-md-12">
<a href="javascript:void(0)" @click="discount = false" class="btn btn-icon btn-outline-secondary"> <a href="javascript:void(0)" @click="discount = false" class="btn btn-icon btn-outline-secondary">
<span class="btn-inner--icon"><i class="fas fa-times"></i></span> <span class="btn-inner--icon"><i class="fas fa-times"></i></span>
<span class="btn-inner--text">{{ trans('general.cancel') }}</span> <span class="btn-inner--text">{{ trans('general.cancel') }}</span>
</a> </a>
@ -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,39 +16,36 @@
@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
data-item="name" :form-classes="[{'has-error': form.errors.get('name') }]"
required="required" :placeholder="'{{ trans('general.type_item_name') }}'"
name="items[][name]" :name="'item_id'"
v-model="row.name" :options="{{ json_encode($items) }}"
@input="onGetItem($event, index)" :value="'{{ old('item_id', '') }}'"
type="text" :add-new="{{ json_encode([
autocomplete="off"> 'status' => true,
<div class="dropdown-menu item-show dropdown-menu-center" ref="menu" :class="[{show: row.show}]"> 'text' => trans('general.form.add_new', ['field' => '']),
<div class="list-group list-group-flush"> 'path' => route('modals.items.store'),
<a class="list-group-item list-group-item-action" v-for="(item, item_index) in items" @click="onSelectItem(item, index)"> 'type' => 'inline',
<div class="row align-items-center"> 'field' => 'name',
<div class="col ml--2"> ])}}"
<div class="d-flex justify-content-between align-items-center"> @interface="row.item_id = $event"
<div> @label="row.name = $event"
<div class="name" v-text="item.name"></div> @option="onSelectItem($event, index)"
</div> :remote-action="'{{ route('items.autocomplete') }}'"
</div> :remote-type="'bill'"
</div> :currency-code="form.currency_code"
</div> :form-error="form.errors.get('name')"
</a> :loading-text="'{{ trans('general.loading') }}'"
</div> :no-data-text="'{{ trans('general.no_data') }}'"
</div> :no-matching-data-text="'{{ trans('general.no_matching_data') }}'"
<input name="items[][show]" ></akaunting-select-remote>
value="false" <input type="hidden"
v-model="row.show" data-item="name"
data-item="show" v-model="row.name"
type="hidden"> @input="onCalculateTotal"
<input name="items[][item_id]" name="item[][name]">
v-model="row.item_id" {!! $errors->first('item.name', '<p class="help-block">:message</p>') !!}
data-item="item_id"
type="hidden">
{!! $errors->first('item.name', '<p class="help-block">:message</p>') !!}
@stack('name_input_end') @stack('name_input_end')
</td> </td>
@stack('name_td_end') @stack('name_td_end')
@ -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>