Skip to content

Commit 7ad54b3

Browse files
committed
Create delivery from order
1 parent 2a57d30 commit 7ad54b3

File tree

18 files changed

+376
-81009
lines changed

18 files changed

+376
-81009
lines changed

resources/assets/css/app.css

Lines changed: 6 additions & 11728 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: 5 additions & 10978 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: 2 additions & 58218 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/lang/en/lang.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,4 +421,5 @@
421421
'order_number' => 'order number',
422422
'quote_number' => 'quote number',
423423
'from_quote' => 'from quote',
424+
'from_order' => 'from order'
424425
];

resources/sass/_custom.scss

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -141,34 +141,22 @@ dt {
141141
border-bottom-color: #ffffff !important;
142142
}
143143

144-
#dealProducts .row:not(:first-child) label{
144+
#dealProductsTotals label,
145+
#quoteProductsTotals label,
146+
#orderProductsTotals label,
147+
#invoiceLinesTotals label,
148+
#deliveryProductsTotals label{
145149
display: none;
146150
}
147151

148-
#quoteProducts .row:not(:first-child) label{
149-
display: none;
150-
}
151-
152-
#quoteProductsTotals label{
153-
display: none;
154-
}
155-
156-
#orderProducts .row:not(:first-child) label{
152+
#dealProducts .row:not(:first-child) label,
153+
#quoteProducts .row:not(:first-child) label,
154+
#orderProducts .row:not(:first-child) label,
155+
#invoiceLines .row:not(:first-child) label,
156+
#deliveryProducts .row:not(:first-child) label{
157157
display: none;
158158
}
159159

