4 Commits

Author SHA1 Message Date
dhanabalan
cfe8ac3496 Added invoicemail ad productionmail report views pages and commands pages 2025-07-05 20:53:31 +05:30
dhanabalan
be79dcdc45 Added alertmailrule resource pages 2025-07-05 20:51:07 +05:30
dhanabalan
9398374f88 Added Alertmailrule model page 2025-07-05 20:50:26 +05:30
dhanabalan
43edf2ec5a Added alret mail rules migration file 2025-07-05 20:50:00 +05:30
15 changed files with 1094 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
<?php
namespace App\Console\Commands;
use App\Models\AlertMailRule;
use Illuminate\Console\Scheduling\Schedule;
class ScheduleList
{
public function schedule(Schedule $schedule): void
{
// Invoice Report Scheduling
$scheduleType = AlertMailRule::where('module', 'InvoiceValidation')
->where('rule_name', 'InvoiceMailAlert')
->value('schedule_type');
switch ($scheduleType) {
case 'Live':
$schedule->command('send:invoice-report')->everyMinute()->runInBackground();
break;
case 'Hourly':
$schedule->command('send:invoice-report')->hourly()->runInBackground();
break;
// case 'Daily':
// $schedule->command('send:invoice-report')->daily()->runInBackground(); //->dailyAt('07:59')
// break;
case 'Daily':
$schedule->command('send:invoice-report')->dailyAt('07:59')->runInBackground(); //->dailyAt('07:59')
break;
default:
$schedule->command('send:invoice-report')->hourly()->runInBackground();
break;
}
// Production Report Scheduling
$productionScheduleType = AlertMailRule::where('module', 'ProductionQuantities')
->where('rule_name', 'ProductionMailAlert')
->value('schedule_type');
switch ($productionScheduleType) {
case 'Live':
$schedule->command('send:production-report')->everyMinute()->runInBackground();
break;
case 'Hourly':
$schedule->command('send:production-report')->hourly()->runInBackground();
break;
case 'Daily':
$schedule->command('send:production-report')->dailyAt('07:59')->runInBackground();
break;
default:
$schedule->command('send:production-report')->hourly()->runInBackground();
break;
}
}
}

View File

