WIP Work on new Quotes

This commit is contained in:
Nisse Lommerde 2025-02-01 09:57:57 -08:00
parent 0b8fd00f67
commit 1a74442110
12 changed files with 275 additions and 44 deletions

1
.gitignore vendored
View File

@ -106,3 +106,4 @@ fabric.properties
.directory
.directory
.directory
public

View File

@ -6,6 +6,9 @@
use App\Models\Customer;
use App\Models\Quote;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Placeholder;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
@ -30,6 +33,8 @@ class QuoteResource extends Resource
public static function form(Form $form): Form
{
return $form
->schema([
Grid::make(3)
->schema([
Section::make([
Select::make('customer_id')
@ -41,12 +46,32 @@ public static function form(Form $form): Form
->columnSpan(1),
DatePicker::make('date')
->default(today())
->required(),
TextArea::make('notes')
->rows(3)
->columnSpan(2),
])
->columns(2),
->columns(2)
->columnSpan(2),
Section::make()
->schema([
Placeholder::make('Id')
->label('ID')
->content(fn (Quote $record): ?string => $record->id),
Placeholder::make('created_at')
->content(fn (Quote $record): ?string => $record->created_at?->diffForHumans().' at '.$record->created_at->format('Y-m-d')),
Placeholder::make('updated_at')
->content(fn (Quote $record): ?string => $record->updated_at?->diffForHumans().' at '.$record->updated_at->format('Y-m-d')),
])
->columnSpan(1)
->hidden(fn (?Quote $record) => $record === null),
]),
TableRepeater::make('embroideryEntries')
->relationship('embroideryEntries')
@ -65,10 +90,47 @@ public static function form(Form $form): Form
->prefix('$'),
TextInput::make('run_charge')
->prefix('$'),
]),
])
->addActionLabel('Add Embroidery Entry')
->defaultItems(0),
TableRepeater::make('screenPrintEntries')
Repeater::make('screenPrintEntries')
->relationship('screenPrintEntries')
->schema([
Grid::make(8)
->schema([
TextInput::make('logo')
->label('Logo name')
->columnSpan(2),
TextInput::make('quantity')
->prefix('#'),
TextInput::make('width')
->suffix('"'),
TextInput::make('height')
->suffix('"'),
TextInput::make('setup_number')
->prefix('#'),
TextInput::make('color_amount')
->prefix('#'),
TextInput::make('color_match')
->prefix('$'),
TextInput::make('flash')
->prefix('$'),
TextInput::make('fleece')
->prefix('$'),
TextInput::make('poly_ink')
->prefix('$'),
TextInput::make('run_charge')
->prefix('$'),
TextInput::make('other_charges')
->prefix('$'),
]),
])
->addActionLabel('Add Screen Print Entry')
->defaultItems(0),
TableRepeater::make('heatTransferEntries')
->relationship('heatTransferEntries')
->schema([
TextInput::make('logo')
->label('Logo name'),
@ -78,32 +140,11 @@ public static function form(Form $form): Form
->suffix('"'),
TextInput::make('height')
->suffix('"'),
TextInput::make('color_amount'),
TextInput::make('color_match')
->prefix('$'),
TextInput::make('flash')
->prefix('$'),
TextInput::make('fleece')
->prefix('$'),
TextInput::make('poly_ink')
->prefix('$'),
TextInput::make('other_charges'),
]),
TableRepeater::make('heatTransferEntries')
->relationship('heatTransferEntries')
->schema([
TextInput::make('logo')
->label('Logo name'),
TextInput::make('quantity')
->prefix('#'),
TextInput::make('Width')
->suffix('"'),
TextInput::make('Height')
->suffix('"'),
TextInput::make('price')
->prefix('$'),
]),
])
->addActionLabel('Add Heat Transfer Entry')
->defaultItems(0),
])->columns(1);
}
@ -111,6 +152,10 @@ public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('id')
->color('primary')
->searchable(),
TextColumn::make('date')
->date('Y-m-d')
->sortable()

View File

@ -3,7 +3,9 @@
namespace App\Filament\Admin\Resources\QuoteResource\Pages;
use App\Filament\Admin\Resources\QuoteResource;
use App\Models\Quote;
use Filament\Actions;
use Filament\Actions\Action;
use Filament\Resources\Pages\EditRecord;
class EditQuote extends EditRecord
@ -13,6 +15,16 @@ class EditQuote extends EditRecord
protected function getHeaderActions(): array
{
return [
Action::make('save')
->label('Save changes')
->action('save')
->icon('lucide-save'),
Action::make('print')
->icon('lucide-printer')
->url(fn (Quote $record) => route('pdf.quote', $record))
->openUrlInNewTab(),
Actions\DeleteAction::make(),
];
}

View File

@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Models\InvoiceReport;
use App\Models\Quote;
use Spatie\Browsershot\Browsershot;
use Spatie\LaravelPdf\Facades\Pdf;
@ -23,4 +24,22 @@ public function invoiceReport(int $id)
return redirect($url);
}
public function quote(int $id)
{
$quote = Quote::find($id);
$company_name = $quote->customer->company_name ?? '';
$url = strtolower('TN-quote-'.$quote->id.'.pdf');
Pdf::view('pdf.quote', ['quote' => $quote])
->withBrowsershot(function (Browsershot $browsershot) {
$browsershot->noSandbox();
})
->margins(8, 8, 15, 8)
->footerView('pdf.quote-footer', ['quote' => $quote])
->save($url);
return redirect($url);
}
}

View File

@ -14,7 +14,7 @@ class EmbroideryEntry extends Model
'width',
'height',
'placement',
'stitches',
'stitch_count',
'digitizing_cost',
'run_charge',
];

