Skip to content

Commit f808c73

Browse files
committed
Updated create invoice from order
1 parent 7add92b commit f808c73

File tree

20 files changed

+282
-102
lines changed

20 files changed

+282
-102
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class AddOrderProductIdToLaravelCrmInvoiceLinesTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table(config('laravel-crm.db_table_prefix').'invoice_lines', function (Blueprint $table) {
17+
$table->unsignedBigInteger('order_product_id')->index()->nullable()->after('product_variation_id');
18+
$table->foreign('order_product_id')->references('id')->on(config('laravel-crm.db_table_prefix').'order_products');
19+
});
20+
}
21+
22+
/**
23+
* Reverse the migrations.
24+
*
25+
* @return void
26+
*/
27+
public function down()
28+
{
29+
Schema::table(config('laravel-crm.db_table_prefix').'invoice_lines', function (Blueprint $table) {
30+
$table->dropColumn([
31+
'order_product_id',
32+
]);
33+
});
34+
}
35+
}

resources/assets/css/app.css

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/assets/css/document.css

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/assets/js/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/assets/js/app.js.LICENSE.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
2-
* Bootstrap v4.6.0 (https://getbootstrap.com/)
3-
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
2+
* Bootstrap v4.6.2 (https://getbootstrap.com/)
3+
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
44
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
55
*/
66

@@ -21,21 +21,21 @@
2121
*/
2222

2323
/*!
24-
* Chart.js v3.6.0
24+
* Chart.js v3.2.1
2525
* https://www.chartjs.org
2626
* (c) 2021 Chart.js Contributors
2727
* Released under the MIT License
2828
*/
2929

3030
/*!
31-
* Sizzle CSS Selector Engine v2.3.6
31+
* Sizzle CSS Selector Engine v2.3.5
3232
* https://sizzlejs.com/
3333
*
3434
* Copyright JS Foundation and other contributors
3535
* Released under the MIT license
3636
* https://js.foundation/
3737
*
38-
* Date: 2021-02-16
38+
* Date: 2020-03-14
3939
*/
4040

4141
/*!
@@ -45,17 +45,17 @@
4545
*/
4646

4747
/*!
48-
* jQuery JavaScript Library v3.6.0
48+
* jQuery JavaScript Library v3.5.1
4949
* https://jquery.com/
5050
*
5151
* Includes Sizzle.js
5252
* https://sizzlejs.com/
5353
*
54-
* Copyright OpenJS Foundation and other contributors
54+
* Copyright JS Foundation and other contributors
5555
* Released under the MIT license
5656
* https://jquery.org/license
5757
*
58-
* Date: 2021-03-02T17:08Z
58+
* Date: 2020-05-04T22:49Z
5959
*/
6060

6161
/*!

resources/js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const appJquery = function() {
9595
tags: tags
9696
});
9797

98-
$("select[name^='invoiceLines']").select2({
98+
$("td.bind-select2 select[name^='invoiceLines']").select2({
9999
data: products,
100100
tags: tags
101101
});
Lines changed: 105 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,112 @@
11
<tr wire:key="select2-{{ $value }}" data-number="{{ $value }}" class="item-tr">
22
<td colspan="5" class="pt-3 bind-select2" style="position: relative;">
3+
@include('laravel-crm::partials.form.hidden',[
4+
'name' => 'invoiceLines['.$value.'][order_product_id]',
5+
'attributes' => [
6+
'wire:model' => 'order_product_id.'.$value,
7+
]
8+
])
9+
310
@include('laravel-crm::partials.form.hidden',[
411
'name' => 'invoiceLines['.$value.'][invoice_line_id]',
512
'attributes' => [
613
'wire:model' => 'invoice_line_id.'.$value,
714
]
815
])
9-
{{--<span class="autocomplete autocomplete-product-name">
10-
@include('laravel-crm::partials.form.hidden',[
11-
'name' => 'invoiceLines['.$value.'][product_id]',
12-
'attributes' => [
13-
'wire:model' => 'product_id.'.$value,
14-
]
15-
])
16-
<span wire:ignore>
16+
<span wire:ignore>
17+
@if($fromOrder)
18+
19+
@include('laravel-crm::partials.form.hidden',[
20+
'name' => 'invoiceLines['.$value.'][product_id]',
21+
'attributes' => [
22+
'wire:model' => 'product_id.'.$value,
23+
]
24+
])
25+
1726
@include('laravel-crm::partials.form.text',[
18-
'name' => 'invoiceLines['.$value.'][name]',
19-
/*'label' => ucfirst(__('laravel-crm::lang.name')),*/
27+
'name' => 'invoiceLines['.$value.'][name]',
28+
'label' => ucfirst(__('laravel-crm::lang.name')),
29+
'attributes' => [
30+
'wire:model' => 'name.'.$value,
31+
'readonly' => 'readonly'
32+
]
33+
])
34+
35+
@else
36+
@include('laravel-crm::partials.form.select',[
37+
'name' => 'invoiceLines['.$value.'][product_id]',
38+
'label' => ucfirst(__('laravel-crm::lang.name')),
39+
'options' => [
40+
$this->product_id[$value] ?? null => $this->name[$value] ?? null,
41+
],
42+
'value' => $this->product_id[$value] ?? null,
2043
'attributes' => [
21-
'wire:model' => 'name.'.$value,
22-
'autocomplete' => \Illuminate\Support\Str::random(),
44+
'wire:model' => 'product_id.'.$value,
45+
'data-value' => $value
2346
]
2447
])
25-
</span>
26-
</span>--}}
27-
<span wire:ignore>
28-
@include('laravel-crm::partials.form.select',[
29-
'name' => 'invoiceLines['.$value.'][product_id]',
30-
'label' => ucfirst(__('laravel-crm::lang.name')),
31-
'options' => [
32-
$this->product_id[$value] ?? null => $this->name[$value] ?? null,
33-
],
34-
'value' => $this->product_id[$value] ?? null,
35-
'attributes' => [
36-
'wire:model' => 'product_id.'.$value,
37-
'data-value' => $value
38-
]
39-
])
48+
@endif
4049
</span>
50+
@if(!$fromOrder)
4151
<span style="position: absolute;top:13%; right: 5px;">
4252
<button wire:click.prevent="remove({{ $value }})" type="button" class="btn btn-outline-danger btn-sm btn-close"><span class="fa fa-remove"></span></button>
4353
</span>
54+
@endif
4455
</td>
4556
</tr>
4657
<tr data-number="{{ $value }}" class="item-tr">
4758
<td colspan="3" class="border-0 pt-0">
48-
@include('laravel-crm::partials.form.text',[
49-
'name' => 'invoiceLines['.$value.'][price]',
50-
'label' => ucfirst(__('laravel-crm::lang.price')),
51-
'type' => 'number',
52-
'prepend' => '<span class="fa fa-dollar" aria-hidden="true"></span>',
53-
'attributes' => [
54-
'wire:model' => 'price.'.$value,
55-
'wire:change' => 'calculateAmounts',
56-
'step' => .01
57-
]
58-
])
59+
@if($fromOrder)
60+
@include('laravel-crm::partials.form.text',[
61+
'name' => 'invoiceLines['.$value.'][price]',
62+
'label' => ucfirst(__('laravel-crm::lang.price')),
63+
'type' => 'number',
64+
'prepend' => '<span class="fa fa-dollar" aria-hidden="true"></span>',
65+
'attributes' => [
66+
'wire:model' => 'price.'.$value,
67+
'wire:change' => 'calculateAmounts',
68+
'step' => .01,
69+
'readonly' => 'readonly'
70+
]
71+
])
72+
@else
73+
@include('laravel-crm::partials.form.text',[
74+
'name' => 'invoiceLines['.$value.'][price]',
75+
'label' => ucfirst(__('laravel-crm::lang.price')),
76+
'type' => 'number',
77+
'prepend' => '<span class="fa fa-dollar" aria-hidden="true"></span>',
78+
'attributes' => [
79+
'wire:model' => 'price.'.$value,
80+
'wire:change' => 'calculateAmounts',
81+
'step' => .01
82+
]
83+
])
84+
@endif
5985
</td>
6086
<td class="border-0 pt-0">
61-
@include('laravel-crm::partials.form.text',[
62-
'name' => 'invoiceLines['.$value.'][quantity]',
63-
'label' => ucfirst(__('laravel-crm::lang.quantity')),
64-
'type' => 'number',
65-
'attributes' => [
66-
'wire:model' => 'quantity.'.$value,
67-
'wire:change' => 'calculateAmounts'
68-
]
69-
])
87+
@if($fromOrder)
88+
@include('laravel-crm::partials.form.select',[
89+
'name' => 'invoiceLines['.$value.'][quantity]',
90+
'label' => ucfirst(__('laravel-crm::lang.quantity')),
91+
'options' => $this->order_quantities[$value],
92+
'value' => $this->quantity[$value] ?? null,
93+
'attributes' => [
94+
'wire:model' => 'quantity.'.$value,
95+
'data-value' => $value,
96+
'wire:change' => 'calculateAmounts'
97+
]
98+
])
99+
@else
100+
@include('laravel-crm::partials.form.text',[
101+
'name' => 'invoiceLines['.$value.'][quantity]',
102+
'label' => ucfirst(__('laravel-crm::lang.quantity')),
103+
'type' => 'number',
104+
'attributes' => [
105+
'wire:model' => 'quantity.'.$value,
106+
'wire:change' => 'calculateAmounts'
107+
]
108+
])
109+
@endif
70110
</td>
71111
<td class="border-0 pt-0">
72112
@include('laravel-crm::partials.form.text',[
@@ -84,12 +124,23 @@
84124
</tr>
85125
<tr data-number="{{ $value }}" class="item-tr">
86126
<td colspan="5" class="border-0 pt-0 pb-4">
87-
@include('laravel-crm::partials.form.text',[
88-
'name' => 'invoiceLines['.$value.'][comments]',
89-
'label' => ucfirst(__('laravel-crm::lang.comments')),
90-
'attributes' => [
91-
'wire:model' => 'comments.'.$value,
92-
]
93-
])
127+
@if($fromOrder)
128+
@include('laravel-crm::partials.form.text',[
129+
'name' => 'invoiceLines['.$value.'][comments]',
130+
'label' => ucfirst(__('laravel-crm::lang.comments')),
131+
'attributes' => [
132+
'wire:model' => 'comments.'.$value,
133+
'readonly' => 'readonly'
134+
]
135+
])
136+
@else
137+
@include('laravel-crm::partials.form.text',[
138+
'name' => 'invoiceLines['.$value.'][comments]',
139+
'label' => ucfirst(__('laravel-crm::lang.comments')),
140+
'attributes' => [
141+
'wire:model' => 'comments.'.$value,
142+
]
143+
])
144+
@endif
94145
</td>
95146
</tr>

resources/views/invoices/partials/card-create.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
@component('laravel-crm::components.card-header')
66

77
@slot('title')
8-
{{ ucfirst(__('laravel-crm::lang.create_invoice')) }}
8+
{{ ucfirst(__('laravel-crm::lang.create_invoice')) }} @isset($order){{ __('laravel-crm::lang.from_order') }} <a href="{{ route('laravel-crm.orders.show', $order) }}">{{ $order->order_id }}</a> @endisset
99
@endslot
1010

1111
@slot('actions')

resources/views/invoices/partials/fields.blade.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@
121121
@livewire('invoice-lines',[
122122
'invoice' => $invoice ?? null,
123123
'invoiceLines' => $invoice->invoiceLines ?? $order->orderProducts ?? null,
124-
'old' => old('invoiceLines')
124+
'old' => old('invoiceLines'),
125+
'fromOrder' => (isset($order)) ? $order : false
125126
])
126127
</div>
127128
</div>

resources/views/layouts/app.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
</div>
8383
</footer>
8484
</div>
85-
<script src="{{ asset('vendor/laravel-crm/js/app.js') }}?v=563899465348"></script>
85+
<script src="{{ asset('vendor/laravel-crm/js/app.js') }}?v=75687958794678"></script>
8686
<script src="{{ asset('vendor/laravel-crm/libs/bootstrap-multiselect/bootstrap-multiselect.min.js') }}"></script>
8787
<script src="https://cdn.jsdelivr.net/npm/bs-custom-file-input/dist/bs-custom-file-input.min.js"></script>
8888
@livewireScripts

0 commit comments

Comments
 (0)