160-
#orderProductsTotals label{
161-
display: none;
162-
}
163-
164-
#invoiceLines .row:not(:first-child) label{
165-
display: none;
166-
}
167-
168-
#invoiceLinesTotals label{
169-
display: none;
170-
}
171-
172160
.bootstrap-duallistbox-container .btn-outline-secondary,
173161
.bootstrap-duallistbox-container select{
174162
color: #495057 !important;

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
1-
<form method="POST" action="{{ url(route('laravel-crm.invoices.store')) }}">
1+
<form method="POST" action="{{ url(route('laravel-crm.deliveries.store')) }}">
22
@csrf
33
@component('laravel-crm::components.card')
44

55
@component('laravel-crm::components.card-header')
66

77
@slot('title')
8-
{{ ucfirst(__('laravel-crm::lang.create_invoice')) }}
8+
{{ ucfirst(__('laravel-crm::lang.create_delivery')) }} @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')
12-
@include('laravel-crm::partials.return-button',[
13-
'model' => new \VentureDrake\LaravelCrm\Models\Invoice(),
14-
'route' => 'invoices'
15-
])
12+
@if(isset($order))
13+
@include('laravel-crm::partials.return-button',[
14+
'model' => new \VentureDrake\LaravelCrm\Models\Order(),
15+
'route' => 'orders'
16+
])
17+
@else
18+
@include('laravel-crm::partials.return-button',[
19+
'model' => new \VentureDrake\LaravelCrm\Models\Delivery(),
20+
'route' => 'deliveries'
21+
])
22+
@endif
1623
@endslot
1724

1825
@endcomponent
1926

2027
@component('laravel-crm::components.card-body')
2128

22-
@include('laravel-crm::invoices.partials.fields')
29+
@include('laravel-crm::deliveries.partials.fields')
2330

2431
@endcomponent
2532

2633
@component('laravel-crm::components.card-footer')
27-
<a href="{{ url(route('laravel-crm.invoices.index')) }}" class="btn btn-outline-secondary">{{ ucfirst(__('laravel-crm::lang.cancel')) }}</a>
34+
<a href="{{ url(route('laravel-crm.deliveries.index')) }}" class="btn btn-outline-secondary">{{ ucfirst(__('laravel-crm::lang.cancel')) }}</a>
2835
<button type="submit" class="btn btn-primary">{{ ucfirst(__('laravel-crm::lang.save')) }}</button>
2936
@endcomponent
3037

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
])
2525
</div>
2626
<div class="col-sm-7">
27-
{{--
2827
@livewire('delivery-items',[
29-
'order' => $order ?? null,
30-
'products' => $order->orderProducts ?? null,
31-
'old' => old('products')
32-
])--}}
28+
'delivery' => $delivery ?? null,
29+
'products' => $delivery->deliveryProducts ?? $order->orderProducts ?? null,
30+
'old' => old('deliveries'),
31+
'fromOrder' => (isset($order)) ? $order : false
32+
])
3333
</div>
3434
</div>
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<tr wire:key="select2-{{ $value }}" data-number="{{ $value }}" class="item-tr">
2+
<td class="pt-3 bind-select2" style="position: relative;">
3+
@include('laravel-crm::partials.form.hidden',[
4+
'name' => 'products['.$value.'][delivery_product_id]',
5+
'attributes' => [
6+
'wire:model' => 'delivery_product_id.'.$value,
7+
]
8+
])
9+
@include('laravel-crm::partials.form.hidden',[
10+
'name' => 'products['.$value.'][order_product_id]',
11+
'attributes' => [
12+
'wire:model' => 'order_product_id.'.$value,
13+
]
14+
])
15+
<span wire:ignore>
16+
@if($fromOrder)
17+
18+
@include('laravel-crm::partials.form.hidden',[
19+
'name' => 'products['.$value.'][product_id]',
20+
'attributes' => [
21+
'wire:model' => 'product_id.'.$value,
22+
]
23+
])
24+
25+
@include('laravel-crm::partials.form.text',[
26+
'name' => 'products['.$value.'][name]',
27+
'label' => ucfirst(__('laravel-crm::lang.name')),
28+
'attributes' => [
29+
'wire:model' => 'name.'.$value,
30+
'readonly' => 'readonly'
31+
]
32+
])
33+
34+
@else
35+
@include('laravel-crm::partials.form.select',[
36+
'name' => 'products['.$value.'][product_id]',
37+
'label' => ucfirst(__('laravel-crm::lang.name')),
38+
'options' => [
39+
$this->product_id[$value] ?? null => $this->name[$value] ?? null,
40+
],
41+
'value' => $this->product_id[$value] ?? null,
42+
'attributes' => [
43+
'wire:model' => 'product_id.'.$value,
44+
'data-value' => $value
45+
]
46+
])
47+
@endif
48+
</span>
49+
@if(!isset($fromOrder))
50+
<span style="position: absolute;top:13%; right: 5px;">
51+
<button wire:click.prevent="remove({{ $value }})" type="button" class="btn btn-outline-danger btn-sm btn-close"><span class="fa fa-remove"></span></button>
52+
</span>
53+
@endif
54+
</td>
55+
</tr>
56+
<tr data-number="{{ $value }}" class="item-tr">
57+
<td class="border-0 pt-0">
58+
@if($fromOrder)
59+
@include('laravel-crm::partials.form.select',[
60+
'name' => 'products['.$value.'][quantity]',
61+
'label' => ucfirst(__('laravel-crm::lang.quantity')),
62+
'options' => $this->order_quantities[$value],
63+
'value' => $this->quantity[$value] ?? null,
64+
'attributes' => [
65+
'wire:model' => 'quantity.'.$value,
66+
'data-value' => $value,
67+
'wire:change' => 'calculateAmounts'
68+
]
69+
])
70+
@else
71+
@include('laravel-crm::partials.form.text',[
72+
'name' => 'products['.$value.'][quantity]',
73+
'label' => ucfirst(__('laravel-crm::lang.quantity')),
74+
'type' => 'number',
75+
'attributes' => [
76+
'wire:model' => 'quantity.'.$value,
77+
'wire:change' => 'calculateAmounts'
78+
]
79+
])
80+
@endif
81+
</td>
82+
</tr>

resources/views/layouts/app.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
1919