@@ -0,0 +1,223 @@
<?php
namespace App\Console\Commands;
use App\Models\InvoiceValidation;
use App\Models\Plant;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
use App\Mail\test;
class SendInvoiceReport extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
// protected $signature = 'app:send-invoice-report';
protected $signature = 'send:invoice-report';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
// public function handle()
// {
// //
// }
// public function handle()
// {
// $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')
// ->where('rule_name', 'InvoiceMailAlert')
// ->get();
// $emails = $mailRules->pluck('email')->unique()->toArray();
// $plants = InvoiceValidation::select('plant_id')->distinct()->pluck('plant_id');
// $tableData = [];
// $no = 1;
// foreach ($plants as $plantId) {
// $plant = Plant::find($plantId);
// $plantName = $plant ? $plant->name : $plantId;
// $totalInvoice = InvoiceValidation::where('plant_id', $plantId)
// ->distinct('invoice_number')
// ->count('invoice_number');
// $startDate = now()->setTime(8, 0, 0);
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
// $scannedInvoice = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->whereNull('quantity')
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)")
// ->count();
// $tableData[] = [
// 'no' => $no++,
// 'plant' => $plantName,
// 'totalInvoice' => $totalInvoice,
// 'scannedInvoice' => $scannedInvoice,
// ];
// }
// // Mail::to('jothikumar.padmanaban@cripumps.com')->send(
// // new test($tableData)
// // );
// if (!empty($emails))
// {
// // Mail::to($emails)->send(new test($tableData));
// // $this->info('Invoice report email sent successfully to: ' . implode(', ', $emails));
// foreach ($emails as $email) {
// Mail::to($email)->send(new test($tableData));
// }
// }
// else
// {
// $this->info('No recipients found for InvoiceMailAlert.');
// }
// }
public function handle()
{
// Group emails by rule name
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
$startDate = now()->setTime(8, 0, 0);
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
$plants = InvoiceValidation::select('plant_id')->distinct()->pluck('plant_id');
// Build all tables once
$serialTableData = [];
$materialTableData = [];
$bundleTableData = [];
$noSerial = 1;
$noMaterial = 1;
$noBundle = 1;
foreach ($plants as $plantId) {
$plant = Plant::find($plantId);
$plantName = $plant ? $plant->name : $plantId;
//..Serial Invoice
$totalSerialCount = InvoiceValidation::where('plant_id', $plantId)
->whereNull('quantity')
->whereBetween('created_at', [$startDate, $endDate])
->distinct('invoice_number')
->count('invoice_number');
$scannedSerialCount = InvoiceValidation::select('invoice_number')
->where('plant_id', $plantId)
->whereNull('quantity')
->whereBetween('updated_at', [$startDate, $endDate])
->groupBy('invoice_number')
->havingRaw(
"COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
)
->count();
$serialTableData[] = [
'no' => $noSerial++,
'plant' => $plantName,
'totalInvoice' => $totalSerialCount,
'scannedInvoice' => $scannedSerialCount,
];
//..Individual Invoice
$TotalMatCount = InvoiceValidation::where('plant_id', $plantId)
->where('quantity', 1)
->whereBetween('created_at', [$startDate, $endDate])
->distinct('invoice_number')
->count('invoice_number');
$scannedMatCount = InvoiceValidation::select('invoice_number')
->where('plant_id', $plantId)
->where('quantity', 1)
->whereBetween('updated_at', [$startDate, $endDate])
->groupBy('invoice_number')
->havingRaw(
"COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
)
->count();
$materialTableData[] = [
'no' => $noMaterial++,
'plant' => $plantName,
'totalInvoice' => $TotalMatCount,
'scannedInvoice' => $scannedMatCount,
];
//..BUndle Invoice
$totalBundleCount = InvoiceValidation::where('plant_id', $plantId)
->where('quantity', '>', 1)
->whereBetween('created_at', [$startDate, $endDate])
->distinct('invoice_number')
->count('invoice_number');
$scannedBundleCount = InvoiceValidation::select('invoice_number')
->where('plant_id', $plantId)
->where('quantity', '>', 1)
->whereBetween('updated_at', [$startDate, $endDate])
->groupBy('invoice_number')
->havingRaw(
"COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
)
->count();
$bundleTableData[] = [
'no' => $noBundle++,
'plant' => $plantName,
'totalInvoice' => $totalBundleCount,
'scannedInvoice' => $scannedBundleCount,
];
}
// Send to SerialInvoiceMail recipients
if ($mailRules->has('SerialInvoiceMail')) {
$emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
foreach ($emails as $email) {
Mail::to($email)->send(new test($serialTableData, [], []));
}
}
// Send to MaterialInvoiceMail recipients (material + bundle table)
if ($mailRules->has('MaterialInvoiceMail')) {
$emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
foreach ($emails as $email) {
Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
}
}
// Send to InvoiceMail recipients (all three tables)
if ($mailRules->has('InvoiceMail')) {
$emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
foreach ($emails as $email) {
Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData));
}
}
//$this->info(json_encode($materialTableData));
}
}

View File

