Skip to content

Commit cc93583

Browse files
committed
Show orders on quotes, and invoices/deliveries on orders
1 parent 4f15752 commit cc93583

File tree

9 files changed

+206
-7
lines changed

9 files changed

+206
-7
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
@component('laravel-crm::components.card')
2+
3+
@component('laravel-crm::components.card-table')
4+
<table class="table mb-0 card-table table-hover">
5+
<thead>
6+
<tr>
7+
<th scope="col">{{ ucwords(__('laravel-crm::lang.created')) }}</th>
8+
<th scope="col">{{ ucwords(__('laravel-crm::lang.reference')) }}</th>
9+
<th scope="col">{{ ucwords(__('laravel-crm::lang.shipping_address')) }}</th>
10+
<th scope="col">{{ ucwords(__('laravel-crm::lang.delivery_expected')) }}</th>
11+
<th scope="col">{{ ucwords(__('laravel-crm::lang.delivered_on')) }}</th>
12+
</tr>
13+
</thead>
14+
<tbody>
15+
@foreach($deliveries as $delivery)
16+
<tr class="has-link" data-url="{{ url(route('laravel-crm.deliveries.show', $delivery)) }}">
17+
<td>{{ $delivery->created_at->diffForHumans() }}</td>
18+
<td>
19+
@if($delivery->order)
20+
<a href="{{ route('laravel-crm.orders.show', $delivery->order) }}">{{ $delivery->order->reference }}</a>
21+
@endif
22+
</td>
23+
<td>
24+
@if($address = $delivery->getShippingAddress())
25+
{{ \VentureDrake\LaravelCrm\Http\Helpers\AddressLine\addressSingleLine($address) }} {{ ($address->primary) ? '(Primary)' : null }}
26+
@if($address->contact)
27+
<small><br >{{ ucwords(__('laravel-crm::lang.contact')) }}: {{ $address->contact }}</small>
28+
@endif
29+
@if($address->phone)
30+
<small><br >{{ ucwords(__('laravel-crm::lang.phone')) }}: {{ $address->phone }}</small>
31+
@endif
32+
@endif
33+
</td>
34+
<td>
35+
{{ $delivery->delivery_expected ?? null }}
36+
</td>
37+
<td>
38+
{{ $delivery->delivered_on ?? null }}
39+
</td>
40+
</tr>
41+
@endforeach
42+
</tbody>
43+
</table>
44+
45+
@endcomponent
46+
@endcomponent
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@component('laravel-crm::components.card')
2+
3+
@component('laravel-crm::components.card-table')
4+
<table class="table mb-0 card-table table-hover">
5+
<thead>
6+
<tr>
7+
<th scope="col">{{ ucwords(__('laravel-crm::lang.number')) }}</th>
8+
<th scope="col">{{ ucwords(__('laravel-crm::lang.reference')) }}</th>
9+
<th scope="col">{{ ucwords(__('laravel-crm::lang.date')) }}</th>
10+
<th scope="col">{{ ucwords(__('laravel-crm::lang.due_date')) }}</th>
11+
<th scope="col">{{ ucwords(__('laravel-crm::lang.overdue_by')) }}</th>
12+
<th scope="col">{{ ucwords(__('laravel-crm::lang.paid_date')) }}</th>
13+
<th scope="col">{{ ucwords(__('laravel-crm::lang.paid')) }}</th>
14+
<th scope="col">{{ ucwords(__('laravel-crm::lang.due')) }}</th>
15+
<th scope="col">{{ ucwords(__('laravel-crm::lang.sent')) }}</th>
16+
<th scope="col"></th>
17+
</tr>
18+
</thead>
19+
<tbody>
20+
@foreach($invoices as $invoice)
21+
<tr @if(! $invoice->xeroInvoice) class="has-link" data-url="{{ url(route('laravel-crm.invoices.show', $invoice)) }}" @endif>
22+
<td>{{ $invoice->xeroInvoice->number ?? $invoice->invoice_id }}</td>
23+
<td>{{ $invoice->xeroInvoice->reference ?? $invoice->reference }}</td>
24+
<td>{{ $invoice->issue_date->format($dateFormat) }}</td>
25+
<td>{{ $invoice->due_date->format($dateFormat) }}</td>
26+
<td class="text-danger">
27+
@if(! $invoice->fully_paid_at && $invoice->due_date->diffinDays() > 0 && $invoice->due_date < \Carbon\Carbon::now()->timezone($timezone))
28+
{{ $invoice->due_date->diffForHumans(false, true) }}
29+
@endif
30+
</td>
31+
<td>{{ ($invoice->fully_paid_at) ? $invoice->fully_paid_at->format($dateFormat) : null }}</td>
32+
<td>{{ money($invoice->amount_paid, $invoice->currency) }}</td>
33+
<td>{{ money($invoice->amount_due, $invoice->currency) }}</td>
34+
<td>
35+
@if($invoice->sent == 1)
36+
<span class="text-success">Sent</span>
37+
@endif
38+
</td>
39+
<td>
40+
@if($invoice->xeroInvoice)
41+
<img src="/vendor/laravel-crm/img/xero-icon.png" height="30" />
42+
@endif
43+
</td>
44+
</tr>
45+
@endforeach
46+
</tbody>
47+
</table>
48+
49+
@endcomponent
50+
51+
@endcomponent
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
@component('laravel-crm::components.card')
2+
3+
@component('laravel-crm::components.card-table')
4+
5+
<table class="table mb-0 card-table table-hover">
6+
<thead>
7+
<tr>
8+
<th scope="col">{{ ucwords(__('laravel-crm::lang.created')) }}</th>
9+
<th scope="col">{{ ucwords(__('laravel-crm::lang.number')) }}</th>
10+
<th scope="col">{{ ucwords(__('laravel-crm::lang.reference')) }}</th>
11+
<th scope="col">{{ ucwords(__('laravel-crm::lang.sub_total')) }}</th>
12+
<th scope="col">{{ ucwords(__('laravel-crm::lang.discount')) }}</th>
13+
<th scope="col">{{ ucwords(__('laravel-crm::lang.tax')) }}</th>
14+
<th scope="col">{{ ucwords(__('laravel-crm::lang.adjustment')) }}</th>
15+
<th scope="col">{{ ucwords(__('laravel-crm::lang.total')) }}</th>
16+
</tr>
17+
</thead>
18+
<tbody>
19+
@foreach($orders as $order)
20+
<tr class="has-link" data-url="{{ url(route('laravel-crm.orders.show', $order)) }}">
21+
<td>{{ $order->created_at->diffForHumans() }}</td>
22+
<td>{{ $order->order_id }}</td>
23+
<td>{{ $order->reference }}</td>
24+
<td>
25+
@if(! \VentureDrake\LaravelCrm\Http\Helpers\CheckAmount\subTotal($order))
26+
<span data-toggle="tooltip" data-placement="top" title="Error with sub total" class="text-danger">
27+
{{ money($order->subtotal, $order->currency) }}
28+
</span>
29+
@else
30+
{{ money($order->subtotal, $order->currency) }}
31+
@endif
32+
</td>
33+
<td>{{ money($order->discount, $order->currency) }}</td>
34+
<td>{{ money($order->tax, $order->currency) }}</td>
35+
<td>{{ money($order->adjustments, $order->currency) }}</td>
36+
<td>
37+
@if(! \VentureDrake\LaravelCrm\Http\Helpers\CheckAmount\total($order))
38+
<span data-toggle="tooltip" data-placement="top" title="Error with total" class="text-danger">
39+
{{ money($order->total, $order->currency) }}
40+
</span>
41+
@else
42+
{{ money($order->total, $order->currency) }}
43+
@endif
44+
</td>
45+
</tr>
46+
@endforeach
47+
</tbody>
48+
</table>
49+
50+
@endcomponent
51+
52+
@endcomponent