2020
<!-- Styles -->
21-
<link href="{{ asset('vendor/laravel-crm/css/app.css') }}?v=76546474567678" rel="stylesheet">
21+
<link href="{{ asset('vendor/laravel-crm/css/app.css') }}?v=567867589789" rel="stylesheet">
2222

2323
@livewireStyles
2424

@@ -82,7 +82,7 @@
8282
</div>
8383
</footer>
8484
</div>
85-
<script src="{{ asset('vendor/laravel-crm/js/app.js') }}?v=5789678608909"></script>
85+
<script src="{{ asset('vendor/laravel-crm/js/app.js') }}?v=6537685769780"></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
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<div>
2+
<h6 class="text-uppercase section-h6-title"><span class="fa fa-cart-arrow-down" aria-hidden="true"></span> {{ ucfirst(__('laravel-crm::lang.delivery_items')) }} @if(!isset($fromOrder))<span class="float-right"><button class="btn btn-outline-secondary btn-sm" wire:click.prevent="add({{ $i }})"><span class="fa fa-plus" aria-hidden="true"></span></button></span>@endif</h6>
3+
<hr class="mb-0" />
4+
<script type="text/javascript">
5+
let products = {!! \VentureDrake\LaravelCrm\Http\Helpers\AutoComplete\productsSelect2() !!}
6+
</script>
7+
<span id="deliveryProducts">
8+
<div class="table-responsive">
9+
<table class="table table-sm table-items">
10+
{{--<thead>
11+
<tr>
12+
<th scope="col" class="border-0">{{ ucfirst(__('laravel-crm::lang.name')) }}</th>
13+
<th scope="col" class="col-3 border-0">{{ ucfirst(__('laravel-crm::lang.price')) }}</th>
14+
<th scope="col" class="col-2 border-0">{{ ucfirst(__('laravel-crm::lang.quantity')) }}</th>
15+
<th scope="col" class="col-3 border-0">{{ ucfirst(__('laravel-crm::lang.amount')) }}</th>
16+
</tr>
17+
</thead>--}}
18+
<tbody>
19+
@foreach($inputs as $key => $value)
20+
@include('laravel-crm::delivery-products.partials.fields')
21+
@endforeach
22+
</tbody>
23+
</table>
24+
</div>
25+
</span>
26+
27+
@push('livewire-js')
28+
<script>
29+
$(document).ready(function () {
30+
/*$(document).delegate("input[name^='products']", "focus", function() {
31+
var number = $(this).attr('value')
32+
$(this).autocomplete({
33+
source: products,
34+
onSelectItem: function(item, element){
35+
@this.set('product_id.' + number,item.value);
36+
@this.set('name.' + number,item.label);
37+
Livewire.emit('loadItemDefault', number)
38+
},
39+
highlightClass: 'text-danger',
40+
treshold: 2,
41+
});
42+
})*/
43+
44+
window.addEventListener('addedItem', event => {
45+
$("tr[data-number='" + event.detail.id + "'] td.bind-select2 select[name^='products']").select2({
46+
data: products,
47+
}).select2('open')
48+
.on('change', function (e) {
49+
@this.set('product_id.' + $(this).data('value'), $(this).val());
50+
@this.set('name.' + $(this).data('value'), $(this).find("option:selected").text());
51+
Livewire.emit('loadItemDefault', $(this).data('value'))
52+
});
53+
});
54+
55+
/*window.addEventListener('removedItem', event => {
56+
$("tr[data-number='" + event.detail.id + "']").remove()
57+
});*/
58+
59+
$("td.bind-select2 select[name^='products']").on('change', function (e) {
60+
@this.set('product_id.' + $(this).data('value'), $(this).val());
61+
@this.set('name.' + $(this).data('value'), $(this).find("option:selected").text());
62+
Livewire.emit('loadItemDefault', $(this).data('value'))
63+
});
64+
});
65+
</script>
66+
@endpush
67+
</div>

0 commit comments

Comments
 (0)