Compare commits
111 Commits
da8b2a00fb
...
ranjith-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a1fb39068 | ||
|
|
33635fd9af | ||
|
|
10e493ca51 | ||
|
|
85f1a84321 | ||
|
|
994591da54 | ||
|
|
7aaca611dc | ||
|
|
251ef26c41 | ||
|
|
ebf5e60a00 | ||
|
|
37eed0640f | ||
|
|
143fe85b2e | ||
|
|
bb8000d177 | ||
|
|
2d4f6d8069 | ||
|
|
219279c641 | ||
|
|
2fb7ed7895 | ||
|
|
b4ef782067 | ||
|
|
dc028c91bb | ||
|
|
a42f7c1fae | ||
|
|
ec0fe66874 | ||
|
|
a6ec37fd3d | ||
|
|
f4bfc5c4dc | ||
|
|
2a83033541 | ||
|
|
f8dc95054b | ||
|
|
017f57878d | ||
|
|
561e0b448f | ||
|
|
8eb0985128 | ||
|
|
245c9e1782 | ||
|
|
b8fe29644e | ||
|
|
e09a362c96 | ||
|
|
7d84624843 | ||
|
|
b6519e3bbf | ||
|
|
bceba8db5f | ||
|
|
dd1a884b22 | ||
|
|
5b333621fe | ||
|
|
b52fd57c23 | ||
|
|
6bac832d1f | ||
|
|
8dbdcf4f35 | ||
|
|
115cc912c7 | ||
|
|
544e593d19 | ||
|
|
246b8715ca | ||
|
|
cd3598d67e | ||
|
|
3b9d94552b | ||
|
|
ba55567aed | ||
|
|
d32408bebd | ||
|
|
854330caf2 | ||
|
|
4309003fbd | ||
|
|
c500759f52 | ||
|
|
0a07e4b6e6 | ||
|
|
21b40b499a | ||
|
|
447c0a73a0 | ||
|
|
2431f73571 | ||
|
|
62259d4afe | ||
|
|
ec831f0fb9 | ||
|
|
e09f6582e9 | ||
|
|
7e543b30c3 | ||
|
|
8b9901c27d | ||
|
|
adfce88a3e | ||
|
|
fb12e2fb48 | ||
|
|
52cee81573 | ||
|
|
0bd910c6d0 | ||
|
|
a74aa3bde5 | ||
|
|
6f93f2bd92 | ||
|
|
d19b8120e2 | ||
|
|
8fb42203c3 | ||
|
|
bb2f5082b1 | ||
|
|
3215cd39ad | ||
|
|
7755d15741 | ||
|
|
4586fc0d60 | ||
|
|
65fc5202a4 | ||
|
|
770f0c9af3 | ||
|
|
47a0cf31d2 | ||
|
|
e5f23303d9 | ||
|
|
b9e164725e | ||
|
|
4699de9a77 | ||
|
|
196117f07f | ||
|
|
84b617f8fb | ||
|
|
9f6959784f | ||
|
|
bbdd9fb75c | ||
|
|
cc788ea6d4 | ||
|
|
8c0af96b94 | ||
|
|
b02954d0a2 | ||
|
|
9b098864bc | ||
|
|
50f542c3d1 | ||
|
|
dfb48055ea | ||
|
|
881e2fa6d9 | ||
|
|
3a7104513c | ||
|
|
25cfaa6479 | ||
|
|
b7e8182309 | ||
|
|
bce19056c7 | ||
|
|
8e2a0e79dc | ||
|
|
63c1cc14b2 | ||
|
|
1ddd27433c | ||
|
|
80d7258ae0 | ||
|
|
f10b4daddf | ||
|
|
b183a1d350 | ||
|
|
dd57d14f79 | ||
|
|
71e89c7927 | ||
|
|
a230208718 | ||
|
|
e27871d0c0 | ||
|
|
b188714b06 | ||
|
|
9bb6e05589 | ||
|
|
6cb33879f5 | ||
|
|
27164556ee | ||
|
|
b70d078ca9 | ||
|
|
2f36fe7270 | ||
|
|
bc874e23d2 | ||
|
|
fcd7d1ccc1 | ||
|
|
b409a021c4 | ||
|
|
48e6732257 | ||
|
|
653026a36d | ||
|
|
7a423d0f62 | ||
|
|
a6d3add1ac |
@@ -40,6 +40,7 @@ class Scheduler extends Command
|
|||||||
{
|
{
|
||||||
|
|
||||||
$this->call('approval:trigger-mails');
|
$this->call('approval:trigger-mails');
|
||||||
|
// $this->call('sftp:process-files');
|
||||||
|
|
||||||
// --- Production Rules ---
|
// --- Production Rules ---
|
||||||
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
||||||
@@ -234,6 +235,89 @@ class Scheduler extends Command
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ImportTransitRules = AlertMailRule::where('module', 'ImportTransit')
|
||||||
|
->where('rule_name', 'ImportTransitMail')
|
||||||
|
->select('plant', 'schedule_type')
|
||||||
|
->distinct()
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($ImportTransitRules as $rule) {
|
||||||
|
|
||||||
|
switch ($rule->schedule_type) {
|
||||||
|
case 'Live':
|
||||||
|
// Run every minute
|
||||||
|
\Artisan::call('send-import-transit', [
|
||||||
|
'schedule_type' => $rule->schedule_type,
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
case 'Hourly':
|
||||||
|
if (now()->minute == 0) {
|
||||||
|
\Artisan::call('send-import-transit', [
|
||||||
|
'schedule_type' => $rule->schedule_type,
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'Daily':
|
||||||
|
if (now()->format('H:i') == '11:10') {
|
||||||
|
try {
|
||||||
|
\Artisan::call('send-import-transit', [
|
||||||
|
'schedule_type' => $rule->schedule_type,
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Log::info('Invoice Transit executed', [
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
'type' => $rule->schedule_type,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
catch (\Throwable $e) {
|
||||||
|
Log::error('Invoice Transit FAILED', [
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
'trace' => $e->getTraceAsString(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$vehicleReports = AlertMailRule::where('module', 'VehicleReport')
|
||||||
|
->where('rule_name', 'VehicleReportMail')
|
||||||
|
->select('plant', 'schedule_type')
|
||||||
|
->distinct()
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($vehicleReports as $rule) {
|
||||||
|
switch ($rule->schedule_type) {
|
||||||
|
case 'Live':
|
||||||
|
// Run every minute
|
||||||
|
\Artisan::call('send:vehicle-report', [
|
||||||
|
'schedule_type' => $rule->schedule_type,
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
case 'Hourly':
|
||||||
|
if (now()->minute == 0) {
|
||||||
|
\Artisan::call('send:vehicle-report', [
|
||||||
|
'schedule_type' => $rule->schedule_type,
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'Daily':
|
||||||
|
if (now()->format('H:i') == '07:59') {
|
||||||
|
\Artisan::call('send:vehicle-report', [
|
||||||
|
'schedule_type' => $rule->schedule_type,
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
138
app/Console/Commands/SendImportTransit.php
Normal file
138
app/Console/Commands/SendImportTransit.php
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Mail\ImportTransitMail;
|
||||||
|
use App\Models\AlertMailRule;
|
||||||
|
use App\Models\ImportTransit;
|
||||||
|
use App\Models\Plant;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class SendImportTransit extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'send-import-transit {schedule_type} {plant}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Command description';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
|
||||||
|
$scheduleType = $this->argument('schedule_type');
|
||||||
|
$plantId = (int) $this->argument('plant');
|
||||||
|
|
||||||
|
$mailRules = AlertMailRule::where('module', 'ImportTransit')
|
||||||
|
->where('rule_name', 'ImportTransitMail')
|
||||||
|
->where('schedule_type', $scheduleType)
|
||||||
|
->where('plant', $plantId)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$plants = ($plantId == 0)
|
||||||
|
? Plant::all()
|
||||||
|
: Plant::where('id', $plantId)->get();
|
||||||
|
|
||||||
|
$plantCodes = $plants->pluck('name', 'id');
|
||||||
|
|
||||||
|
if ($plants->isEmpty()) {
|
||||||
|
$this->error('No valid plant(s) found.');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $todayRecordExists = ImportTransit::whereDate('created_at', now()->toDateString())->first();
|
||||||
|
|
||||||
|
// if (!$todayRecordExists) {
|
||||||
|
// $this->info('No records created today. Mail not sent.');
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
$tableData = ImportTransit::select([
|
||||||
|
'cri_rfq_number',
|
||||||
|
'mail_received_date',
|
||||||
|
'pricol_ref_number',
|
||||||
|
'requester',
|
||||||
|
'shipper',
|
||||||
|
'shipper_location',
|
||||||
|
'shipper_invoice',
|
||||||
|
'shipper_invoice_date',
|
||||||
|
'customs_agent_name',
|
||||||
|
'eta_date',
|
||||||
|
'status',
|
||||||
|
'delivery_location',
|
||||||
|
'etd_date',
|
||||||
|
'mode',
|
||||||
|
'inco_terms',
|
||||||
|
'port_of_loading',
|
||||||
|
'port_of_discharge',
|
||||||
|
'delivery_city',
|
||||||
|
'packages',
|
||||||
|
'type_of_package',
|
||||||
|
'gross_weight',
|
||||||
|
'volume',
|
||||||
|
'bill_number',
|
||||||
|
'bill_received_date',
|
||||||
|
'vessel_number',
|
||||||
|
])
|
||||||
|
->where('status', '!=', 'Delivered')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if ($tableData->isEmpty()) {
|
||||||
|
$this->info('No pending Import Transit records found. Mail skipped.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strtolower($scheduleType) == 'daily')
|
||||||
|
{
|
||||||
|
foreach ($mailRules as $rule) {
|
||||||
|
|
||||||
|
$mailSubject = 'Daily Import Transit Report';
|
||||||
|
|
||||||
|
$mail = new ImportTransitMail(
|
||||||
|
$scheduleType,
|
||||||
|
$tableData,
|
||||||
|
$mailSubject
|
||||||
|
);
|
||||||
|
|
||||||
|
$toEmails = collect(explode(',', $rule->email))
|
||||||
|
->map(fn ($e) => trim($e))
|
||||||
|
->filter()
|
||||||
|
->unique()
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$ccEmails = collect(explode(',', $rule->cc_emails))
|
||||||
|
->map(fn ($e) => trim($e))
|
||||||
|
->filter()
|
||||||
|
->unique()
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
if (empty($toEmails)) {
|
||||||
|
$this->warn("Skipping rule {$rule->id} — no To emails.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
\Mail::to($toEmails)
|
||||||
|
->cc($ccEmails)
|
||||||
|
->send($mail);
|
||||||
|
|
||||||
|
$this->info(
|
||||||
|
"Mail sent → Rule {$rule->id} | To: " . implode(', ', $toEmails)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,6 +34,8 @@ class SendInvoiceReport extends Command
|
|||||||
// $scheduleType = $this->argument('scheduleType');
|
// $scheduleType = $this->argument('scheduleType');
|
||||||
$plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants
|
$plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants
|
||||||
|
|
||||||
|
// $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||||
|
|
||||||
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||||
|
|
||||||
// $startDate = now()->setTime(8, 0, 0);
|
// $startDate = now()->setTime(8, 0, 0);
|
||||||
@@ -91,6 +93,7 @@ class SendInvoiceReport extends Command
|
|||||||
|
|
||||||
$serialTableData[] = [
|
$serialTableData[] = [
|
||||||
'no' => $no,
|
'no' => $no,
|
||||||
|
'plant_id' => $plantId,
|
||||||
'plant' => $plantName,
|
'plant' => $plantName,
|
||||||
'totalInvoice' => $totalSerialCount,
|
'totalInvoice' => $totalSerialCount,
|
||||||
'scannedInvoice' => $scannedSerialCount,
|
'scannedInvoice' => $scannedSerialCount,
|
||||||
@@ -127,6 +130,7 @@ class SendInvoiceReport extends Command
|
|||||||
|
|
||||||
$materialTableData[] = [
|
$materialTableData[] = [
|
||||||
'no' => $no,
|
'no' => $no,
|
||||||
|
'plant_id' => $plantId,
|
||||||
'plant' => $plantName,
|
'plant' => $plantName,
|
||||||
'totalInvoice' => $totalMatCount,
|
'totalInvoice' => $totalMatCount,
|
||||||
'scannedInvoice' => $scannedMatCount,
|
'scannedInvoice' => $scannedMatCount,
|
||||||
@@ -163,6 +167,7 @@ class SendInvoiceReport extends Command
|
|||||||
|
|
||||||
$bundleTableData[] = [
|
$bundleTableData[] = [
|
||||||
'no' => $no,
|
'no' => $no,
|
||||||
|
'plant_id' => $plantId,
|
||||||
'plant' => $plantName,
|
'plant' => $plantName,
|
||||||
'totalInvoice' => $totalBundleCount,
|
'totalInvoice' => $totalBundleCount,
|
||||||
'scannedInvoice' => $scannedBundleCount,
|
'scannedInvoice' => $scannedBundleCount,
|
||||||
@@ -206,7 +211,26 @@ class SendInvoiceReport extends Command
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
\Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, [], [], $schedule));
|
if ($rule->plant == 0) {
|
||||||
|
$filteredSerialData = $serialTableData;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$filteredSerialData = collect($serialTableData)
|
||||||
|
->where('plant_id', $rule->plant)
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
\Mail::to($toEmails)
|
||||||
|
->cc($ccEmails)
|
||||||
|
->send(new test(
|
||||||
|
$filteredSerialData,
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
$schedule
|
||||||
|
));
|
||||||
|
|
||||||
|
// \Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, [], [], $schedule));
|
||||||
|
|
||||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||||
}
|
}
|
||||||
@@ -240,7 +264,35 @@ class SendInvoiceReport extends Command
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
\Mail::to($toEmails)->cc($ccEmails)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
// FILTER DATA
|
||||||
|
if ($rule->plant == 0) {
|
||||||
|
|
||||||
|
$filteredMaterialData = $materialTableData;
|
||||||
|
$filteredBundleData = $bundleTableData;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$filteredMaterialData = collect($materialTableData)
|
||||||
|
->where('plant_id', $rule->plant)
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$filteredBundleData = collect($bundleTableData)
|
||||||
|
->where('plant_id', $rule->plant)
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
\Mail::to($toEmails)
|
||||||
|
->cc($ccEmails)
|
||||||
|
->send(new test(
|
||||||
|
[],
|
||||||
|
$filteredMaterialData,
|
||||||
|
$filteredBundleData,
|
||||||
|
$schedule
|
||||||
|
));
|
||||||
|
|
||||||
|
// \Mail::to($toEmails)->cc($ccEmails)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
||||||
|
|
||||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||||
}
|
}
|
||||||
@@ -275,7 +327,51 @@ class SendInvoiceReport extends Command
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
\Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
// FILTER DATA
|
||||||
|
if ($rule->plant == 0) {
|
||||||
|
|
||||||
|
$filteredSerialData = $serialTableData;
|
||||||
|
$filteredMaterialData = $materialTableData;
|
||||||
|
$filteredBundleData = $bundleTableData;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$filteredSerialData = collect($serialTableData)
|
||||||
|
->where('plant_id', $rule->plant)
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$filteredMaterialData = collect($materialTableData)
|
||||||
|
->where('plant_id', $rule->plant)
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$filteredBundleData = collect($bundleTableData)
|
||||||
|
->where('plant_id', $rule->plant)
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent empty mails
|
||||||
|
if (
|
||||||
|
empty($filteredSerialData) &&
|
||||||
|
empty($filteredMaterialData) &&
|
||||||
|
empty($filteredBundleData)
|
||||||
|
) {
|
||||||
|
$this->warn("Skipping empty mail for rule {$rule->id}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
\Mail::to($toEmails)
|
||||||
|
->cc($ccEmails)
|
||||||
|
->send(new test(
|
||||||
|
$filteredSerialData,
|
||||||
|
$filteredMaterialData,
|
||||||
|
$filteredBundleData,
|
||||||
|
$schedule
|
||||||
|
));
|
||||||
|
|
||||||
|
// \Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
||||||
|
|
||||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||||
}
|
}
|
||||||
|
|||||||
134
app/Console/Commands/SendVehicleReport.php
Normal file
134
app/Console/Commands/SendVehicleReport.php
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Mail\VehicleEntryMail;
|
||||||
|
use App\Models\AlertMailRule;
|
||||||
|
use App\Models\Plant;
|
||||||
|
use App\Models\VehicleEntry;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Mail;
|
||||||
|
|
||||||
|
class SendVehicleReport extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'send:vehicle-report {schedule_type} {plant}';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Command description';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
|
||||||
|
$scheduleType = $this->argument('schedule_type');
|
||||||
|
$plantId = (int) $this->argument('plant');
|
||||||
|
|
||||||
|
$mailRules = AlertMailRule::where('module', 'VehicleReport')
|
||||||
|
->where('rule_name', 'VehicleReportMail')
|
||||||
|
->where('schedule_type', $scheduleType)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$plants = ($plantId == 0)
|
||||||
|
? Plant::all()
|
||||||
|
: Plant::where('id', $plantId)->get();
|
||||||
|
|
||||||
|
if ($plants->isEmpty()) {
|
||||||
|
$this->error('No valid plant(s) found.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strtolower($scheduleType) == 'daily') {
|
||||||
|
$startDate = now()->subDay()->setTime(8, 0, 0);
|
||||||
|
$endDate = now()->setTime(8, 0, 0);
|
||||||
|
} else {
|
||||||
|
$startDate = now()->setTime(8, 0, 0);
|
||||||
|
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($plants as $plant) {
|
||||||
|
|
||||||
|
$vehicleEntries = VehicleEntry::select([
|
||||||
|
'vehicle_number',
|
||||||
|
'boom_opened',
|
||||||
|
'entry_time',
|
||||||
|
'exit_time',
|
||||||
|
'duration',
|
||||||
|
'type',
|
||||||
|
])
|
||||||
|
->where('plant_id', $plant->id)
|
||||||
|
->whereBetween('created_at', [$startDate, $endDate])
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if ($vehicleEntries->isEmpty()) {
|
||||||
|
$this->warn("No records for {$plant->name}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tableData = [];
|
||||||
|
$no = 1;
|
||||||
|
|
||||||
|
foreach ($vehicleEntries as $vehicleEntry) {
|
||||||
|
$tableData[] = [
|
||||||
|
'no' => $no++,
|
||||||
|
'plant' => $plant->name,
|
||||||
|
'vehicleNumber' => strtoupper($vehicleEntry->vehicle_number),
|
||||||
|
'entryTime' => $vehicleEntry->entry_time,
|
||||||
|
'exitTime' => $vehicleEntry->exit_time,
|
||||||
|
'duration' => $vehicleEntry->duration,
|
||||||
|
'type' => $vehicleEntry->type,
|
||||||
|
'boom' => $vehicleEntry->boom_opened,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($plantId == 0) {
|
||||||
|
$rule = $mailRules->first();
|
||||||
|
} else {
|
||||||
|
$rule = $mailRules->where('plant', $plant->id)->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$rule) {
|
||||||
|
$this->warn("No mail rule for {$plant->name}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$toEmails = collect(explode(',', $rule->email))
|
||||||
|
->map(fn($e) => trim($e))
|
||||||
|
->filter()
|
||||||
|
->unique()
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$ccEmails = collect(explode(',', $rule->cc_emails))
|
||||||
|
->map(fn($e) => trim($e))
|
||||||
|
->filter()
|
||||||
|
->unique()
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$mail = new VehicleEntryMail(
|
||||||
|
$scheduleType,
|
||||||
|
$tableData,
|
||||||
|
'Daily Vehicle Transit Report'
|
||||||
|
);
|
||||||
|
|
||||||
|
Mail::to($toEmails)->cc($ccEmails)->send($mail);
|
||||||
|
|
||||||
|
$this->info("Mail sent for {$plant->name}");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,9 +5,12 @@ namespace App\Console\Commands;
|
|||||||
use App\Mail\CharacteristicApprovalMail;
|
use App\Mail\CharacteristicApprovalMail;
|
||||||
use App\Models\CharacteristicApproverMaster;
|
use App\Models\CharacteristicApproverMaster;
|
||||||
use App\Models\RequestCharacteristic;
|
use App\Models\RequestCharacteristic;
|
||||||
|
use App\Models\TempClassCharacteristic;
|
||||||
|
// use App\Models\TempClassCharacteristic;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class TriggerPendingApprovalMails extends Command
|
class TriggerPendingApprovalMails extends Command
|
||||||
{
|
{
|
||||||
@@ -40,6 +43,8 @@ class TriggerPendingApprovalMails extends Command
|
|||||||
|
|
||||||
public $subjectLine;
|
public $subjectLine;
|
||||||
|
|
||||||
|
// public $tempCharacteristics = [];
|
||||||
|
|
||||||
public $wfId;
|
public $wfId;
|
||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
@@ -195,6 +200,38 @@ class TriggerPendingApprovalMails extends Command
|
|||||||
$updateData['mail_status'] = 'Sent-Mail3';
|
$updateData['mail_status'] = 'Sent-Mail3';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$totalMinutes =
|
||||||
|
$this->convertToMinutes($approver->duration1 ?? 0) +
|
||||||
|
$this->convertToMinutes($approver->duration2 ?? 0) +
|
||||||
|
$this->convertToMinutes($approver->duration3 ?? 0);
|
||||||
|
|
||||||
|
$expiryTime = Carbon::parse($first->created_at)
|
||||||
|
->copy()
|
||||||
|
->addMinutes($totalMinutes);
|
||||||
|
|
||||||
|
$ids = $groupRecords->pluck('id');
|
||||||
|
|
||||||
|
$this->info("Expiry Time for ID {$first->id}: {$expiryTime}, Now: {$now}");
|
||||||
|
|
||||||
|
// --- AUTO REJECT ---
|
||||||
|
if (
|
||||||
|
$first->mail_status == 'Sent-Mail3' &&
|
||||||
|
(is_null($first->approver_status1) || $first->approver_status1 == 'Hold') &&
|
||||||
|
(is_null($first->approver_status2) || $first->approver_status2 == 'Hold') &&
|
||||||
|
(is_null($first->approver_status3) || $first->approver_status3 == 'Hold') &&
|
||||||
|
$now->gte($expiryTime)
|
||||||
|
) {
|
||||||
|
RequestCharacteristic::whereIn('id', $ids)
|
||||||
|
->update([
|
||||||
|
'approver_status3' => 'Rejected',
|
||||||
|
'approver_remark3' => 'Time Limit Reached',
|
||||||
|
'approved3_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->info("Auto Rejected ID: {$first->id}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$level || !$mail) {
|
if (!$level || !$mail) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -203,6 +240,8 @@ class TriggerPendingApprovalMails extends Command
|
|||||||
|
|
||||||
$subjectLine = 'Characteristic Approval Mail';
|
$subjectLine = 'Characteristic Approval Mail';
|
||||||
|
|
||||||
|
// $emails = array_map('trim', explode(',', $mail));
|
||||||
|
|
||||||
Mail::to($mail)->send(
|
Mail::to($mail)->send(
|
||||||
new CharacteristicApprovalMail(
|
new CharacteristicApprovalMail(
|
||||||
$first,
|
$first,
|
||||||
@@ -251,6 +290,23 @@ class TriggerPendingApprovalMails extends Command
|
|||||||
return $approver && $approver->approver_type == 'Quality';
|
return $approver && $approver->approver_type == 'Quality';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// $approvers = CharacteristicApproverMaster::where('approver_type', 'Quality')
|
||||||
|
// ->get()
|
||||||
|
// ->keyBy('id');
|
||||||
|
|
||||||
|
// $qualityRecords = RequestCharacteristic::where(function ($q) {
|
||||||
|
// $q->whereNull('approver_status1')->orWhere('approver_status1', 'Hold');
|
||||||
|
// })
|
||||||
|
// ->where(function ($q) {
|
||||||
|
// $q->whereNull('approver_status2')->orWhere('approver_status2', 'Hold');
|
||||||
|
// })
|
||||||
|
// ->where(function ($q) {
|
||||||
|
// $q->whereNull('approver_status3')->orWhere('approver_status3', 'Hold');
|
||||||
|
// })
|
||||||
|
// ->whereIn('characteristic_approver_master_id', $approvers->keys())
|
||||||
|
// ->get();
|
||||||
|
|
||||||
|
|
||||||
if ($qualityRecords->isEmpty()) {
|
if ($qualityRecords->isEmpty()) {
|
||||||
$this->info('No quality pending approvals');
|
$this->info('No quality pending approvals');
|
||||||
return;
|
return;
|
||||||
@@ -283,6 +339,43 @@ class TriggerPendingApprovalMails extends Command
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$columns = Schema::getColumnListing('temp_class_characteristics');
|
||||||
|
|
||||||
|
$exclude = ['id', 'plant_id', 'machine_id', 'item_id', 'aufnr', 'class', 'arbid', 'gamng', 'lmnga', 'zz1_cn_bill_ord', 'zmm_heading', 'created_at', 'updated_at', 'deleted_at', 'has_work_flow_id', 'model_type', 'created_by', 'updated_by' ];
|
||||||
|
|
||||||
|
$filteredColumns = array_diff($columns, $exclude);
|
||||||
|
|
||||||
|
$row1 = TempClassCharacteristic::where('plant_id', $first->plant_id)
|
||||||
|
->where('machine_id', $first->machine_id)
|
||||||
|
->where('aufnr', $first->aufnr)
|
||||||
|
->where('model_type', $first->model_type)
|
||||||
|
->latest()
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$this->info(json_encode([
|
||||||
|
'id' => $row1->id,
|
||||||
|
'plant_id' => $row1->plant_id,
|
||||||
|
'machine_id' => $row1->machine_id,
|
||||||
|
'aufnr' => $row1->aufnr,
|
||||||
|
'motor_speed' => $row1->zmm_motor_speed,
|
||||||
|
'all_data' => $row1->toArray(),
|
||||||
|
]));
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
if ($row1) {
|
||||||
|
foreach ($filteredColumns as $column) {
|
||||||
|
|
||||||
|
$value = $row1->getAttribute($column);
|
||||||
|
|
||||||
|
if ($value != null && $value != '') {
|
||||||
|
$data[$column] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$characteristics = $data;
|
||||||
|
|
||||||
$level = null;
|
$level = null;
|
||||||
$mail = null;
|
$mail = null;
|
||||||
$name = null;
|
$name = null;
|
||||||
@@ -359,6 +452,38 @@ class TriggerPendingApprovalMails extends Command
|
|||||||
$updateData['mail_status'] = 'Sent-Mail3';
|
$updateData['mail_status'] = 'Sent-Mail3';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$totalMinutes =
|
||||||
|
$this->convertToMinutes($approver->duration1 ?? 0) +
|
||||||
|
$this->convertToMinutes($approver->duration2 ?? 0) +
|
||||||
|
$this->convertToMinutes($approver->duration3 ?? 0);
|
||||||
|
|
||||||
|
$expiryTime = Carbon::parse($first->created_at)
|
||||||
|
->copy()
|
||||||
|
->addMinutes($totalMinutes);
|
||||||
|
|
||||||
|
$ids = $groupRecords->pluck('id');
|
||||||
|
|
||||||
|
$this->info("Expiry Time for ID {$first->id}: {$expiryTime}, Now: {$now}");
|
||||||
|
|
||||||
|
// --- AUTO REJECT ---
|
||||||
|
if (
|
||||||
|
$first->mail_status == 'Sent-Mail3' &&
|
||||||
|
(is_null($first->approver_status1) || $first->approver_status1 == 'Hold') &&
|
||||||
|
(is_null($first->approver_status2) || $first->approver_status2 == 'Hold') &&
|
||||||
|
(is_null($first->approver_status3) || $first->approver_status3 == 'Hold') &&
|
||||||
|
$now->gte($expiryTime)
|
||||||
|
) {
|
||||||
|
RequestCharacteristic::whereIn('id', $ids)
|
||||||
|
->update([
|
||||||
|
'approver_status3' => 'Rejected',
|
||||||
|
'approver_remark3' => 'Time Limit Reached',
|
||||||
|
'approved3_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->info("Auto Rejected ID: {$first->id}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$level || !$mail) {
|
if (!$level || !$mail) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -381,8 +506,8 @@ class TriggerPendingApprovalMails extends Command
|
|||||||
$pdfPath,
|
$pdfPath,
|
||||||
$pendingApprovers,
|
$pendingApprovers,
|
||||||
$approverNameFromMaster,
|
$approverNameFromMaster,
|
||||||
$subjectLine
|
$subjectLine,
|
||||||
// $characteristics
|
$characteristics
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -406,4 +531,16 @@ class TriggerPendingApprovalMails extends Command
|
|||||||
|
|
||||||
$this->info('Approval mail job completed');
|
$this->info('Approval mail job completed');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function convertToMinutes($duration)
|
||||||
|
{
|
||||||
|
if (!$duration) return 0;
|
||||||
|
|
||||||
|
$parts = explode('.', (string)$duration);
|
||||||
|
|
||||||
|
$hours = (int)($parts[0] ?? 0);
|
||||||
|
$minutes = (int)($parts[1] ?? 0);
|
||||||
|
|
||||||
|
return ($hours * 60) + $minutes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
97
app/Filament/Exports/ImportTransitExporter.php
Normal file
97
app/Filament/Exports/ImportTransitExporter.php
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Exports;
|
||||||
|
|
||||||
|
use App\Models\ImportTransit;
|
||||||
|
use Filament\Actions\Exports\ExportColumn;
|
||||||
|
use Filament\Actions\Exports\Exporter;
|
||||||
|
use Filament\Actions\Exports\Models\Export;
|
||||||
|
|
||||||
|
class ImportTransitExporter extends Exporter
|
||||||
|
{
|
||||||
|
protected static ?string $model = ImportTransit::class;
|
||||||
|
|
||||||
|
public static function getColumns(): array
|
||||||
|
{
|
||||||
|
static $rowNumber = 0;
|
||||||
|
return [
|
||||||
|
ExportColumn::make('no')
|
||||||
|
->label('NO')
|
||||||
|
->state(function ($record) use (&$rowNumber) {
|
||||||
|
return ++$rowNumber;
|
||||||
|
}),
|
||||||
|
ExportColumn::make('cri_rfq_number')
|
||||||
|
->label('CRI RFQ NUMBER'),
|
||||||
|
ExportColumn::make('mail_received_date')
|
||||||
|
->label('MAIL RECEIVED DATE'),
|
||||||
|
ExportColumn::make('pricol_ref_number')
|
||||||
|
->label('PRICOL REF NUMBER'),
|
||||||
|
ExportColumn::make('requester')
|
||||||
|
->label('REQUESTER'),
|
||||||
|
ExportColumn::make('shipper')
|
||||||
|
->label('SHIPPER'),
|
||||||
|
ExportColumn::make('shipper_location')
|
||||||
|
->label('SHIPPER LOCATION'),
|
||||||
|
ExportColumn::make('shipper_invoice')
|
||||||
|
->label('SHIPPER INVOICE'),
|
||||||
|
ExportColumn::make('shipper_invoice_date')
|
||||||
|
->label('SHIPPER INVOICE DATE'),
|
||||||
|
ExportColumn::make('customs_agent_name')
|
||||||
|
->label('CUSTOMS AGENT NAME'),
|
||||||
|
ExportColumn::make('eta_date')
|
||||||
|
->label('ETA DATE'),
|
||||||
|
ExportColumn::make('status')
|
||||||
|
->label('STATUS'),
|
||||||
|
ExportColumn::make('delivery_location')
|
||||||
|
->label('DELIVERY LOCATION'),
|
||||||
|
ExportColumn::make('etd_date')
|
||||||
|
->label('ETD DATE'),
|
||||||
|
ExportColumn::make('mode')
|
||||||
|
->label('MODE'),
|
||||||
|
ExportColumn::make('inco_terms')
|
||||||
|
->label('INCO TERMS'),
|
||||||
|
ExportColumn::make('port_of_loading')
|
||||||
|
->label('PORT OF LOADING'),
|
||||||
|
ExportColumn::make('port_of_discharge')
|
||||||
|
->label('PORT OF DISCHARGE'),
|
||||||
|
ExportColumn::make('delivery_city')
|
||||||
|
->label('DELIVERY CITY'),
|
||||||
|
ExportColumn::make('packages')
|
||||||
|
->label('PACKAGES'),
|
||||||
|
ExportColumn::make('type_of_package')
|
||||||
|
->label('TYPE OF PACKAGE'),
|
||||||
|
ExportColumn::make('gross_weight')
|
||||||
|
->label('GROSS WEIGHT'),
|
||||||
|
ExportColumn::make('volume')
|
||||||
|
->label('VOLUME'),
|
||||||
|
ExportColumn::make('bill_number')
|
||||||
|
->label('BILL NUMBER'),
|
||||||
|
ExportColumn::make('bill_received_date')
|
||||||
|
->label('BILL RECEIVED DATE'),
|
||||||
|
ExportColumn::make('vessel_number')
|
||||||
|
->label('VESSEL NUMBER'),
|
||||||
|
ExportColumn::make('created_at')
|
||||||
|
->label('CREATED AT'),
|
||||||
|
ExportColumn::make('updated_at')
|
||||||
|
->label('UPDATED AT'),
|
||||||
|
ExportColumn::make('created_by')
|
||||||
|
->label('CREATED BY'),
|
||||||
|
ExportColumn::make('updated_by')
|
||||||
|
->label('UPDATED BY'),
|
||||||
|
ExportColumn::make('deleted_at')
|
||||||
|
->label('DELETED AT')
|
||||||
|
->enabledByDefault(false),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCompletedNotificationBody(Export $export): string
|
||||||
|
{
|
||||||
|
$body = 'Your import transit export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||||
|
|
||||||
|
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||||
|
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,6 +34,8 @@ class InvoiceValidationExporter extends Exporter
|
|||||||
->label('ITEM CODE'),
|
->label('ITEM CODE'),
|
||||||
ExportColumn::make('stickerMaster.item.description')
|
ExportColumn::make('stickerMaster.item.description')
|
||||||
->label('ITEM DESCRIPTION'),
|
->label('ITEM DESCRIPTION'),
|
||||||
|
ExportColumn::make('stickerMaster.item.uom')
|
||||||
|
->label('UNIT OF MEASURE'),
|
||||||
ExportColumn::make('motor_scanned_status')
|
ExportColumn::make('motor_scanned_status')
|
||||||
->label('MOTOR SCANNED STATUS'),
|
->label('MOTOR SCANNED STATUS'),
|
||||||
ExportColumn::make('pump_scanned_status')
|
ExportColumn::make('pump_scanned_status')
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ class PlantExporter extends Exporter
|
|||||||
->label('CODE'),
|
->label('CODE'),
|
||||||
ExportColumn::make('name')
|
ExportColumn::make('name')
|
||||||
->label('NAME'),
|
->label('NAME'),
|
||||||
|
ExportColumn::make('warehouse_number')
|
||||||
|
->label('WAREHOUSE_NUMBER'),
|
||||||
ExportColumn::make('address')
|
ExportColumn::make('address')
|
||||||
->label('ADDRESS'),
|
->label('ADDRESS'),
|
||||||
ExportColumn::make('created_at')
|
ExportColumn::make('created_at')
|
||||||
@@ -44,10 +46,10 @@ class PlantExporter extends Exporter
|
|||||||
|
|
||||||
public static function getCompletedNotificationBody(Export $export): string
|
public static function getCompletedNotificationBody(Export $export): string
|
||||||
{
|
{
|
||||||
$body = 'Your plant export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
$body = 'Your plant export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
|
||||||
|
|
||||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $body;
|
return $body;
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ class ProcessOrderExporter extends Exporter
|
|||||||
ExportColumn::make('deleted_at')
|
ExportColumn::make('deleted_at')
|
||||||
->enabledByDefault(false)
|
->enabledByDefault(false)
|
||||||
->label('DELETED AT'),
|
->label('DELETED AT'),
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ class ProductCharacteristicsMasterExporter extends Exporter
|
|||||||
->label('CHARACTERISTICS TYPE'),
|
->label('CHARACTERISTICS TYPE'),
|
||||||
ExportColumn::make('name')
|
ExportColumn::make('name')
|
||||||
->label('CHARACTERISTICS NAME'),
|
->label('CHARACTERISTICS NAME'),
|
||||||
|
ExportColumn::make('category')
|
||||||
|
->label('CATEGORY'),
|
||||||
ExportColumn::make('inspection_type')
|
ExportColumn::make('inspection_type')
|
||||||
->label('INSPECTION TYPE'),
|
->label('INSPECTION TYPE'),
|
||||||
ExportColumn::make('lower')
|
ExportColumn::make('lower')
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ class InvoiceValidationImporter extends Importer
|
|||||||
ImportColumn::make('operator_id')
|
ImportColumn::make('operator_id')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('OPERATOR ID')
|
->exampleHeader('OPERATOR ID')
|
||||||
->example('USER1')
|
->example('USER00001')
|
||||||
->label('OPERATOR ID')
|
->label('OPERATOR ID')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('created_at')
|
ImportColumn::make('created_at')
|
||||||
@@ -122,19 +122,19 @@ class InvoiceValidationImporter extends Importer
|
|||||||
ImportColumn::make('created_by')
|
ImportColumn::make('created_by')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('CREATED BY')
|
->exampleHeader('CREATED BY')
|
||||||
->example('USER1')
|
->example('USER00001')
|
||||||
->label('CREATED BY')
|
->label('CREATED BY')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('updated_at')
|
ImportColumn::make('updated_at')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('UPDATED AT')
|
->exampleHeader('UPDATED AT')
|
||||||
->example('USER1')
|
->example('')
|
||||||
->label('UPDATED AT')
|
->label('UPDATED AT')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('updated_by')
|
ImportColumn::make('updated_by')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('UPDATED BY')
|
->exampleHeader('UPDATED BY')
|
||||||
->example('')
|
->example('USER00001')
|
||||||
->label('UPDATED BY')
|
->label('UPDATED BY')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -37,6 +37,12 @@ class PlantImporter extends Importer
|
|||||||
->example('Ransar Industries-I')
|
->example('Ransar Industries-I')
|
||||||
->label('NAME')
|
->label('NAME')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
|
ImportColumn::make('warehouse_number')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('WAREHOUSE_NUMBER')
|
||||||
|
->example('001')
|
||||||
|
->label('WAREHOUSE_NUMBER')
|
||||||
|
->rules(['required']),
|
||||||
ImportColumn::make('address')
|
ImportColumn::make('address')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('ADDRESS')
|
->exampleHeader('ADDRESS')
|
||||||
@@ -53,6 +59,7 @@ class PlantImporter extends Importer
|
|||||||
$comp = trim($this->data['company']) ?? null;
|
$comp = trim($this->data['company']) ?? null;
|
||||||
$code = trim($this->data['code']) ?? null;
|
$code = trim($this->data['code']) ?? null;
|
||||||
$name = trim($this->data['name']) ?? null;
|
$name = trim($this->data['name']) ?? null;
|
||||||
|
$wareHouseNo = trim($this->data['warehouse_number']) ?? null;
|
||||||
$addr = trim($this->data['address']) ?? null;
|
$addr = trim($this->data['address']) ?? null;
|
||||||
|
|
||||||
if ($comp == null || $comp == '' || ! $comp) {
|
if ($comp == null || $comp == '' || ! $comp) {
|
||||||
@@ -74,6 +81,13 @@ class PlantImporter extends Importer
|
|||||||
} elseif (Str::length($name) < 5) {
|
} elseif (Str::length($name) < 5) {
|
||||||
$warnMsg[] = 'Name should contain at least 5 characters!';
|
$warnMsg[] = 'Name should contain at least 5 characters!';
|
||||||
}
|
}
|
||||||
|
if ($wareHouseNo == null || $wareHouseNo == '' || ! $wareHouseNo) {
|
||||||
|
// $warnMsg[] = "Warehouse number can't be empty!";
|
||||||
|
} elseif (! is_numeric($wareHouseNo)) {
|
||||||
|
$warnMsg[] = 'Warehouse number should contain only numeric values!';
|
||||||
|
} elseif (Str::length($wareHouseNo) == 3) {
|
||||||
|
$warnMsg[] = 'Warehouse number must contain 3 digits only!';
|
||||||
|
}
|
||||||
if ($addr == null || $addr == '' || ! $addr) {
|
if ($addr == null || $addr == '' || ! $addr) {
|
||||||
$warnMsg[] = "Address can't be empty!";
|
$warnMsg[] = "Address can't be empty!";
|
||||||
} elseif (Str::length($addr) < 5) {
|
} elseif (Str::length($addr) < 5) {
|
||||||
@@ -92,6 +106,7 @@ class PlantImporter extends Importer
|
|||||||
}
|
}
|
||||||
|
|
||||||
$plantCN = Plant::where('code', $code)->where('name', $name)->first();
|
$plantCN = Plant::where('code', $code)->where('name', $name)->first();
|
||||||
|
$plantCW = Plant::where('code', $code)->where('warehouse_number', $wareHouseNo)->first();
|
||||||
if (! $plantCN) {
|
if (! $plantCN) {
|
||||||
$plantCode = Plant::where('code', $code)->first();
|
$plantCode = Plant::where('code', $code)->first();
|
||||||
$plantName = Plant::where('name', $name)->first();
|
$plantName = Plant::where('name', $name)->first();
|
||||||
@@ -99,6 +114,16 @@ class PlantImporter extends Importer
|
|||||||
throw new RowImportFailedException('Duplicate plant name found!');
|
throw new RowImportFailedException('Duplicate plant name found!');
|
||||||
} elseif ($plantCode) {
|
} elseif ($plantCode) {
|
||||||
throw new RowImportFailedException('Duplicate plant code found!');
|
throw new RowImportFailedException('Duplicate plant code found!');
|
||||||
|
} elseif (! $plantCW) {
|
||||||
|
$wareHouse = Plant::where('warehouse_number', $wareHouseNo)->first();
|
||||||
|
if ($wareHouse) {
|
||||||
|
throw new RowImportFailedException('Duplicate warehouse number found!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif (! $plantCW) {
|
||||||
|
$wareHouse = Plant::where('warehouse_number', $wareHouseNo)->first();
|
||||||
|
if ($wareHouse) {
|
||||||
|
throw new RowImportFailedException('Duplicate warehouse number found!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +132,7 @@ class PlantImporter extends Importer
|
|||||||
'name' => $name,
|
'name' => $name,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
'warehouse_number' => $wareHouseNo,
|
||||||
'address' => $addr,
|
'address' => $addr,
|
||||||
'company_id' => $compId,
|
'company_id' => $compId,
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -70,6 +70,11 @@ class ProductCharacteristicsMasterImporter extends Importer
|
|||||||
->exampleHeader('CHARACTERISTICS NAME')
|
->exampleHeader('CHARACTERISTICS NAME')
|
||||||
->example(['TEST01', 'TEST02'])
|
->example(['TEST01', 'TEST02'])
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
|
ImportColumn::make('category')
|
||||||
|
->label('CATEGORY')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('CATEGORY')
|
||||||
|
->example(['Open Pump', 'Submersible Pump']),
|
||||||
ImportColumn::make('inspection_type')
|
ImportColumn::make('inspection_type')
|
||||||
->label('INSPECTION TYPE')
|
->label('INSPECTION TYPE')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
@@ -102,7 +107,6 @@ class ProductCharacteristicsMasterImporter extends Importer
|
|||||||
|
|
||||||
public function resolveRecord(): ?ProductCharacteristicsMaster
|
public function resolveRecord(): ?ProductCharacteristicsMaster
|
||||||
{
|
{
|
||||||
|
|
||||||
$warnMsg = [];
|
$warnMsg = [];
|
||||||
$plantCod = trim($this->data['plant']) ?? null;
|
$plantCod = trim($this->data['plant']) ?? null;
|
||||||
$itemCod = trim($this->data['item']) ?? null;
|
$itemCod = trim($this->data['item']) ?? null;
|
||||||
@@ -111,6 +115,7 @@ class ProductCharacteristicsMasterImporter extends Importer
|
|||||||
$workCenter = trim($this->data['machine']) ?? null;
|
$workCenter = trim($this->data['machine']) ?? null;
|
||||||
$charTyp = trim($this->data['characteristics_type']) ?? null;
|
$charTyp = trim($this->data['characteristics_type']) ?? null;
|
||||||
$charNam = trim($this->data['name']) ?? null;
|
$charNam = trim($this->data['name']) ?? null;
|
||||||
|
$category = trim($this->data['category']) ?? null;
|
||||||
$inspectTyp = trim($this->data['inspection_type']) ?? null;
|
$inspectTyp = trim($this->data['inspection_type']) ?? null;
|
||||||
$lower = trim($this->data['lower']) ?? null;
|
$lower = trim($this->data['lower']) ?? null;
|
||||||
$middle = trim($this->data['middle']) ?? null;
|
$middle = trim($this->data['middle']) ?? null;
|
||||||
@@ -296,6 +301,7 @@ class ProductCharacteristicsMasterImporter extends Importer
|
|||||||
'name' => $charNam,
|
'name' => $charNam,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
'category' => $category,
|
||||||
'inspection_type' => $inspectTyp,
|
'inspection_type' => $inspectTyp,
|
||||||
'lower' => $lower,
|
'lower' => $lower,
|
||||||
'middle' => $middle,
|
'middle' => $middle,
|
||||||
|
|||||||
@@ -2,10 +2,17 @@
|
|||||||
|
|
||||||
namespace App\Filament\Imports;
|
namespace App\Filament\Imports;
|
||||||
|
|
||||||
|
use App\Models\Item;
|
||||||
|
use App\Models\Line;
|
||||||
|
use App\Models\Machine;
|
||||||
|
use App\Models\Plant;
|
||||||
use App\Models\ProductionCharacteristic;
|
use App\Models\ProductionCharacteristic;
|
||||||
|
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||||
use Filament\Actions\Imports\ImportColumn;
|
use Filament\Actions\Imports\ImportColumn;
|
||||||
use Filament\Actions\Imports\Importer;
|
use Filament\Actions\Imports\Importer;
|
||||||
use Filament\Actions\Imports\Models\Import;
|
use Filament\Actions\Imports\Models\Import;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Str;
|
||||||
|
|
||||||
class ProductionCharacteristicImporter extends Importer
|
class ProductionCharacteristicImporter extends Importer
|
||||||
{
|
{
|
||||||
@@ -16,40 +23,170 @@ class ProductionCharacteristicImporter extends Importer
|
|||||||
return [
|
return [
|
||||||
ImportColumn::make('plant')
|
ImportColumn::make('plant')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->relationship()
|
->exampleHeader('PLANT CODE')
|
||||||
|
->example('1200')
|
||||||
|
->label('PLANT CODE')
|
||||||
|
->relationship(resolveUsing: 'code')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('line')
|
ImportColumn::make('line')
|
||||||
->requiredMapping()
|
->exampleHeader('LINE NAME')
|
||||||
->relationship()
|
->example('Poly Wrapped Wire SFG')
|
||||||
->rules(['required']),
|
->label('LINE NAME')
|
||||||
|
->relationship(resolveUsing: 'name'),
|
||||||
ImportColumn::make('item')
|
ImportColumn::make('item')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->relationship()
|
->exampleHeader('ITEM CODE')
|
||||||
|
->example('123456')
|
||||||
|
->label('ITEM CODE')
|
||||||
|
->relationship(resolveUsing: 'code')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('machine')
|
ImportColumn::make('machine_name')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->relationship()
|
->exampleHeader('MACHINE NAME')
|
||||||
|
->example('RMI001234')
|
||||||
|
->label('MACHINE NAME')
|
||||||
|
// ->relationship(resolveUsing: 'work_center')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('production_order'),
|
ImportColumn::make('production_order')
|
||||||
ImportColumn::make('serial_number'),
|
->requiredMapping()
|
||||||
ImportColumn::make('characteristic_name'),
|
->exampleHeader('PRODUCTION ORDER')
|
||||||
ImportColumn::make('observed_value'),
|
->example('1880231')
|
||||||
ImportColumn::make('status'),
|
->label('PRODUCTION ORDER')
|
||||||
ImportColumn::make('inspection_status'),
|
->rules(['required']),
|
||||||
ImportColumn::make('remark'),
|
ImportColumn::make('serial_number')
|
||||||
ImportColumn::make('created_by'),
|
->requiredMapping()
|
||||||
ImportColumn::make('updated_by'),
|
->exampleHeader('SERIAL NUMBER')
|
||||||
|
->example('20001202121')
|
||||||
|
->label('SERIAL NUMBER')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('characteristic_name')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('CHARACTERISTIC NAME')
|
||||||
|
->example('Voltage')
|
||||||
|
->label('CHARACTERISTIC NAME'),
|
||||||
|
ImportColumn::make('observed_value')
|
||||||
|
->exampleHeader('OBSERVED VALUE')
|
||||||
|
->example('0')
|
||||||
|
->label('OBSERVED VALUE'),
|
||||||
|
ImportColumn::make('status')
|
||||||
|
->exampleHeader('STATUS')
|
||||||
|
->example('Ok')
|
||||||
|
->label('STATUS'),
|
||||||
|
ImportColumn::make('remark')
|
||||||
|
->exampleHeader('REMARK')
|
||||||
|
->example('Issue')
|
||||||
|
->label('REMARK'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resolveRecord(): ?ProductionCharacteristic
|
public function resolveRecord(): ?ProductionCharacteristic
|
||||||
{
|
{
|
||||||
// return ProductionCharacteristic::firstOrNew([
|
|
||||||
// // Update existing records, matching them by `$this->data['column_name']`
|
|
||||||
// 'email' => $this->data['email'],
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
return new ProductionCharacteristic();
|
$warnMsg = [];
|
||||||
|
$plant = null;
|
||||||
|
$plantCod = trim($this->data['plant']) ?? '';
|
||||||
|
$plantId = null;
|
||||||
|
$iCode = trim($this->data['item']) ?? '';
|
||||||
|
$itemId = null;
|
||||||
|
$lineNam = trim($this->data['line']) ?? '';
|
||||||
|
$lineId = null;
|
||||||
|
$machineName = trim($this->data['machine_name'] ?? '');
|
||||||
|
$pOrder = trim($this->data['production_order'] ?? '');
|
||||||
|
$sNo = trim($this->data['serial_number'] ?? '');
|
||||||
|
$charName = trim($this->data['characteristic_name'] ?? '');
|
||||||
|
$obsValue = trim($this->data['observed_value'] ?? '');
|
||||||
|
$status = trim($this->data['status'] ?? '');
|
||||||
|
$remark = trim($this->data['remark'] ?? '');
|
||||||
|
|
||||||
|
if ($plantCod == null || $plantCod == '') {
|
||||||
|
$warnMsg[] = "Plant code can't be empty!";
|
||||||
|
} elseif (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||||
|
$warnMsg[] = 'Invalid plant code found';
|
||||||
|
}
|
||||||
|
if ($iCode == null || $iCode == '') {
|
||||||
|
$warnMsg[] = "Item code can't be empty!";
|
||||||
|
} elseif (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||||
|
$warnMsg[] = 'Invalid item code found!';
|
||||||
|
}
|
||||||
|
if ($machineName != null && $machineName != '' && Str::length($machineName) > 18) {
|
||||||
|
$warnMsg[] = 'Invalid machine name found!';
|
||||||
|
}
|
||||||
|
|
||||||
|
$plant = Plant::where('code', $plantCod)->first();
|
||||||
|
if (! $plant) {
|
||||||
|
$warnMsg[] = 'Plant not found!';
|
||||||
|
} else {
|
||||||
|
$plantId = $plant->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$itemCode = Item::where('code', $iCode)->first();
|
||||||
|
if (! $itemCode) {
|
||||||
|
$warnMsg[] = 'Item code not found!';
|
||||||
|
} else {
|
||||||
|
if ($plantId) {
|
||||||
|
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||||
|
if (! $itemCode) {
|
||||||
|
$warnMsg[] = 'Item code not found for the given plant!';
|
||||||
|
} else {
|
||||||
|
$itemId = $itemCode->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$lineExists = Line::where('name', $lineNam)->first();
|
||||||
|
if (! $lineExists) {
|
||||||
|
$warnMsg[] = 'Line name not found!';
|
||||||
|
} else {
|
||||||
|
if ($plantId) {
|
||||||
|
$lineAgainstPlant = Line::where('name', $lineNam)->where('plant_id', $plantId)->first();
|
||||||
|
if (! $lineAgainstPlant) {
|
||||||
|
$warnMsg[] = 'Line name not found for the given plant!';
|
||||||
|
} else {
|
||||||
|
$lineId = $lineAgainstPlant->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$machineExists = Machine::where('work_center', $machineName)->first();
|
||||||
|
if (! $machineExists) {
|
||||||
|
$warnMsg[] = 'Machine not found!';
|
||||||
|
} else {
|
||||||
|
if ($plantId) {
|
||||||
|
$machineAgainstPlant = Machine::where('work_center', $machineName)->where('plant_id', $plantId)->first();
|
||||||
|
if (! $machineAgainstPlant) {
|
||||||
|
$warnMsg[] = 'Machine not found for the given plant!';
|
||||||
|
} else {
|
||||||
|
$machineId = $machineAgainstPlant->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($warnMsg)) {
|
||||||
|
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||||
|
}
|
||||||
|
|
||||||
|
ProductionCharacteristic::Create(
|
||||||
|
[
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'line_id' => $lineId,
|
||||||
|
'item_id' => $itemId,
|
||||||
|
'machine_id' => $machineId,
|
||||||
|
'production_order' => $pOrder,
|
||||||
|
'serial_number' => $sNo,
|
||||||
|
'characteristic_name' => $charName,
|
||||||
|
'observed_value' => $obsValue,
|
||||||
|
'status' => $status,
|
||||||
|
'remark' => $remark,
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
'created_by' => Filament::auth()->user()->name,
|
||||||
|
'updated_by' => Filament::auth()->user()->name,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// return new ProductionCharacteristic();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Import $import): string
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class ProductionOrderImporter extends Importer
|
|||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->label('PLANT CODE')
|
->label('PLANT CODE')
|
||||||
->exampleHeader('PLANT CODE')
|
->exampleHeader('PLANT CODE')
|
||||||
->example('1000')
|
->example('TEST007')
|
||||||
->relationship(resolveUsing: 'code')
|
->relationship(resolveUsing: 'code')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('item')
|
ImportColumn::make('item')
|
||||||
|
|||||||
141
app/Filament/Imports/RequestCharacteristicImporter.php
Normal file
141
app/Filament/Imports/RequestCharacteristicImporter.php
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Imports;
|
||||||
|
|
||||||
|
use App\Models\RequestCharacteristic;
|
||||||
|
use Filament\Actions\Imports\ImportColumn;
|
||||||
|
use Filament\Actions\Imports\Importer;
|
||||||
|
use Filament\Actions\Imports\Models\Import;
|
||||||
|
|
||||||
|
class RequestCharacteristicImporter extends Importer
|
||||||
|
{
|
||||||
|
protected static ?string $model = RequestCharacteristic::class;
|
||||||
|
|
||||||
|
public static function getColumns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ImportColumn::make('plant')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('PLANT CODE')
|
||||||
|
->example('1000')
|
||||||
|
->label('PLANT CODE')
|
||||||
|
->relationship(resolveUsing: 'code')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('machine')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('WORK CENTER')
|
||||||
|
->example('RMGLAS01')
|
||||||
|
->label('WORK CENTER')
|
||||||
|
->relationship(resolveUsing: 'work_center')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('item')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('ITEM CODE')
|
||||||
|
->example('630214')
|
||||||
|
->label('ITEM CODE')
|
||||||
|
->relationship(resolveUsing: 'code')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('characteristicApproverMaster')
|
||||||
|
->requiredMapping()
|
||||||
|
->relationship()
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('aufnr')
|
||||||
|
->label('AUFNR')
|
||||||
|
->exampleHeader('AUFNR')
|
||||||
|
->example('1234567'),
|
||||||
|
ImportColumn::make('characteristic_name')
|
||||||
|
->label('CHARACTERISTIC NAME')
|
||||||
|
->exampleHeader('CHARACTERISTIC NAME')
|
||||||
|
->example('ZMM_PUMPSET_MODEL'),
|
||||||
|
ImportColumn::make('current_value')
|
||||||
|
->label('CURRENT VALUE')
|
||||||
|
->exampleHeader('CURRENT VALUE')
|
||||||
|
->example('MVN-32/02 D R'),
|
||||||
|
ImportColumn::make('update_value')
|
||||||
|
->label('UPDATE VALUE')
|
||||||
|
->exampleHeader('UPDATE VALUE')
|
||||||
|
->example('MVN-32/02 TR3'),
|
||||||
|
ImportColumn::make('approver_status1')
|
||||||
|
->label('APPROVER STATUS 1')
|
||||||
|
->exampleHeader('APPROVER STATUS 1')
|
||||||
|
->example('Hold'),
|
||||||
|
ImportColumn::make('approver_status2')
|
||||||
|
->label('APPROVER STATUS 2')
|
||||||
|
->exampleHeader('APPROVER STATUS 2')
|
||||||
|
->example('Approved'),
|
||||||
|
ImportColumn::make('approver_status3')
|
||||||
|
->label('APPROVER STATUS 3')
|
||||||
|
->exampleHeader('APPROVER STATUS 3')
|
||||||
|
->example('Rejected'),
|
||||||
|
ImportColumn::make('approver_remark1')
|
||||||
|
->label('APPROVER REMARK 1')
|
||||||
|
->exampleHeader('APPROVER REMARK 1')
|
||||||
|
->example('Hold for review'),
|
||||||
|
ImportColumn::make('approver_remark2')
|
||||||
|
->label('APPROVER REMARK 2')
|
||||||
|
->exampleHeader('APPROVER REMARK 2')
|
||||||
|
->example('Approved with comments'),
|
||||||
|
ImportColumn::make('approver_remark3')
|
||||||
|
->label('APPROVER REMARK 3')
|
||||||
|
->exampleHeader('APPROVER REMARK 3')
|
||||||
|
->example('Rejected due to incorrect value'),
|
||||||
|
ImportColumn::make('work_flow_id')
|
||||||
|
->label('WORK FLOW ID')
|
||||||
|
->exampleHeader('WORK FLOW ID')
|
||||||
|
->example('WF-260303-0001'),
|
||||||
|
ImportColumn::make('mail_status')
|
||||||
|
->label('MAIL STATUS')
|
||||||
|
->exampleHeader('MAIL STATUS')
|
||||||
|
->example('Sent'),
|
||||||
|
ImportColumn::make('trigger_at')
|
||||||
|
->label('TRIGGER AT')
|
||||||
|
->exampleHeader('MAIL STATUS')
|
||||||
|
->rules(['datetime']),
|
||||||
|
ImportColumn::make('approved1_at')
|
||||||
|
->label('APPROVED1 AT')
|
||||||
|
->exampleHeader('APPROVED1 AT')
|
||||||
|
->rules(['datetime']),
|
||||||
|
ImportColumn::make('approved2_at')
|
||||||
|
->label('APPROVED2 AT')
|
||||||
|
->exampleHeader('APPROVED2 AT')
|
||||||
|
->rules(['datetime']),
|
||||||
|
ImportColumn::make('approved3_at')
|
||||||
|
->label('APPROVED3 AT')
|
||||||
|
->exampleHeader('APPROVED3 AT')
|
||||||
|
->rules(['datetime']),
|
||||||
|
ImportColumn::make('created_by')
|
||||||
|
->label('CREATED BY')
|
||||||
|
->exampleHeader('CREATED BY')
|
||||||
|
->example('RAW01234'),
|
||||||
|
ImportColumn::make('updated_by')
|
||||||
|
->label('UPDATED BY')
|
||||||
|
->exampleHeader('UPDATED BY')
|
||||||
|
->example('RAW01234'),
|
||||||
|
ImportColumn::make('model_type')
|
||||||
|
->label('MODEL TYPE')
|
||||||
|
->exampleHeader('MODEL TYPE')
|
||||||
|
->example('PUMP'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolveRecord(): ?RequestCharacteristic
|
||||||
|
{
|
||||||
|
// return RequestCharacteristic::firstOrNew([
|
||||||
|
// // Update existing records, matching them by `$this->data['column_name']`
|
||||||
|
// 'email' => $this->data['email'],
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
return new RequestCharacteristic();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
|
{
|
||||||
|
$body = 'Your request characteristic import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||||
|
|
||||||
|
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||||
|
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,8 @@ class Dashboard extends \Filament\Pages\Dashboard
|
|||||||
|
|
||||||
protected static string $view = 'filament.pages.dashboard';
|
protected static string $view = 'filament.pages.dashboard';
|
||||||
|
|
||||||
|
protected static ?string $slug = 'welcome';
|
||||||
|
|
||||||
// public function mount(): void
|
// public function mount(): void
|
||||||
// {
|
// {
|
||||||
// session()->forget(['selected_plant']);
|
// session()->forget(['selected_plant']);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use Filament\Forms\Form;
|
|||||||
use Filament\Pages\Page;
|
use Filament\Pages\Page;
|
||||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Filament\Forms\Components\DatePicker;
|
||||||
|
|
||||||
class InvoiceDashboard extends Page
|
class InvoiceDashboard extends Page
|
||||||
{
|
{
|
||||||
@@ -27,9 +28,13 @@ class InvoiceDashboard extends Page
|
|||||||
public function mount(): void
|
public function mount(): void
|
||||||
{
|
{
|
||||||
session()->forget(['selec_plant', 'select_invoice']);
|
session()->forget(['selec_plant', 'select_invoice']);
|
||||||
|
session()->forget(['from_date']);
|
||||||
|
session()->forget(['to_date']);
|
||||||
$this->filtersForm->fill([
|
$this->filtersForm->fill([
|
||||||
'plant' => null,
|
'plant' => null,
|
||||||
'invoice' => null,
|
'invoice' => null,
|
||||||
|
'from_date' => null,
|
||||||
|
'to_date' => null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,9 +67,23 @@ class InvoiceDashboard extends Page
|
|||||||
->afterStateUpdated(function ($state) {
|
->afterStateUpdated(function ($state) {
|
||||||
session(['select_invoice' => $state]);
|
session(['select_invoice' => $state]);
|
||||||
$this->dispatch('invoiceChart');
|
$this->dispatch('invoiceChart');
|
||||||
})
|
}),
|
||||||
|
DatePicker::make('created_from')
|
||||||
|
->label('Created From')
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state,callable $set) {
|
||||||
|
session(['from_date' => $state]);
|
||||||
|
$this->dispatch('invoiceChart');
|
||||||
|
}),
|
||||||
|
DatePicker::make('created_to')
|
||||||
|
->label('Created To')
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state,callable $set) {
|
||||||
|
session(['to_date' => $state]);
|
||||||
|
$this->dispatch('invoiceChart');
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
->columns(2);
|
->columns(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getNavigationLabel(): string
|
public static function getNavigationLabel(): string
|
||||||
|
|||||||
@@ -291,7 +291,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
|||||||
$machineId = $get('machine_id');
|
$machineId = $get('machine_id');
|
||||||
|
|
||||||
$this->mNam = $machineId;
|
$this->mNam = $machineId;
|
||||||
|
|
||||||
})
|
})
|
||||||
->extraAttributes(fn ($get) => [
|
->extraAttributes(fn ($get) => [
|
||||||
// 'class' => $get('pqLineError') ? 'border-red-500' : '',
|
// 'class' => $get('pqLineError') ? 'border-red-500' : '',
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ class AlertMailRuleResource extends Resource
|
|||||||
'ProductionQuantities' => 'ProductionQuantities',
|
'ProductionQuantities' => 'ProductionQuantities',
|
||||||
'QualityValidation' => 'QualityValidation',
|
'QualityValidation' => 'QualityValidation',
|
||||||
'InvoiceTransit' => 'InvoiceTransit',
|
'InvoiceTransit' => 'InvoiceTransit',
|
||||||
|
'ImportTransit' => 'ImportTransit',
|
||||||
|
'VehicleReport' => 'VehicleReport',
|
||||||
]),
|
]),
|
||||||
Forms\Components\Select::make('rule_name')
|
Forms\Components\Select::make('rule_name')
|
||||||
->label('Rule Name')
|
->label('Rule Name')
|
||||||
@@ -69,6 +71,8 @@ class AlertMailRuleResource extends Resource
|
|||||||
'InvoiceDataMail' => 'Invoice Data Mail',
|
'InvoiceDataMail' => 'Invoice Data Mail',
|
||||||
'QualityMail' => 'Quality Mail',
|
'QualityMail' => 'Quality Mail',
|
||||||
'InvoiceTransitMail' => 'Invoice Transit Mail',
|
'InvoiceTransitMail' => 'Invoice Transit Mail',
|
||||||
|
'ImportTransitMail' => 'Import Transit Mail',
|
||||||
|
'VehicleReportMail' => 'Vehicle Report Mail',
|
||||||
])
|
])
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\TextInput::make('email')
|
Forms\Components\TextInput::make('email')
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use App\Filament\Exports\CharacteristicApproverMasterExporter;
|
|||||||
use App\Filament\Imports\CharacteristicApproverMasterImporter;
|
use App\Filament\Imports\CharacteristicApproverMasterImporter;
|
||||||
use App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
use App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
||||||
use App\Models\CharacteristicApproverMaster;
|
use App\Models\CharacteristicApproverMaster;
|
||||||
|
use App\Models\Item;
|
||||||
use App\Models\Machine;
|
use App\Models\Machine;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
@@ -20,6 +21,10 @@ use Filament\Tables\Table;
|
|||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Tables\Filters\Filter;
|
||||||
|
|
||||||
class CharacteristicApproverMasterResource extends Resource
|
class CharacteristicApproverMasterResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -392,7 +397,203 @@ class CharacteristicApproverMasterResource extends Resource
|
|||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
Tables\Filters\TrashedFilter::make(),
|
Tables\Filters\TrashedFilter::make(),
|
||||||
|
Filter::make('advanced_filters')
|
||||||
|
->label('Advanced Filters')
|
||||||
|
->form([
|
||||||
|
Select::make('Plant')
|
||||||
|
->label('Search by Plant Name')
|
||||||
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||||
|
} else {
|
||||||
|
return Plant::whereHas('requestCharacteristics', function ($query) {
|
||||||
|
$query->whereNotNull('id');
|
||||||
|
})->orderBy('code')->pluck('name', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||||
|
$set('machine', null);
|
||||||
|
// $set('aufnr', null);
|
||||||
|
}),
|
||||||
|
Select::make('machine')
|
||||||
|
->label('Search by Work Center')
|
||||||
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
|
if (empty($plantId)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Machine::whereHas('requestCharacteristics', function ($query) use ($plantId) {
|
||||||
|
if ($plantId) {
|
||||||
|
$query->where('plant_id', $plantId);
|
||||||
|
}
|
||||||
|
})->pluck('work_center', 'id');
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||||
|
// $set('item_id', null);
|
||||||
|
// $set('aufnr', null);
|
||||||
|
}),
|
||||||
|
Select::make('approver_type')
|
||||||
|
->label('Approver Type')
|
||||||
|
->options([
|
||||||
|
'Characteristic' => 'Characteristic',
|
||||||
|
'Quality' => 'Quality',
|
||||||
|
])
|
||||||
|
->placeholder('Select Type')
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('name1', null);
|
||||||
|
$set('name2', null);
|
||||||
|
$set('name3', null);
|
||||||
|
}),
|
||||||
|
TextInput::make('machine_name')
|
||||||
|
->label('Machine Name')
|
||||||
|
->placeholder('Enter Machine Name'),
|
||||||
|
TextInput::make('characteristic_field')
|
||||||
|
->label('Characteristic Field')
|
||||||
|
->placeholder('Enter Characteristic Field'),
|
||||||
|
TextInput::make('name1')
|
||||||
|
->label('Approver Name 1')
|
||||||
|
->placeholder('Enter Approver Name 2')
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('name2', null);
|
||||||
|
$set('name3', null);
|
||||||
|
}),
|
||||||
|
TextInput::make('name2')
|
||||||
|
->label('Approver Name 2')
|
||||||
|
->placeholder('Enter Approver Name 2')
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('name3', null);
|
||||||
|
}),
|
||||||
|
TextInput::make('name3')
|
||||||
|
->label('Approver Name 3')
|
||||||
|
->placeholder('Enter Approver Name 2'),
|
||||||
|
DateTimePicker::make(name: 'created_from')
|
||||||
|
->label('Created From')
|
||||||
|
->placeholder('Select From DateTime')
|
||||||
|
->reactive()
|
||||||
|
->native(false),
|
||||||
|
DateTimePicker::make('created_to')
|
||||||
|
->label('Created To')
|
||||||
|
->placeholder('Select To DateTime')
|
||||||
|
->reactive()
|
||||||
|
->native(false),
|
||||||
|
])
|
||||||
|
->query(function ($query, array $data) {
|
||||||
|
// Hide all records initially if no filters are applied
|
||||||
|
if (empty($data['Plant']) && empty($data['machine']) && empty($data['machine_name']) && empty($data['characteristic_field']) && empty($data['approver_type']) && empty($data['name1']) && empty($data['name2']) && empty($data['name3']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||||
|
return $query->whereRaw('1 = 0');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['Plant'])) { // $plant = $data['Plant'] ?? null
|
||||||
|
$query->where('plant_id', $data['Plant']);
|
||||||
|
} else {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return $query->whereRaw('1 = 0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['machine'])) {
|
||||||
|
$query->where('machine_id', $data['machine']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['machine_name'])) {
|
||||||
|
$query->where('machine_name', 'like', '%'.$data['machine_name'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['characteristic_field'])) {
|
||||||
|
$query->where('characteristic_field', 'like', '%'.$data['characteristic_field'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['approver_type'])) {
|
||||||
|
$query->where('approver_type', 'like', '%'.$data['approver_type'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['name1'])) {
|
||||||
|
$query->where('name1', 'like', '%'.$data['name1'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['name2'])) {
|
||||||
|
$query->where('name2', 'like', '%'.$data['name2'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['name3'])) {
|
||||||
|
$query->where('name3', 'like', '%'.$data['name3'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_from'])) {
|
||||||
|
$query->where('created_at', '>=', $data['created_from']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_to'])) {
|
||||||
|
$query->where('created_at', '<=', $data['created_to']);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->indicateUsing(function (array $data) {
|
||||||
|
$indicators = [];
|
||||||
|
|
||||||
|
if (! empty($data['Plant'])) {
|
||||||
|
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||||
|
} else {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return 'Plant: Choose plant to filter records.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['machine'])) {
|
||||||
|
$indicators[] = 'Work Center: '.Machine::where('id', $data['machine'])->value('work_center');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['machine_name'])) {
|
||||||
|
$indicators[] = 'Machine Name: '.$data['machine_name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['characteristic_field'])) {
|
||||||
|
$indicators[] = 'Characteristic Field: '.$data['characteristic_field'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['approver_type'])) {
|
||||||
|
$indicators[] = 'Approver Type: '.$data['approver_type'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['name1'])) {
|
||||||
|
$indicators[] = 'Approver Name 1: '.$data['name1'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['name2'])) {
|
||||||
|
$indicators[] = 'Approver Name 2: '.$data['name2'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['name3'])) {
|
||||||
|
$indicators[] = 'Approver Name 3: '.$data['name3'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_from'])) {
|
||||||
|
$indicators[] = 'From: '.$data['created_from'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_to'])) {
|
||||||
|
$indicators[] = 'To: '.$data['created_to'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $indicators;
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
|
->filtersFormMaxHeight('280px')
|
||||||
->actions([
|
->actions([
|
||||||
Tables\Actions\ViewAction::make(),
|
Tables\Actions\ViewAction::make(),
|
||||||
Tables\Actions\EditAction::make(),
|
Tables\Actions\EditAction::make(),
|
||||||
|
|||||||
@@ -2028,6 +2028,9 @@ class ClassCharacteristicResource extends Resource
|
|||||||
TextInput::make('gernr')
|
TextInput::make('gernr')
|
||||||
->label('Serial Number')
|
->label('Serial Number')
|
||||||
->placeholder('Enter Serial Number'),
|
->placeholder('Enter Serial Number'),
|
||||||
|
TextInput::make('zmm_heading')
|
||||||
|
->label('Heading')
|
||||||
|
->placeholder('Enter Heading'),
|
||||||
DateTimePicker::make(name: 'created_from')
|
DateTimePicker::make(name: 'created_from')
|
||||||
->label('Created From')
|
->label('Created From')
|
||||||
->placeholder('Select From DateTime')
|
->placeholder('Select From DateTime')
|
||||||
@@ -2041,7 +2044,7 @@ class ClassCharacteristicResource extends Resource
|
|||||||
])
|
])
|
||||||
->query(function ($query, array $data) {
|
->query(function ($query, array $data) {
|
||||||
// Hide all records initially if no filters are applied
|
// Hide all records initially if no filters are applied
|
||||||
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['created_from']) && empty($data['created_to'])) {
|
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['zmm_heading']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||||
return $query->whereRaw('1 = 0');
|
return $query->whereRaw('1 = 0');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2071,6 +2074,10 @@ class ClassCharacteristicResource extends Resource
|
|||||||
$query->where('gernr', 'like', '%'.$data['gernr'].'%');
|
$query->where('gernr', 'like', '%'.$data['gernr'].'%');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['zmm_heading'])) {
|
||||||
|
$query->where('zmm_heading', 'like', '%'.$data['zmm_heading'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($data['created_from'])) {
|
if (! empty($data['created_from'])) {
|
||||||
$query->where('created_at', '>=', $data['created_from']);
|
$query->where('created_at', '>=', $data['created_from']);
|
||||||
}
|
}
|
||||||
@@ -2108,6 +2115,10 @@ class ClassCharacteristicResource extends Resource
|
|||||||
$indicators[] = 'Serial Number: '.$data['gernr'];
|
$indicators[] = 'Serial Number: '.$data['gernr'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['zmm_heading'])) {
|
||||||
|
$indicators[] = 'Heading: '.$data['zmm_heading'];
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($data['created_from'])) {
|
if (! empty($data['created_from'])) {
|
||||||
$indicators[] = 'From: '.$data['created_from'];
|
$indicators[] = 'From: '.$data['created_from'];
|
||||||
}
|
}
|
||||||
|
|||||||
664
app/Filament/Resources/ImportTransitResource.php
Normal file
664
app/Filament/Resources/ImportTransitResource.php
Normal file
@@ -0,0 +1,664 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Exports\ImportTransitExporter;
|
||||||
|
use App\Filament\Resources\ImportTransitResource\Pages;
|
||||||
|
use App\Filament\Resources\ImportTransitResource\RelationManagers;
|
||||||
|
use App\Models\ImportTransit;
|
||||||
|
use App\Models\InvoiceDataValidation;
|
||||||
|
use App\Models\Plant;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
|
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\FileUpload;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
// use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||||
|
|
||||||
|
class ImportTransitResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = ImportTransit::class;
|
||||||
|
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'Manufacturing SD';
|
||||||
|
|
||||||
|
public static function form(Form $form): Form
|
||||||
|
{
|
||||||
|
return $form
|
||||||
|
->schema([
|
||||||
|
Forms\Components\TextInput::make('cri_rfq_number')
|
||||||
|
->label('CRI/RFQ Number')
|
||||||
|
->disabled(fn ($operation) => $operation == 'edit')
|
||||||
|
->unique(ignoreRecord: true),
|
||||||
|
Forms\Components\DatePicker::make('mail_received_date')
|
||||||
|
->label('Mail Received Date')
|
||||||
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('pricol_ref_number')
|
||||||
|
->label('Pricol Ref Number')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('requester')
|
||||||
|
->label('Requester')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('shipper')
|
||||||
|
->label('Shipper')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('shipper_location')
|
||||||
|
->label('Shipper Location')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('shipper_invoice')
|
||||||
|
->label('Shipper Invoice')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\DatePicker::make('shipper_invoice_date')
|
||||||
|
->label('Shipper Invoice Date')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('customs_agent_name')
|
||||||
|
->label('Customs Agent Name')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\DatePicker::make('eta_date')
|
||||||
|
->label('ETA Date')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\Select::make('status')
|
||||||
|
->label('Status')
|
||||||
|
->options([
|
||||||
|
'Under Service Provider Finalization' => 'Under Service Provider Finalization',
|
||||||
|
'Yet to pick up' => 'Yet to pick up',
|
||||||
|
'Awaiting Vessel Loading' => 'Awaiting Vessel Loading',
|
||||||
|
'In Transit' => 'In Transit',
|
||||||
|
'Under Import Customs Clearance in Destination' => 'Under Import Customs Clearance in Destination',
|
||||||
|
'Delivered' => 'Delivered',
|
||||||
|
])
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('delivery_location')
|
||||||
|
->label('Delivery Location')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\DatePicker::make('etd_date')
|
||||||
|
->label('ETD Date')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('mode')
|
||||||
|
->label('Mode')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('inco_terms')
|
||||||
|
->label('Inco Terms')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('port_of_loading')
|
||||||
|
->label('Port of Loading')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('port_of_discharge')
|
||||||
|
->label('Port of Discharge')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('delivery_city')
|
||||||
|
->label('Delivery City')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('packages')
|
||||||
|
->label('Packages')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('type_of_package')
|
||||||
|
->label('Type of Package')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('gross_weight')
|
||||||
|
->label('Gross Weight')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('volume')
|
||||||
|
->label('Volume')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('bill_number')
|
||||||
|
->label('Bill Number')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\DatePicker::make('bill_received_date')
|
||||||
|
->label('Bill Received Date')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('vessel_number')
|
||||||
|
->label('Vessel Number')
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
Forms\Components\Hidden::make('created_by')
|
||||||
|
->label('Created By')
|
||||||
|
->default(Filament::auth()->user()?->name),
|
||||||
|
Forms\Components\Hidden::make('updated_by')
|
||||||
|
->label('Updated By')
|
||||||
|
->default(Filament::auth()->user()?->name),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
Tables\Columns\TextColumn::make('No.')
|
||||||
|
->label('No.')
|
||||||
|
->alignCenter()
|
||||||
|
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||||
|
$paginator = $livewire->getTableRecords();
|
||||||
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
|
}),
|
||||||
|
Tables\Columns\TextColumn::make('cri_rfq_number')
|
||||||
|
->label('CRI/RFQ Number')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('mail_received_date')
|
||||||
|
->label('Mail Received Date')
|
||||||
|
->date()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('pricol_ref_number')
|
||||||
|
->label('Pricol Ref Number')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('requester')
|
||||||
|
->label('Requester')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('shipper')
|
||||||
|
->label('Shipper')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('shipper_location')
|
||||||
|
->label('Shipper Location')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('shipper_invoice')
|
||||||
|
->label('Shipper Invoice')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('shipper_invoice_date')
|
||||||
|
->label('Shipper Invoice Date')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('customs_agent_name')
|
||||||
|
->label('Customs Agent Name')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('eta_date')
|
||||||
|
->label('ETA Date')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('status')
|
||||||
|
->label('Status')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('delivery_location')
|
||||||
|
->label('Delivery Location')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('etd_date')
|
||||||
|
->label('ETD Date')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('mode')
|
||||||
|
->label('Mode')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('inco_terms')
|
||||||
|
->label('Inco Terms')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('port_of_loading')
|
||||||
|
->label('Port of Loading')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('port_of_discharge')
|
||||||
|
->label('Port of Discharge')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('delivery_city')
|
||||||
|
->label('Delivery City')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('packages')
|
||||||
|
->label('Packages')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('type_of_package')
|
||||||
|
->label('Type of Package')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('gross_weight')
|
||||||
|
->label('Gross Weight')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('volume')
|
||||||
|
->label('Volume')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('bill_number')
|
||||||
|
->label('Bill Number')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('bill_received_date')
|
||||||
|
->label('Bill Received Date')
|
||||||
|
->alignCenter()
|
||||||
|
->date()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('vessel_number')
|
||||||
|
->label('Vessel Number')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
|
->label('Created At')
|
||||||
|
->alignCenter()
|
||||||
|
->dateTime()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('created_by')
|
||||||
|
->label('Created By')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('updated_at')
|
||||||
|
->label('Updated At')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('updated_by')
|
||||||
|
->label('Updated By')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('deleted_at')
|
||||||
|
->label('Deleted At')
|
||||||
|
->alignCenter()
|
||||||
|
->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(),
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
->headerActions([
|
||||||
|
Tables\Actions\Action::make('Import Transit')
|
||||||
|
->label('Import Transit')
|
||||||
|
->form([
|
||||||
|
FileUpload::make('import_transit_file')
|
||||||
|
->label('Import Transit')
|
||||||
|
// ->required()
|
||||||
|
->preserveFilenames()
|
||||||
|
->storeFiles(false)
|
||||||
|
->reactive()
|
||||||
|
->required()
|
||||||
|
->disk('local')
|
||||||
|
// ->visible(fn (Get $get) => !empty($get('plant_id')))
|
||||||
|
->directory('uploads/ImportTransit'),
|
||||||
|
])
|
||||||
|
->action(function (array $data) {
|
||||||
|
$uploadedFile = $data['import_transit_file'];
|
||||||
|
|
||||||
|
$disk = Storage::disk('local');
|
||||||
|
|
||||||
|
$user = Filament::auth()->user();
|
||||||
|
|
||||||
|
$operatorName = $user->name;
|
||||||
|
|
||||||
|
// Get original filename
|
||||||
|
$originalName = $uploadedFile->getClientOriginalName(); // e.g. 3RA0018732.xlsx
|
||||||
|
|
||||||
|
$originalNameOnly = pathinfo($originalName, PATHINFO_FILENAME);
|
||||||
|
|
||||||
|
// Store manually using storeAs to keep original name
|
||||||
|
$path = $uploadedFile->storeAs('uploads/ImportTransit', $originalName, 'local'); // returns relative path
|
||||||
|
|
||||||
|
$fullPath = Storage::disk('local')->path($path);
|
||||||
|
|
||||||
|
if ($fullPath && file_exists($fullPath)) {
|
||||||
|
$rows = Excel::toArray(null, $fullPath)[0];
|
||||||
|
|
||||||
|
if ((count($rows) - 1) <= 0) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Records Not Found')
|
||||||
|
->body("Import the valid 'Import Transit' file to proceed..!")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
if ($disk->exists($path))
|
||||||
|
{
|
||||||
|
$disk->delete($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$invalidCriNo = [];
|
||||||
|
|
||||||
|
foreach ($rows as $index => $row)
|
||||||
|
{
|
||||||
|
if ($index == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rowNumber = $index + 1;
|
||||||
|
|
||||||
|
$criRfqNo = trim($row[1] ?? '');
|
||||||
|
$mailRcvdDate = trim($row[2] ?? '');
|
||||||
|
$pricolRefNo = trim($row[3] ?? '');
|
||||||
|
$requester = trim($row[4] ?? '');
|
||||||
|
$shipper = trim($row[5] ?? '');
|
||||||
|
$shipperLocation = trim($row[6] ?? '');
|
||||||
|
$shipperInv = trim($row[7] ?? '');
|
||||||
|
$shipperInvDate = trim($row[8] ?? '');
|
||||||
|
$cha = trim($row[9] ?? '');
|
||||||
|
$eta = trim($row[10] ?? '');
|
||||||
|
$status = trim($row[11] ?? '');
|
||||||
|
$dlyLoc = trim($row[12] ?? '');
|
||||||
|
$etd = trim($row[13] ?? '');
|
||||||
|
$mode = trim($row[14] ?? '');
|
||||||
|
$incoTerms = trim($row[15] ?? '');
|
||||||
|
$portOfLoading = trim($row[16] ?? '');
|
||||||
|
$portOfDischarge = trim($row[17] ?? '');
|
||||||
|
$deliveryCity = trim($row[18] ?? '');
|
||||||
|
$packages = trim($row[19] ?? '');
|
||||||
|
$typeOfPkg = trim($row[20] ?? '');
|
||||||
|
$grossWeight = trim($row[21] ?? '');
|
||||||
|
$volumeWeight = trim($row[22] ?? '');
|
||||||
|
$blNo = trim($row[23] ?? '');
|
||||||
|
$blRcvdDate = trim($row[24] ?? '');
|
||||||
|
$vesselNo = trim($row[25] ?? '');
|
||||||
|
|
||||||
|
if (empty($criRfqNo)) {
|
||||||
|
$invalidCriNo[] = $rowNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($invalidCriNo)){
|
||||||
|
|
||||||
|
$errorMsg = '';
|
||||||
|
|
||||||
|
if (! empty($invalidCriNo)) {
|
||||||
|
$errorMsg .= 'Missing CRI Rfq No in rows: '.implode(', ', $invalidCriNo).'<br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
Notification::make()
|
||||||
|
->title('Missing Mandatory Fields')
|
||||||
|
->body($errorMsg)
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
if ($disk->exists($path)) {
|
||||||
|
$disk->delete($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// $spreadsheet = IOFactory::load($fullPath);
|
||||||
|
|
||||||
|
// foreach ($spreadsheet->getAllSheets() as $sheet) {
|
||||||
|
// $state = $sheet->getSheetState();
|
||||||
|
// if ($state == \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::SHEETSTATE_HIDDEN ||
|
||||||
|
// $state == \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::SHEETSTATE_VERYHIDDEN) {
|
||||||
|
// Notification::make()
|
||||||
|
// ->title('Import Failed')
|
||||||
|
// ->body("Hidden sheet found: \"{$sheet->getTitle()}\". Please remove all hidden sheets and try again.")
|
||||||
|
// ->danger()
|
||||||
|
// ->send();
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach ($rows as $index => $row)
|
||||||
|
{
|
||||||
|
if ($index == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rowNumber = $index + 1;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
$formattedDate = null;
|
||||||
|
$formattedShipperDate = null;
|
||||||
|
$etaDate = null;
|
||||||
|
$etdDate = null;
|
||||||
|
$formattedBlRcvdDate = null;
|
||||||
|
|
||||||
|
$criRfqNo = trim($row[1] ?? '');
|
||||||
|
$mailRcvdDate = trim($row[2] ?? '');
|
||||||
|
$pricolRefNo = trim($row[3] ?? '');
|
||||||
|
$requester = trim($row[4] ?? '');
|
||||||
|
$shipper = trim($row[5] ?? '');
|
||||||
|
$shipperLocation = trim($row[6] ?? '');
|
||||||
|
$shipperInv = trim($row[7] ?? '');
|
||||||
|
$shipperInvDate = trim($row[8] ?? '');
|
||||||
|
$cha = trim($row[9] ?? '');
|
||||||
|
$eta = trim($row[10] ?? '');
|
||||||
|
$status = trim($row[11] ?? '');
|
||||||
|
$dlyLoc = trim($row[12] ?? '');
|
||||||
|
$etd = trim($row[13] ?? '');
|
||||||
|
$mode = trim($row[14] ?? '');
|
||||||
|
$incoTerms = trim($row[15] ?? '');
|
||||||
|
$portOfLoading = trim($row[16] ?? '');
|
||||||
|
$portOfDischarge = trim($row[17] ?? '');
|
||||||
|
$deliveryCity = trim($row[18] ?? '');
|
||||||
|
$packages = trim($row[19] ?? '');
|
||||||
|
$typeOfPkg = trim($row[20] ?? '');
|
||||||
|
$grossWeight = trim($row[21] ?? '');
|
||||||
|
$volumeWeight = trim($row[22] ?? '');
|
||||||
|
$blNo = trim($row[23] ?? '');
|
||||||
|
$blRcvdDate = trim($row[24] ?? '');
|
||||||
|
$vesselNo = trim($row[25] ?? '');
|
||||||
|
|
||||||
|
|
||||||
|
if (! empty($mailRcvdDate)) {
|
||||||
|
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $mailRcvdDate)) {
|
||||||
|
[$day, $month, $year] = preg_split('/[-\/]/', $mailRcvdDate);
|
||||||
|
$formattedDate = "{$year}-{$month}-{$day}";
|
||||||
|
} elseif (is_numeric($mailRcvdDate)) {
|
||||||
|
$formattedDate = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($mailRcvdDate)->format('Y-m-d');
|
||||||
|
} else {
|
||||||
|
$formattedDate = date('Y-m-d', strtotime($mailRcvdDate));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! empty($shipperInvDate)) {
|
||||||
|
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $shipperInvDate)) {
|
||||||
|
[$day, $month, $year] = preg_split('/[-\/]/', $shipperInvDate);
|
||||||
|
$formattedShipperDate = "{$year}-{$month}-{$day}";
|
||||||
|
} elseif (is_numeric($shipperInvDate)) {
|
||||||
|
$formattedShipperDate = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($shipperInvDate)->format('Y-m-d');
|
||||||
|
} else {
|
||||||
|
$formattedShipperDate = date('Y-m-d', strtotime($shipperInvDate));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! empty($eta)) {
|
||||||
|
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $eta)) {
|
||||||
|
[$day, $month, $year] = preg_split('/[-\/]/', $eta);
|
||||||
|
$etaDate = "{$year}-{$month}-{$day}";
|
||||||
|
} elseif (is_numeric($eta)) {
|
||||||
|
$etaDate = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($eta)->format('Y-m-d');
|
||||||
|
} else {
|
||||||
|
$etaDate = date('Y-m-d', strtotime($eta));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! empty($etd)) {
|
||||||
|
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $etd)) {
|
||||||
|
[$day, $month, $year] = preg_split('/[-\/]/', $etd);
|
||||||
|
$etdDate = "{$year}-{$month}-{$day}";
|
||||||
|
} elseif (is_numeric($etd)) {
|
||||||
|
$etdDate = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($etd)->format('Y-m-d');
|
||||||
|
} else {
|
||||||
|
$etdDate = date('Y-m-d', strtotime($etd));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! empty($blRcvdDate)) {
|
||||||
|
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $blRcvdDate)) {
|
||||||
|
[$day, $month, $year] = preg_split('/[-\/]/', $blRcvdDate);
|
||||||
|
$formattedBlRcvdDate = "{$year}-{$month}-{$day}";
|
||||||
|
} elseif (is_numeric($blRcvdDate)) {
|
||||||
|
$formattedBlRcvdDate = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($blRcvdDate)->format('Y-m-d');
|
||||||
|
} else {
|
||||||
|
$formattedBlRcvdDate = date('Y-m-d', strtotime($blRcvdDate));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$inserted = ImportTransit::updateOrCreate(
|
||||||
|
[
|
||||||
|
'cri_rfq_number' => $criRfqNo,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'mail_received_date' => $formattedDate ?? null,
|
||||||
|
'pricol_ref_number' => $pricolRefNo ?? null,
|
||||||
|
'requester' => $requester ?? null,
|
||||||
|
'shipper' => $shipper ?? null,
|
||||||
|
'shipper_location' => $shipperLocation ?? null,
|
||||||
|
'shipper_invoice' => $shipperInv ?? null,
|
||||||
|
'shipper_invoice_date' => $formattedShipperDate ?? null,
|
||||||
|
'customs_agent_name' => $cha ?? null,
|
||||||
|
'eta_date' => $etaDate ?? null,
|
||||||
|
'status' => $status ?? null,
|
||||||
|
'delivery_location' => $dlyLoc ?? null,
|
||||||
|
'etd_date' => $etdDate ?? null,
|
||||||
|
'mode' => $mode ?? null,
|
||||||
|
'inco_terms' => $incoTerms ?? null,
|
||||||
|
'port_of_loading' => $portOfLoading ?? null,
|
||||||
|
'port_of_discharge' => $portOfDischarge ?? null,
|
||||||
|
'delivery_city' => $deliveryCity ?? null,
|
||||||
|
'packages' => $packages ?? null,
|
||||||
|
'type_of_package' => $typeOfPkg ?? null,
|
||||||
|
'gross_weight' => $grossWeight ?? null,
|
||||||
|
'volume' => $volumeWeight ?? null,
|
||||||
|
'bill_number' => $blNo ?? null,
|
||||||
|
'bill_received_date' => $formattedBlRcvdDate ?? null,
|
||||||
|
'vessel_number' => $vesselNo ?? null,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (\Exception $e) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Import Failed')
|
||||||
|
->body("Error occurred while processing row. Error : {$e->getMessage()}")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! $inserted) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Failed')
|
||||||
|
->body("Records insertion failed!")
|
||||||
|
->success()
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Notification::make()
|
||||||
|
->title('Success')
|
||||||
|
->body("Records inserted successfully!")
|
||||||
|
->success()
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (\Exception $e) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Import Failed')
|
||||||
|
->body("No records were inserted. Error : {$e->getMessage()}")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->visible(function () {
|
||||||
|
return Filament::auth()->user()->can('view import transit');
|
||||||
|
}),
|
||||||
|
ExportAction::make()
|
||||||
|
->label('Export Import Transit')
|
||||||
|
->color('warning')
|
||||||
|
->exporter(ImportTransitExporter::class)
|
||||||
|
->visible(function () {
|
||||||
|
return Filament::auth()->user()->can('view export import transit');
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => Pages\ListImportTransits::route('/'),
|
||||||
|
'create' => Pages\CreateImportTransit::route('/create'),
|
||||||
|
'view' => Pages\ViewImportTransit::route('/{record}'),
|
||||||
|
'edit' => Pages\EditImportTransit::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEloquentQuery(): Builder
|
||||||
|
{
|
||||||
|
return parent::getEloquentQuery()
|
||||||
|
->withoutGlobalScopes([
|
||||||
|
SoftDeletingScope::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\ImportTransitResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\ImportTransitResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
|
||||||
|
class CreateImportTransit extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = ImportTransitResource::class;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\ImportTransitResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\ImportTransitResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
|
class EditImportTransit extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = ImportTransitResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\ViewAction::make(),
|
||||||
|
Actions\DeleteAction::make(),
|
||||||
|
Actions\ForceDeleteAction::make(),
|
||||||
|
Actions\RestoreAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\ImportTransitResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\ImportTransitResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListImportTransits extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = ImportTransitResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\ImportTransitResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\ImportTransitResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
|
||||||
|
class ViewImportTransit extends ViewRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = ImportTransitResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\EditAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -61,6 +61,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
Section::make('')
|
Section::make('')
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
|
->label('Plant Name')
|
||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->required()
|
->required()
|
||||||
// ->preload()
|
// ->preload()
|
||||||
@@ -278,6 +279,11 @@ class InvoiceValidationResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable() // ->searchable()
|
->sortable() // ->searchable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('stickerMaster.item.uom')
|
||||||
|
->label('Unit of Measure')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable() // ->searchable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
Tables\Columns\TextColumn::make('serial_number')
|
Tables\Columns\TextColumn::make('serial_number')
|
||||||
->label('Serial Number')
|
->label('Serial Number')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
@@ -323,7 +329,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->numeric(),
|
->numeric(),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
->label('Plant')
|
->label('Plant Name')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('created_by')
|
Tables\Columns\TextColumn::make('created_by')
|
||||||
@@ -381,7 +387,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->searchable()
|
->searchable()
|
||||||
->label('Select Plant')
|
->label('Search by Plant Name')
|
||||||
->required()
|
->required()
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(InvoiceValidation::latest()->first())->plant_id;
|
return optional(InvoiceValidation::latest()->first())->plant_id;
|
||||||
@@ -404,7 +410,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
->reactive(),
|
->reactive(),
|
||||||
|
|
||||||
FileUpload::make('invoice_serial_number')
|
FileUpload::make('invoice_serial_number')
|
||||||
->label('Invoice Serial Number')
|
->label('Choose Serial Invoice')
|
||||||
->required()
|
->required()
|
||||||
->acceptedFileTypes([
|
->acceptedFileTypes([
|
||||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||||
@@ -732,7 +738,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->searchable()
|
->searchable()
|
||||||
->label('Select Plant')
|
->label('Search by Plant Name')
|
||||||
->required()
|
->required()
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(InvoiceValidation::latest()->first())->plant_id;
|
return optional(InvoiceValidation::latest()->first())->plant_id;
|
||||||
@@ -755,7 +761,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
->reactive(),
|
->reactive(),
|
||||||
|
|
||||||
FileUpload::make('invoice_material')
|
FileUpload::make('invoice_material')
|
||||||
->label('Invoice Material')
|
->label('Choose Material Invoice')
|
||||||
->required()
|
->required()
|
||||||
->acceptedFileTypes([
|
->acceptedFileTypes([
|
||||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ use App\Models\InvoiceValidation;
|
|||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\StickerMaster;
|
use App\Models\StickerMaster;
|
||||||
|
use App\Models\WireMasterPacking;
|
||||||
|
use DB;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Pages\Concerns\ExposesTableToWidgets;
|
use Filament\Pages\Concerns\ExposesTableToWidgets;
|
||||||
@@ -174,17 +176,15 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($matches[1])) {
|
if (isset($matches[1])) {
|
||||||
$invoiceNumber = $matches[1];
|
$invoiceNumber = strtoupper($matches[1]);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$invoiceNumber = strtoupper($invoiceNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
// dd($invoiceNumber);
|
|
||||||
|
|
||||||
// ..
|
|
||||||
|
|
||||||
$updateStatus = $this->form->getState()['update_invoice'] ?? null;
|
$updateStatus = $this->form->getState()['update_invoice'] ?? null;
|
||||||
|
|
||||||
$this->invoiceNumber = trim($this->form->getState()['invoice_number']) ?? $invoiceNumber;
|
$this->invoiceNumber = strtoupper(trim($this->form->getState()['invoice_number'])) ?? $invoiceNumber;
|
||||||
|
|
||||||
$invoiceType = null;
|
$invoiceType = null;
|
||||||
// $this->invoiceNumber = $this->invoiceNumber ?? $invoiceNumber;
|
// $this->invoiceNumber = $this->invoiceNumber ?? $invoiceNumber;
|
||||||
@@ -2317,7 +2317,7 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
protected function refreshInvoiceTable()
|
protected function refreshInvoiceTable()
|
||||||
{
|
{
|
||||||
$this->plantId = $this->form->getState()['plant_id'] ?? '';
|
$this->plantId = $this->form->getState()['plant_id'] ?? '';
|
||||||
$this->invoiceNumber = $this->form->getState()['invoice_number'] ?? '';
|
$this->invoiceNumber = strtoupper(trim($this->form->getState()['invoice_number'])) ?? '';
|
||||||
|
|
||||||
if (! empty($this->invoiceNumber)) {
|
if (! empty($this->invoiceNumber)) {
|
||||||
$hasInvoice = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $this->plantId)->first();
|
$hasInvoice = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $this->plantId)->first();
|
||||||
@@ -2378,7 +2378,7 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
$serialNumber = null;
|
$serialNumber = null;
|
||||||
$plantId = $this->form->getState()['plant_id'];
|
$plantId = $this->form->getState()['plant_id'];
|
||||||
$this->plantId = $plantId;
|
$this->plantId = $plantId;
|
||||||
$invoiceNumber = $this->form->getState()['invoice_number'];
|
$invoiceNumber = strtoupper(trim($this->form->getState()['invoice_number']));
|
||||||
$this->invoiceNumber = $invoiceNumber;
|
$this->invoiceNumber = $invoiceNumber;
|
||||||
|
|
||||||
$plant = Plant::find($plantId);
|
$plant = Plant::find($plantId);
|
||||||
@@ -2455,14 +2455,65 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pattern0 = '/^(?<item_code>[^|]+)\|(?<batch_id>[^|]+)\|(?<batch_count>[^|]+)\|(?<batch_quantity>[0-9]+(?:\.[0-9]+)?)\s?kg$/i';
|
||||||
$pattern1 = '/^(?<item_code>[^|]+)\|(?<batch_number>[^|]+)\|(?<batch_id>[^|]+)\|(?<batch_count>[^|]+)\/(?<batch_quantity>.+)$/i';
|
$pattern1 = '/^(?<item_code>[^|]+)\|(?<batch_number>[^|]+)\|(?<batch_id>[^|]+)\|(?<batch_count>[^|]+)\/(?<batch_quantity>.+)$/i';
|
||||||
$pattern2 = '/^(?<item_code>[^|]+)\|(?<batch_number>[^|]+)\|(?<batch_id>[^|]+)\|(?<batch_count>.+)$/i';
|
$pattern2 = '/^(?<item_code>[^|]+)\|(?<batch_number>[^|]+)\|(?<batch_id>[^|]+)\|(?<batch_count>.+)$/i';
|
||||||
$pattern3 = '/^(?<item_code>[^|]+)\|(?<batch_id>[^|]+)-(?<batch_count>.+)$/i';
|
$pattern3 = '/^(?<item_code>[^|]+)\|(?<batch_id>[^|]+)-(?<batch_count>.+)$/i';
|
||||||
|
$pattern4 = '/^MP-(?<code>.+)$/i';
|
||||||
$itemCode = '';
|
$itemCode = '';
|
||||||
$batchNumber = '';
|
$batchNumber = '';
|
||||||
$curScanQty = '';
|
$curScanQty = '';
|
||||||
|
$wirePallet = '';
|
||||||
|
$curMaterialQty = '';
|
||||||
|
$curMaterialSer = '';
|
||||||
|
|
||||||
if (preg_match($pattern1, $serNo, $matches)) {
|
if (preg_match($pattern0, $serNo, $matches)) {
|
||||||
|
$itemCode = $matches['item_code'];
|
||||||
|
$this->currentItemCode = $itemCode;
|
||||||
|
$curScanQty = trim($matches['batch_quantity']);
|
||||||
|
$serialNumber = $matches['batch_id'].'-'.$matches['batch_count'];
|
||||||
|
$serNo = null;
|
||||||
|
|
||||||
|
if (empty($matches['batch_id']) || ! $matches['batch_id']) {
|
||||||
|
Notification::make()
|
||||||
|
->danger()
|
||||||
|
->title('Invalid Material QR Format')
|
||||||
|
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||||
|
->seconds(2)
|
||||||
|
->send();
|
||||||
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'invoice_number' => $invoiceNumber,
|
||||||
|
'serial_number' => null,
|
||||||
|
'total_quantity' => $totQuan,
|
||||||
|
'update_invoice' => false,
|
||||||
|
'scanned_quantity' => $scanMQuan,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
} elseif (empty($matches['batch_count']) || ! $matches['batch_count']) {
|
||||||
|
Notification::make()
|
||||||
|
->danger()
|
||||||
|
->title('Invalid Material QR Format')
|
||||||
|
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||||
|
->seconds(2)
|
||||||
|
->send();
|
||||||
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'invoice_number' => $invoiceNumber,
|
||||||
|
'serial_number' => null,
|
||||||
|
'total_quantity' => $totQuan,
|
||||||
|
'update_invoice' => false,
|
||||||
|
'scanned_quantity' => $scanMQuan,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} elseif (preg_match($pattern1, $serNo, $matches)) {
|
||||||
$itemCode = $matches['item_code'];
|
$itemCode = $matches['item_code'];
|
||||||
$this->currentItemCode = $itemCode;
|
$this->currentItemCode = $itemCode;
|
||||||
$batchNumber = $matches['batch_number'];
|
$batchNumber = $matches['batch_number'];
|
||||||
@@ -2470,11 +2521,45 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
$curScanQty = $matches['batch_quantity'];
|
$curScanQty = $matches['batch_quantity'];
|
||||||
$serNo = null;
|
$serNo = null;
|
||||||
|
|
||||||
if (empty($matches['batch_id']) || ! $matches['batch_id']) {
|
if (empty($matches['batch_number']) || ! $matches['batch_number']) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->danger()
|
->danger()
|
||||||
->title('Invalid Material QR Format')
|
->title('Invalid Material QR Format')
|
||||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||||
|
->seconds(2)
|
||||||
|
->send();
|
||||||
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
// .Mail
|
||||||
|
|
||||||
|
// $mailData = $this->getMail();
|
||||||
|
// $mPlantName = $mailData['plant_name'];
|
||||||
|
// $emails = $mailData['emails'];
|
||||||
|
// $mInvoiceType = 'Material';
|
||||||
|
|
||||||
|
// if (! empty($emails)) {
|
||||||
|
// Mail::to($emails)->send(
|
||||||
|
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||||
|
// );
|
||||||
|
// } else {
|
||||||
|
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
// }
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'invoice_number' => $invoiceNumber,
|
||||||
|
'serial_number' => null,
|
||||||
|
'total_quantity' => $totQuan,
|
||||||
|
'update_invoice' => false,
|
||||||
|
'scanned_quantity' => $scanMQuan,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
} elseif (empty($matches['batch_id']) || ! $matches['batch_id']) {
|
||||||
|
Notification::make()
|
||||||
|
->danger()
|
||||||
|
->title('Invalid Material QR Format')
|
||||||
|
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
@@ -2508,42 +2593,7 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
Notification::make()
|
Notification::make()
|
||||||
->danger()
|
->danger()
|
||||||
->title('Invalid Material QR Format')
|
->title('Invalid Material QR Format')
|
||||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||||
->seconds(2)
|
|
||||||
->send();
|
|
||||||
$this->dispatch('playWarnSound');
|
|
||||||
|
|
||||||
// .Mail
|
|
||||||
|
|
||||||
// $mailData = $this->getMail();
|
|
||||||
// $mPlantName = $mailData['plant_name'];
|
|
||||||
// $emails = $mailData['emails'];
|
|
||||||
// $mInvoiceType = 'Material';
|
|
||||||
|
|
||||||
// if (! empty($emails)) {
|
|
||||||
// // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
|
||||||
// Mail::to($emails)->send(
|
|
||||||
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
|
||||||
// );
|
|
||||||
// } else {
|
|
||||||
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
|
||||||
// }
|
|
||||||
|
|
||||||
$this->form->fill([
|
|
||||||
'plant_id' => $plantId,
|
|
||||||
'invoice_number' => $invoiceNumber,
|
|
||||||
'serial_number' => null,
|
|
||||||
'total_quantity' => $totQuan,
|
|
||||||
'update_invoice' => false,
|
|
||||||
'scanned_quantity' => $scanMQuan,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return;
|
|
||||||
} elseif (! is_numeric($curScanQty)) {
|
|
||||||
Notification::make()
|
|
||||||
->danger()
|
|
||||||
->title('Invalid Material QR Format')
|
|
||||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
@@ -2580,13 +2630,48 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
$this->currentItemCode = $itemCode;
|
$this->currentItemCode = $itemCode;
|
||||||
$batchNumber = $matches['batch_number'];
|
$batchNumber = $matches['batch_number'];
|
||||||
$serialNumber = $matches['batch_id'].'-'.$matches['batch_count'];
|
$serialNumber = $matches['batch_id'].'-'.$matches['batch_count'];
|
||||||
|
$curMaterialSer = $matches['batch_number'].'-'.$matches['batch_id'];
|
||||||
|
$curMaterialQty = $matches['batch_count'];
|
||||||
$serNo = null;
|
$serNo = null;
|
||||||
|
|
||||||
if (empty($matches['batch_id']) || ! $matches['batch_id']) {
|
if (empty($matches['batch_number']) || ! $matches['batch_number']) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->danger()
|
->danger()
|
||||||
->title('Invalid Material QR Format')
|
->title('Invalid Material QR Format')
|
||||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||||
|
->seconds(2)
|
||||||
|
->send();
|
||||||
|
$this->dispatch('playWarnSound');
|
||||||
|
// .Mail
|
||||||
|
|
||||||
|
// $mailData = $this->getMail();
|
||||||
|
// $mPlantName = $mailData['plant_name'];
|
||||||
|
// $emails = $mailData['emails'];
|
||||||
|
// $mInvoiceType = 'Material';
|
||||||
|
|
||||||
|
// if (! empty($emails)) {
|
||||||
|
// Mail::to($emails)->send(
|
||||||
|
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||||
|
// );
|
||||||
|
// } else {
|
||||||
|
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
// }
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'invoice_number' => $invoiceNumber,
|
||||||
|
'serial_number' => null,
|
||||||
|
'total_quantity' => $totQuan,
|
||||||
|
'update_invoice' => false,
|
||||||
|
'scanned_quantity' => $scanMQuan,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
} elseif (empty($matches['batch_id']) || ! $matches['batch_id']) {
|
||||||
|
Notification::make()
|
||||||
|
->danger()
|
||||||
|
->title('Invalid Material QR Format')
|
||||||
|
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
@@ -2619,7 +2704,7 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
Notification::make()
|
Notification::make()
|
||||||
->danger()
|
->danger()
|
||||||
->title('Invalid Material QR Format')
|
->title('Invalid Material QR Format')
|
||||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
@@ -2659,7 +2744,7 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
Notification::make()
|
Notification::make()
|
||||||
->danger()
|
->danger()
|
||||||
->title('Invalid Material QR Format')
|
->title('Invalid Material QR Format')
|
||||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
@@ -2693,7 +2778,7 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
Notification::make()
|
Notification::make()
|
||||||
->danger()
|
->danger()
|
||||||
->title('Invalid Material QR Format')
|
->title('Invalid Material QR Format')
|
||||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
@@ -2723,6 +2808,294 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} elseif (preg_match($pattern4, $serNo, $matches)) {
|
||||||
|
$wirePallet = 'MP-'.$matches['code'];
|
||||||
|
$wirePattern = '/^MP-(?<code>\d+)$/i';
|
||||||
|
|
||||||
|
if (! preg_match($wirePattern, $serNo, $matches)) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Invalid Master Packing QR Format')
|
||||||
|
->body("Scan valid Master Packing QR code proceed!<br>Sample format : 'MP-2601001'")
|
||||||
|
->danger()
|
||||||
|
->seconds(1)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$wireMaster = WireMasterPacking::where('plant_id', $plantId)->where('wire_packing_number', $wirePallet)->first();
|
||||||
|
|
||||||
|
if (! $wireMaster) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Master Pallet Not Found')
|
||||||
|
->body("No record found for this Master Packing QR $wirePallet")
|
||||||
|
->danger()
|
||||||
|
->seconds(2)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$wireItemCodes = WireMasterPacking::join('items', 'items.id', '=', 'wire_master_packings.item_id')
|
||||||
|
->where('wire_master_packings.plant_id', $plantId)
|
||||||
|
->where('wire_master_packings.wire_packing_number', $wirePallet)
|
||||||
|
->pluck('items.code')
|
||||||
|
->unique()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$invoiceItemCodes = InvoiceValidation::join(
|
||||||
|
'sticker_masters',
|
||||||
|
'sticker_masters.id',
|
||||||
|
'=',
|
||||||
|
'invoice_validations.sticker_master_id'
|
||||||
|
)
|
||||||
|
->join(
|
||||||
|
'items',
|
||||||
|
'items.id',
|
||||||
|
'=',
|
||||||
|
'sticker_masters.item_id'
|
||||||
|
)
|
||||||
|
->where('invoice_validations.plant_id', $plantId)
|
||||||
|
->where('invoice_validations.invoice_number', $this->invoiceNumber)
|
||||||
|
->pluck('items.code')
|
||||||
|
->unique()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$missedCodes = array_diff($wireItemCodes, $invoiceItemCodes);
|
||||||
|
|
||||||
|
if (! empty($missedCodes)) {
|
||||||
|
|
||||||
|
Notification::make()
|
||||||
|
->title('Items Missing in Invoice')
|
||||||
|
->body('Item codes are missing in invoice: '.implode(', ', $missedCodes))
|
||||||
|
->danger()
|
||||||
|
->seconds(3)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$duplicateSerial = [];
|
||||||
|
$weightExceeded = [];
|
||||||
|
$processedItems = [];
|
||||||
|
$invalidMaterialItems = [];
|
||||||
|
|
||||||
|
$wireItems1 = WireMasterPacking::join('items', 'items.id', '=', 'wire_master_packings.item_id')
|
||||||
|
->where('wire_master_packings.plant_id', $plantId)
|
||||||
|
->where('wire_master_packings.wire_packing_number', $wirePallet)
|
||||||
|
->select(
|
||||||
|
'items.code as item_code',
|
||||||
|
'wire_master_packings.process_order',
|
||||||
|
DB::raw('SUM(wire_master_packings.weight::numeric) as pallet_weight')
|
||||||
|
)
|
||||||
|
->groupBy('items.code', 'wire_master_packings.process_order')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($wireItems1 as $wireItem) {
|
||||||
|
$processOrder = $wireItem->process_order;
|
||||||
|
$palletWeight = $wireItem->pallet_weight;
|
||||||
|
$itemCode = $wireItem->item_code;
|
||||||
|
|
||||||
|
$processedItems[] = $itemCode;
|
||||||
|
|
||||||
|
$duplicate = InvoiceValidation::where('plant_id', $this->plantId)
|
||||||
|
->where('invoice_number', $this->invoiceNumber)
|
||||||
|
->where('serial_number', $processOrder)
|
||||||
|
->exists();
|
||||||
|
|
||||||
|
if ($duplicate) {
|
||||||
|
$duplicateSerial[] = $processOrder;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$materialType = StickerMaster::where('item_id', function ($q) use ($itemCode) {
|
||||||
|
$q->select('id')->from('items')->where('code', $itemCode);
|
||||||
|
})->value('material_type');
|
||||||
|
|
||||||
|
if ($materialType != 3) {
|
||||||
|
if (! in_array($itemCode, $invalidMaterialItems)) {
|
||||||
|
$invalidMaterialItems[] = $itemCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$scannedQty = InvoiceValidation::join('sticker_masters', 'sticker_masters.id', '=', 'invoice_validations.sticker_master_id')
|
||||||
|
->join('items', 'items.id', '=', 'sticker_masters.item_id')
|
||||||
|
->where('invoice_validations.plant_id', $plantId)
|
||||||
|
->where('invoice_validations.invoice_number', $this->invoiceNumber)
|
||||||
|
->where('items.code', $itemCode)
|
||||||
|
->sum(DB::raw('invoice_validations.quantity::numeric'));
|
||||||
|
|
||||||
|
if ($palletWeight > $scannedQty) {
|
||||||
|
$weightExceeded[] = $itemCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($invalidMaterialItems)) {
|
||||||
|
$uniqueInvalidItems = array_unique($invalidMaterialItems);
|
||||||
|
Notification::make()
|
||||||
|
->title('Invalid Material Type')
|
||||||
|
->body(implode(', ', $uniqueInvalidItems)."<br>Invalid material type found for the invoice '$invoiceNumber'.")
|
||||||
|
->danger()
|
||||||
|
->seconds(4)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
} elseif (! empty($weightExceeded)) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Item Code Limit')
|
||||||
|
->body(implode(', ', $weightExceeded)."<br>Master pallet weight exceeds the remaining quantity in invoice '$invoiceNumber'.")
|
||||||
|
->danger()
|
||||||
|
->seconds(4)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
} elseif (! empty($duplicateSerial)) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Duplicate Serial Number')
|
||||||
|
->body(implode(', ', $duplicateSerial)."<br>Duplicate Serial numbers found for the invoice '$invoiceNumber'.")
|
||||||
|
->danger()
|
||||||
|
->seconds(4)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$itemExceeded = [];
|
||||||
|
|
||||||
|
$invoiceRows = InvoiceValidation::where('plant_id', $plantId)
|
||||||
|
->where('invoice_number', $invoiceNumber)
|
||||||
|
->whereNull('serial_number')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$palletItems = WireMasterPacking::where('wire_master_packings.plant_id', $plantId)
|
||||||
|
->where('wire_master_packings.wire_packing_number', $wirePallet)
|
||||||
|
->join('items', 'items.id', '=', 'wire_master_packings.item_id')
|
||||||
|
->select(
|
||||||
|
'items.code as item_code',
|
||||||
|
DB::raw('SUM(wire_master_packings.weight::numeric) as pallet_weight')
|
||||||
|
)
|
||||||
|
->groupBy('items.code')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($invoiceRows as $row) {
|
||||||
|
$itemCode = $row->stickerMaster->item->code ?? null;
|
||||||
|
|
||||||
|
if (! $itemCode) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pallet = $palletItems->firstWhere('item_code', $itemCode);
|
||||||
|
$palletWeight = $pallet->pallet_weight ?? 0;
|
||||||
|
|
||||||
|
$remainingQty = $row->quantity;
|
||||||
|
|
||||||
|
if ($palletWeight > $remainingQty) {
|
||||||
|
$itemExceeded[] = $itemCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = implode(', ', $itemExceeded);
|
||||||
|
|
||||||
|
if (! empty($itemExceeded)) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Item Code Limit')
|
||||||
|
->body("Pallet weight exceeds remaining quantity for invoice number '$invoiceNumber'for below item codes <br>$items")
|
||||||
|
->danger()
|
||||||
|
->seconds(5)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$wireItems = WireMasterPacking::join('items', 'items.id', '=', 'wire_master_packings.item_id')
|
||||||
|
->where('wire_master_packings.wire_packing_number', $wirePallet)
|
||||||
|
->select(
|
||||||
|
'items.code as item_code',
|
||||||
|
'wire_master_packings.process_order',
|
||||||
|
'wire_master_packings.weight as pallet_weight'
|
||||||
|
// DB::raw('(wire_master_packings.weight::numeric) as pallet_weight')
|
||||||
|
)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($wireItems as $wireItem) {
|
||||||
|
|
||||||
|
$itemCode = $wireItem->item_code;
|
||||||
|
$palletWeight = $wireItem->pallet_weight;
|
||||||
|
$processOrder = $wireItem->process_order;
|
||||||
|
|
||||||
|
if (! $processOrder || $palletWeight <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$records = InvoiceValidation::join('sticker_masters', 'sticker_masters.id', '=', 'invoice_validations.sticker_master_id')
|
||||||
|
->join('items', 'items.id', '=', 'sticker_masters.item_id')
|
||||||
|
->where('invoice_validations.invoice_number', $invoiceNumber)
|
||||||
|
->where('invoice_validations.plant_id', $plantId)
|
||||||
|
->where('items.code', $itemCode)
|
||||||
|
->whereNull('invoice_validations.serial_number')
|
||||||
|
->where('invoice_validations.quantity', '>', 0)
|
||||||
|
->orderBy('invoice_validations.created_at')
|
||||||
|
->select('invoice_validations.*')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if ($records->isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($records as $record) {
|
||||||
|
|
||||||
|
if ($palletWeight <= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$usedQty = min($record->quantity, $palletWeight);
|
||||||
|
|
||||||
|
$record->quantity -= $usedQty;
|
||||||
|
|
||||||
|
if ($usedQty == $record->quantity + $usedQty) {
|
||||||
|
$record->serial_number = $processOrder;
|
||||||
|
$record->quantity = $palletWeight;
|
||||||
|
$record->save();
|
||||||
|
} else {
|
||||||
|
$record->save();
|
||||||
|
|
||||||
|
InvoiceValidation::create([
|
||||||
|
'sticker_master_id' => $record->sticker_master_id,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'invoice_number' => $invoiceNumber,
|
||||||
|
'serial_number' => $processOrder,
|
||||||
|
'quantity' => $usedQty,
|
||||||
|
'operator_id' => $operatorName,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'updated_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$palletWeight -= $usedQty;
|
||||||
|
|
||||||
|
// if ($record->quantity <= 0) {
|
||||||
|
// $records->forget($key);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||||
|
|
||||||
|
$totQuan = InvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
|
||||||
|
|
||||||
|
$scanMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'invoice_number' => $invoiceNumber,
|
||||||
|
'serial_number' => null,
|
||||||
|
'total_quantity' => $totQuan,
|
||||||
|
'update_invoice' => false,
|
||||||
|
'scanned_quantity' => $scanMQuan,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
$itemCode = null;
|
$itemCode = null;
|
||||||
$this->currentItemCode = '';
|
$this->currentItemCode = '';
|
||||||
@@ -2733,7 +3106,7 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
Notification::make()
|
Notification::make()
|
||||||
->danger()
|
->danger()
|
||||||
->title('Invalid Material QR Format')
|
->title('Invalid Material QR Format')
|
||||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||||
->seconds(1)
|
->seconds(1)
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
@@ -2866,6 +3239,12 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
$hasQuanTyp = ($record->material_type == 3) ? true : false;
|
$hasQuanTyp = ($record->material_type == 3) ? true : false;
|
||||||
|
|
||||||
|
if ($hasQuanTyp && $curMaterialSer && $curMaterialQty) {
|
||||||
|
$batchNumber = null;
|
||||||
|
$serialNumber = $curMaterialSer;
|
||||||
|
$curScanQty = $curMaterialQty;
|
||||||
|
}
|
||||||
|
|
||||||
$record = InvoiceValidation::where('invoice_number', $invoiceNumber)
|
$record = InvoiceValidation::where('invoice_number', $invoiceNumber)
|
||||||
->where('plant_id', $plantId)
|
->where('plant_id', $plantId)
|
||||||
->whereHas('stickerMasterRelation.item', function ($query) use ($itemCode) {
|
->whereHas('stickerMasterRelation.item', function ($query) use ($itemCode) {
|
||||||
@@ -2948,7 +3327,7 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
Notification::make()
|
Notification::make()
|
||||||
->danger()
|
->danger()
|
||||||
->title('Invalid Quantity Material QR Format')
|
->title('Invalid Quantity Material QR Format')
|
||||||
->body('Scan valid Quantity Material QR code proceed!<br>Ex:123456|12345|12345678|1/1')
|
->body('Scan valid Quantity Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1')
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
@@ -2994,8 +3373,8 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
$record->serial_number = $serialNumber;
|
$record->serial_number = $serialNumber;
|
||||||
$record->batch_number = $batchNumber;
|
$record->batch_number = $batchNumber;
|
||||||
$record->operator_id = $operatorName;
|
$record->operator_id = $operatorName;
|
||||||
// $record->updated_by = $operatorName;
|
$record->updated_by = $operatorName;
|
||||||
// $record->updated_at = now();
|
$record->updated_at = now();
|
||||||
$record->save();
|
$record->save();
|
||||||
|
|
||||||
// InvoiceValidation::create([
|
// InvoiceValidation::create([
|
||||||
@@ -3231,7 +3610,6 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
$record = InvoiceValidation::where('serial_number', $serialNumber)->where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first();
|
$record = InvoiceValidation::where('serial_number', $serialNumber)->where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first();
|
||||||
// $invoiceNumber = $this->form->getState()['invoice_number'];
|
|
||||||
|
|
||||||
if (! $record) {
|
if (! $record) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class PlantResource extends Resource
|
|||||||
Section::make('')
|
Section::make('')
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\TextInput::make('code')
|
Forms\Components\TextInput::make('code')
|
||||||
|
->label('Code')
|
||||||
->required()
|
->required()
|
||||||
->unique(ignoreRecord: true)
|
->unique(ignoreRecord: true)
|
||||||
->integer()
|
->integer()
|
||||||
@@ -78,7 +79,8 @@ class PlantResource extends Resource
|
|||||||
->hint(fn ($get) => $get('pCodeError') ? $get('pCodeError') : null)
|
->hint(fn ($get) => $get('pCodeError') ? $get('pCodeError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
Forms\Components\Select::make('company_id')
|
Forms\Components\Select::make('company_id')
|
||||||
// ->placeholder('Choose the valid company name')
|
->label('Company')
|
||||||
|
->placeholder('Choose the valid company nany')
|
||||||
->relationship('company', 'name')
|
->relationship('company', 'name')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -104,9 +106,10 @@ class PlantResource extends Resource
|
|||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
Forms\Components\TextInput::make('name')
|
Forms\Components\TextInput::make('name')
|
||||||
->required()
|
->required()
|
||||||
|
->label('Name')
|
||||||
->placeholder('Scan the valid name')
|
->placeholder('Scan the valid name')
|
||||||
->unique(ignoreRecord: true)
|
->unique(ignoreRecord: true)
|
||||||
->columnSpanFull()
|
// ->columnSpanFull()
|
||||||
->reactive()
|
->reactive()
|
||||||
->minLength(5)
|
->minLength(5)
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
@@ -128,8 +131,38 @@ class PlantResource extends Resource
|
|||||||
])
|
])
|
||||||
->hint(fn ($get) => $get('pNameError') ? $get('pNameError') : null)
|
->hint(fn ($get) => $get('pNameError') ? $get('pNameError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
|
Forms\Components\TextInput::make('warehouse_number')
|
||||||
|
// ->required()
|
||||||
|
->label('Warehouse Number')
|
||||||
|
->placeholder('Scan the valid warehouse number')
|
||||||
|
->unique(ignoreRecord: true)
|
||||||
|
->reactive()
|
||||||
|
->numeric()
|
||||||
|
->length(3),
|
||||||
|
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
// $codeId = $get('warehouse_number');
|
||||||
|
// // Ensure `linestop_id` is not cleared
|
||||||
|
// if (! $codeId) {
|
||||||
|
// $set('wNumberError', 'Scan the valid warehouse number.');
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// } else {
|
||||||
|
// if (strlen($codeId) != 3) {
|
||||||
|
// $set('wNumberError', 'Warehouse number must be exactly 3 digits!');
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// $set('wNumberError', null);
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// ->extraAttributes(fn ($get) => [
|
||||||
|
// 'class' => $get('wNumberError') ? 'border-red-500' : '',
|
||||||
|
// ])
|
||||||
|
// ->hint(fn ($get) => $get('wNumberError') ? $get('wNumberError') : null)
|
||||||
|
// ->hintColor('danger'),
|
||||||
Forms\Components\Textarea::make('address')
|
Forms\Components\Textarea::make('address')
|
||||||
->required()
|
->required()
|
||||||
|
->label('Address')
|
||||||
->placeholder('Scan the valid address')
|
->placeholder('Scan the valid address')
|
||||||
->unique(ignoreRecord: true)
|
->unique(ignoreRecord: true)
|
||||||
->columnSpanFull()
|
->columnSpanFull()
|
||||||
@@ -190,6 +223,11 @@ class PlantResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable()
|
->sortable()
|
||||||
->searchable(),
|
->searchable(),
|
||||||
|
Tables\Columns\TextColumn::make('warehouse_number')
|
||||||
|
->label('Warehouse Number')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('address')
|
Tables\Columns\TextColumn::make('address')
|
||||||
->label('Address')
|
->label('Address')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
|||||||
@@ -221,6 +221,12 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
->afterStateUpdated(function ($state, callable $set) {
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
}),
|
}),
|
||||||
|
Forms\Components\TextInput::make('category')
|
||||||
|
->label('Category')
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\Select::make('inspection_type')
|
Forms\Components\Select::make('inspection_type')
|
||||||
->label('Inspection Type')
|
->label('Inspection Type')
|
||||||
->searchable()
|
->searchable()
|
||||||
@@ -351,6 +357,11 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('category')
|
||||||
|
->label('Category')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('line.name')
|
Tables\Columns\TextColumn::make('line.name')
|
||||||
->label('Line Name')
|
->label('Line Name')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
|||||||
@@ -339,8 +339,9 @@ class ProductionCharacteristicResource extends Resource
|
|||||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('Item', null);
|
|
||||||
$set('Line', null);
|
$set('Line', null);
|
||||||
|
$set('Item', null);
|
||||||
|
$set('Machine', null);
|
||||||
}),
|
}),
|
||||||
Select::make('Line')
|
Select::make('Line')
|
||||||
->label('Search by Line Name')
|
->label('Search by Line Name')
|
||||||
@@ -361,7 +362,7 @@ class ProductionCharacteristicResource extends Resource
|
|||||||
})->pluck('name', 'id');
|
})->pluck('name', 'id');
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('process_order', null);
|
$set('Machine', null);
|
||||||
}),
|
}),
|
||||||
Select::make('Item')
|
Select::make('Item')
|
||||||
->label('Search by Item Code')
|
->label('Search by Item Code')
|
||||||
|
|||||||
@@ -203,7 +203,6 @@ class ProductionOrderResource extends Resource
|
|||||||
->label('Production Order')
|
->label('Production Order')
|
||||||
->readOnly()
|
->readOnly()
|
||||||
->visible(fn ($get) => $get('quantity') > 0),
|
->visible(fn ($get) => $get('quantity') > 0),
|
||||||
// ->visible(fn ($get) => $get('show_extra_fields')),
|
|
||||||
Forms\Components\TextInput::make('from_serial_number')
|
Forms\Components\TextInput::make('from_serial_number')
|
||||||
->label('From Serial Number')
|
->label('From Serial Number')
|
||||||
->readOnly()
|
->readOnly()
|
||||||
@@ -248,6 +247,18 @@ class ProductionOrderResource extends Resource
|
|||||||
->searchable()
|
->searchable()
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('item.description')
|
||||||
|
->label('Item Description')
|
||||||
|
->searchable()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('item.uom')
|
||||||
|
->label('Unit of Measure')
|
||||||
|
->searchable()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
Tables\Columns\TextColumn::make('quantity')
|
Tables\Columns\TextColumn::make('quantity')
|
||||||
->label('Quantity')
|
->label('Quantity')
|
||||||
->searchable()
|
->searchable()
|
||||||
|
|||||||
@@ -210,6 +210,41 @@ class CreateProductionOrder extends CreateRecord
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function printItemSerial()
|
||||||
|
{
|
||||||
|
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||||
|
|
||||||
|
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||||
|
|
||||||
|
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||||
|
|
||||||
|
if (empty($plantId)) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Plant name cannot be empty!')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
} elseif (empty($pOrder)) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Production order cannot be empty!')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||||
|
|
||||||
|
if (! $pOrderExists) {
|
||||||
|
Notification::make()
|
||||||
|
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function printPanel()
|
public function printPanel()
|
||||||
{
|
{
|
||||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||||
@@ -245,7 +280,6 @@ class CreateProductionOrder extends CreateRecord
|
|||||||
} else {
|
} else {
|
||||||
return redirect()->route('production-orders.printpanel', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
return redirect()->route('production-orders.printpanel', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getFormActions(): array
|
protected function getFormActions(): array
|
||||||
|
|||||||
@@ -89,6 +89,74 @@ class EditProductionOrder extends EditRecord
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public function printItemSerial()
|
||||||
|
// {
|
||||||
|
// $pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||||
|
|
||||||
|
// $plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||||
|
// $plantCode = Plant::where('id', $plantId)->value('code');
|
||||||
|
// if (empty($plantId)) {
|
||||||
|
// Notification::make()
|
||||||
|
// ->title('Plant name cannot be empty!')
|
||||||
|
// ->danger()
|
||||||
|
// ->send();
|
||||||
|
// return;
|
||||||
|
// } elseif (empty($pOrder)) {
|
||||||
|
// Notification::make()
|
||||||
|
// ->title('Production order cannot be empty!')
|
||||||
|
// ->danger()
|
||||||
|
// ->send();
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||||
|
|
||||||
|
// if (! $pOrderExists) {
|
||||||
|
// Notification::make()
|
||||||
|
// ->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||||
|
// ->danger()
|
||||||
|
// ->send();
|
||||||
|
// return;
|
||||||
|
// } else {
|
||||||
|
// return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function printItemSerial()
|
||||||
|
{
|
||||||
|
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||||
|
|
||||||
|
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||||
|
|
||||||
|
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||||
|
|
||||||
|
if (empty($plantId)) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Plant name cannot be empty!')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
} elseif (empty($pOrder)) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Production order cannot be empty!')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||||
|
|
||||||
|
if (! $pOrderExists) {
|
||||||
|
Notification::make()
|
||||||
|
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class ViewProductionOrder extends ViewRecord
|
|||||||
{
|
{
|
||||||
protected static string $resource = ProductionOrderResource::class;
|
protected static string $resource = ProductionOrderResource::class;
|
||||||
|
|
||||||
public function printProductionOrder()
|
public function printProductionOrder()
|
||||||
{
|
{
|
||||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||||
|
|
||||||
@@ -89,6 +89,76 @@ class ViewProductionOrder extends ViewRecord
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public function printItemSerial()
|
||||||
|
// {
|
||||||
|
// $pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||||
|
|
||||||
|
// $plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||||
|
|
||||||
|
// $plantCode = Plant::where('id', $plantId)->value('code');
|
||||||
|
|
||||||
|
// if (empty($plantId)) {
|
||||||
|
// Notification::make()
|
||||||
|
// ->title('Plant name cannot be empty!')
|
||||||
|
// ->danger()
|
||||||
|
// ->send();
|
||||||
|
// return;
|
||||||
|
// } elseif (empty($pOrder)) {
|
||||||
|
// Notification::make()
|
||||||
|
// ->title('Production order cannot be empty!')
|
||||||
|
// ->danger()
|
||||||
|
// ->send();
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||||
|
|
||||||
|
// if (! $pOrderExists) {
|
||||||
|
// Notification::make()
|
||||||
|
// ->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||||
|
// ->danger()
|
||||||
|
// ->send();
|
||||||
|
// return;
|
||||||
|
// } else {
|
||||||
|
// return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function printItemSerial()
|
||||||
|
{
|
||||||
|
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||||
|
|
||||||
|
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||||
|
|
||||||
|
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||||
|
|
||||||
|
if (empty($plantId)) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Plant name cannot be empty!')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
} elseif (empty($pOrder)) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Production order cannot be empty!')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||||
|
|
||||||
|
if (! $pOrderExists) {
|
||||||
|
Notification::make()
|
||||||
|
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class QualityValidationResource extends Resource
|
|||||||
Forms\Components\Hidden::make('plant')
|
Forms\Components\Hidden::make('plant')
|
||||||
->default(fn () => session('last_selected_plant_id'))
|
->default(fn () => session('last_selected_plant_id'))
|
||||||
->afterStateHydrated(function ($state, $set) {
|
->afterStateHydrated(function ($state, $set) {
|
||||||
if (!$state && request()->has('plant_id')) {
|
if (! $state && request()->has('plant_id')) {
|
||||||
$set('plant_id', request()->get('plant_id'));
|
$set('plant_id', request()->get('plant_id'));
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
@@ -136,7 +136,7 @@ class QualityValidationResource extends Resource
|
|||||||
Forms\Components\Hidden::make('line')
|
Forms\Components\Hidden::make('line')
|
||||||
->default(fn () => session('last_selected_line'))
|
->default(fn () => session('last_selected_line'))
|
||||||
->afterStateHydrated(function ($state, $set) {
|
->afterStateHydrated(function ($state, $set) {
|
||||||
if (!$state && request()->has('line_id')) {
|
if (! $state && request()->has('line_id')) {
|
||||||
$set('line_id', request()->get('line_id'));
|
$set('line_id', request()->get('line_id'));
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
@@ -178,7 +178,7 @@ class QualityValidationResource extends Resource
|
|||||||
Forms\Components\Hidden::make('production')
|
Forms\Components\Hidden::make('production')
|
||||||
->default(fn () => session('last_selected_production'))
|
->default(fn () => session('last_selected_production'))
|
||||||
->afterStateHydrated(function ($state, $set) {
|
->afterStateHydrated(function ($state, $set) {
|
||||||
if (!$state && request()->has('production_order')) {
|
if (! $state && request()->has('production_order')) {
|
||||||
$set('production_order', request()->get('production_order'));
|
$set('production_order', request()->get('production_order'));
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
@@ -2423,7 +2423,6 @@ class QualityValidationResource extends Resource
|
|||||||
$emails = $mailData['emails'];
|
$emails = $mailData['emails'];
|
||||||
$mUserName = Filament::auth()->user()->name;
|
$mUserName = Filament::auth()->user()->name;
|
||||||
|
|
||||||
|
|
||||||
if (! empty($emails)) {
|
if (! empty($emails)) {
|
||||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||||
Mail::to($emails)->send(
|
Mail::to($emails)->send(
|
||||||
@@ -2519,7 +2518,6 @@ class QualityValidationResource extends Resource
|
|||||||
$emails = $mailData['emails'];
|
$emails = $mailData['emails'];
|
||||||
$mUserName = Filament::auth()->user()->name;
|
$mUserName = Filament::auth()->user()->name;
|
||||||
|
|
||||||
|
|
||||||
if (! empty($emails)) {
|
if (! empty($emails)) {
|
||||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||||
Mail::to($emails)->send(
|
Mail::to($emails)->send(
|
||||||
@@ -2711,7 +2709,6 @@ class QualityValidationResource extends Resource
|
|||||||
$emails = $mailData['emails'];
|
$emails = $mailData['emails'];
|
||||||
$mUserName = Filament::auth()->user()->name;
|
$mUserName = Filament::auth()->user()->name;
|
||||||
|
|
||||||
|
|
||||||
if (! empty($emails)) {
|
if (! empty($emails)) {
|
||||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||||
Mail::to($emails)->send(
|
Mail::to($emails)->send(
|
||||||
@@ -2864,16 +2861,6 @@ class QualityValidationResource extends Resource
|
|||||||
'showChecklist' => $livewire->showChecklist,
|
'showChecklist' => $livewire->showChecklist,
|
||||||
]),
|
]),
|
||||||
|
|
||||||
// Forms\Components\View::make('components.production-checklist-wrapper')
|
|
||||||
// ->statePath('checklist')
|
|
||||||
// ->key('checklist-view')
|
|
||||||
// ->viewData(fn ($livewire) => [
|
|
||||||
// 'existingRecords' => is_array($livewire->existingRecords)
|
|
||||||
// ? $livewire->existingRecords
|
|
||||||
// : $livewire->existingRecords->toArray(),
|
|
||||||
// 'showChecklist' => $livewire->showChecklist,
|
|
||||||
// ]),
|
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3066,7 +3053,6 @@ class QualityValidationResource extends Resource
|
|||||||
])
|
])
|
||||||
|
|
||||||
->filters([
|
->filters([
|
||||||
|
|
||||||
Tables\Filters\TrashedFilter::make(),
|
Tables\Filters\TrashedFilter::make(),
|
||||||
Filter::make('advanced_filters')
|
Filter::make('advanced_filters')
|
||||||
->label('Advanced Filters')
|
->label('Advanced Filters')
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class CreateQualityValidation extends CreateRecord
|
|||||||
'checklistUpdated' => 'setChecklist',
|
'checklistUpdated' => 'setChecklist',
|
||||||
'checklist-cancelled' => 'handleChecklistCancel',
|
'checklist-cancelled' => 'handleChecklistCancel',
|
||||||
'checklist-saved' => 'checkListSaved',
|
'checklist-saved' => 'checkListSaved',
|
||||||
'trigger-create' => 'doCreate',
|
// 'trigger-create' => 'doCreate',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function setChecklist($checklist)
|
public function setChecklist($checklist)
|
||||||
@@ -89,13 +89,15 @@ class CreateQualityValidation extends CreateRecord
|
|||||||
->where('plant_id', $plantId)
|
->where('plant_id', $plantId)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
|
$categoryName = trim($item->category) ?? null;
|
||||||
|
|
||||||
if (!$item) {
|
if (!$item) {
|
||||||
$this->existingRecords = collect();
|
$this->existingRecords = collect();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->existingRecords = ProductCharacteristicsMaster::where('plant_id', $plantId)
|
$this->existingRecords = ProductCharacteristicsMaster::where('plant_id', $plantId)
|
||||||
->where('item_id', $item->id)
|
->where('category', $categoryName)
|
||||||
->where('line_id', $lineId)
|
->where('line_id', $lineId)
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
@@ -201,6 +203,7 @@ class CreateQualityValidation extends CreateRecord
|
|||||||
$checklist = $this->data['data']['checklist'] ?? [];
|
$checklist = $this->data['data']['checklist'] ?? [];
|
||||||
|
|
||||||
if (count($this->existingRecords) > 0){
|
if (count($this->existingRecords) > 0){
|
||||||
|
|
||||||
$this->showChecklist = true;
|
$this->showChecklist = true;
|
||||||
$this->halt();
|
$this->halt();
|
||||||
}
|
}
|
||||||
@@ -223,10 +226,11 @@ class CreateQualityValidation extends CreateRecord
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$item_id = $item->id;
|
// $item_id = $item->id;
|
||||||
|
$categoryName = trim($item->category) ?? null;
|
||||||
|
|
||||||
$this->existingRecords = ProductCharacteristicsMaster::where('plant_id', $plant_id)
|
$this->existingRecords = ProductCharacteristicsMaster::where('plant_id', $plant_id)
|
||||||
->where('item_id', $item_id)
|
->where('category', $categoryName)
|
||||||
->where('line_id', $line_id)
|
->where('line_id', $line_id)
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,14 @@
|
|||||||
namespace App\Filament\Resources;
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
use App\Filament\Exports\RequestCharacteristicExporter;
|
use App\Filament\Exports\RequestCharacteristicExporter;
|
||||||
|
use App\Filament\Imports\RequestCharacteristicImporter;
|
||||||
use App\Filament\Resources\RequestCharacteristicResource\Pages;
|
use App\Filament\Resources\RequestCharacteristicResource\Pages;
|
||||||
use App\Models\CharacteristicApproverMaster;
|
use App\Models\CharacteristicApproverMaster;
|
||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\Machine;
|
use App\Models\Machine;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\RequestCharacteristic;
|
use App\Models\RequestCharacteristic;
|
||||||
|
use App\Models\StickerMaster;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
@@ -19,6 +21,7 @@ use Filament\Forms\Components\TextInput;
|
|||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Forms\Get;
|
use Filament\Forms\Get;
|
||||||
use Filament\Forms\Set;
|
use Filament\Forms\Set;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\ExportAction;
|
use Filament\Tables\Actions\ExportAction;
|
||||||
@@ -27,6 +30,7 @@ use Filament\Tables\Filters\Filter;
|
|||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
@@ -128,6 +132,16 @@ class RequestCharacteristicResource extends Resource
|
|||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||||
|
Forms\Components\Hidden::make('show_validation_image')
|
||||||
|
->reactive()
|
||||||
|
->default(false),
|
||||||
|
Forms\Components\Hidden::make('validation1_image_url')
|
||||||
|
->reactive(),
|
||||||
|
|
||||||
|
Forms\Components\View::make('components.part-validation-error-icon')
|
||||||
|
->statePath('validation1_image_url')
|
||||||
|
->visible(fn ($get) => $get('show_validation_image') == true)
|
||||||
|
->reactive(),
|
||||||
Forms\Components\TextInput::make('work_flow_id')
|
Forms\Components\TextInput::make('work_flow_id')
|
||||||
->label('Work Flow ID')
|
->label('Work Flow ID')
|
||||||
->readOnly()
|
->readOnly()
|
||||||
@@ -139,7 +153,42 @@ class RequestCharacteristicResource extends Resource
|
|||||||
return self::isNewWorkFlow($get);
|
return self::isNewWorkFlow($get);
|
||||||
}
|
}
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
}),
|
})
|
||||||
|
->suffixAction(
|
||||||
|
Forms\Components\Actions\Action::make('toggleValidationImage')
|
||||||
|
->icon(fn (callable $get) => $get('show_validation_image') ? 'heroicon-o-eye-slash' : 'heroicon-o-eye')
|
||||||
|
->tooltip('View Validation Image')
|
||||||
|
->action(function (callable $get, $set) {
|
||||||
|
|
||||||
|
$currentState = $get('show_validation_image');
|
||||||
|
$set('show_validation_image', ! $currentState);
|
||||||
|
|
||||||
|
if ($currentState == true) {
|
||||||
|
$set('validation1_image_url', null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$workFlowId = $get('work_flow_id');
|
||||||
|
|
||||||
|
if (!$workFlowId) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Missing Workflow ID')
|
||||||
|
->body('Please select a Workflow ID.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build filename
|
||||||
|
$fileName = "{$workFlowId}.png";
|
||||||
|
|
||||||
|
$imageUrl = route('workflow.image', [
|
||||||
|
'filename' => $fileName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$set('validation1_image_url', $imageUrl);
|
||||||
|
})
|
||||||
|
),
|
||||||
// ->rule(function (callable $get) {
|
// ->rule(function (callable $get) {
|
||||||
// return Rule::unique('request_characteristics', 'work_flow_id')
|
// return Rule::unique('request_characteristics', 'work_flow_id')
|
||||||
// ->where('plant_id', $get('plant_id'))
|
// ->where('plant_id', $get('plant_id'))
|
||||||
@@ -312,7 +361,7 @@ class RequestCharacteristicResource extends Resource
|
|||||||
Forms\Components\Select::make('characteristic_approver_master_id')
|
Forms\Components\Select::make('characteristic_approver_master_id')
|
||||||
->label('Master Characteristic Field')
|
->label('Master Characteristic Field')
|
||||||
// ->relationship('characteristicApproverMaster', 'characteristic_field')
|
// ->relationship('characteristicApproverMaster', 'characteristic_field')
|
||||||
->columnSpan(2)
|
// ->columnSpan(2)
|
||||||
->reactive()
|
->reactive()
|
||||||
->nullable()
|
->nullable()
|
||||||
->searchable()
|
->searchable()
|
||||||
@@ -340,6 +389,17 @@ class RequestCharacteristicResource extends Resource
|
|||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('model_type')
|
||||||
|
->label('Model Type')
|
||||||
|
->reactive()
|
||||||
|
->nullable()
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('characteristic_name', null);
|
||||||
|
$set('current_value', null);
|
||||||
|
$set('update_value', null);
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
})
|
||||||
|
->required(),
|
||||||
// ->disabled(fn ($get) => self::isFieldDisabled($get))
|
// ->disabled(fn ($get) => self::isFieldDisabled($get))
|
||||||
Section::make('Request Characteristic Details')
|
Section::make('Request Characteristic Details')
|
||||||
// ->columnSpan(['default' => 2, 'sm' => 4])
|
// ->columnSpan(['default' => 2, 'sm' => 4])
|
||||||
@@ -500,6 +560,7 @@ class RequestCharacteristicResource extends Resource
|
|||||||
Forms\Components\TextInput::make('approver_remark1')
|
Forms\Components\TextInput::make('approver_remark1')
|
||||||
->label('Approver Remark')
|
->label('Approver Remark')
|
||||||
->live()
|
->live()
|
||||||
|
->maxLength(60)
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$appStat = $get('approver_status1');
|
$appStat = $get('approver_status1');
|
||||||
if ($appStat && $state) {
|
if ($appStat && $state) {
|
||||||
@@ -615,6 +676,7 @@ class RequestCharacteristicResource extends Resource
|
|||||||
Forms\Components\TextInput::make('approver_remark2')
|
Forms\Components\TextInput::make('approver_remark2')
|
||||||
->label('Approver Remark')
|
->label('Approver Remark')
|
||||||
->live()
|
->live()
|
||||||
|
->maxLength(60)
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$appStat = $get('approver_status2');
|
$appStat = $get('approver_status2');
|
||||||
if ($appStat && $state) {
|
if ($appStat && $state) {
|
||||||
@@ -727,6 +789,7 @@ class RequestCharacteristicResource extends Resource
|
|||||||
Forms\Components\TextInput::make('approver_remark3')
|
Forms\Components\TextInput::make('approver_remark3')
|
||||||
->label('Approver Remark')
|
->label('Approver Remark')
|
||||||
->live()
|
->live()
|
||||||
|
->maxLength(60)
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$appStat = $get('approver_status3');
|
$appStat = $get('approver_status3');
|
||||||
if ($appStat && $state) {
|
if ($appStat && $state) {
|
||||||
@@ -916,6 +979,11 @@ class RequestCharacteristicResource extends Resource
|
|||||||
->formatStateUsing(fn (string $state): string => strtoupper(__($state)))
|
->formatStateUsing(fn (string $state): string => strtoupper(__($state)))
|
||||||
->extraAttributes(['class' => 'uppercase'])
|
->extraAttributes(['class' => 'uppercase'])
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('model_type')
|
||||||
|
->label('Model Type')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('characteristic_name')
|
Tables\Columns\TextColumn::make('characteristic_name')
|
||||||
->label('Characteristic Name')
|
->label('Characteristic Name')
|
||||||
->default('-')
|
->default('-')
|
||||||
@@ -956,12 +1024,14 @@ class RequestCharacteristicResource extends Resource
|
|||||||
default => 'gray',
|
default => 'gray',
|
||||||
})
|
})
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
->default('-')
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('approver_remark1')
|
Tables\Columns\TextColumn::make('approver_remark1')
|
||||||
->label('Approver Remark 1')
|
->label('Approver Remark 1')
|
||||||
// ->color('success')
|
// ->color('success')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
->default('-')
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('approved1_at')
|
Tables\Columns\TextColumn::make('approved1_at')
|
||||||
@@ -984,12 +1054,14 @@ class RequestCharacteristicResource extends Resource
|
|||||||
default => 'gray',
|
default => 'gray',
|
||||||
})
|
})
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
->default('-')
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('approver_remark2')
|
Tables\Columns\TextColumn::make('approver_remark2')
|
||||||
->label('Approver Remark 2')
|
->label('Approver Remark 2')
|
||||||
// ->color('success')
|
// ->color('success')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
->default('-')
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('approved2_at')
|
Tables\Columns\TextColumn::make('approved2_at')
|
||||||
@@ -1012,12 +1084,14 @@ class RequestCharacteristicResource extends Resource
|
|||||||
default => 'gray',
|
default => 'gray',
|
||||||
})
|
})
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
->default('-')
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('approver_remark3')
|
Tables\Columns\TextColumn::make('approver_remark3')
|
||||||
->label('Approver Remark 3')
|
->label('Approver Remark 3')
|
||||||
// ->color('success')
|
// ->color('success')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
->default('-')
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('approved3_at')
|
Tables\Columns\TextColumn::make('approved3_at')
|
||||||
@@ -1160,6 +1234,67 @@ class RequestCharacteristicResource extends Resource
|
|||||||
->numeric()
|
->numeric()
|
||||||
->minlength(7)
|
->minlength(7)
|
||||||
->maxlength(10),
|
->maxlength(10),
|
||||||
|
TextInput::make('work_flow_id')
|
||||||
|
->label('Work Flow ID')
|
||||||
|
->placeholder('Enter Work Flow ID'),
|
||||||
|
TextInput::make('machine_name')
|
||||||
|
->label('Machine Name')
|
||||||
|
->placeholder('Enter Machine Name'),
|
||||||
|
Select::make('request_type')
|
||||||
|
->label('Request Type')
|
||||||
|
->options([
|
||||||
|
'Characteristic' => 'Characteristic',
|
||||||
|
'Quality' => 'Quality',
|
||||||
|
])
|
||||||
|
->placeholder('Select Request Type'),
|
||||||
|
TextInput::make('master_characteristic_field')
|
||||||
|
->label('Master Characteristic Field')
|
||||||
|
->placeholder('Enter Master Characteristic Field'),
|
||||||
|
TextInput::make('model_type')
|
||||||
|
->label('Model Type')
|
||||||
|
->placeholder('Enter Model Type'),
|
||||||
|
Select::make('approver_status')
|
||||||
|
->label('Approver Status')
|
||||||
|
->options([
|
||||||
|
'Approved' => 'Approved',
|
||||||
|
'Hold' => 'Hold',
|
||||||
|
'Rejected' => 'Rejected',
|
||||||
|
])
|
||||||
|
->placeholder('Select Status')
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('approver_status1', null);
|
||||||
|
$set('approver_status2', null);
|
||||||
|
$set('approver_status3', null);
|
||||||
|
}),
|
||||||
|
Select::make('approver_status1')
|
||||||
|
->label('Approver Status 1')
|
||||||
|
->options([
|
||||||
|
'Approved' => 'Approved',
|
||||||
|
'Hold' => 'Hold',
|
||||||
|
'Rejected' => 'Rejected',
|
||||||
|
])
|
||||||
|
->placeholder('Select Status')
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('approver_status2', null);
|
||||||
|
$set('approver_status3', null);
|
||||||
|
}),
|
||||||
|
Select::make('approver_status2')
|
||||||
|
->label('Approver Status 2')
|
||||||
|
->options([
|
||||||
|
'Approved' => 'Approved',
|
||||||
|
'Hold' => 'Hold',
|
||||||
|
'Rejected' => 'Rejected',
|
||||||
|
])
|
||||||
|
->placeholder('Select Status'),
|
||||||
|
Select::make('approver_status3')
|
||||||
|
->label('Approver Status 3')
|
||||||
|
->options([
|
||||||
|
'Approved' => 'Approved',
|
||||||
|
'Hold' => 'Hold',
|
||||||
|
'Rejected' => 'Rejected',
|
||||||
|
])
|
||||||
|
->placeholder('Select Status'),
|
||||||
|
|
||||||
DateTimePicker::make(name: 'created_from')
|
DateTimePicker::make(name: 'created_from')
|
||||||
->label('Created From')
|
->label('Created From')
|
||||||
->placeholder('Select From DateTime')
|
->placeholder('Select From DateTime')
|
||||||
@@ -1173,7 +1308,7 @@ class RequestCharacteristicResource extends Resource
|
|||||||
])
|
])
|
||||||
->query(function ($query, array $data) {
|
->query(function ($query, array $data) {
|
||||||
// Hide all records initially if no filters are applied
|
// Hide all records initially if no filters are applied
|
||||||
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['created_from']) && empty($data['created_to'])) {
|
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['model_type']) && empty($data['work_flow_id']) && empty($data['machine_name']) && empty($data['request_type']) && empty($data['master_characteristic_field'])&& empty($data['approver_status1']) && empty($data['approver_status2']) && empty($data['approver_status3']) && empty($data['approver_status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||||
return $query->whereRaw('1 = 0');
|
return $query->whereRaw('1 = 0');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1199,6 +1334,70 @@ class RequestCharacteristicResource extends Resource
|
|||||||
$query->where('aufnr', 'like', '%'.$data['aufnr'].'%');
|
$query->where('aufnr', 'like', '%'.$data['aufnr'].'%');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['model_type'])) {
|
||||||
|
$query->where('model_type', 'like', '%'.$data['model_type'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['work_flow_id'])) {
|
||||||
|
$query->where('work_flow_id', 'like', '%'.$data['work_flow_id'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($data['machine_name'])) {
|
||||||
|
$query->whereHas('characteristicApproverMaster', function ($q) use ($data) {
|
||||||
|
$q->where('characteristic_approver_masters.machine_name', '=', (string) $data['machine_name']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($data['request_type'])) {
|
||||||
|
$query->whereHas('characteristicApproverMaster', function ($q) use ($data) {
|
||||||
|
$q->where('characteristic_approver_masters.approver_type', '=', (string) $data['request_type']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($data['master_characteristic_field'])) {
|
||||||
|
$query->whereHas('characteristicApproverMaster', function ($q) use ($data) {
|
||||||
|
$q->where('characteristic_approver_masters.characteristic_field', '=', (string) $data['master_characteristic_field']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['approver_status1'])) {
|
||||||
|
$query->where('approver_status1', 'like', '%'.$data['approver_status1'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['approver_status2'])) {
|
||||||
|
$query->where('approver_status2', 'like', '%'.$data['approver_status2'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['approver_status3'])) {
|
||||||
|
$query->where('approver_status3', 'like', '%'.$data['approver_status3'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($data['approver_status'])) {
|
||||||
|
|
||||||
|
$status = $data['approver_status'];
|
||||||
|
|
||||||
|
$query->whereRaw("
|
||||||
|
CASE
|
||||||
|
|
||||||
|
-- If status3 exists, it must be considered first
|
||||||
|
WHEN approver_status3 IS NOT NULL AND approver_status3 != ''
|
||||||
|
THEN approver_status3
|
||||||
|
|
||||||
|
-- then status2 overrides only if status3 is empty
|
||||||
|
WHEN approver_status2 IS NOT NULL AND approver_status2 != ''
|
||||||
|
THEN approver_status2
|
||||||
|
|
||||||
|
-- finally status1 only if both 2 and 3 are empty
|
||||||
|
WHEN approver_status1 IS NOT NULL AND approver_status1 != ''
|
||||||
|
THEN approver_status1
|
||||||
|
|
||||||
|
ELSE NULL
|
||||||
|
|
||||||
|
END = ?
|
||||||
|
", [$status]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($data['created_from'])) {
|
if (! empty($data['created_from'])) {
|
||||||
$query->where('created_at', '>=', $data['created_from']);
|
$query->where('created_at', '>=', $data['created_from']);
|
||||||
}
|
}
|
||||||
@@ -1232,6 +1431,42 @@ class RequestCharacteristicResource extends Resource
|
|||||||
$indicators[] = 'Job No: '.$data['aufnr'];
|
$indicators[] = 'Job No: '.$data['aufnr'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['model_type'])) {
|
||||||
|
$indicators[] = 'Model Type: '.$data['model_type'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['work_flow_id'])) {
|
||||||
|
$indicators[] = 'Work Flow ID: '.$data['work_flow_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['machine_name'])) {
|
||||||
|
$indicators[] = 'Machine Name: '.$data['machine_name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['request_type'])) {
|
||||||
|
$indicators[] = 'Request Type: '.$data['request_type'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['master_characteristic_field'])) {
|
||||||
|
$indicators[] = 'Master Characteristic Field: '.$data['master_characteristic_field'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['approver_status'])) {
|
||||||
|
$indicators[] = 'Approver Status: '.$data['approver_status'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['approver_status1'])) {
|
||||||
|
$indicators[] = 'Approver Status 1: '.$data['approver_status1'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['approver_status2'])) {
|
||||||
|
$indicators[] = 'Approver Status 2: '.$data['approver_status2'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['approver_status3'])) {
|
||||||
|
$indicators[] = 'Approver Status 3: '.$data['approver_status3'];
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($data['created_from'])) {
|
if (! empty($data['created_from'])) {
|
||||||
$indicators[] = 'From: '.$data['created_from'];
|
$indicators[] = 'From: '.$data['created_from'];
|
||||||
}
|
}
|
||||||
@@ -1256,13 +1491,13 @@ class RequestCharacteristicResource extends Resource
|
|||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
// ImportAction::make()
|
ImportAction::make()
|
||||||
// ->label('Import Request Characteristics')
|
->label('Import Request Characteristics')
|
||||||
// ->color('warning')
|
->color('warning')
|
||||||
// ->importer(RequestCharacteristicImporter::class)
|
->importer(RequestCharacteristicImporter::class)
|
||||||
// ->visible(function () {
|
->visible(function () {
|
||||||
// return Filament::auth()->user()->can('view import request characteristic');
|
return Filament::auth()->user()->can('view import request characteristic');
|
||||||
// }),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Request Characteristics')
|
->label('Export Request Characteristics')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
|
|||||||
@@ -5,28 +5,27 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\TempClassCharacteristicExporter;
|
use App\Filament\Exports\TempClassCharacteristicExporter;
|
||||||
use App\Filament\Imports\TempClassCharacteristicImporter;
|
use App\Filament\Imports\TempClassCharacteristicImporter;
|
||||||
use App\Filament\Resources\TempClassCharacteristicResource\Pages;
|
use App\Filament\Resources\TempClassCharacteristicResource\Pages;
|
||||||
use App\Filament\Resources\TempClassCharacteristicResource\RelationManagers;
|
|
||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\Machine;
|
use App\Models\Machine;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\TempClassCharacteristic;
|
use App\Models\TempClassCharacteristic;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
|
use Filament\Forms\Components\Section;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Table;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
||||||
use Filament\Forms\Components\Section;
|
|
||||||
use Filament\Forms\Get;
|
|
||||||
use Illuminate\Validation\Rule;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
use Filament\Tables\Actions\ExportAction;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Filters\Filter;
|
use Filament\Tables\Filters\Filter;
|
||||||
use Filament\Forms\Components\DateTimePicker;
|
use Filament\Tables\Table;
|
||||||
use Filament\Forms\Components\Select;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class TempClassCharacteristicResource extends Resource
|
class TempClassCharacteristicResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -1029,6 +1028,10 @@ class TempClassCharacteristicResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('model_type')
|
||||||
|
->label('MODEL TYPE')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('aufnr')
|
Tables\Columns\TextColumn::make('aufnr')
|
||||||
->label('AUFNR')
|
->label('AUFNR')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
@@ -1055,10 +1058,6 @@ class TempClassCharacteristicResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('model_type')
|
|
||||||
->label('MODEL TYPE')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('zz1_cn_bill_ord')
|
Tables\Columns\TextColumn::make('zz1_cn_bill_ord')
|
||||||
->label('ZZ1 CN BILL ORD')
|
->label('ZZ1 CN BILL ORD')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
@@ -1181,6 +1180,7 @@ class TempClassCharacteristicResource extends Resource
|
|||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('zmm_ratedpower')
|
Tables\Columns\TextColumn::make('zmm_ratedpower')
|
||||||
->label('ZMM RATEDPOWER')
|
->label('ZMM RATEDPOWER')
|
||||||
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('zmm_region')
|
Tables\Columns\TextColumn::make('zmm_region')
|
||||||
->label('ZMM REGION')
|
->label('ZMM REGION')
|
||||||
@@ -1577,14 +1577,12 @@ class TempClassCharacteristicResource extends Resource
|
|||||||
Tables\Columns\TextColumn::make('winded_serial_number')
|
Tables\Columns\TextColumn::make('winded_serial_number')
|
||||||
->label('WINDED SERIAL NUMBER')
|
->label('WINDED SERIAL NUMBER')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('part_validation_1')
|
Tables\Columns\TextColumn::make('model_type')
|
||||||
->label('PART VALIDATION 1')
|
->label('MODEL TYPE')
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('part_validation_2')
|
|
||||||
->label('PART VALIDATION 2')
|
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('has_work_flow_id')
|
Tables\Columns\TextColumn::make('has_work_flow_id')
|
||||||
->label('HAS WORK FLOW ID')
|
->label('HAS WORK FLOW ID')
|
||||||
@@ -1599,14 +1597,28 @@ class TempClassCharacteristicResource extends Resource
|
|||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
|
->label('CREATED AT')
|
||||||
|
->alignCenter()
|
||||||
|
->dateTime()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('created_by')
|
||||||
|
->label('CREATED BY')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('updated_at')
|
||||||
|
->label('UPDATED AT')
|
||||||
|
->alignCenter()
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
Tables\Columns\TextColumn::make('updated_at')
|
Tables\Columns\TextColumn::make('updated_by')
|
||||||
->dateTime()
|
->label('UPDATED BY')
|
||||||
|
->alignCenter()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
Tables\Columns\TextColumn::make('deleted_at')
|
Tables\Columns\TextColumn::make('deleted_at')
|
||||||
|
->label('DELETED AT')
|
||||||
|
->alignCenter()
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
@@ -1690,6 +1702,12 @@ class TempClassCharacteristicResource extends Resource
|
|||||||
TextInput::make('gernr')
|
TextInput::make('gernr')
|
||||||
->label('Serial Number')
|
->label('Serial Number')
|
||||||
->placeholder('Enter Serial Number'),
|
->placeholder('Enter Serial Number'),
|
||||||
|
TextInput::make('zmm_heading')
|
||||||
|
->label('Heading')
|
||||||
|
->placeholder('Enter Heading'),
|
||||||
|
TextInput::make('model_type')
|
||||||
|
->label('Model Type')
|
||||||
|
->placeholder('Enter Model Type'),
|
||||||
Select::make('work_flow_status')
|
Select::make('work_flow_status')
|
||||||
->label('Work Flow Status')
|
->label('Work Flow Status')
|
||||||
->placeholder('Select Work Flow Status')
|
->placeholder('Select Work Flow Status')
|
||||||
@@ -1711,7 +1729,7 @@ class TempClassCharacteristicResource extends Resource
|
|||||||
])
|
])
|
||||||
->query(function ($query, array $data) {
|
->query(function ($query, array $data) {
|
||||||
// Hide all records initially if no filters are applied
|
// Hide all records initially if no filters are applied
|
||||||
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['created_from']) && empty($data['created_to']) && !array_key_exists('work_flow_status', $data)) {
|
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['zmm_heading']) && empty($data['model_type']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||||
return $query->whereRaw('1 = 0');
|
return $query->whereRaw('1 = 0');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1741,6 +1759,14 @@ class TempClassCharacteristicResource extends Resource
|
|||||||
$query->where('gernr', 'like', '%'.$data['gernr'].'%');
|
$query->where('gernr', 'like', '%'.$data['gernr'].'%');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['zmm_heading'])) {
|
||||||
|
$query->where('zmm_heading', 'like', '%'.$data['zmm_heading'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['model_type'])) {
|
||||||
|
$query->where('model_type', 'like', '%'.$data['model_type'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
if (array_key_exists('work_flow_status', $data) && $data['work_flow_status'] != '') {
|
if (array_key_exists('work_flow_status', $data) && $data['work_flow_status'] != '') {
|
||||||
$query->where('has_work_flow_id', $data['work_flow_status']);
|
$query->where('has_work_flow_id', $data['work_flow_status']);
|
||||||
}
|
}
|
||||||
@@ -1782,6 +1808,14 @@ class TempClassCharacteristicResource extends Resource
|
|||||||
$indicators[] = 'Serial Number: '.$data['gernr'];
|
$indicators[] = 'Serial Number: '.$data['gernr'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['zmm_heading'])) {
|
||||||
|
$indicators[] = 'Heading: '.$data['zmm_heading'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['model_type'])) {
|
||||||
|
$indicators[] = 'Model Type: '.$data['model_type'];
|
||||||
|
}
|
||||||
|
|
||||||
if (array_key_exists('work_flow_status', $data) && $data['work_flow_status'] != '') {
|
if (array_key_exists('work_flow_status', $data) && $data['work_flow_status'] != '') {
|
||||||
$statusMap = [
|
$statusMap = [
|
||||||
'1' => 'Pending Approval',
|
'1' => 'Pending Approval',
|
||||||
@@ -1789,7 +1823,7 @@ class TempClassCharacteristicResource extends Resource
|
|||||||
'0' => 'Approved',
|
'0' => 'Approved',
|
||||||
];
|
];
|
||||||
|
|
||||||
$indicators[] = 'Work Flow Status: ' . ($statusMap[$data['work_flow_status']] ?? '');
|
$indicators[] = 'Work Flow Status: '.($statusMap[$data['work_flow_status']] ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['created_from'])) {
|
if (! empty($data['created_from'])) {
|
||||||
|
|||||||
@@ -630,7 +630,7 @@ class TestingPanelReadingResource extends Resource
|
|||||||
->options(function () {
|
->options(function () {
|
||||||
// return Plant::pluck('name', 'id');
|
// return Plant::pluck('name', 'id');
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
if ($userHas && strlen($userHas) > 0) {
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Resources;
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
use App\Filament\Resources\VehicleEntryResource\Pages;
|
use App\Filament\Resources\VehicleEntryResource\Pages;
|
||||||
|
use App\Models\Item;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\VehicleEntry;
|
use App\Models\VehicleEntry;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
@@ -14,6 +15,10 @@ use Filament\Tables;
|
|||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
use Filament\Tables\Filters\Filter;
|
||||||
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
|
||||||
class VehicleEntryResource extends Resource
|
class VehicleEntryResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -37,9 +42,15 @@ class VehicleEntryResource extends Resource
|
|||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('uuid')
|
||||||
|
->label('Uuid')
|
||||||
|
->required(),
|
||||||
Forms\Components\TextInput::make('vehicle_number')
|
Forms\Components\TextInput::make('vehicle_number')
|
||||||
->label('Vehicle Number')
|
->label('Vehicle Number')
|
||||||
->required(),
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('boom_opened')
|
||||||
|
->label('Boom Opened')
|
||||||
|
->required(),
|
||||||
Forms\Components\DateTimePicker::make('entry_time')
|
Forms\Components\DateTimePicker::make('entry_time')
|
||||||
->label('Entry Time')
|
->label('Entry Time')
|
||||||
->required()
|
->required()
|
||||||
@@ -102,10 +113,21 @@ class VehicleEntryResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable()
|
->sortable()
|
||||||
->searchable(),
|
->searchable(),
|
||||||
|
// Tables\Columns\TextColumn::make('uuid')
|
||||||
|
// ->label('UUID')
|
||||||
|
// ->alignCenter()
|
||||||
|
// ->sortable()
|
||||||
|
// ->searchable(),
|
||||||
Tables\Columns\TextColumn::make('vehicle_number')
|
Tables\Columns\TextColumn::make('vehicle_number')
|
||||||
->label('Vehicle Number')
|
->label('Vehicle Number')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable()
|
->sortable()
|
||||||
|
->searchable()
|
||||||
|
->formatStateUsing(fn ($state) => strtoupper($state)),
|
||||||
|
Tables\Columns\TextColumn::make('boom_opened')
|
||||||
|
->label('Boom Opened')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
->searchable(),
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('entry_time')
|
Tables\Columns\TextColumn::make('entry_time')
|
||||||
->label('Entry Time')
|
->label('Entry Time')
|
||||||
@@ -148,7 +170,106 @@ class VehicleEntryResource extends Resource
|
|||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
Tables\Filters\TrashedFilter::make(),
|
Tables\Filters\TrashedFilter::make(),
|
||||||
|
Filter::make('advanced_filters')
|
||||||
|
->label('Advanced Filters')
|
||||||
|
->form([
|
||||||
|
Select::make('Plant')
|
||||||
|
->label('Search by Plant Name')
|
||||||
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||||
|
} else {
|
||||||
|
return Plant::whereHas('vehicleEntries', function ($query) {
|
||||||
|
$query->whereNotNull('id');
|
||||||
|
})->orderBy('code')->pluck('name', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('vehicle_number', null);
|
||||||
|
}),
|
||||||
|
TextInput::make('vehicle_number')
|
||||||
|
->label('Vehicle Number')
|
||||||
|
->reactive()
|
||||||
|
->placeholder('Enter Vehicle Number')
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('Rework', null);
|
||||||
|
}),
|
||||||
|
DateTimePicker::make('created_from')
|
||||||
|
->label('Created From')
|
||||||
|
->placeholder('Select From DateTime')
|
||||||
|
->reactive()
|
||||||
|
->native(false),
|
||||||
|
DateTimePicker::make('created_to')
|
||||||
|
->label('Created To')
|
||||||
|
->placeholder('Select To DateTime')
|
||||||
|
->reactive()
|
||||||
|
->native(false),
|
||||||
|
])
|
||||||
|
->query(function ($query, array $data) {
|
||||||
|
// Hide all records initially if no filters are applied
|
||||||
|
if (empty($data['Plant']) && empty($data['vehicle_number']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||||
|
return $query->whereRaw('1 = 0');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['Plant'])) {
|
||||||
|
$query->where('plant_id', $data['Plant']);
|
||||||
|
} else {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return $query->whereRaw('1 = 0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['vehicle_number'])) {
|
||||||
|
$query->where('vehicle_number', 'like', '%'.$data['vehicle_number'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_from'])) {
|
||||||
|
$query->where('created_at', '>=', $data['created_from']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_to'])) {
|
||||||
|
$query->where('created_at', '<=', $data['created_to']);
|
||||||
|
}
|
||||||
|
// $query->orderBy('created_at', 'asc');
|
||||||
|
})
|
||||||
|
->indicateUsing(function (array $data) {
|
||||||
|
$indicators = [];
|
||||||
|
|
||||||
|
if (! empty($data['Plant'])) {
|
||||||
|
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||||
|
} else {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return 'Plant Name: Choose plant to filter records.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['vehicle_number'])) {
|
||||||
|
$indicators[] = 'Vehicle Number: '.$data['vehicle_number'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_from'])) {
|
||||||
|
$indicators[] = 'From: '.$data['created_from'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_to'])) {
|
||||||
|
$indicators[] = 'To: '.$data['created_to'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $indicators;
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
|
->filtersFormMaxHeight('280px')
|
||||||
->actions([
|
->actions([
|
||||||
Tables\Actions\ViewAction::make(),
|
Tables\Actions\ViewAction::make(),
|
||||||
Tables\Actions\EditAction::make(),
|
Tables\Actions\EditAction::make(),
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ namespace App\Filament\Resources;
|
|||||||
|
|
||||||
use App\Filament\Resources\WireMasterPackingResource\Pages;
|
use App\Filament\Resources\WireMasterPackingResource\Pages;
|
||||||
use App\Models\CustomerPoMaster;
|
use App\Models\CustomerPoMaster;
|
||||||
|
use App\Models\Item;
|
||||||
|
use App\Models\Line;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\WireMasterPacking;
|
use App\Models\WireMasterPacking;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
@@ -17,6 +19,10 @@ use Filament\Tables;
|
|||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
use Filament\Tables\Filters\Filter;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
|
use Str;
|
||||||
|
|
||||||
class WireMasterPackingResource extends Resource
|
class WireMasterPackingResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -269,7 +275,189 @@ class WireMasterPackingResource extends Resource
|
|||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
Tables\Filters\TrashedFilter::make(),
|
Tables\Filters\TrashedFilter::make(),
|
||||||
|
Filter::make('advanced_filters')
|
||||||
|
->label('Advanced Filters')
|
||||||
|
->form([
|
||||||
|
Select::make('Plant')
|
||||||
|
->label('Search by Plant Name')
|
||||||
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||||
|
} else {
|
||||||
|
return Plant::whereHas('wireMasterPacking', function ($query) {
|
||||||
|
$query->whereNotNull('id');
|
||||||
|
})->orderBy('code')->pluck('name', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('Item', null);
|
||||||
|
}),
|
||||||
|
Select::make('Item')
|
||||||
|
->label('Search by Item Code')
|
||||||
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
|
if (empty($plantId)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Item::whereHas('wireMasterPacking', function ($query) use ($plantId) {
|
||||||
|
if ($plantId) {
|
||||||
|
$query->where('plant_id', $plantId);
|
||||||
|
}
|
||||||
|
})->pluck('code', 'id');
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('process_order', null);
|
||||||
|
}),
|
||||||
|
TextInput::make('wire_packing_number')
|
||||||
|
->label('Wire Packing Number')
|
||||||
|
->reactive()
|
||||||
|
->placeholder('Enter Wire Packing Number')
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('process_order', null);
|
||||||
|
}),
|
||||||
|
TextInput::make('process_order')
|
||||||
|
->label('Process Order')
|
||||||
|
->reactive()
|
||||||
|
->placeholder('Enter Process Order')
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('Rework', null);
|
||||||
|
}),
|
||||||
|
TextInput::make('customer_po_master_id')
|
||||||
|
->label('Customer PO')
|
||||||
|
->reactive()
|
||||||
|
->placeholder('Enter Customer PO'),
|
||||||
|
Select::make('wire_packing_status')
|
||||||
|
->label('Wire Packing Status')
|
||||||
|
->reactive()
|
||||||
|
->options([
|
||||||
|
'Completed' => 'Completed',
|
||||||
|
'Pending' => 'Pending',
|
||||||
|
]),
|
||||||
|
DateTimePicker::make(name: 'created_from')
|
||||||
|
->label('Created From')
|
||||||
|
->placeholder('Select From DateTime')
|
||||||
|
->reactive()
|
||||||
|
->native(false),
|
||||||
|
DateTimePicker::make('created_to')
|
||||||
|
->label('Created To')
|
||||||
|
->placeholder('Select To DateTime')
|
||||||
|
->reactive()
|
||||||
|
->native(false),
|
||||||
|
])
|
||||||
|
->query(function ($query, array $data) {
|
||||||
|
// Hide all records initially if no filters are applied
|
||||||
|
if (empty($data['Plant']) && empty($data['Item']) && empty($data['process_order']) && empty($data['wire_packing_number']) && empty($data['customer_po_master_id']) && empty($data['wire_packing_status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||||
|
return $query->whereRaw('1 = 0');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['Plant'])) {
|
||||||
|
$query->where('plant_id', $data['Plant']);
|
||||||
|
} else {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return $query->whereRaw('1 = 0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['Item'])) {
|
||||||
|
$query->where('item_id', $data['Item']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['process_order'])) {
|
||||||
|
$query->where('process_order', 'like', '%'.$data['process_order'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['wire_packing_number'])) {
|
||||||
|
$query->where('wire_packing_number', 'like', '%'.$data['wire_packing_number'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($data['customer_po_master_id'])) {
|
||||||
|
|
||||||
|
$customerPoId = CustomerPoMaster::where('customer_po', $data['customer_po_master_id'])
|
||||||
|
->where('plant_id', $data['Plant'])
|
||||||
|
->value('id');
|
||||||
|
|
||||||
|
$query->where('customer_po_master_id', $customerPoId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['wire_packing_status'])) {
|
||||||
|
if ($data['wire_packing_status'] == 'Pending') {
|
||||||
|
$query->where(function ($q) {
|
||||||
|
$q->whereNull('wire_packing_status')
|
||||||
|
->orWhere('wire_packing_status', '');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$query->where('wire_packing_status', $data['wire_packing_status']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_from'])) {
|
||||||
|
$query->where('created_at', '>=', $data['created_from']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_to'])) {
|
||||||
|
$query->where('created_at', '<=', $data['created_to']);
|
||||||
|
}
|
||||||
|
// $query->orderBy('created_at', 'asc');
|
||||||
|
})
|
||||||
|
->indicateUsing(function (array $data) {
|
||||||
|
$indicators = [];
|
||||||
|
|
||||||
|
if (! empty($data['Plant'])) {
|
||||||
|
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||||
|
} else {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return 'Plant Name: Choose plant to filter records.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['Item'])) {
|
||||||
|
$indicators[] = 'Item Code: '.Item::where('id', $data['Item'])->value('code');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['process_order'])) {
|
||||||
|
$indicators[] = 'Process Order: '.$data['process_order'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['wire_packing_number'])) {
|
||||||
|
$indicators[] = 'Wire Packing Number: '.$data['wire_packing_number'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['customer_po_master_id'])) {
|
||||||
|
$indicators[] = 'Customer PO: '.$data['customer_po_master_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['wire_packing_status'])) {
|
||||||
|
$indicators[] = 'Wire Packing Status: '.$data['wire_packing_status'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_from'])) {
|
||||||
|
$indicators[] = 'From: '.$data['created_from'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_to'])) {
|
||||||
|
$indicators[] = 'To: '.$data['created_to'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $indicators;
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
|
->filtersFormMaxHeight('280px')
|
||||||
->actions([
|
->actions([
|
||||||
Tables\Actions\ViewAction::make(),
|
Tables\Actions\ViewAction::make(),
|
||||||
Tables\Actions\EditAction::make(),
|
Tables\Actions\EditAction::make(),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Resources\WireMasterPackingResource\Pages;
|
namespace App\Filament\Resources\WireMasterPackingResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\WireMasterPackingResource;
|
use App\Filament\Resources\WireMasterPackingResource;
|
||||||
|
use App\Models\CustomerPoMaster;
|
||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\WireMasterPacking;
|
use App\Models\WireMasterPacking;
|
||||||
@@ -81,7 +82,9 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pattern = '/^([^|]+)\|([^|]+)\|(\d+(\.\d+)?)$/';
|
// $pattern = '/^([^|]+)\|([^|]+)\|(\d+(\.\d+)?)$/';
|
||||||
|
// $pattern = '/^([^|]+)\|([^|]+)\|([^|]+)\|(\d+(\.\d+)?)$/';
|
||||||
|
$pattern = '/^([^|]+)\|([^|]+)\|([^|]+)\|(\d+(\.\d+)?)(kg)?$/i';
|
||||||
|
|
||||||
if (!preg_match($pattern, $processOrder, $matches))
|
if (!preg_match($pattern, $processOrder, $matches))
|
||||||
{
|
{
|
||||||
@@ -106,7 +109,8 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
|
|
||||||
$materialCode = $matches[1];
|
$materialCode = $matches[1];
|
||||||
$processOrderId = $matches[2];
|
$processOrderId = $matches[2];
|
||||||
$weight = $matches[3];
|
$coilNo = $matches[3];
|
||||||
|
$weight = $matches[4];
|
||||||
|
|
||||||
$icode = Item::where('code', $materialCode)->first();
|
$icode = Item::where('code', $materialCode)->first();
|
||||||
|
|
||||||
@@ -160,7 +164,34 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$processOrderAgaPlant = WireMasterPacking::where('process_order', $processOrderId)->where('plant_id', $plantId)->first();
|
$itemId = Item::where('code', $materialCode)
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->value('id');
|
||||||
|
|
||||||
|
$icodeAgaCPoPlant = CustomerPoMaster::where('item_id', $itemId)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
|
if(!$icodeAgaCPoPlant)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Unknown Item Code in Customer PO")
|
||||||
|
->body("Item Code '$materialCode' not found in any active Customer PO against Plant Code '$plantcode'")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $wirePackNo,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$processOrderAgaPlant = WireMasterPacking::where('process_order', $processOrderId . '-' . $coilNo)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
if($processOrderAgaPlant)
|
if($processOrderAgaPlant)
|
||||||
{
|
{
|
||||||
@@ -182,6 +213,68 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
]);
|
]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$customerPoRecord = CustomerPoMaster::where('id', $customerPo)
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$customerPoName = $customerPoRecord->customer_po;
|
||||||
|
|
||||||
|
if ($customerPoRecord) {
|
||||||
|
$customerPoName = $customerPoRecord->customer_po;
|
||||||
|
} else {
|
||||||
|
$customerPoName = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$customerPoRecord)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("PO Not Found")
|
||||||
|
->body("Customer PO '$customerPoName' for Item '$materialCode' not found against Plant '$plantcode'")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $wirePackNo,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$alreadyScannedQty = WireMasterPacking::where('customer_po_master_id', $customerPo)
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->where('item_id', $itemId)
|
||||||
|
->selectRaw('SUM(CAST(weight AS NUMERIC)) as total_weight')
|
||||||
|
->value('total_weight');
|
||||||
|
|
||||||
|
$totalQty = (float)$alreadyScannedQty + (float)$weight;
|
||||||
|
|
||||||
|
if($totalQty > (float)$customerPoRecord->quantity)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Scanned Weight Exceeds PO Quantity")
|
||||||
|
->body("Scanned weight '$weight' and already scanned weight '$alreadyScannedQty' exceeds allowed quantity '{$customerPoRecord->quantity}' for PO '$customerPoName' and Item '$materialCode'")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $wirePackNo,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$existingPallet = WireMasterPacking::where('plant_id', $plantId)
|
$existingPallet = WireMasterPacking::where('plant_id', $plantId)
|
||||||
@@ -200,7 +293,7 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'item_id' => $itemId,
|
'item_id' => $itemId,
|
||||||
'wire_packing_number' => $wirePackNo,
|
'wire_packing_number' => $wirePackNo,
|
||||||
'process_order' => $processOrderId,
|
'process_order' => $processOrderId . '-' . $coilNo,
|
||||||
'customer_po_master_id' => $customerPo,
|
'customer_po_master_id' => $customerPo,
|
||||||
'weight' => $weight,
|
'weight' => $weight,
|
||||||
'created_by' => $createdBy,
|
'created_by' => $createdBy,
|
||||||
@@ -590,6 +683,33 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pattern = '/^([^|]+)\|([^|]+)\|([^|]+)\|(\d+(\.\d+)?)(kg)?$/i';
|
||||||
|
|
||||||
|
if (!preg_match($pattern, $processOrder, $matches))
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Scan Valid Qr code ")
|
||||||
|
->body("Expected Format : (MaterialCode|Process Order|Id|Weight)")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$materialCode = $matches[1];
|
||||||
|
$processOrderId = $matches[2];
|
||||||
|
$coilNo = $matches[3];
|
||||||
|
$weight = $matches[4];
|
||||||
|
|
||||||
$count = WireMasterPacking::where('plant_id', $plantId)
|
$count = WireMasterPacking::where('plant_id', $plantId)
|
||||||
->where('wire_packing_number', $palletNumber)
|
->where('wire_packing_number', $palletNumber)
|
||||||
->count('wire_packing_number');
|
->count('wire_packing_number');
|
||||||
@@ -618,7 +738,7 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
|
|
||||||
|
|
||||||
$processOrderexist = WireMasterPacking::where('plant_id', $plantId)
|
$processOrderexist = WireMasterPacking::where('plant_id', $plantId)
|
||||||
->where('process_order', $processOrder)
|
->where('process_order', $processOrderId . '-' . $coilNo)
|
||||||
->first();
|
->first();
|
||||||
if (!$processOrderexist)
|
if (!$processOrderexist)
|
||||||
{
|
{
|
||||||
@@ -643,7 +763,7 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
$palletExist = WireMasterPacking::where('plant_id', $plantId)
|
$palletExist = WireMasterPacking::where('plant_id', $plantId)
|
||||||
->where('process_order', $processOrder)
|
->where('process_order', $processOrderId . '-' . $coilNo)
|
||||||
->where('wire_packing_number', '!=', '')
|
->where('wire_packing_number', '!=', '')
|
||||||
->where('wire_packing_number', '!=', null)
|
->where('wire_packing_number', '!=', null)
|
||||||
->first();
|
->first();
|
||||||
@@ -673,7 +793,7 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
|
|
||||||
$deleted = WireMasterPacking::where('plant_id', $plantId)
|
$deleted = WireMasterPacking::where('plant_id', $plantId)
|
||||||
->where('wire_packing_number', $palletNumber)
|
->where('wire_packing_number', $palletNumber)
|
||||||
->where('process_order', $processOrder)
|
->where('process_order', $processOrderId . '-' . $coilNo)
|
||||||
->forceDelete();
|
->forceDelete();
|
||||||
|
|
||||||
if ($deleted)
|
if ($deleted)
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ class InvoiceChart extends ChartWidget
|
|||||||
{
|
{
|
||||||
$selectedPlant = session('selec_plant');
|
$selectedPlant = session('selec_plant');
|
||||||
$selectedInvoice = session('select_invoice');
|
$selectedInvoice = session('select_invoice');
|
||||||
|
|
||||||
|
$fromDt = session('from_date');
|
||||||
|
$toDt = session('to_date');
|
||||||
|
|
||||||
$activeFilter = $this->filter; // Assuming filter is passed and activeFilter can be 'yesterday', 'this_week', 'this_month'
|
$activeFilter = $this->filter; // Assuming filter is passed and activeFilter can be 'yesterday', 'this_week', 'this_month'
|
||||||
|
|
||||||
if (!$selectedPlant || !$selectedInvoice) {
|
if (!$selectedPlant || !$selectedInvoice) {
|
||||||
@@ -31,23 +35,33 @@ class InvoiceChart extends ChartWidget
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the date range based on the active filter
|
$isCustomDate = !empty($fromDt) && !empty($toDt);
|
||||||
if ($activeFilter == 'yesterday') {
|
|
||||||
$startDate = now()->subDay()->setTime(8, 0, 0);
|
if (!empty($fromDt) && !empty($toDt)) {
|
||||||
$endDate = now()->setTime(8, 0, 0);
|
$startDate = \Carbon\Carbon::parse($fromDt)->setTime(8, 0, 0);
|
||||||
$groupBy = 'none'; // No grouping by hour
|
$endDate = \Carbon\Carbon::parse($toDt)->addDay()->setTime(8, 0, 0);
|
||||||
} elseif ($activeFilter == 'this_week') {
|
$groupBy = 'none';
|
||||||
$startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
}
|
||||||
$endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
else{
|
||||||
$groupBy = 'day_of_week';
|
|
||||||
} elseif ($activeFilter == 'this_month') {
|
// Define the date range based on the active filter
|
||||||
$startDate = now()->startOfMonth()->setTime(8, 0, 0);
|
if ($activeFilter == 'yesterday') {
|
||||||
$endDate = now()->endOfMonth()->setTime(8, 0, 0);
|
$startDate = now()->subDay()->setTime(8, 0, 0);
|
||||||
$groupBy = 'week_of_month';
|
$endDate = now()->setTime(8, 0, 0);
|
||||||
} else {
|
$groupBy = 'none'; // No grouping by hour
|
||||||
$startDate = now()->setTime(8, 0, 0);
|
} elseif ($activeFilter == 'this_week') {
|
||||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
$startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||||
$groupBy = 'none'; // No grouping by hour
|
$endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||||
|
$groupBy = 'day_of_week';
|
||||||
|
} elseif ($activeFilter == 'this_month') {
|
||||||
|
$startDate = now()->startOfMonth()->setTime(8, 0, 0);
|
||||||
|
$endDate = now()->endOfMonth()->setTime(8, 0, 0);
|
||||||
|
$groupBy = 'week_of_month';
|
||||||
|
} else {
|
||||||
|
$startDate = now()->setTime(8, 0, 0);
|
||||||
|
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||||
|
$groupBy = 'none'; // No grouping by hour
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the counts for Imported Invoices (unique invoice numbers) and Completed Invoices
|
// Get the counts for Imported Invoices (unique invoice numbers) and Completed Invoices
|
||||||
@@ -111,7 +125,11 @@ class InvoiceChart extends ChartWidget
|
|||||||
$labels = []; // Labels for each bar
|
$labels = []; // Labels for each bar
|
||||||
$datasets = []; // Datasets for the chart
|
$datasets = []; // Datasets for the chart
|
||||||
|
|
||||||
if (in_array($activeFilter, ['yesterday'])) {
|
if (!empty($fromDt) && !empty($toDt)) {
|
||||||
|
$activeFilter = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isCustomDate || in_array($activeFilter, ['yesterday'])) {
|
||||||
$labels = ['Imported Invoice', 'Completed Invoice'];
|
$labels = ['Imported Invoice', 'Completed Invoice'];
|
||||||
$datasets = [[
|
$datasets = [[
|
||||||
'label' => 'Invoices',
|
'label' => 'Invoices',
|
||||||
@@ -120,8 +138,7 @@ class InvoiceChart extends ChartWidget
|
|||||||
'fill' => false,
|
'fill' => false,
|
||||||
]];
|
]];
|
||||||
}
|
}
|
||||||
|
elseif ($isCustomDate || $activeFilter == 'this_week')
|
||||||
elseif ($activeFilter == 'this_week')
|
|
||||||
{
|
{
|
||||||
$daysOfWeek = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
$daysOfWeek = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
||||||
$importedInvoicesPerDay = array_fill(0, 7, 0);
|
$importedInvoicesPerDay = array_fill(0, 7, 0);
|
||||||
@@ -191,7 +208,7 @@ class InvoiceChart extends ChartWidget
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
elseif ($activeFilter == 'this_month') {
|
elseif ($isCustomDate || $activeFilter == 'this_month') {
|
||||||
$startOfMonth = now()->startOfMonth()->setTime(8, 0, 0);
|
$startOfMonth = now()->startOfMonth()->setTime(8, 0, 0);
|
||||||
$endOfMonth = now()->endOfMonth()->addDay()->setTime(23, 59, 59); // include full last day
|
$endOfMonth = now()->endOfMonth()->addDay()->setTime(23, 59, 59); // include full last day
|
||||||
$monthName = $startOfMonth->format('M');
|
$monthName = $startOfMonth->format('M');
|
||||||
@@ -279,7 +296,7 @@ class InvoiceChart extends ChartWidget
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
else
|
elseif (!$isCustomDate)
|
||||||
{
|
{
|
||||||
$labels = ['Imported Invoice', 'Completed Invoice'];
|
$labels = ['Imported Invoice', 'Completed Invoice'];
|
||||||
$datasets = [[
|
$datasets = [[
|
||||||
@@ -354,7 +371,7 @@ class InvoiceChart extends ChartWidget
|
|||||||
|
|
||||||
public static function canView(): bool
|
public static function canView(): bool
|
||||||
{
|
{
|
||||||
// dd('Checking route:', request()->route()->getName());
|
// dd('Checking route:', request()->route()->getName());
|
||||||
// to avoid showing the widget in other pages
|
// to avoid showing the widget in other pages
|
||||||
return request()->routeIs('filament.admin.pages.invoice-dashboard');
|
return request()->routeIs('filament.admin.pages.invoice-dashboard');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\CharacteristicApproverMaster;
|
||||||
use App\Models\ClassCharacteristic;
|
use App\Models\ClassCharacteristic;
|
||||||
use App\Models\RequestCharacteristic;
|
use App\Models\RequestCharacteristic;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class CharacteristicApprovalController extends Controller
|
class CharacteristicApprovalController extends Controller
|
||||||
{
|
{
|
||||||
@@ -358,10 +360,26 @@ class CharacteristicApprovalController extends Controller
|
|||||||
->where('work_flow_id', $record->work_flow_id)
|
->where('work_flow_id', $record->work_flow_id)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
$approverMasterNames = CharacteristicApproverMaster::find($record->characteristic_approver_master_id);
|
||||||
|
|
||||||
|
if (! $approverMasterNames) {
|
||||||
|
abort(500, 'Approver master not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$approverNameColumn = match ($level) {
|
||||||
|
1 => 'name1',
|
||||||
|
2 => 'name2',
|
||||||
|
3 => 'name3',
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
|
||||||
|
$updatedBy = $approverNameColumn ? $approverMasterNames->$approverNameColumn : null;
|
||||||
|
|
||||||
$updateData = [
|
$updateData = [
|
||||||
$statusColumn => $status,
|
$statusColumn => $status,
|
||||||
$remarkColumn => $request->input('remark'),
|
$remarkColumn => $request->input('remark'),
|
||||||
$approvedAtColumn => Carbon::now(),
|
$approvedAtColumn => Carbon::now(),
|
||||||
|
'updated_by' => $updatedBy,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (in_array($status, ['Approved', 'Rejected'])) {
|
if (in_array($status, ['Approved', 'Rejected'])) {
|
||||||
@@ -386,6 +404,14 @@ class CharacteristicApprovalController extends Controller
|
|||||||
// ->where('aufnr', $record->aufnr)
|
// ->where('aufnr', $record->aufnr)
|
||||||
// ->update(['has_work_flow_id' => $record->work_flow_id]);
|
// ->update(['has_work_flow_id' => $record->work_flow_id]);
|
||||||
|
|
||||||
|
if ($status == 'Rejected') {
|
||||||
|
$filePath = 'uploads/LaserDocs/'.$record->work_flow_id.'.png';
|
||||||
|
|
||||||
|
if (Storage::disk('local')->exists($filePath)) {
|
||||||
|
Storage::disk('local')->delete($filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($returnView) {
|
if ($returnView) {
|
||||||
return match ($status) {
|
return match ($status) {
|
||||||
'Approved' => view('approval.success'),
|
'Approved' => view('approval.success'),
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -107,7 +107,7 @@ class PalletPrintController extends Controller
|
|||||||
|
|
||||||
$index = $completedPallets->search($pallet);
|
$index = $completedPallets->search($pallet);
|
||||||
|
|
||||||
$currentPalletNo = ($index != false) ? $index + 1 : 0;
|
$currentPalletNo = ($index !== false) ? $index + 1 : 0;
|
||||||
|
|
||||||
$boxLabel = $currentPalletNo.'/'.$totalBoxes;
|
$boxLabel = $currentPalletNo.'/'.$totalBoxes;
|
||||||
|
|
||||||
@@ -143,8 +143,10 @@ class PalletPrintController extends Controller
|
|||||||
'customerName' => $customerName,
|
'customerName' => $customerName,
|
||||||
'masterBox' => $boxLabel,
|
'masterBox' => $boxLabel,
|
||||||
'items' => $items,
|
'items' => $items,
|
||||||
'grossWeight' => $grossWeight,
|
'grossWeight' => $grossWeight + 3.050,
|
||||||
'netWeight' => $grossWeight - 3.05,
|
'netWeight' => $grossWeight,
|
||||||
|
// 'grossWeight' => $grossWeight,
|
||||||
|
// 'netWeight' => $grossWeight - 3.05,
|
||||||
'pallet' => $pallet,
|
'pallet' => $pallet,
|
||||||
])->setPaper([0, 0, $widthPt, $heightPt], 'portrait');
|
])->setPaper([0, 0, $widthPt, $heightPt], 'portrait');
|
||||||
|
|
||||||
|
|||||||
@@ -29,30 +29,30 @@ class PlantController extends Controller
|
|||||||
public function get_all_data(Request $request)
|
public function get_all_data(Request $request)
|
||||||
{
|
{
|
||||||
$expectedUser = env('API_AUTH_USER');
|
$expectedUser = env('API_AUTH_USER');
|
||||||
$expectedPw = env('API_AUTH_PW');
|
$expectedPw = env('API_AUTH_PW');
|
||||||
$header_auth = $request->header('Authorization');
|
$header_auth = $request->header('Authorization');
|
||||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||||
|
|
||||||
if ("Bearer " . $expectedToken != $header_auth)
|
if ('Bearer '.$expectedToken != $header_auth) {
|
||||||
{
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => 'Invalid authorization token!'
|
'status_description' => 'Invalid authorization token!',
|
||||||
], 403);
|
], 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
$plants = Plant::with('company')->orderBy('code')->get();
|
$plants = Plant::with('company')->orderBy('code')->get();
|
||||||
$plantsData = $plants->map(function($plant) {
|
$plantsData = $plants->map(function ($plant) {
|
||||||
return [
|
return [
|
||||||
'company' => $plant->company ? $plant->company->name : "", // Get company name
|
'company' => $plant->company ? $plant->company->name : '', // Get company name
|
||||||
'plant_code' => (String)$plant->code,
|
'plant_code' => (string) $plant->code,
|
||||||
'plant_name' => $plant->name,
|
'plant_name' => $plant->name,
|
||||||
'plant_address' => $plant->address,
|
'plant_warehouse_number' => (string) $plant->warehouse_number,
|
||||||
|
'plant_address' => $plant->address,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'plants' => $plantsData
|
'plants' => $plantsData,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Plant;
|
||||||
use App\Models\ProductionOrder;
|
use App\Models\ProductionOrder;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -49,6 +50,7 @@ class ProductionOrderController extends Controller
|
|||||||
|
|
||||||
$qrCode = new QrCode($qrData);
|
$qrCode = new QrCode($qrData);
|
||||||
$output = new Output\Png;
|
$output = new Output\Png;
|
||||||
|
// $qrBinary = $output->output($qrCode, 100);
|
||||||
$qrBinary = $output->output($qrCode, 100);
|
$qrBinary = $output->output($qrCode, 100);
|
||||||
$qrBase64 = base64_encode($qrBinary);
|
$qrBase64 = base64_encode($qrBinary);
|
||||||
|
|
||||||
@@ -68,8 +70,28 @@ class ProductionOrderController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function printpanel($production_order, $plantCode){
|
public function printpanel($production_order, $plantCode){
|
||||||
|
|
||||||
|
\Log::info('Print Panel Started', [
|
||||||
|
'production_order' => $production_order,
|
||||||
|
'plantCode' => $plantCode,
|
||||||
|
]);
|
||||||
|
|
||||||
$order = ProductionOrder::where('production_order', $production_order)->first();
|
$order = ProductionOrder::where('production_order', $production_order)->first();
|
||||||
|
|
||||||
|
$wareHouseNo = Plant::where('code', $plantCode)->first();
|
||||||
|
|
||||||
|
$wareNo = $wareHouseNo->warehouse_number ?? null;
|
||||||
|
|
||||||
|
|
||||||
|
\Log::info('Plant Data', [
|
||||||
|
'plant' => $wareHouseNo ? $wareHouseNo->toArray() : null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
\Log::info('Warehouse Number', [
|
||||||
|
'warehouse_number' => $wareNo,
|
||||||
|
'final_code' => $plantCode . $wareNo,
|
||||||
|
]);
|
||||||
|
|
||||||
if (!$order) {
|
if (!$order) {
|
||||||
abort(404, 'Production Order not found');
|
abort(404, 'Production Order not found');
|
||||||
}
|
}
|
||||||
@@ -88,12 +110,11 @@ class ProductionOrderController extends Controller
|
|||||||
{
|
{
|
||||||
|
|
||||||
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
||||||
$serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -5);
|
$serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -6);
|
||||||
|
|
||||||
$qrData = $plantCode . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
$qrData = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
||||||
|
|
||||||
$panel = $plantCode . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
|
||||||
|
|
||||||
|
$panel = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
||||||
|
|
||||||
$qrCode = new QrCode($qrData);
|
$qrCode = new QrCode($qrData);
|
||||||
$output = new Output\Png;
|
$output = new Output\Png;
|
||||||
@@ -115,6 +136,77 @@ class ProductionOrderController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function printitemserial($production_order, $plantCode)
|
||||||
|
{
|
||||||
|
$order = ProductionOrder::where('production_order', $production_order)->first();
|
||||||
|
|
||||||
|
if (!$order) {
|
||||||
|
abort(404, 'Production Order not found');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$fromSerial = (int) $order->from_serial_number;
|
||||||
|
$toSerial = (int) $order->to_serial_number;
|
||||||
|
$itemCode = $order->item->code ?? '';
|
||||||
|
$itemDes = $order->item->description ?? '';
|
||||||
|
|
||||||
|
$wareHouseNo = Plant::where('code', $plantCode)->first();
|
||||||
|
|
||||||
|
$wareNo = $wareHouseNo->warehouse_number ?? null;
|
||||||
|
|
||||||
|
$now = Carbon::now();
|
||||||
|
$year = $now->format('y');
|
||||||
|
$month = $now->format('m');
|
||||||
|
|
||||||
|
$stickers = [];
|
||||||
|
|
||||||
|
for ($i = $fromSerial; $i <= $toSerial; $i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
||||||
|
|
||||||
|
if(!empty($wareNo)){
|
||||||
|
$serial = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
|
||||||
|
$qrData = $itemCode . '|' . $serial;
|
||||||
|
} else {
|
||||||
|
$qrData = $itemCode . '|' . $serial;
|
||||||
|
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// $qrData = $itemCode . '|' . $serial;
|
||||||
|
|
||||||
|
// $serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -6);
|
||||||
|
|
||||||
|
// $serialWithWarehouse = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
|
||||||
|
|
||||||
|
// $qrData = $itemCode . '|' . $serialWithWarehouse;
|
||||||
|
|
||||||
|
// $panel = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
||||||
|
|
||||||
|
// $qrBase64 = base64_encode(
|
||||||
|
// QrCode::format('png')->size(100)->generate($qrData)
|
||||||
|
// );
|
||||||
|
|
||||||
|
$qrCode = new QrCode($qrData);
|
||||||
|
$output = new Output\Png;
|
||||||
|
// $qrBinary = $output->output($qrCode, 100);
|
||||||
|
$qrBinary = $output->output($qrCode, 100);
|
||||||
|
$qrBase64 = base64_encode($qrBinary);
|
||||||
|
|
||||||
|
$stickers[] = [
|
||||||
|
'serial' => $serial,
|
||||||
|
'qr' => 'data:image/png;base64,' . $qrBase64,
|
||||||
|
'production_order' => $itemCode,
|
||||||
|
'description' => $itemDes ?? ''
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdf = Pdf::loadView('production-orders.printItemSerial', compact('stickers'))
|
||||||
|
->setPaper([0, 0, 170, 40]);
|
||||||
|
|
||||||
|
return $pdf->stream('stickers.pdf');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -41,12 +41,11 @@ class VehicleController extends Controller
|
|||||||
|
|
||||||
if (!ctype_digit((string) $plantCode)) {
|
if (!ctype_digit((string) $plantCode)) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status' => 'error',
|
'status' => 'ERROR',
|
||||||
'status_description' => "plant code must be $plantCode a numeric value",
|
'status_description' => "plant code must be $plantCode a numeric value",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$plantCod = Plant::where('code', $plantCode)->first();
|
$plantCod = Plant::where('code', $plantCode)->first();
|
||||||
|
|
||||||
if(!$plantCod){
|
if(!$plantCod){
|
||||||
@@ -58,100 +57,178 @@ class VehicleController extends Controller
|
|||||||
|
|
||||||
$plantId = $plantCod->id;
|
$plantId = $plantCod->id;
|
||||||
|
|
||||||
$data = $request->all();
|
// $data = $request->all();
|
||||||
|
|
||||||
$vehicleNo = $data['vehicle_number'] ?? '';
|
$data = $request->json()->all();
|
||||||
$entryTimeRaw = $data['entry_time'] ?? '';
|
|
||||||
$exitTimeRaw = $data['exit_time'] ?? '';
|
|
||||||
$duration = $data['duration'] ?? '';
|
|
||||||
$type = $data['type'] ?? '';
|
|
||||||
|
|
||||||
if(!$vehicleNo)
|
$results = [];
|
||||||
|
|
||||||
|
foreach ($data as $item) {
|
||||||
|
|
||||||
|
$uuid = $item['uuid'] ?? '';
|
||||||
|
$vehicleNo = trim($item['vehicle_number'] ?? '');
|
||||||
|
$entryTimeRaw = $item['entry_time'] ?? '';
|
||||||
|
$exitTimeRaw = $item['exit_time'] ?? '';
|
||||||
|
$duration = $item['duration'] ?? '';
|
||||||
|
$type = $item['type'] ?? '';
|
||||||
|
|
||||||
|
if (!$vehicleNo) {
|
||||||
|
|
||||||
|
$results[] = [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Vehicle number can't be empty!"
|
||||||
|
];
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
elseif (strlen($vehicleNo) < 8) {
|
||||||
|
|
||||||
|
$results[] = [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Vehicle number '$vehicleNo' must be at least 8 characters long"
|
||||||
|
];
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
elseif (!$entryTimeRaw) {
|
||||||
|
|
||||||
|
$results[] = [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Entry time can't be empty!"
|
||||||
|
];
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
elseif (!$type) {
|
||||||
|
|
||||||
|
$results[] = [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Type can't be empty!"
|
||||||
|
];
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
elseif ($entryTimeRaw && !Carbon::hasFormat($entryTimeRaw, 'd/m/Y h:i:s A')) {
|
||||||
|
$results[] = [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Invalid Entry time format $entryTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM"
|
||||||
|
];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if ($exitTimeRaw && !Carbon::hasFormat($exitTimeRaw, 'd/m/Y h:i:s A')) {
|
||||||
|
|
||||||
|
$results[] = [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Invalid Exit time format $exitTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM"
|
||||||
|
];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
elseif ($duration && !preg_match('/^\d{2}:\d{2}:\d{2}$/', $duration)) {
|
||||||
|
|
||||||
|
$results[] = [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Invalid duration format $duration"
|
||||||
|
];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($results)){
|
||||||
|
return response()->json($results, 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($data as $item) {
|
||||||
|
|
||||||
|
$uuid = $item['uuid'] ?? '';
|
||||||
|
// $vehicleNo = strtoupper(trim($item['vehicle_number'] ?? ''));
|
||||||
|
$vehicleNo = strtoupper(
|
||||||
|
str_replace(' ', '', trim($item['vehicle_number'] ?? ''))
|
||||||
|
);
|
||||||
|
$entryTimeRaw = $item['entry_time'] ?? '';
|
||||||
|
$exitTimeRaw = $item['exit_time'] ?? '';
|
||||||
|
$duration = $item['duration'] ?? '';
|
||||||
|
$type = $item['type'] ?? '';
|
||||||
|
|
||||||
|
$manualVehicles = [
|
||||||
|
'TN01KK0004',
|
||||||
|
'TN01KK0001',
|
||||||
|
];
|
||||||
|
|
||||||
|
$boomOpened = in_array($vehicleNo, $manualVehicles) ? 'Manual' : 'Auto';
|
||||||
|
|
||||||
|
if(!empty($entryTimeRaw)){
|
||||||
|
$entryTime = $entryTimeRaw
|
||||||
|
? Carbon::createFromFormat('d/m/Y h:i:s A', $entryTimeRaw)
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$exitTime = null;
|
||||||
|
|
||||||
|
if(!empty($exitTimeRaw)){
|
||||||
|
|
||||||
|
$exitTime = $exitTimeRaw
|
||||||
|
? Carbon::createFromFormat('d/m/Y h:i:s A', $exitTimeRaw)
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
empty($duration) &&
|
||||||
|
!empty($entryTime) &&
|
||||||
|
!empty($exitTime)
|
||||||
|
) {
|
||||||
|
|
||||||
|
$totalSeconds = $entryTime->diffInSeconds($exitTime);
|
||||||
|
|
||||||
|
$hours = floor($totalSeconds / 3600);
|
||||||
|
$minutes = floor(($totalSeconds % 3600) / 60);
|
||||||
|
$seconds = $totalSeconds % 60;
|
||||||
|
|
||||||
|
$duration = sprintf(
|
||||||
|
'%02d:%02d:%02d',
|
||||||
|
$hours,
|
||||||
|
$minutes,
|
||||||
|
$seconds
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$record = VehicleEntry::updateOrInsert(
|
||||||
|
[
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'uuid' => $uuid
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'vehicle_number' => $vehicleNo,
|
||||||
|
'boom_opened' => $boomOpened,
|
||||||
|
'entry_time' => $entryTime,
|
||||||
|
'exit_time' => $exitTime ?? null,
|
||||||
|
'duration' => $duration ?: null,
|
||||||
|
'type' => $type,
|
||||||
|
'updated_at' => now(),
|
||||||
|
'created_at' => now(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($record){
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'SUCCESS',
|
||||||
|
'status_description' => 'Vehicle entry inserted successfully'
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status' => 'ERROR',
|
'status' => 'ERROR',
|
||||||
'status_description' => "Vehicle number cant't be empty!",
|
'status_description' => 'Failed to insert record in the table vehicle entry'
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
else if (strlen($vehicleNo) < 8) {
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'ERROR',
|
|
||||||
'status_description' => "vehicle number '$vehicleNo' must be at least 8 characters long",
|
|
||||||
], 404);
|
|
||||||
}
|
|
||||||
else if(!$entryTimeRaw)
|
|
||||||
{
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'ERROR',
|
|
||||||
'status_description' => "Entry time cant't be empty!",
|
|
||||||
], 404);
|
|
||||||
}
|
|
||||||
else if(!$exitTimeRaw)
|
|
||||||
{
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'ERROR',
|
|
||||||
'status_description' => "Exit time cant't be empty!",
|
|
||||||
], 404);
|
|
||||||
}
|
|
||||||
else if(!$duration)
|
|
||||||
{
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'ERROR',
|
|
||||||
'status_description' => "Duration cant't be empty!",
|
|
||||||
], 404);
|
|
||||||
}
|
|
||||||
else if(!$type)
|
|
||||||
{
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'ERROR',
|
|
||||||
'status_description' => "type cant't be empty!",
|
|
||||||
], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($entryTimeRaw && !Carbon::hasFormat($entryTimeRaw, 'd/m/Y h:i:s A')) {
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'ERROR',
|
|
||||||
'status_description' => "Invalid Entry time format $entryTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM",
|
|
||||||
], 404);
|
|
||||||
}
|
|
||||||
else if ($exitTimeRaw && !Carbon::hasFormat($exitTimeRaw, 'd/m/Y h:i:s A')) {
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'ERROR',
|
|
||||||
'status_description' => "Invalid Exit time format $exitTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM",
|
|
||||||
], 404);
|
|
||||||
}
|
|
||||||
else if ($duration && !preg_match('/^\d{2}:\d{2}:\d{2}$/', $duration)) {
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'error',
|
|
||||||
'status_description' => "Invalid duration format $duration. Expected HH:MM:SS",
|
|
||||||
], 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
$entryTime = $entryTimeRaw
|
|
||||||
? Carbon::createFromFormat('d/m/Y h:i:s A', $entryTimeRaw)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
$exitTime = $exitTimeRaw
|
|
||||||
? Carbon::createFromFormat('d/m/Y h:i:s A', $exitTimeRaw)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
VehicleEntry::insert([
|
|
||||||
'plant_id' => $plantId,
|
|
||||||
'vehicle_number' => $vehicleNo,
|
|
||||||
'entry_time' => $entryTime,
|
|
||||||
'exit_time' => $exitTime,
|
|
||||||
'duration' => $duration,
|
|
||||||
'type' => $type,
|
|
||||||
'created_at' => now(),
|
|
||||||
'updated_at' => now(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'success',
|
|
||||||
'status_description' => 'Vehicle entry inserted successfully'
|
|
||||||
], 200);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ class CharacteristicApprovalMail extends Mailable
|
|||||||
|
|
||||||
public $subjectLine;
|
public $subjectLine;
|
||||||
|
|
||||||
|
public $characteristics;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new message instance.
|
* Create a new message instance.
|
||||||
*/
|
*/
|
||||||
|
|||||||
93
app/Mail/ImportTransitMail.php
Normal file
93
app/Mail/ImportTransitMail.php
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Mail;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
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 ImportTransitMail extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public $scheduleType;
|
||||||
|
|
||||||
|
public $tableData;
|
||||||
|
|
||||||
|
public $mailSubject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
*/
|
||||||
|
public function __construct($scheduleType, $tableData, $mailSubject)
|
||||||
|
{
|
||||||
|
$this->scheduleType = $scheduleType;
|
||||||
|
$this->tableData = $tableData ?? [];
|
||||||
|
$this->mailSubject = $mailSubject ?? 'Import Transit';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message envelope.
|
||||||
|
*/
|
||||||
|
public function envelope(): Envelope
|
||||||
|
{
|
||||||
|
return new Envelope(
|
||||||
|
subject: 'Import Transit Mail',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message content definition.
|
||||||
|
*/
|
||||||
|
public function content(): Content
|
||||||
|
{
|
||||||
|
$greeting = '<b>Dear Sir</b>';
|
||||||
|
|
||||||
|
//$greeting1 = 'Dear C.R.I Branch Team, <br><br> Please follow and ensure the same';
|
||||||
|
|
||||||
|
if ($this->scheduleType == 'daily') {
|
||||||
|
$reportPeriod = "The following report presents results";
|
||||||
|
$greeting .= $reportPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->scheduleType == 'Hourly') {
|
||||||
|
$now = now();
|
||||||
|
$fromHour = $now->copy()->subHour()->format('H:i:s');
|
||||||
|
$toHour = $now->format('H:i:s');
|
||||||
|
$reportDate = $now->format('d/m/Y');
|
||||||
|
$greeting .= "from: $reportDate, $fromHour to $toHour. <br><br>Please arrange to receipt the same immediately.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->scheduleType == 'Live') {
|
||||||
|
$now = now();
|
||||||
|
$fromMinute = $now->copy()->subMinute()->format('d/m/Y H:i:s');
|
||||||
|
$toMinute = $now->format('d/m/Y H:i:s');
|
||||||
|
$greeting .= "from: $fromMinute to $toMinute. <br><br>Please arrange to receipt the same immediately.";
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Content(
|
||||||
|
view: 'mail.import_transit_report',
|
||||||
|
with: [
|
||||||
|
'company' => 'CRI Digital Manufacturing Solutions',
|
||||||
|
'greeting' => $greeting,
|
||||||
|
'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 [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,28 +4,42 @@ namespace App\Mail;
|
|||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Mail\Mailable;
|
use Illuminate\Mail\Mailable;
|
||||||
use Illuminate\Mail\Mailables\Content;
|
use Illuminate\Mail\Mailables\Content;
|
||||||
use Illuminate\Mail\Mailables\Envelope;
|
use Illuminate\Mail\Mailables\Envelope;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
// use App\Exports\ProductionExport;
|
||||||
|
// use Illuminate\Mail\Mailables\Attachment;
|
||||||
|
// use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
|
||||||
class ProductionMail extends Mailable
|
class ProductionMail extends Mailable
|
||||||
{
|
{
|
||||||
use Queueable, SerializesModels;
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
public $tableData;
|
public $tableData;
|
||||||
|
|
||||||
public $scheduleType;
|
public $scheduleType;
|
||||||
|
// public $excelData;
|
||||||
|
// public $dates;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new message instance.
|
* Create a new message instance.
|
||||||
*/
|
*/
|
||||||
public function __construct($scheduleType,$tableData = [])
|
public function __construct($scheduleType, $tableData = [])
|
||||||
{
|
{
|
||||||
$this->scheduleType = $scheduleType;
|
$this->scheduleType = $scheduleType;
|
||||||
$this->tableData = $tableData ?? [];
|
$this->tableData = $tableData ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public function __construct($scheduleType,$tableData = [],$excelData = [],$dates = [])
|
||||||
|
// {
|
||||||
|
// $this->scheduleType = $scheduleType;
|
||||||
|
// $this->tableData = $tableData;
|
||||||
|
// $this->excelData = $excelData;
|
||||||
|
// $this->dates = $dates;
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the message envelope.
|
* Get the message envelope.
|
||||||
*/
|
*/
|
||||||
@@ -52,13 +66,14 @@ class ProductionMail extends Mailable
|
|||||||
// ],
|
// ],
|
||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public function content(): Content
|
public function content(): Content
|
||||||
{
|
{
|
||||||
$greeting = "Dear Sir/Madam,<br><br>Kindly find the attached production report status details for the 'Target Quantity' and 'Production Quantity' count,";
|
$greeting = "Dear Sir/Madam,<br><br>Kindly find the attached production report status details for the 'Target Quantity' and 'Production Quantity' count,";
|
||||||
|
|
||||||
if ($this->scheduleType == 'Daily') {
|
if ($this->scheduleType == 'Daily') {
|
||||||
$fromDate = (new DateTime('yesterday 08:00'))->format('d/m/Y H:i') . ':000';
|
$fromDate = (new DateTime('yesterday 08:00'))->format('d/m/Y H:i').':000';
|
||||||
$toDate = (new DateTime('today 07:59'))->format('d/m/Y H:i') . ':999';
|
$toDate = (new DateTime('today 07:59'))->format('d/m/Y H:i').':999';
|
||||||
$reportPeriod = "The following report presents results from: $fromDate to $toDate.";
|
$reportPeriod = "The following report presents results from: $fromDate to $toDate.";
|
||||||
$greeting .= $reportPeriod;
|
$greeting .= $reportPeriod;
|
||||||
}
|
}
|
||||||
@@ -74,22 +89,21 @@ class ProductionMail extends Mailable
|
|||||||
if ($this->scheduleType == 'Live') {
|
if ($this->scheduleType == 'Live') {
|
||||||
$now = now();
|
$now = now();
|
||||||
$fromMinute = $now->copy()->subMinute()->format('d/m/Y H:i:s');
|
$fromMinute = $now->copy()->subMinute()->format('d/m/Y H:i:s');
|
||||||
$toMinute = $now->format('d/m/Y H:i:s');
|
$toMinute = $now->format('d/m/Y H:i:s');
|
||||||
$greeting .= "The following report presents results from: $fromMinute to $toMinute.";
|
$greeting .= "The following report presents results from: $fromMinute to $toMinute.";
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Content(
|
return new Content(
|
||||||
view: 'mail.production_report',
|
view: 'mail.production_report',
|
||||||
with: [
|
with: [
|
||||||
'company' => "CRI Digital Manufacturing Solutions",
|
'company' => 'CRI Digital Manufacturing Solutions',
|
||||||
'greeting' => $greeting,
|
'greeting' => $greeting,
|
||||||
'tableData' => $this->tableData,
|
'tableData' => $this->tableData,
|
||||||
'wishes' => "Thanks & Regards,<br>CRI Digital Manufacturing Solutions"
|
'wishes' => 'Thanks & Regards,<br>CRI Digital Manufacturing Solutions',
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the attachments for the message.
|
* Get the attachments for the message.
|
||||||
*
|
*
|
||||||
@@ -98,5 +112,19 @@ class ProductionMail extends Mailable
|
|||||||
public function attachments(): array
|
public function attachments(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
// return [
|
||||||
|
// Attachment::fromData(
|
||||||
|
// fn () => Excel::raw(
|
||||||
|
// new ProductionExport(
|
||||||
|
// $this->excelData,
|
||||||
|
// $this->dates
|
||||||
|
// ),
|
||||||
|
// \Maatwebsite\Excel\Excel::XLSX
|
||||||
|
// ),
|
||||||
|
// 'production_plan_data.xlsx'
|
||||||
|
// )->withMime(
|
||||||
|
// 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||||
|
// ),
|
||||||
|
// ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
90
app/Mail/VehicleEntryMail.php
Normal file
90
app/Mail/VehicleEntryMail.php
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
<?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 VehicleEntryMail extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public $scheduleType;
|
||||||
|
|
||||||
|
public $tableData;
|
||||||
|
|
||||||
|
public $mailSubject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
*/
|
||||||
|
public function __construct($scheduleType, $tableData, $mailSubject)
|
||||||
|
{
|
||||||
|
$this->scheduleType = $scheduleType;
|
||||||
|
$this->tableData = $tableData ?? [];
|
||||||
|
$this->mailSubject = $mailSubject ?? 'Vehicle Entry Report';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message envelope.
|
||||||
|
*/
|
||||||
|
public function envelope(): Envelope
|
||||||
|
{
|
||||||
|
return new Envelope(
|
||||||
|
subject: 'Vehicle Entry Mail',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message content definition.
|
||||||
|
*/
|
||||||
|
public function content(): Content
|
||||||
|
{
|
||||||
|
$greeting = '<b>Dear Sir</b>';
|
||||||
|
|
||||||
|
//$greeting1 = 'Dear C.R.I Branch Team, <br><br> Please follow and ensure the same';
|
||||||
|
|
||||||
|
if ($this->scheduleType == 'Daily') {
|
||||||
|
$reportPeriod = "";
|
||||||
|
$greeting .= $reportPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->scheduleType == 'Hourly') {
|
||||||
|
$now = now();
|
||||||
|
$fromHour = $now->copy()->subHour()->format('H:i:s');
|
||||||
|
$toHour = $now->format('H:i:s');
|
||||||
|
$reportDate = $now->format('d/m/Y');
|
||||||
|
$greeting .= "from: $reportDate, $fromHour to $toHour. <br><br>Please arrange to receipt the same immediately.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->scheduleType == 'Live') {
|
||||||
|
$now = now();
|
||||||
|
$fromMinute = $now->copy()->subMinute()->format('d/m/Y H:i:s');
|
||||||
|
$toMinute = $now->format('d/m/Y H:i:s');
|
||||||
|
$greeting .= "from: $fromMinute to $toMinute. <br><br>Please arrange to receipt the same immediately.";
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Content(
|
||||||
|
view: 'mail.vehicle_entry_report',
|
||||||
|
with: [
|
||||||
|
'company' => 'CRI Digital Manufacturing Solutions',
|
||||||
|
'greeting' => $greeting,
|
||||||
|
'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 [];
|
||||||
|
}
|
||||||
|
}
|
||||||
45
app/Models/ImportTransit.php
Normal file
45
app/Models/ImportTransit.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class ImportTransit extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'cri_rfq_number',
|
||||||
|
'mail_received_date',
|
||||||
|
'pricol_ref_number',
|
||||||
|
'requester',
|
||||||
|
'shipper',
|
||||||
|
'shipper_location',
|
||||||
|
'shipper_invoice',
|
||||||
|
'shipper_invoice_date',
|
||||||
|
'customs_agent_name',
|
||||||
|
'eta_date',
|
||||||
|
'status',
|
||||||
|
'delivery_location',
|
||||||
|
'etd_date',
|
||||||
|
'mode',
|
||||||
|
'inco_terms',
|
||||||
|
'port_of_loading',
|
||||||
|
'port_of_discharge',
|
||||||
|
'delivery_city',
|
||||||
|
'packages',
|
||||||
|
'type_of_package',
|
||||||
|
'gross_weight',
|
||||||
|
'volume',
|
||||||
|
'bill_number',
|
||||||
|
'bill_received_date',
|
||||||
|
'vessel_number',
|
||||||
|
'created_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_at',
|
||||||
|
'updated_by',
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
@@ -54,6 +54,11 @@ class Item extends Model
|
|||||||
return $this->hasMany(ProcessOrder::class);
|
return $this->hasMany(ProcessOrder::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function productionOrders()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProductionOrder::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function productCharacteristicsMasters()
|
public function productCharacteristicsMasters()
|
||||||
{
|
{
|
||||||
return $this->hasMany(ProductCharacteristicsMaster::class);
|
return $this->hasMany(ProductCharacteristicsMaster::class);
|
||||||
@@ -74,6 +79,11 @@ class Item extends Model
|
|||||||
return $this->hasMany(RequestCharacteristic::class, 'item_id', 'id');
|
return $this->hasMany(RequestCharacteristic::class, 'item_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function wireMasterPacking()
|
||||||
|
{
|
||||||
|
return $this->hasMany(WireMasterPacking::class, 'item_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
public function productionCharacteristics()
|
public function productionCharacteristics()
|
||||||
{
|
{
|
||||||
return $this->hasMany(ProductionCharacteristic::class, 'item_id', 'id');
|
return $this->hasMany(ProductionCharacteristic::class, 'item_id', 'id');
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class Plant extends Model
|
|||||||
'company_id',
|
'company_id',
|
||||||
'name',
|
'name',
|
||||||
'address',
|
'address',
|
||||||
|
'warehouse_number',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function company(): BelongsTo
|
public function company(): BelongsTo
|
||||||
@@ -108,6 +109,16 @@ class Plant extends Model
|
|||||||
return $this->hasMany(ProcessOrder::class, 'plant_id', 'id');
|
return $this->hasMany(ProcessOrder::class, 'plant_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function wireMasterPacking()
|
||||||
|
{
|
||||||
|
return $this->hasMany(WireMasterPacking::class, 'plant_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function productionOrder()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProductionOrder::class, 'plant_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
public function productCharacteristicsMasters()
|
public function productCharacteristicsMasters()
|
||||||
{
|
{
|
||||||
return $this->hasMany(ProductCharacteristicsMaster::class, 'plant_id', 'id');
|
return $this->hasMany(ProductCharacteristicsMaster::class, 'plant_id', 'id');
|
||||||
@@ -152,4 +163,9 @@ class Plant extends Model
|
|||||||
{
|
{
|
||||||
return $this->hasMany(User::class, 'plant_id', 'id');
|
return $this->hasMany(User::class, 'plant_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function vehicleEntries()
|
||||||
|
{
|
||||||
|
return $this->hasMany(VehicleEntry::class, 'plant_id', 'id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class ProductCharacteristicsMaster extends Model
|
|||||||
'machine_id',
|
'machine_id',
|
||||||
'characteristics_type',
|
'characteristics_type',
|
||||||
'name',
|
'name',
|
||||||
|
'category',
|
||||||
'inspection_type',
|
'inspection_type',
|
||||||
'lower',
|
'lower',
|
||||||
'upper',
|
'upper',
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class RequestCharacteristic extends Model
|
|||||||
'mail_status',
|
'mail_status',
|
||||||
'trigger_at',
|
'trigger_at',
|
||||||
'work_flow_id',
|
'work_flow_id',
|
||||||
|
'model_type',
|
||||||
'created_at',
|
'created_at',
|
||||||
'updated_at',
|
'updated_at',
|
||||||
'created_by',
|
'created_by',
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ class VehicleEntry extends Model
|
|||||||
'exit_time',
|
'exit_time',
|
||||||
'duration',
|
'duration',
|
||||||
'type',
|
'type',
|
||||||
|
'uuid',
|
||||||
|
'boom_opened',
|
||||||
'created_at',
|
'created_at',
|
||||||
'created_by',
|
'created_by',
|
||||||
'updated_at',
|
'updated_at',
|
||||||
|
|||||||
106
app/Policies/ImportTransitPolicy.php
Normal file
106
app/Policies/ImportTransitPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Policies;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Access\Response;
|
||||||
|
use App\Models\ImportTransit;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class ImportTransitPolicy
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine whether the user can view any models.
|
||||||
|
*/
|
||||||
|
public function viewAny(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('view-any ImportTransit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can view the model.
|
||||||
|
*/
|
||||||
|
public function view(User $user, ImportTransit $importtransit): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('view ImportTransit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can create models.
|
||||||
|
*/
|
||||||
|
public function create(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('create ImportTransit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can update the model.
|
||||||
|
*/
|
||||||
|
public function update(User $user, ImportTransit $importtransit): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('update ImportTransit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can delete the model.
|
||||||
|
*/
|
||||||
|
public function delete(User $user, ImportTransit $importtransit): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('delete ImportTransit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can delete any models.
|
||||||
|
*/
|
||||||
|
public function deleteAny(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('delete-any ImportTransit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can restore the model.
|
||||||
|
*/
|
||||||
|
public function restore(User $user, ImportTransit $importtransit): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('restore ImportTransit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can restore any models.
|
||||||
|
*/
|
||||||
|
public function restoreAny(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('restore-any ImportTransit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can replicate the model.
|
||||||
|
*/
|
||||||
|
public function replicate(User $user, ImportTransit $importtransit): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('replicate ImportTransit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can reorder the models.
|
||||||
|
*/
|
||||||
|
public function reorder(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('reorder ImportTransit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can permanently delete the model.
|
||||||
|
*/
|
||||||
|
public function forceDelete(User $user, ImportTransit $importtransit): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('force-delete ImportTransit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can permanently delete any models.
|
||||||
|
*/
|
||||||
|
public function forceDeleteAny(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('force-delete-any ImportTransit');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
DB::statement(<<<SQL
|
||||||
|
ALTER TABLE invoice_validations
|
||||||
|
ALTER COLUMN quantity TYPE NUMERIC(10,3)
|
||||||
|
USING quantity::NUMERIC(10,3);
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Schema::table('invoice_validations', function (Blueprint $table) {
|
||||||
|
// //
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
$sql1 = <<<'SQL'
|
||||||
|
ALTER TABLE request_characteristics
|
||||||
|
ADD COLUMN model_type TEXT DEFAULT NULL
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
DB::statement($sql1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Schema::table('request_characteristics', function (Blueprint $table) {
|
||||||
|
// //
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
$sql1 = <<<'SQL'
|
||||||
|
ALTER TABLE product_characteristics_masters
|
||||||
|
ADD COLUMN category TEXT DEFAULT NULL
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
DB::statement($sql1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Schema::table('product_characteristics_masters', function (Blueprint $table) {
|
||||||
|
// //
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?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 import_transits (
|
||||||
|
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||||
|
|
||||||
|
cri_rfq_number TEXT DEFAULT NULL,
|
||||||
|
mail_received_date DATE DEFAULT NULL,
|
||||||
|
pricol_ref_number TEXT DEFAULT NULL,
|
||||||
|
requester TEXT DEFAULT NULL,
|
||||||
|
shipper TEXT DEFAULT NULL,
|
||||||
|
shipper_location TEXT DEFAULT NULL,
|
||||||
|
shipper_invoice TEXT DEFAULT NULL,
|
||||||
|
shipper_invoice_date DATE DEFAULT NULL,
|
||||||
|
customs_agent_name TEXT DEFAULT NULL,
|
||||||
|
eta_date DATE DEFAULT NULL,
|
||||||
|
status TEXT DEFAULT NULL,
|
||||||
|
delivery_location TEXT DEFAULT NULL,
|
||||||
|
etd_date DATE DEFAULT NULL,
|
||||||
|
mode TEXT DEFAULT NULL,
|
||||||
|
inco_terms TEXT DEFAULT NULL,
|
||||||
|
port_of_loading TEXT DEFAULT NULL,
|
||||||
|
port_of_discharge TEXT DEFAULT NULL,
|
||||||
|
delivery_city TEXT DEFAULT NULL,
|
||||||
|
packages TEXT DEFAULT NULL,
|
||||||
|
type_of_package TEXT DEFAULT NULL,
|
||||||
|
gross_weight TEXT DEFAULT NULL,
|
||||||
|
volume TEXT DEFAULT NULL,
|
||||||
|
bill_number TEXT DEFAULT NULL,
|
||||||
|
bill_received_date DATE DEFAULT NULL,
|
||||||
|
vessel_number TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
created_by TEXT DEFAULT NULL,
|
||||||
|
updated_by TEXT DEFAULT NULL,
|
||||||
|
deleted_at TIMESTAMP
|
||||||
|
);
|
||||||
|
SQL;
|
||||||
|
DB::statement($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('import_transits');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
$sql1 = <<<'SQL'
|
||||||
|
ALTER TABLE plants
|
||||||
|
ADD COLUMN warehouse_number TEXT DEFAULT NULL
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
DB::statement($sql1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Schema::table('plants', function (Blueprint $table) {
|
||||||
|
// //
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
$sql1 = <<<'SQL'
|
||||||
|
ALTER TABLE vehicle_entries
|
||||||
|
ADD COLUMN uuid TEXT DEFAULT NULL
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
DB::statement($sql1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Schema::table('vehicle_entries', function (Blueprint $table) {
|
||||||
|
// //
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
$sql1 = <<<'SQL'
|
||||||
|
ALTER TABLE vehicle_entries
|
||||||
|
ADD COLUMN boom_opened TEXT DEFAULT NULL
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
DB::statement($sql1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Schema::table('vehicle_entries', function (Blueprint $table) {
|
||||||
|
// //
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -21,7 +21,7 @@ class AdminSeeder extends Seeder
|
|||||||
// Data to update/create
|
// Data to update/create
|
||||||
[
|
[
|
||||||
'name' => 'Admin',
|
'name' => 'Admin',
|
||||||
'password' => Hash::make('jOtHi#9000'),
|
'password' => Hash::make('jOtHi$9000'),
|
||||||
'updated_at' => now(),
|
'updated_at' => now(),
|
||||||
'created_at' => now(),
|
'created_at' => now(),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -210,7 +210,20 @@ class PermissionSeeder extends Seeder
|
|||||||
Permission::updateOrCreate(['name' => 'view import temp class characteristic']);
|
Permission::updateOrCreate(['name' => 'view import temp class characteristic']);
|
||||||
Permission::updateOrCreate(['name' => 'view export temp class characteristic']);
|
Permission::updateOrCreate(['name' => 'view export temp class characteristic']);
|
||||||
|
|
||||||
|
Permission::updateOrCreate(['name' => 'view import production temp']);
|
||||||
|
Permission::updateOrCreate(['name' => 'view export production temp']);
|
||||||
|
|
||||||
|
Permission::updateOrCreate(['name' => 'view import production orders']);
|
||||||
|
Permission::updateOrCreate(['name' => 'view export production orders']);
|
||||||
|
|
||||||
|
Permission::updateOrCreate(['name' => 'view import transit']);
|
||||||
|
Permission::updateOrCreate(['name' => 'view export import transit']);
|
||||||
|
|
||||||
|
Permission::updateOrCreate(['name' => 'view reprint production order']);
|
||||||
|
Permission::updateOrCreate(['name' => 'create osp production sticker reprint page']);
|
||||||
|
|
||||||
|
Permission::updateOrCreate(['name' => 'view print production order button']);
|
||||||
|
Permission::updateOrCreate(['name' => 'view save production order button']);
|
||||||
|
Permission::updateOrCreate(['name' => 'view print panel production order button']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -948,84 +948,80 @@ function cameraCapture() {
|
|||||||
|
|
||||||
|
|
||||||
async verifyPhoto() {
|
async verifyPhoto() {
|
||||||
if (!this.capturedPhoto) {
|
if (!this.capturedPhoto) {
|
||||||
alert("Please capture a photo first!");
|
alert("Please capture a photo first!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isWorkerReady) {
|
if (!this.isWorkerReady) {
|
||||||
alert("OCR worker not ready yet!");
|
alert("OCR worker not ready yet!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
img.src = this.capturedPhoto;
|
img.src = this.capturedPhoto;
|
||||||
|
|
||||||
img.onload = async () => {
|
img.onload = async () => {
|
||||||
|
|
||||||
// Reuse the same temp canvas (no memory leak)
|
// Reuse the same temp canvas (no memory leak)
|
||||||
this.tempCanvas.width = img.width;
|
this.tempCanvas.width = img.width;
|
||||||
this.tempCanvas.height = img.height;
|
this.tempCanvas.height = img.height;
|
||||||
this.tempCtx.drawImage(img, 0, 0);
|
this.tempCtx.drawImage(img, 0, 0);
|
||||||
|
|
||||||
// Worker OCR — much faster
|
// Worker OCR — much faster
|
||||||
const result = await this.ocrWorker.recognize(this.tempCanvas);
|
const result = await this.ocrWorker.recognize(this.tempCanvas);
|
||||||
|
|
||||||
const detectedText = result.data.text.trim();
|
const detectedText = result.data.text.trim();
|
||||||
console.log("Detected Text:", detectedText);
|
console.log("Detected Text:", detectedText);
|
||||||
|
|
||||||
// -------------------------------------------------------
|
const serialWithLabelRegex = /Serial\s*No[:\-]?\s*([A-Za-z0-9]+)/i;
|
||||||
// SERIAL EXTRACTION LOGIC — SAME AS YOUR ORIGINAL
|
const match = detectedText.match(serialWithLabelRegex);
|
||||||
// -------------------------------------------------------
|
|
||||||
const serialWithLabelRegex = /Serial\s*No[:\-]?\s*([A-Za-z0-9]+)/i;
|
|
||||||
const match = detectedText.match(serialWithLabelRegex);
|
|
||||||
|
|
||||||
if (match && match[1]) {
|
if (match && match[1]) {
|
||||||
// "Serial No: XXXXX"
|
this.serialNumbers = [match[1].trim()];
|
||||||
this.serialNumbers = [match[1].trim()];
|
console.log("Serial with Label:", this.serialNumbers[0]);
|
||||||
console.log("Serial with Label:", this.serialNumbers[0]);
|
}
|
||||||
} else {
|
else
|
||||||
// Extract first 4 alphanumeric sequences of 4+ chars
|
{
|
||||||
const generalNums = detectedText.match(/[A-Za-z0-9]{4,}/g) || [];
|
const generalNums = detectedText.match(/[A-Za-z0-9]{4,}/g) || [];
|
||||||
this.serialNumbers = generalNums.slice(0, 4);
|
this.serialNumbers = generalNums.slice(0, 4);
|
||||||
|
|
||||||
if (this.serialNumbers.length === 0) {
|
if (this.serialNumbers.length == 0) {
|
||||||
alert("No serial numbers detected!");
|
alert("No serial numbers detected!");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Serial Numbers List:", this.serialNumbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Serial Numbers List:", this.serialNumbers);
|
// Save into hidden input (your original logic)
|
||||||
|
this.$refs.hiddenInputSerials.value = JSON.stringify(this.serialNumbers);
|
||||||
|
|
||||||
|
alert("Serial numbers:\n" + this.$refs.hiddenInputSerials.value);
|
||||||
|
|
||||||
|
fetch('/save-serials-to-session', {
|
||||||
|
method: 'POST',
|
||||||
|
credentials: 'same-origin',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
serial_numbers: this.serialNumbers,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
console.log("Session Updated:", data);
|
||||||
|
alert("✅ Serial numbers saved to session!");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
} catch (err) {
|
||||||
|
console.error("OCR verify error:", err);
|
||||||
|
alert("OCR verify failed:\n" + (err.message || err));
|
||||||
}
|
}
|
||||||
|
},
|
||||||
// Save into hidden input (your original logic)
|
|
||||||
this.$refs.hiddenInputSerials.value = JSON.stringify(this.serialNumbers);
|
|
||||||
|
|
||||||
alert("Serial numbers:\n" + this.$refs.hiddenInputSerials.value);
|
|
||||||
|
|
||||||
fetch('/save-serials-to-session', {
|
|
||||||
method: 'POST',
|
|
||||||
credentials: 'same-origin',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
serial_numbers: this.serialNumbers,
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => {
|
|
||||||
console.log("Session Updated:", data);
|
|
||||||
alert("✅ Serial numbers saved to session!");
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
console.error("OCR verify error:", err);
|
|
||||||
alert("OCR verify failed:\n" + (err.message || err));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
startDetection() {
|
startDetection() {
|
||||||
if (this.textDetectionInterval) {
|
if (this.textDetectionInterval) {
|
||||||
|
|||||||
@@ -101,7 +101,7 @@
|
|||||||
if (!scanInput) return;
|
if (!scanInput) return;
|
||||||
|
|
||||||
scanInput.addEventListener('keydown', function (event) {
|
scanInput.addEventListener('keydown', function (event) {
|
||||||
if (event.key === 'Enter') {
|
if (event.key == 'Enter') {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
const value = scanInput.value.trim();
|
const value = scanInput.value.trim();
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
|
||||||
|
<div class="flex flex-row gap-2 items-center flex-wrap">
|
||||||
|
@can('view save production order button')
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
wire:click="saveProductionOrder"
|
||||||
|
class="px-2 py-1 border border-primary-500 text-primary-600 rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
@endcan
|
||||||
|
@can('view print production order button')
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
wire:click="printProductionOrder"
|
||||||
|
class="px-2 py-1 border border-primary-500 text-primary-600 rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
|
||||||
|
>
|
||||||
|
Print
|
||||||
|
</button>
|
||||||
|
@endcan
|
||||||
|
@can('view print panel production order button')
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
wire:click="printPanel"
|
||||||
|
class="px-2 py-1 border border-primary-500 text-primary-600 rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
|
||||||
|
>
|
||||||
|
Print Panel
|
||||||
|
</button>
|
||||||
|
@endcan
|
||||||
|
@can('view print item serial production order button')
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
wire:click="printItemSerial"
|
||||||
|
class="px-2 py-1 border border-primary-500 text-primary-600 rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
|
||||||
|
>
|
||||||
|
Print Item
|
||||||
|
</button>
|
||||||
|
@endcan
|
||||||
|
</div>
|
||||||
|
|
||||||
@@ -3,7 +3,8 @@
|
|||||||
<div class="bg-white max-h-[80vh] overflow-hidden p-6 rounded-lg shadow-lg pointer-events-auto"
|
<div class="bg-white max-h-[80vh] overflow-hidden p-6 rounded-lg shadow-lg pointer-events-auto"
|
||||||
style="width:30vw !important; max-width:none !important;">
|
style="width:30vw !important; max-width:none !important;">
|
||||||
|
|
||||||
@if($records && $records->count())
|
{{-- @if($records && $records->count()) --}}
|
||||||
|
@if(!empty($records) && count($records))
|
||||||
<div style="max-height:250px; overflow-y:auto; border:1px solid #ccc;">
|
<div style="max-height:250px; overflow-y:auto; border:1px solid #ccc;">
|
||||||
|
|
||||||
{{-- <table class="min-w-full border"> --}}
|
{{-- <table class="min-w-full border"> --}}
|
||||||
|
|||||||
@@ -33,6 +33,10 @@
|
|||||||
<td>Job Number</td>
|
<td>Job Number</td>
|
||||||
<td style="text-align: center;">{{ $request->aufnr }}</td>
|
<td style="text-align: center;">{{ $request->aufnr }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Model Type</td>
|
||||||
|
<td style="text-align: center;">{{ $request->model_type }}</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Work Flow ID</td>
|
<td>Work Flow ID</td>
|
||||||
<td style="text-align: center;">{{ $request->work_flow_id }}</td>
|
<td style="text-align: center;">{{ $request->work_flow_id }}</td>
|
||||||
@@ -103,8 +107,8 @@
|
|||||||
<td style="text-align: center;">
|
<td style="text-align: center;">
|
||||||
<a href="{{ $approveUrl }}" style="color: #28a745; font-weight: bold; text-decoration: underline;">Approve</a>
|
<a href="{{ $approveUrl }}" style="color: #28a745; font-weight: bold; text-decoration: underline;">Approve</a>
|
||||||
|
|
|
|
||||||
<a href="{{ $holdUrl }}" style="color: #FF8800; font-weight: bold; text-decoration: underline;">Hold</a>
|
{{-- <a href="{{ $holdUrl }}" style="color: #FF8800; font-weight: bold; text-decoration: underline;">Hold</a>
|
||||||
|
|
| --}}
|
||||||
<a href="{{ $rejectUrl }}" style="color: #dc3545; font-weight: bold; text-decoration: underline;">Reject</a>
|
<a href="{{ $rejectUrl }}" style="color: #dc3545; font-weight: bold; text-decoration: underline;">Reject</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -123,6 +127,30 @@
|
|||||||
@endif
|
@endif
|
||||||
</table>
|
</table>
|
||||||
@elseif($approverNameFromMaster && $approverNameFromMaster->approver_type == 'Quality')
|
@elseif($approverNameFromMaster && $approverNameFromMaster->approver_type == 'Quality')
|
||||||
|
{{-- <table style="margin-left: 3%" border="1" width="30%" cellpadding="6" cellspacing="0"> --}}
|
||||||
|
<table style="margin-left: 3%; " border="1" width="30%" cellpadding="6" cellspacing="0">
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th colspan="2" style="text-align: center; font-weight: bold;">
|
||||||
|
TEMPLATE CHARACTERISTICS
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Value</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
@forelse ($tableData as $key => $value)
|
||||||
|
<tr>
|
||||||
|
<td style="text-align: center;">{{ strtoupper($key) }}</td>
|
||||||
|
<td style="text-align: center;">{{ $value }}</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">No Characteristics Found</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</table>
|
||||||
<br>
|
<br>
|
||||||
<table style="margin-left: 3%" border="1" width="50%" cellpadding="6" cellspacing="0">
|
<table style="margin-left: 3%" border="1" width="50%" cellpadding="6" cellspacing="0">
|
||||||
<tr>
|
<tr>
|
||||||
@@ -159,8 +187,8 @@
|
|||||||
<td style="text-align: center;">
|
<td style="text-align: center;">
|
||||||
<a href="{{ $approveUrl }}" style="color: #28a745; font-weight: bold; text-decoration: underline;">Approve</a>
|
<a href="{{ $approveUrl }}" style="color: #28a745; font-weight: bold; text-decoration: underline;">Approve</a>
|
||||||
|
|
|
|
||||||
<a href="{{ $holdUrl }}" style="color: #FF8800; font-weight: bold; text-decoration: underline;">Hold</a>
|
{{-- <a href="{{ $holdUrl }}" style="color: #FF8800; font-weight: bold; text-decoration: underline;">Hold</a>
|
||||||
|
|
| --}}
|
||||||
<a href="{{ $rejectUrl }}" style="color: #dc3545; font-weight: bold; text-decoration: underline;">Reject</a>
|
<a href="{{ $rejectUrl }}" style="color: #dc3545; font-weight: bold; text-decoration: underline;">Reject</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
130
resources/views/mail/import_transit_report.blade.php
Normal file
130
resources/views/mail/import_transit_report.blade.php
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Import Transit Report</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Segoe UI', Arial, sans-serif;
|
||||||
|
background-color: #f9fafb;
|
||||||
|
color: #333;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
color: #215c98;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
width: 100%;
|
||||||
|
font-size: 14px;
|
||||||
|
white-space: nowrap !important;
|
||||||
|
}
|
||||||
|
th, td {
|
||||||
|
border: 1px solid #020813da;
|
||||||
|
padding: 8px 10px;
|
||||||
|
text-align: center;
|
||||||
|
white-space: nowrap !important;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
.td-left {
|
||||||
|
text-align: left !important;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background-color: #215c98;
|
||||||
|
color: #fff;
|
||||||
|
white-space: nowrap !important;
|
||||||
|
}
|
||||||
|
tr:nth-child(even) {
|
||||||
|
background-color: #f3f4f6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #6b7280;
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div style="text-align: center; font-weight: bold;">
|
||||||
|
{{ $company }}
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<p>{!! $greeting !!}</p>
|
||||||
|
<div class="container">
|
||||||
|
@if(empty($tableData))
|
||||||
|
<p style="text-align:center;">No invoice in transit data available.</p>
|
||||||
|
@else
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>No</th>
|
||||||
|
<th>CRI RFQ Number</th>
|
||||||
|
<th>Mail Received Date</th>
|
||||||
|
<th>Pricol Ref Number</th>
|
||||||
|
<th>Requestor</th>
|
||||||
|
<th>Shipper</th>
|
||||||
|
<th>Shipper Location</th>
|
||||||
|
<th>Shipper Invoice</th>
|
||||||
|
<th>Shipper Invoice Date</th>
|
||||||
|
<th>Custom Agent Name</th>
|
||||||
|
<th>ETA Date</th>
|
||||||
|
<th>Status</th>
|
||||||
|
<th>Delivery Location</th>
|
||||||
|
<th>ETD Date</th>
|
||||||
|
<th>Mode</th>
|
||||||
|
<th>Inco Terms</th>
|
||||||
|
<th>Port Of Loading</th>
|
||||||
|
<th>Port Of Discharge</th>
|
||||||
|
<th>Delivery City</th>
|
||||||
|
<th>Packages</th>
|
||||||
|
<th>Type of package</th>
|
||||||
|
<th>Gross Weight</th>
|
||||||
|
<th>Volume</th>
|
||||||
|
<th>Bill Number</th>
|
||||||
|
<th>Bill Received Date</th>
|
||||||
|
<th>Vessel Number</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach ($tableData as $row)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $loop->iteration }}</td>
|
||||||
|
<td>{{ $row['cri_rfq_number'] }}</td>
|
||||||
|
<td>{{ $row['mail_received_date'] }}</td>
|
||||||
|
<td>{{ $row['pricol_ref_number'] }}</td>
|
||||||
|
<td>{{ $row['requester'] }}</td>
|
||||||
|
<td>{{ $row['shipper'] }}</td>
|
||||||
|
<td>{{ $row['shipper_location'] }}</td>
|
||||||
|
<td>{{ $row['shipper_invoice'] }}</td>
|
||||||
|
<td>{{ $row['shipper_invoice_date'] }}</td>
|
||||||
|
<td>{{ $row['customs_agent_name'] }}</td>
|
||||||
|
<td>{{ $row['eta_date'] }}</td>
|
||||||
|
<td>{{ $row['status'] }}</td>
|
||||||
|
<td>{{ $row['delivery_location'] }}</td>
|
||||||
|
<td>{{ $row['etd_date'] }}</td>
|
||||||
|
<td>{{ $row['mode'] }}</td>
|
||||||
|
<td>{{ $row['inco_terms'] }}</td>
|
||||||
|
<td>{{ $row['port_of_loading'] }}</td>
|
||||||
|
<td>{{ $row['port_of_discharge'] }}</td>
|
||||||
|
<td>{{ $row['delivery_city'] }}</td>
|
||||||
|
<td>{{ $row['packages'] }}</td>
|
||||||
|
<td>{{ $row['type_of_package'] }}</td>
|
||||||
|
<td>{{ $row['gross_weight'] }}</td>
|
||||||
|
<td>{{ $row['volume'] }}</td>
|
||||||
|
<td>{{ $row['bill_number'] }}</td>
|
||||||
|
<td>{{ $row['bill_received_date'] }}</td>
|
||||||
|
<td>{{ $row['vessel_number'] }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
@endif
|
||||||
|
<p>{!! $wishes !!}</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -106,7 +106,6 @@
|
|||||||
-
|
-
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
{{-- <td>{{ $row['lr_bl_aw_date'] }}</td> --}}
|
{{-- <td>{{ $row['lr_bl_aw_date'] }}</td> --}}
|
||||||
<td>{{ $row['transit_days'] }}</td>
|
<td>{{ $row['transit_days'] }}</td>
|
||||||
<td>{{ $row['status'] }}</td>
|
<td>{{ $row['status'] }}</td>
|
||||||
|
|||||||
94
resources/views/mail/vehicle_entry_report.blade.php
Normal file
94
resources/views/mail/vehicle_entry_report.blade.php
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Vehicle Entry Report</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Segoe UI', Arial, sans-serif;
|
||||||
|
background-color: #f9fafb;
|
||||||
|
color: #333;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
color: #215c98;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
width: 100%;
|
||||||
|
font-size: 14px;
|
||||||
|
white-space: nowrap !important;
|
||||||
|
}
|
||||||
|
th, td {
|
||||||
|
border: 1px solid #020813da;
|
||||||
|
padding: 8px 10px;
|
||||||
|
text-align: center;
|
||||||
|
white-space: nowrap !important;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
.td-left {
|
||||||
|
text-align: left !important;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background-color: #215c98;
|
||||||
|
color: #fff;
|
||||||
|
white-space: nowrap !important;
|
||||||
|
}
|
||||||
|
tr:nth-child(even) {
|
||||||
|
background-color: #f3f4f6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #6b7280;
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div style="text-align: center; font-weight: bold;">
|
||||||
|
{{ $company }}
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<p>{!! $greeting !!}</p>
|
||||||
|
<div class="container">
|
||||||
|
@if(empty($tableData))
|
||||||
|
<p style="text-align:center;">No vehicle entry data available.</p>
|
||||||
|
@else
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>No</th>
|
||||||
|
<th>Plant Name</th>
|
||||||
|
<th>Vehicle Number</th>
|
||||||
|
<th>Boom Opened</th>
|
||||||
|
<th>Entry Time</th>
|
||||||
|
<th>Exit Time</th>
|
||||||
|
<th>Duration</th>
|
||||||
|
<th>Type</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach ($tableData as $row)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $loop->iteration }}</td>
|
||||||
|
<td>{{ $row['plant'] }}</td>
|
||||||
|
<td>{{ $row['vehicleNumber'] }}</td>
|
||||||
|
<td>{{ $row['boom'] }}</td>
|
||||||
|
<td>{{ $row['entryTime'] }}</td>
|
||||||
|
<td>{{ $row['exitTime'] }}</td>
|
||||||
|
<td>{{ $row['duration'] }}</td>
|
||||||
|
<td>{{ $row['type'] }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
@endif
|
||||||
|
<p>{!! $wishes !!}</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
119
resources/views/production-orders/printItemSerial.blade.php
Normal file
119
resources/views/production-orders/printItemSerial.blade.php
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
@page {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
/* font-family: "Arial Narrow", "DejaVu Sans", sans-serif; */
|
||||||
|
}
|
||||||
|
|
||||||
|
.sticker {
|
||||||
|
width: 170pt;
|
||||||
|
height: 40pt;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sticker:last-child {
|
||||||
|
page-break-after: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qr {
|
||||||
|
width: 35pt;
|
||||||
|
height: 35pt;
|
||||||
|
padding-top: 3pt;
|
||||||
|
padding-left: 4pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .text {
|
||||||
|
padding-left: 5pt;
|
||||||
|
} */
|
||||||
|
|
||||||
|
.text {
|
||||||
|
position: relative;
|
||||||
|
padding-left: 5pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .serial {
|
||||||
|
font-size: 10pt;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-top: 6pt;
|
||||||
|
} */
|
||||||
|
|
||||||
|
.serial {
|
||||||
|
font-size: 8pt;
|
||||||
|
font-weight: bold;
|
||||||
|
position: relative;
|
||||||
|
top: 8pt;
|
||||||
|
right: 6pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .po {
|
||||||
|
font-size: 8pt;
|
||||||
|
margin-bottom: 6pt;
|
||||||
|
margin-left: 75pt;
|
||||||
|
} */
|
||||||
|
|
||||||
|
.po {
|
||||||
|
font-size: 8pt;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: left !important;
|
||||||
|
position: absolute;
|
||||||
|
right: 5pt;
|
||||||
|
top: 8pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .desc {
|
||||||
|
font-size: 6pt;
|
||||||
|
margin-left: -5pt;
|
||||||
|
font-weight: bold;
|
||||||
|
padding-top: 10pt;
|
||||||
|
} */
|
||||||
|
.desc {
|
||||||
|
font-family: "Arial Narrow";
|
||||||
|
font-size: 7pt;
|
||||||
|
font-weight: bold;
|
||||||
|
letter-spacing: -0.3px;
|
||||||
|
white-space: nowrap;
|
||||||
|
padding-top: 15pt;
|
||||||
|
margin-left: -5pt;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
@foreach($stickers as $sticker)
|
||||||
|
<div class="sticker">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td style="width:40pt;">
|
||||||
|
<img class="qr" src="{{ $sticker['qr'] }}">
|
||||||
|
</td>
|
||||||
|
<td class="text">
|
||||||
|
<div class="serial">{{ $sticker['serial'] }}</div>
|
||||||
|
<div class="po">{{ $sticker['production_order'] }}</div>
|
||||||
|
<div class="desc">{{ $sticker['description'] }}</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,100 +1,70 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<style>
|
<style>
|
||||||
@page {
|
@page {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body{
|
||||||
margin: 0;
|
margin:0;
|
||||||
padding: 0;
|
padding:0;
|
||||||
/* font-family: "Arial Narrow", "DejaVu Sans", sans-serif; */
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.sticker {
|
.sticker{
|
||||||
width: 113.39pt;
|
width:40mm;
|
||||||
height: 113.39pt;
|
height:40mm;
|
||||||
overflow: hidden;
|
overflow:hidden;
|
||||||
}
|
position:relative;
|
||||||
|
box-sizing:border-box;
|
||||||
|
}
|
||||||
|
|
||||||
.sticker:last-child {
|
.qr{
|
||||||
page-break-after: auto;
|
width:29mm;
|
||||||
}
|
height:29mm;
|
||||||
|
position:absolute;
|
||||||
|
top:-1mm;
|
||||||
|
left:5.8mm;
|
||||||
|
}
|
||||||
|
|
||||||
table {
|
.serial{
|
||||||
width: 100%;
|
position:absolute;
|
||||||
border-collapse: collapse;
|
top:27mm; /* 3 + 22 + 1mm spacing */
|
||||||
}
|
width:100%;
|
||||||
|
text-align:center;
|
||||||
td {
|
font-family:Arial, sans-serif;
|
||||||
padding: 0;
|
font-weight:bold;
|
||||||
margin: 0;
|
font-size:3mm;
|
||||||
vertical-align: top;
|
}
|
||||||
}
|
.desc{
|
||||||
|
position:absolute;
|
||||||
.qr {
|
top:31mm;
|
||||||
width: 90pt;
|
width:100%;
|
||||||
height: 90pt;
|
text-align:center;
|
||||||
padding-top: 2pt;
|
font-family:Arial, sans-serif;
|
||||||
/* padding-left: 12pt; */
|
font-weight:bold;
|
||||||
}
|
font-size:4mm;
|
||||||
|
white-space:nowrap;
|
||||||
.text {
|
}
|
||||||
position: relative;
|
</style>
|
||||||
/* padding-left: 5pt; */
|
|
||||||
}
|
|
||||||
|
|
||||||
.serial {
|
|
||||||
font-size: 7pt;
|
|
||||||
font-weight: bold;
|
|
||||||
position: relative;
|
|
||||||
/* top: 30pt; */
|
|
||||||
top: -5pt;
|
|
||||||
/* padding-left: 1pt; */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* .po {
|
|
||||||
font-size: 8pt;
|
|
||||||
font-weight: bold;
|
|
||||||
text-align: left !important;
|
|
||||||
position: absolute;
|
|
||||||
right: 5pt;
|
|
||||||
top: 8pt;
|
|
||||||
} */
|
|
||||||
|
|
||||||
.desc {
|
|
||||||
font-family: "Arial Narrow";
|
|
||||||
font-size: 6pt;
|
|
||||||
font-weight: bold;
|
|
||||||
white-space: nowrap;
|
|
||||||
/* padding-top: 42pt; */
|
|
||||||
left: -38pt;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@foreach($stickers as $sticker)
|
@foreach($stickers as $sticker)
|
||||||
<div class="sticker">
|
<div class="sticker">
|
||||||
<table>
|
|
||||||
<tr>
|
<img class="qr" src="{{ $sticker['qr'] }}">
|
||||||
<td align="center">
|
|
||||||
<img class="qr" src="{{ $sticker['qr'] }}">
|
<div class="serial">
|
||||||
</td>
|
{{ $sticker['serial'] }}
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="text" align="center">
|
|
||||||
<div class="serial">{{ $sticker['serial'] }}</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="text" align="center">
|
|
||||||
<div class="desc">{{ $sticker['description'] }}</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="desc">
|
||||||
|
{{ $sticker['description'] }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -62,14 +62,21 @@ use Illuminate\Support\Facades\Route;
|
|||||||
// 'data' => $request->all()
|
// 'data' => $request->all()
|
||||||
// ]);
|
// ]);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
// OBD
|
||||||
|
|
||||||
Route::get('obd/get-test-datas', [ObdController::class, 'get_test']);
|
Route::get('obd/get-test-datas', [ObdController::class, 'get_test']);
|
||||||
|
|
||||||
Route::get('obd/get-data', [ObdController::class, 'get_obd']);
|
Route::get('obd/get-data', [ObdController::class, 'get_obd']);
|
||||||
|
|
||||||
Route::post('obd/store-data', [ObdController::class, 'store_obd']);
|
Route::post('obd/store-data', [ObdController::class, 'store_obd']);
|
||||||
|
|
||||||
|
// Plant
|
||||||
|
|
||||||
Route::get('plant/get-all-data', [PlantController::class, 'get_all_data']);
|
Route::get('plant/get-all-data', [PlantController::class, 'get_all_data']);
|
||||||
|
|
||||||
|
// Sticker Master Model Type
|
||||||
|
|
||||||
Route::get('sticker/get-master-type-data', [StickerMasterController::class, 'get_master_type']);
|
Route::get('sticker/get-master-type-data', [StickerMasterController::class, 'get_master_type']);
|
||||||
|
|
||||||
Route::get('/download-qr-pdf/{palletNo}', [PalletController::class, 'downloadQrPdf'])->name('download-qr-pdf');
|
Route::get('/download-qr-pdf/{palletNo}', [PalletController::class, 'downloadQrPdf'])->name('download-qr-pdf');
|
||||||
|
|||||||
@@ -61,6 +61,10 @@ Route::get('production-orders/{production_order}/{plant_code}/printpanel',
|
|||||||
[ProductionOrderController::class, 'printpanel']
|
[ProductionOrderController::class, 'printpanel']
|
||||||
)->name('production-orders.printpanel');
|
)->name('production-orders.printpanel');
|
||||||
|
|
||||||
|
Route::get('production-orders/{production_order}/{plant_code}/printItemSerial',
|
||||||
|
[ProductionOrderController::class, 'printItemSerial']
|
||||||
|
)->name('production-orders.printItemSerial');
|
||||||
|
|
||||||
// Route::get('/characteristic/approve', [CharacteristicApprovalController::class, 'approve'])
|
// Route::get('/characteristic/approve', [CharacteristicApprovalController::class, 'approve'])
|
||||||
// ->name('characteristic.approve')
|
// ->name('characteristic.approve')
|
||||||
// ->middleware('signed');
|
// ->middleware('signed');
|
||||||
|
|||||||
Reference in New Issue
Block a user