@@ -0,0 +1,133 @@
<?php
namespace App\Console\Commands;
use App\Models\InvoiceValidation;
use App\Models\Plant;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
use App\Mail\ProductionMail;
use App\Models\Line;
use App\Models\ProductionQuantity;
class SendProductionReport extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'send:production-report';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
public function handle()
{
$mailRules = \App\Models\AlertMailRule::where('module', 'ProductionQuantities')
->where('rule_name', 'ProductionMail')
->get();
$emails = $mailRules->pluck('email')->unique()->toArray();
$lines = Line::all();
$fgLineIds = [];
$nonFgLineIds = [];
$lineNames = [];
foreach ($lines as $line) {
$lineNames[$line->id] = $line->name;
if ($line->type == 'FG Line') {
$fgLineIds[] = $line->id;
} else {
$nonFgLineIds[] = $line->id;
}
}
// 2. Set date range
$startDate = now()->setTime(8, 0, 0);
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
// 3. Get all plants
$plants = ProductionQuantity::select('plant_id')->distinct()->pluck('plant_id');
// 4. Get production quantities for FG and non-FG lines in one go
// $fgProduction = ProductionQuantity::select('line_id', \DB::raw('COUNT(*) as total_quantity'))
// ->whereBetween('created_at', [$startDate, $endDate])
// ->whereIn('line_id', $fgLineIds)
// ->groupBy('line_id')
// ->pluck('total_quantity', 'line_id')
// ->toArray();
$nonFgProduction = ProductionQuantity::select('line_id', \DB::raw('COUNT(*) as total_quantity'))
->whereBetween('created_at', [$startDate, $endDate])
->whereIn('line_id', $nonFgLineIds)
->groupBy('line_id')
->pluck('total_quantity', 'line_id')
->toArray();
$tableData = [];
$no = 1;
foreach ($plants as $plantId)
{
$plant = Plant::find($plantId);
$plantName = $plant ? $plant->name : $plantId;
//Get all unique line_ids for this plant
$lineIds = ProductionQuantity::where('plant_id', $plantId)
->select('line_id')
->distinct()
->pluck('line_id');
foreach ($lineIds as $lineId) {
$lineName = $lineNames[$lineId] ?? $lineId;
$targetQuantity = \App\Models\ProductionPlan::where('plant_id', $plantId)
->where('line_id', $lineId)
->whereBetween('created_at', [$startDate, $endDate])
->sum('plan_quantity');
// Use the correct production quantity array based on line type
if (in_array($lineId, $nonFgLineIds))
{
$productionQuantity = $nonFgProduction[$lineId] ?? 0;
}
// else
// {
// $productionQuantity = $nonFgProduction[$lineId] ?? 0;
// }
$tableData[] = [
'no' => $no++,
'plant' => $plantName,
'line' => $lineName,
'targetQuantity' => $targetQuantity,
'productionQuantity' => $productionQuantity,
];
}
}
//$this->info(json_encode($tableData));
if (!empty($emails))
{
// Mail::to($emails)->send(new test($tableData));
// $this->info('Invoice report email sent successfully to: ' . implode(', ', $emails));
foreach ($emails as $email)
{
Mail::to($email)->send(new ProductionMail($tableData));
}
}
else
{
$this->info('No recipients found for InvoiceMailAlert.');
}
//$this->info(implode(', ', $emails));
}
}

View File