resources/views/partials/activities.blade.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@
66
<li class="nav-item">
77
<a class="nav-link active" data-toggle="tab" id="tab-activities" href="#tabs-activities">{{ ucfirst(__('laravel-crm::lang.activity')) }}</a>
88
</li>
9+
@isset($orders)
10+
<li class="nav-item">
11+
<a class="nav-link" data-toggle="tab" id="tab-notes" href="#tabs-orders">{{ ucfirst(__('laravel-crm::lang.orders')) }}</a>
12+
</li>
13+
@endisset
14+
@isset($invoices)
15+
<li class="nav-item">
16+
<a class="nav-link" data-toggle="tab" id="tab-notes" href="#tabs-invoices">{{ ucfirst(__('laravel-crm::lang.invoices')) }}</a>
17+
</li>
18+
@endisset
19+
@isset($deliveries)
20+
<li class="nav-item">
21+
<a class="nav-link" data-toggle="tab" id="tab-notes" href="#tabs-deliveries">{{ ucfirst(__('laravel-crm::lang.deliveries')) }}</a>
22+
</li>
23+
@endisset
24+
<li class="nav-item">
25+
<a class="nav-link" data-toggle="tab" id="tab-notes" href="#tabs-notes">{{ ucfirst(__('laravel-crm::lang.notes')) }}</a>
26+
</li>
927
<li class="nav-item">
1028
<a class="nav-link" data-toggle="tab" id="tab-notes" href="#tabs-notes">{{ ucfirst(__('laravel-crm::lang.notes')) }}</a>
1129
</li>
@@ -33,6 +51,33 @@
3351
])
3452
</div>
3553
</div>
54+
@isset($orders)
55+
<div class="tab-pane fade" id="tabs-orders">
56+
<div class="card-body pl-0 pr-0">
57+
@include('laravel-crm::orders.partials.card-index-related',[
58+
'orders' => $orders
59+
])
60+
</div>
61+
</div>
62+
@endisset
63+
@isset($invoices)
64+
<div class="tab-pane fade" id="tabs-invoices">
65+
<div class="card-body pl-0 pr-0">
66+
@include('laravel-crm::invoices.partials.card-index-related',[
67+
'invoices' => $invoices
68+
])
69+
</div>
70+
</div>
71+
@endisset
72+
@isset($deliveries)
73+
<div class="tab-pane fade" id="tabs-deliveries">
74+
<div class="card-body pl-0 pr-0">
75+
@include('laravel-crm::deliveries.partials.card-index-related',[
76+
'deliveries' => $deliveries
77+
])
78+
</div>
79+
</div>
80+
@endisset
3681
<div class="tab-pane fade" id="tabs-notes">
3782
<div class="card-body pl-0 pr-0">
3883
@livewire('notes', [

resources/views/quotes/partials/card-show.blade.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
@can('view crm quotes')
3636
<a class="btn btn-outline-secondary btn-sm" href="{{ route('laravel-crm.quotes.download', $quote) }}">{{ ucfirst(__('laravel-crm::lang.download')) }}</a>
3737
@endcan
38-
@include('laravel-crm::partials.navs.activities') |
38+
@include('laravel-crm::partials.navs.activities', [
39+
'orders' => $orders
40+
]) |
3941
@can('edit crm quotes')
4042
@if(! $quote->accepted_at)
4143
<a href="{{ route('laravel-crm.quotes.edit',$quote) }}" class="btn btn-outline-secondary btn-sm"><span class="fa fa-edit" aria-hidden="true"></span></a>

src/Console/LaravelCrmUpdate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function handle()
113113
$this->info('Updating Laravel CRM split orders, invoices & deliveries...');
114114

115115
foreach(Order::whereNotNull('quote_id')->get() as $order) {
116-
if($order->quote){
116+
if($order->quote) {
117117
foreach($order->quote->quoteProducts as $quoteProduct) {
118118
if($orderProduct = $order->orderProducts()
119119
->whereNull('quote_product_id')
@@ -130,7 +130,7 @@ public function handle()
130130
}
131131

132132
foreach(Invoice::whereNotNull('order_id')->get() as $invoice) {
133-
if($invoice->order){
133+
if($invoice->order) {
134134
foreach($invoice->order->orderProducts as $orderProduct) {
135135
if($invoiceLine = $invoice->invoiceLines()
136136
->whereNull('order_product_id')

src/Http/Controllers/OrderController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ public function show(Order $order)
217217
'phone' => $phone ?? null,
218218
'organisation_address' => $address ?? null,
219219
'addresses' => $order->addresses,
220+
'invoices' => $order->invoices()->latest()->get(),
221+
'deliveries' => $order->deliveries()->latest()->get(),
220222
]);
221223
}
222224

src/Http/Controllers/QuoteController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function index(Request $request)
7171
}
7272

7373
return view('laravel-crm::quotes.index', [
74-
'quotes' => $quotes,
74+
'quotes' => $quotes
7575
]);
7676
}
7777

@@ -187,6 +187,7 @@ public function show(Quote $quote)
187187
'phone' => $phone ?? null,
188188
'address' => $address ?? null,
189189
'organisation_address' => $organisation_address ?? null,
190+
'orders' => $quote->orders()->latest()->get(),
190191
]);
191192
}
192193

src/Http/Middleware/SystemCheck.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function handle($request, Closure $next)
3939

4040
// Check if DB database required
4141
$dbUpdateRequired = false;
42-
42+
4343
if($setting = \VentureDrake\LaravelCrm\Models\Setting::where('name', 'db_update_0180')->first()) {
4444
if($setting->value == 0) {
4545
$dbUpdateRequired = true;
@@ -57,8 +57,8 @@ public function handle($request, Closure $next)
5757
$dbUpdateRequired = true;
5858
}
5959
}
60-
61-
if($dbUpdateRequired){
60+
61+
if($dbUpdateRequired) {
6262
flash('Your Laravel CRM software version requires some database updates to function correctly. Please <a href="https://github.com/venturedrake/laravel-crm#upgrading-from--02">update database</a>')->info()->important();
6363
}
6464
}

0 commit comments

Comments
 (0)