View File

@ -17,6 +17,10 @@ class Quote extends Model
'notes',
];
protected $casts = [
'date' => 'date',
];
public function customer(): BelongsTo
{
return $this->belongsTo(Customer::class);

View File

@ -21,7 +21,7 @@ public function up(): void
$table->decimal('width', 6, 2)->nullable();
$table->decimal('height', 6, 2)->nullable();
$table->string('placement')->nullable();
$table->string('stitches')->nullable();
$table->string('stitch_count')->nullable();
$table->string('digitizing_cost')->nullable();
$table->string('run_charge')->nullable();
$table->text('notes')->nullable();

View File

@ -26,7 +26,7 @@ public function run(): void
ServiceTypeSeeder::class,
ProductServiceSeeder::class,
ServiceFileSeeder::class,
QuoteSeeder::class,
// QuoteSeeder::class,
InvoiceSeeder::class,
InvoiceReportSeeder::class,
]);

View File

@ -0,0 +1,10 @@
<style>
* {
font-size: 12px;
margin: 10px 5px;
}
</style>
<footer>
{{$quote->id}}, page @pageNumber of @totalPages
</footer>'

View File

@ -0,0 +1,138 @@
@extends('layouts.pdf')
<style>
* {
font-size: 0.9rem;
}
</style>
<div class="container-fluid pt-4 font-serif" style="">
<div class="fw-bold">
TOP NOTCH EMBROIDERY & DIGITIZING LTD.
</div>
<div>
108-618 EAST KENT AVE. SOUTH <br>
VANCOUVER BC <br>
(604) 871-9991 <br>
info@sewtopnotch.com <br>
GST# 846025062RT0001 <br>
</div>
<div class="fs-3 fw-bold text-primary mt-2">
QUOTE
</div>
<div class="d-flex flex-row">
<div class="pe-4">
<div class="fw-bold">
DATE
</div>
<div>
{{ $quote->date->format('Y-m-d') }}
</div>
</div>
<div class="pe-4">
<div class="fw-bold">
CUSTOMER
</div>
<div>
{{ $quote->customer->company_name ?? '' }}
</div>
</div>
<div class="">
<div class="fw-bold">
NOTES
</div>
<div>
{{ $quote->notes ?? '' }}
</div>
</div>
</div>
<hr>
@if($quote->embroideryEntries()->count() != 0) <h3 class="h-3">Embroidery</h3> @endif
<table class="table table-sm table-striped">
<tr>
<th>Logo</th>
<th>Placement</th>
<th>Quantity</th>
<th>Width</th>
<th>Height</th>
<th>Stitch count</th>
<th>Digitizing</th>
<th>Run charge</th>
</tr>
@foreach($quote->embroideryEntries as $entry)
<tr>
<td>
{{ $entry->logo }}
</td>
<td>
{{ $entry->placement }}
</td>
<td>
{{ $entry->quantity }}
</td>
<td>
{{$entry->width}}"
</td>
<td>
{{$entry->height}}"
</td>
<td>
{{$entry->stitch_count}}
</td>
<td>
{{$entry->digitizing_cost}}
</td>
<td>
{{$entry->run_charge}}
</td>
</tr>
@endforeach
</table>
@if($quote->screenPrintEntries()->count() != 0) <h3 class="h-3">Screen Printing</h3> @endif
<table class="table table-sm table-striped">
<th>Logo</th>
<th>Quantity</th>
<th>Width</th>
<th>Height</th>
<th># of Colors</th>
<th>Color Match</th>
<th>Flash</th>
<th>Fleece</th>
<th>Poly Ink</th>
<th>Other charges</th>
</table>
{{-- <div class="d-flex flex-row-reverse">--}}
{{-- <div class="text-end ps-5">--}}
{{-- <div>${{number_format($invoice->subtotal, 2)}}</div>--}}
{{-- <div>${{number_format($invoice->gst_amount, 2)}}</div>--}}
{{-- <div>${{number_format($invoice->pst_amount, 2)}}</div>--}}
{{-- <div>${{number_format($invoice->total, 2)}}</div>--}}
{{-- <br>--}}
{{-- <div class="fw-bold">${{number_format($invoice->total, 2)}}</div>--}}
{{-- </div>--}}
{{-- <div class="fw-bold text-end">--}}
{{-- <div>Subtotal</div>--}}
{{-- <div>GST @ {{$invoice->gst_rate}}%</div>--}}
{{-- <div>PST (BC) @ {{$invoice->pst_rate}}%</div>--}}
{{-- <div>TOTAL</div>--}}
{{-- <br>--}}
{{-- <div>BALANCE DUE</div>--}}
{{-- </div>--}}
</div>
</div>

View File

@ -37,7 +37,7 @@
{{
$attributes
->merge($getExtraAttributes(), escape: false)
->class(['bg-white border border-gray-150 rounded-xl relative dark:bg-gray-900 dark:border-gray-800'])
->class(['bg-white border border-gray-150 rounded-xl relative dark:bg-gray-900 dark:border-gray-700'])
}}
>

View File

@ -19,6 +19,8 @@
// Auth::routes();
Route::get('/pdf/invoicereport/{id}', [PdfController::class, 'invoiceReport'])->name('pdf.invoice-report');
Route::get('/pdf/quote/{id}', [PdfController::class, 'quote'])->name('pdf.quote');
Route::get('orders/{order}/pdf', [OrderController::class, 'pdf'])->name('orders.pdf');
Route::get('invoices/{invoice}/pdf', [InvoiceController::class, 'pdf'])->name('invoice.pdf');
Route::get('customers/{customer}/pdf', [CustomerController::class, 'pdf'])->name('customer.pdf');