@@ -0,0 +1,146 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\AlertMailRuleResource\Pages;
use App\Filament\Resources\AlertMailRuleResource\RelationManagers;
use App\Models\AlertMailRule;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
class AlertMailRuleResource extends Resource
{
protected static ?string $model = AlertMailRule::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
public static function form(Form $form): Form
{
return $form
->schema([
Section::make('')
->schema([
Forms\Components\Select::make('module')
->label('Module')
->required()
->options([
'InvoiceValidation' => 'InvoiceValidation',
'QualityValidation' => 'QualityValidation',
'ProductionQuantities' => 'ProductionQuantities',
]),
Forms\Components\Select::make('rule_name')
->label('Rule Name')
->options([
'InvoiceMail' => 'Invoice Mail',
'SerialInvoiceMail' => 'Serial Invoice Mail',
'MaterialInvoiceMail' => 'Material Invoice Mail',
'ProductionMail' => 'Production Mail',
])
->required(),
Forms\Components\TextInput::make('email')
->label('Email')
->required(),
Forms\Components\Select::make('schedule_type')
->label('Schedule Type')
->required()
->options([
'Live' => 'Live',
'Hourly' => 'Hourly',
'Daily' => 'Daily',
]),
Forms\Components\Hidden::make('created_by')
->default(fn () => Filament::auth()->user()?->name),
Forms\Components\Hidden::make('updated_by')
->default(fn () => Filament::auth()->user()?->name),
])
->columns(4),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')
->label('ID')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('module')
->label('Module')
->sortable(),
Tables\Columns\TextColumn::make('rule_name')
->label('Rule Name')
->sortable(),
Tables\Columns\TextColumn::make('email')
->label('Email')
->sortable(),
Tables\Columns\TextColumn::make('schedule_type')
->label('Schedule Type')
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->sortable(),
Tables\Columns\TextColumn::make('updated_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_by')
->label('Updated By')
->sortable(),
Tables\Columns\TextColumn::make('deleted_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListAlertMailRules::route('/'),
'create' => Pages\CreateAlertMailRule::route('/create'),
'view' => Pages\ViewAlertMailRule::route('/{record}'),
'edit' => Pages\EditAlertMailRule::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Filament\Resources\AlertMailRuleResource\Pages;
use App\Filament\Resources\AlertMailRuleResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateAlertMailRule extends CreateRecord
{
protected static string $resource = AlertMailRuleResource::class;
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Filament\Resources\AlertMailRuleResource\Pages;
use App\Filament\Resources\AlertMailRuleResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditAlertMailRule extends EditRecord
{
protected static string $resource = AlertMailRuleResource::class;
protected function getHeaderActions(): array
{
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
Actions\ForceDeleteAction::make(),
Actions\RestoreAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\AlertMailRuleResource\Pages;
use App\Filament\Resources\AlertMailRuleResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListAlertMailRules extends ListRecords
{
protected static string $resource = AlertMailRuleResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\AlertMailRuleResource\Pages;
use App\Filament\Resources\AlertMailRuleResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;
class ViewAlertMailRule extends ViewRecord
{
protected static string $resource = AlertMailRuleResource::class;
protected function getHeaderActions(): array
{
return [
Actions\EditAction::make(),
];
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class ProductionMail extends Mailable
{
use Queueable, SerializesModels;
public $tableData;
/**
* Create a new message instance.
*/
public function __construct($tableData = [])
{
$this->tableData = $tableData ?? [];
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
return new Envelope(
subject: 'Production Mail',
);
}
/**
* Get the message content definition.
*/
public function content(): Content
{
return new Content(
view: 'mail.production_report',
with: [
'company' => "CRI Digital Manufacturing Solutions",
'greeting' => "Dear Sir/Madam,<br><br>Kindly find the attached production report status details for the 'Target Quantity' and 'Production Quantity' count,",
'tableData' => $this->tableData,
'wishes' => "Thanks & Regards,<br>CRI Digital Manufacturing Solutions"
],
);
}
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
public function attachments(): array
{
return [];
}
}

77
app/Mail/test.php Normal file
View File

@@ -0,0 +1,77 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class test extends Mailable
{
use Queueable, SerializesModels;
public $serialTableData;
public $materialTableData;
public $bundleTableData;
/**
* Create a new message instance.
*/
// public function __construct($tableData = [])
// {
// $this->tableData = $tableData ?? [];
// }
public function __construct($serialTableData, $materialTableData, $bundleTableData)
{
$this->serialTableData = $serialTableData;
$this->materialTableData = $materialTableData;
$this->bundleTableData = $bundleTableData;
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
return new Envelope(
subject: 'Invoice Table Report'
);
}
/**
* Get the message content definition.
*/
public function content(): Content
{
return new Content(
view: 'mail.test_mail',
// with: [
// 'name' => "CRI Digital Manufacturing Solutions<br><br>Dear Sir/Madam,<br><br> Kindly find the attached invoice status details for the 'Total Number Of Invoices' and 'Scanned Number Of Invoices' count,",
// 'tableData' => $this->tableData,
// 'wishes' => "Thanks & Regards<br><br>CRI Digital Manufacturing Solutions"
// ],
with: [
'company' => "CRI Digital Manufacturing Solutions",
'greeting' => "Dear Sir/Madam,<br><br>Kindly find the attached invoice status details for the 'Total Number of Invoices' and 'Scanned Number of Invoices' count,",
//'tableData' => $this->tableData,
'serialTableData' => $this->serialTableData,
'materialTableData' => $this->materialTableData,
'bundleTableData' => $this->bundleTableData,
'wishes' => "Thanks & Regards,<br>CRI Digital Manufacturing Solutions"
],
);
}
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
public function attachments(): array
{
return [];
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class AlertMailRule extends Model
{
use SoftDeletes;
protected $fillable = [
'module',
'rule_name',
'email',
'schedule_type',
'created_at',
'updated_at',
'created_by',
'updated_by',
];
public function plant(): BelongsTo
{
return $this->belongsTo(Plant::class);
}
}

View File

@@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$sql = <<<'SQL'
CREATE TABLE alert_mail_rules (
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
module TEXT NOT NULL,
rule_name TEXT NOT NULL,
email TEXT NOT NULL,
schedule_type TEXT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
deleted_at TIMESTAMP,
created_by TEXT NOT NULL,
updated_by TEXT NOT NULL
);
SQL;
DB::statement($sql);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('alert_mail_rules');
}
};

View File

@@ -0,0 +1,82 @@
<!DOCTYPE html>
<html>
<head>
<title>Invoice Table</title>
<style>
table {
border-collapse: collapse;
width: 60%;
}
th, td {
border: 1px solid #444;
padding: 8px;
text-align: left;
}
th {
background: #f2f2f2;
}
</style>
</head>
<body>
{{-- <h5>{{ $name }}</h5> --}}
{{-- <h5>{!! $name !!}</h5> --}}
<div style="text-align: center; font-weight: bold;">
{{ $company }}
</div>
<br>
<p>{!! $greeting !!}</p>
{{-- <table>
<thead>
<tr>
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">No</th>
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Plant</th>
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Line</th>
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Target Quantity</th>
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Production Quantity</th>
</tr>
</thead>
<tbody>
@foreach($tableData as $row)
{{-- <tr>
<td>{{ $row['no'] }}</td>
<td>{{ $row['plant'] }}</td>
<td>{{ $row['totalInvoice'] }}</td>
<td>{{ $row['scannedInvoice'] }}</td>
</tr> --}}
{{-- <tr>
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['no'] }}</td>
<td style="border: 1px solid #444; padding: 8px; text-align: center; white-space: nowrap;">{{ $row['plant'] }}</td>
<td style="border: 1px solid #444; padding: 8px; text-align: center; white-space: nowrap;">{{ $row['line'] }}</td>
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['targetQuantity'] }}</td>
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['productionQuantity'] }}</td> --}}
{{-- <td style="border: 1px solid #444; padding: 8px; text-align: center;"></td> --}}
{{-- </tr>
@endforeach
</tbody>
</table> --}}
<table style="table-layout: auto; width: 100%; border-collapse: collapse;">
<thead>
<tr>
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">No</th>
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2; white-space: nowrap;">Plant</th>
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2; white-space: nowrap;">Line</th>
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Target Quantity</th>
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Production Quantity</th>
</tr>
</thead>
<tbody>
@foreach($tableData as $row)
<tr>
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['no'] }}</td>
<td style="border: 1px solid #444; padding: 8px; text-align: center; white-space: nowrap;">{{ $row['plant'] }}</td>
<td style="border: 1px solid #444; padding: 8px; text-align: center; white-space: nowrap;">{{ $row['line'] }}</td>
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['targetQuantity'] }}</td>
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['productionQuantity'] }}</td>
</tr>
@endforeach
</tbody>
</table>
<p>{!! $wishes !!}</p>
</body>
</html>

View File

@@ -0,0 +1,169 @@
{{-- {{ $name }} --}}
{{-- <!DOCTYPE html>
<html>
<head>
<title>Invoice Table</title>
<style>
table {
border-collapse: collapse;
width: 60%;
}
th, td {
border: 1px solid #444;
padding: 8px;
text-align: left;
}
th {
background: #f2f2f2;
}
</style>
</head>
<body>
{{-- <h5>{{ $name }}</h5> --}}
{{-- <h5>{!! $name !!}</h5> --}}
{{-- <div style="text-align: center; font-weight: bold;">
{{ $company }}
</div>
<br>
<h5>{!! $greeting !!}</h5>
<table>
<thead>
<tr>
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">No</th>
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Plant</th>
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Total Number Of Invoice</th>
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Scanned Number Of Invoice</th>
</tr>
</thead>
<tbody>
@foreach($tableData as $row) --}}
{{-- <tr>
<td>{{ $row['no'] }}</td>
<td>{{ $row['plant'] }}</td>
<td>{{ $row['totalInvoice'] }}</td>
<td>{{ $row['scannedInvoice'] }}</td>
</tr> --}}
{{-- <tr>
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['no'] }}</td>
<td style="border: 1px solid #444; padding: 8px; text-align: center; white-space: nowrap;">{{ $row['plant'] }}</td>
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['totalInvoice'] }}</td>
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['scannedInvoice'] }}</td>
</tr>
@endforeach
</tbody>
</table>
<h5>{!! $wishes !!}</h5>
</body>
</html> --}}
<!DOCTYPE html>
<html>
<head>
<title>Invoice Tables</title>
<style>
table {
border-collapse: collapse;
width: 60%;
margin-bottom: 24px;
}
th, td {
border: 1px solid #444;
padding: 8px;
text-align: center;
}
th {
background: #f2f2f2;
}
h4 {
margin-bottom: 8px;
}
</style>
</head>
<body>
<div style="text-align: center; font-weight: bold;">
{{ $company }}
</div>
<br>
<p>{!! $greeting !!}</p>
{{-- Serial Invoice Table --}}
@if(!empty($serialTableData))
<h4>Serial Invoice</h4>
<table>
<thead>
<tr>
<th>No</th>
<th>Plant</th>
<th>Total Number of Invoice</th>
<th>Scanned Number of Invoice</th>
</tr>
</thead>
<tbody>
@foreach($serialTableData as $row)
<tr>
<td>{{ $row['no'] }}</td>
<td style="white-space: nowrap;">{{ $row['plant'] }}</td>
<td>{{ $row['totalInvoice'] }}</td>
<td>{{ $row['scannedInvoice'] }}</td>
</tr>
@endforeach
</tbody>
</table>
@endif
{{-- Material Invoice Table --}}
@if(!empty($materialTableData))
<h4>Material Invoice</h4>
<table>
<thead>
<tr>
<th>No</th>
<th>Plant</th>
<th>Total Number of Invoice</th>
<th>Scanned Number of Invoice</th>
</tr>
</thead>
<tbody>
@foreach($materialTableData as $row)
<tr>
<td>{{ $row['no'] }}</td>
<td style="white-space: nowrap;">{{ $row['plant'] }}</td>
<td>{{ $row['totalInvoice'] }}</td>
<td>{{ $row['scannedInvoice'] }}</td>
</tr>
@endforeach
</tbody>
</table>
@endif
{{-- Bundle Invoice Table --}}
@if(!empty($bundleTableData))
<h4>Bundle Invoice</h4>
<table>
<thead>
<tr>
<th>No</th>
<th>Plant</th>
<th>Total Number of Invoice</th>
<th>Scanned Number of Invoice</th>
</tr>
</thead>
<tbody>
@foreach($bundleTableData as $row)
<tr>
<td>{{ $row['no'] }}</td>
<td style="white-space: nowrap;">{{ $row['plant'] }}</td>
<td>{{ $row['totalInvoice'] }}</td>
<td>{{ $row['scannedInvoice'] }}</td>
</tr>
@endforeach
</tbody>
</table>
@endif
<p>{!! $wishes !!}</p>
</body>
</html>

View File

@@ -1,8 +1,13 @@
<?php
use App\Models\AlertMailRule;
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');
Schedule::command('send:invoice-report');
Schedule::command('send:production-report');