Skip to content

Commit 23d49bb

Browse files
committed
Create & add another on PO created from orders
1 parent 3136818 commit 23d49bb

File tree

5 files changed

+34
-18
lines changed

5 files changed

+34
-18
lines changed

resources/views/purchase-order-lines/partials/fields.blade.php

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
</td>
5656
</tr>
5757
@if($fromOrder)
58-
<tr data-number="{{ $value }}" class="item-tr">
58+
{{--<tr data-number="{{ $value }}" class="item-tr">
5959
<td colspan="5" class="border-0 pt-0 bind-select2-organisations" style="position: relative;">
6060
@include('laravel-crm::partials.form.select',[
6161
'name' => 'purchaseOrderLines['.$value.'][organisation_id]',
@@ -65,12 +65,12 @@
6565
],
6666
'value' => $this->organisation_id[$value] ?? null,
6767
'attributes' => [
68-
'wire:model' => 'organisation_idnpm .'.$value,
68+
'wire:model' => 'organisation_id .'.$value,
6969
'data-value' => $value
7070
]
7171
])
7272
</td>
73-
</tr>
73+
</tr>--}}
7474
@endif
7575
<tr data-number="{{ $value }}" class="item-tr">
7676
<td colspan="2" class="border-0 pt-0">
@@ -84,7 +84,7 @@
8484
'wire:model' => 'price.'.$value,
8585
'wire:change' => 'calculateAmounts',
8686
'step' => .01,
87-
'readonly' => 'readonly'
87+
/* 'readonly' => 'readonly'*/
8888
]
8989
])
9090
@else
@@ -103,7 +103,7 @@
103103
</td>
104104
<td class="border-0 pt-0">
105105
@if($fromOrder)
106-
@include('laravel-crm::partials.form.select',[
106+
{{--@include('laravel-crm::partials.form.select',[
107107
'name' => 'purchaseOrderLines['.$value.'][quantity]',
108108
'label' => ucfirst(__('laravel-crm::lang.quantity')),
109109
'options' => $this->order_quantities[$value],
@@ -113,6 +113,15 @@
113113
'data-value' => $value,
114114
'wire:change' => 'calculateAmounts'
115115
]
116+
])--}}
117+
@include('laravel-crm::partials.form.text',[
118+
'name' => 'purchaseOrderLines['.$value.'][quantity]',
119+
'label' => ucfirst(__('laravel-crm::lang.quantity')),
120+
'type' => 'number',
121+
'attributes' => [
122+
'wire:model' => 'quantity.'.$value,
123+
'wire:change' => 'calculateAmounts'
124+
]
116125
])
117126
@else
118127
@include('laravel-crm::partials.form.text',[
@@ -156,14 +165,21 @@
156165
<tr data-number="{{ $value }}" class="item-tr">
157166
<td colspan="5" class="border-0 pt-0 pb-4">
158167
@if($fromOrder)
159-
@include('laravel-crm::partials.form.text',[
168+
{{-- @include('laravel-crm::partials.form.text',[
160169
'name' => 'purchaseOrderLines['.$value.'][comments]',
161170
'label' => ucfirst(__('laravel-crm::lang.comments')),
162171
'attributes' => [
163172
'wire:model' => 'comments.'.$value,
164173
'readonly' => 'readonly'
165174
]
166-
])
175+
])--}}
176+
@include('laravel-crm::partials.form.text',[
177+
'name' => 'purchaseOrderLines['.$value.'][comments]',
178+
'label' => ucfirst(__('laravel-crm::lang.comments')),
179+
'attributes' => [
180+
'wire:model' => 'comments.'.$value,
181+
]
182+
])
167183
@else
168184
@include('laravel-crm::partials.form.text',[
169185
'name' => 'purchaseOrderLines['.$value.'][comments]',

resources/views/purchase-orders/partials/card-create.blade.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@if(empty($order))
22
<form method="POST" action="{{ url(route('laravel-crm.purchase-orders.store')) }}">
33
@else
4-
<form method="POST" action="{{ url(route('laravel-crm.purchase-orders.store-multiple')) }}">
4+
<form method="POST" action="{{ url(route('laravel-crm.purchase-orders.store')) }}?order={{ $order->id }}">
55
@endif
66

77
@csrf
@@ -31,10 +31,8 @@
3131

3232
@component('laravel-crm::components.card-footer')
3333
<a href="{{ url(route('laravel-crm.purchase-orders.index')) }}" class="btn btn-outline-secondary">{{ ucfirst(__('laravel-crm::lang.cancel')) }}</a>
34-
{{--
35-
<button type="submit" class="btn btn-primary">{{ ucfirst(__('laravel-crm::lang.create_and_add_another')) }}</button>
36-
--}}
37-
<button type="submit" class="btn btn-primary">{{ ucfirst(__('laravel-crm::lang.create_purchase_order')) }}</button>
34+
<button type="submit" class="btn btn-primary" name="action" value="create_and_add_another">{{ ucfirst(__('laravel-crm::lang.create_and_add_another')) }}</button>
35+
<button type="submit" class="btn btn-primary" name="action">{{ ucfirst(__('laravel-crm::lang.create_purchase_order')) }}</button>
3836
@endcomponent
3937

4038
@endcomponent

resources/views/purchase-orders/partials/fields.blade.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
'name' => 'order_id',
55
'value' => old('order_id', $invoice->order->id ?? $order->id ?? null),
66
])
7-
@empty($order)
87
<span class="autocomplete">
98
@include('laravel-crm::partials.form.hidden',[
109
'name' => 'person_id',
@@ -43,7 +42,6 @@
4342
'required' => 'true'
4443
])
4544
</span>
46-
@endempty
4745
<div class="row">
4846
<div class="col-sm-6">
4947
@include('laravel-crm::partials.form.text',[

src/Http/Controllers/PurchaseOrderController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ public function store(StorePurchaseOrderRequest $request)
137137

138138
flash(ucfirst(trans('laravel-crm::lang.purchase_order_created')))->success()->important();
139139

140+
if($request->action == 'create_and_add_another') {
141+
return redirect(route('laravel-crm.purchase-orders.create', ['model' => 'order', 'id' => $request->order]));
142+
}
143+
140144
return redirect(route('laravel-crm.purchase-orders.index'));
141145
}
142146

src/Http/Requests/StorePurchaseOrderRequest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ public function rules()
3232
'currency' => 'required',
3333
];
3434

35-
if (! request('order_id')) {
36-
$rules['person_name'] = 'required_without:organisation_name|max:255';
37-
$rules['organisation_name'] = 'required_without:person_name|max:255';
38-
}
35+
//if (! request('order_id')) {
36+
$rules['person_name'] = 'required_without:organisation_name|max:255';
37+
$rules['organisation_name'] = 'required_without:person_name|max:255';
38+
//}
3939

4040
if(request('delivery_type') == 'deliver') {
4141
$rules['delivery_address'] = 'required';

0 commit comments

Comments
 (0)