Compare commits
1 Commits
master
...
renovate/i
| Author | SHA1 | Date | |
|---|---|---|---|
| 6d1ad0cf53 |
@@ -1,255 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionTemp;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Services\SftpFileService;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ProcessSftpFiles extends Command
|
||||
{
|
||||
protected $signature = 'sftp:process-files';
|
||||
protected $description = 'Read SFTP files, insert into DB, and move to processed folder';
|
||||
|
||||
protected $sftpService;
|
||||
|
||||
public function __construct(SftpFileService $sftpService)
|
||||
{
|
||||
parent::__construct(); // calls parent class constructor
|
||||
$this->sftpService = $sftpService;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$files = Storage::disk('ftp')->allFiles();
|
||||
|
||||
$folders = Storage::disk('ftp')->directories();
|
||||
|
||||
$allFiles = [];
|
||||
|
||||
foreach ($folders as $folder) {
|
||||
|
||||
Log::info("Checking folder: $folder");
|
||||
|
||||
// Get files inside the current folder
|
||||
$files = Storage::disk('ftp')->files($folder);
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
$allFiles[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($allFiles)) {
|
||||
$this->info('No files to process.');
|
||||
return;
|
||||
}
|
||||
|
||||
$logMessages = [];
|
||||
|
||||
foreach ($allFiles as $file)
|
||||
{
|
||||
$this->info("Processing file: $file");
|
||||
|
||||
$folderName = explode('/', $file)[0];
|
||||
|
||||
$plant = Plant::where('code', $folderName)->first();
|
||||
|
||||
if (!$plant) {
|
||||
$this->warn("No plant found for folder: $folderName. Skipping file.");
|
||||
$logMessages[] = $folderName;
|
||||
continue;
|
||||
}
|
||||
|
||||
$plantId = $plant->id;
|
||||
|
||||
$plantCode = $plant->code ?? null;
|
||||
|
||||
$fileName = basename($file); // GMGLAS03-1818199-1.txt
|
||||
$workCenterCode = explode('-', $fileName)[0]; // GMGLAS03
|
||||
|
||||
$machine = Machine::where('work_center', $workCenterCode)->first();
|
||||
if (!$machine) {
|
||||
$message = "Machine '$workCenterCode' not found and file name '$file'";
|
||||
$logMessages[] = $message;
|
||||
continue;
|
||||
}
|
||||
|
||||
$machineAgaPlant = Machine::where('plant_id', $plantId)->where('work_center', $workCenterCode)->first();
|
||||
if (!$machineAgaPlant) {
|
||||
$message = "Machine '$workCenterCode' not found for plant code '$plantCode' and file name '$file'";
|
||||
$logMessages[] = $message;
|
||||
continue;
|
||||
}
|
||||
|
||||
$machineId = $machineAgaPlant->id;
|
||||
|
||||
$content = $this->sftpService->getFileContent($file);
|
||||
|
||||
$lines = array_filter(preg_split("/\r\n|\n|\r/", $content));
|
||||
|
||||
$headers = array_map(fn($header) => strtolower(trim($header)), str_getcsv(array_shift($lines)));
|
||||
|
||||
$dbColumns = Schema::getColumnListing('production_temps');
|
||||
|
||||
$missingColumns = array_diff($headers, $dbColumns);
|
||||
|
||||
if (!empty($missingColumns)) {
|
||||
|
||||
$message = "Skipping file: $file. The following columns do not exist in the database. Please add them to the database: " . implode(', ', $missingColumns);
|
||||
|
||||
$logMessages[] = $message;
|
||||
|
||||
$this->warn($message);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$expectedColumns = count($headers);
|
||||
$isValidFile = true;
|
||||
$isserialNotEmptyFile = true;
|
||||
|
||||
foreach ($lines as $lineNumber => $line) {
|
||||
$data = str_getcsv($line);
|
||||
|
||||
if (!empty($data[0])) {
|
||||
if (count($data) != $expectedColumns) {
|
||||
$message = "Column mismatch in file: $file at line " . ($lineNumber + 2) .
|
||||
". Expected $expectedColumns, got " . count($data);
|
||||
|
||||
$logMessages[] = $message;
|
||||
|
||||
$isValidFile = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isValidFile) {
|
||||
$message = "Skipping entire file due to invalid column mismatch: $file";
|
||||
$logMessages[] = $message;
|
||||
continue;
|
||||
}
|
||||
else if (!$isserialNotEmptyFile) {
|
||||
$message = "serial number not found in file name $file";
|
||||
$logMessages[] = $message;
|
||||
continue;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
|
||||
// foreach ($lines as $line) {
|
||||
// $data = str_getcsv($line);
|
||||
|
||||
// if (!empty($data[0])) {
|
||||
// $row = [];
|
||||
// foreach ($headers as $index => $column) {
|
||||
// $row[$column] = isset($data[$index]) ? trim($data[$index]) : null;
|
||||
// }
|
||||
|
||||
// $row['plant_id'] = $plantId;
|
||||
// $row['machine_id'] = $machineId;
|
||||
// $row['created_at'] = now();
|
||||
// $row['updated_at'] = now();
|
||||
|
||||
// // $rows[] = $row;
|
||||
// if (!empty($row['gernr'])) {
|
||||
// $rows[] = $row;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
foreach ($lines as $line) {
|
||||
|
||||
$data = str_getcsv($line);
|
||||
|
||||
if (!empty($data[0])) {
|
||||
|
||||
$row = [];
|
||||
|
||||
foreach ($headers as $index => $column) {
|
||||
$row[$column] = isset($data[$index])
|
||||
? trim($data[$index])
|
||||
: null;
|
||||
}
|
||||
|
||||
$row['plant_id'] = $plantId;
|
||||
$row['machine_id'] = $machineId;
|
||||
$row['created_at'] = now();
|
||||
$row['updated_at'] = now();
|
||||
|
||||
if (empty($row['gernr'])) {
|
||||
$message = "serial number not found in file name $file";
|
||||
$logMessages[] = $message;
|
||||
continue;
|
||||
}
|
||||
|
||||
$gamng = (float) ($row['gamng'] ?? 0);
|
||||
$lmnga = (float) ($row['lmnga'] ?? 0);
|
||||
|
||||
$existingRecords = ProductionTemp::where('plant_id', $plantId)
|
||||
->where('aufnr', ($row['aufnr']))
|
||||
->get();
|
||||
|
||||
|
||||
$existingRecord = $existingRecords->where('gernr', $row['gernr'])->first();
|
||||
|
||||
$lastStatus = $existingRecords->max('pending_released_status');
|
||||
|
||||
if ($gamng == $lmnga) {
|
||||
|
||||
$row['pending_released_status'] = 0;
|
||||
|
||||
$this->info("Production order {$row['aufnr']} completed. " ."Serial: {$row['gernr']}. " ."GAMNG: {$row['gamng']}, LMNGA: {$row['lmnga']}. " ."pending_released_status = 0" );
|
||||
|
||||
} elseif ($existingRecord) {
|
||||
|
||||
$row['pending_released_status'] = (int) $existingRecord->pending_released_status;
|
||||
|
||||
$this->info("Same serial already exists. " ."Production order: {$row['aufnr']}. " ."Serial: {$row['gernr']}. " ."Keeping pending_released_status = {$row['pending_released_status']}");
|
||||
|
||||
} else {
|
||||
|
||||
if ($existingRecords->isEmpty()) {
|
||||
|
||||
// First release
|
||||
$row['pending_released_status'] = 0;
|
||||
|
||||
} else {
|
||||
$row['pending_released_status'] = ((int) $lastStatus) + 1;
|
||||
}
|
||||
$this->info("Production order {$row['aufnr']} pending. " ."New serial: {$row['gernr']}. " . "GAMNG: {$row['gamng']}, LMNGA: {$row['lmnga']}. " ."pending_released_status = {$row['pending_released_status']}");
|
||||
}
|
||||
|
||||
$rows[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($rows)) {
|
||||
ProductionTemp::upsert($rows, ['plant_id', 'gernr'], array_keys($rows[0])); //(update + insert)
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($logMessages)) {
|
||||
|
||||
$content = implode(PHP_EOL, $logMessages);
|
||||
|
||||
Mail::raw('Please find attached machine error logs.', function ($message) use ($content) {
|
||||
$message->to(env('ERROR_LOG_MAIL'))
|
||||
->subject('Machine Error Logs')
|
||||
->attachData($content, 'machine_errors.txt', [
|
||||
'mime' => 'text/plain',
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,6 @@ class Scheduler extends Command
|
||||
{
|
||||
|
||||
$this->call('approval:trigger-mails');
|
||||
$this->call('approval:laser-stop');
|
||||
// $this->call('sftp:process-files');
|
||||
|
||||
// --- Production Rules ---
|
||||
@@ -397,81 +396,81 @@ class Scheduler extends Command
|
||||
}
|
||||
|
||||
//..Laser Stop Report
|
||||
// $laserStopReport = AlertMailRule::where('module', 'LaserStopAlert')
|
||||
// ->where('rule_name', 'LaserStopAlertMail')
|
||||
// ->select('plant', 'schedule_type', 'machine_id')
|
||||
// ->distinct()
|
||||
// ->get();
|
||||
$laserStopReport = AlertMailRule::where('module', 'LaserStopAlert')
|
||||
->where('rule_name', 'LaserStopAlertMail')
|
||||
->select('plant', 'schedule_type', 'machine_id')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
// foreach ($laserStopReport as $rule) {
|
||||
// switch ($rule->schedule_type) {
|
||||
// case 'Live':
|
||||
// // Run every minute
|
||||
// \Artisan::call('send:laser-stop-report', [
|
||||
// 'schedule_type' => $rule->schedule_type,
|
||||
// 'plant' => $rule->plant,
|
||||
// 'machine_id' => $rule->machine_id,
|
||||
// ]);
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// if (now()->minute == 0) {
|
||||
// \Artisan::call('send:laser-stop-report', [
|
||||
// 'schedule_type' => $rule->schedule_type,
|
||||
// 'plant' => $rule->plant,
|
||||
// 'machine_id' => $rule->machine_id,
|
||||
// ]);
|
||||
// }
|
||||
// break;
|
||||
// case 'Daily':
|
||||
// if (now()->format('H:i') == '07:59') {
|
||||
// \Artisan::call('send:laser-stop-report', [
|
||||
// 'schedule_type' => $rule->schedule_type,
|
||||
// 'plant' => $rule->plant,
|
||||
// 'machine_id' => $rule->machine_id,
|
||||
// ]);
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
foreach ($laserStopReport as $rule) {
|
||||
switch ($rule->schedule_type) {
|
||||
case 'Live':
|
||||
// Run every minute
|
||||
\Artisan::call('send:laser-stop-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
'machine_id' => $rule->machine_id,
|
||||
]);
|
||||
break;
|
||||
case 'Hourly':
|
||||
if (now()->minute == 0) {
|
||||
\Artisan::call('send:laser-stop-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
'machine_id' => $rule->machine_id,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '07:59') {
|
||||
\Artisan::call('send:laser-stop-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
'machine_id' => $rule->machine_id,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// //..Laser Stop Final Report
|
||||
//..Laser Stop Final Report
|
||||
|
||||
// $laserStopFinalReport = AlertMailRule::where('module', 'LaserStopReport')
|
||||
// ->where('rule_name', 'LaserStopMail')
|
||||
// ->select('plant', 'schedule_type', 'machine_id')
|
||||
// ->distinct()
|
||||
// ->get();
|
||||
$laserStopFinalReport = AlertMailRule::where('module', 'LaserStopReport')
|
||||
->where('rule_name', 'LaserStopMail')
|
||||
->select('plant', 'schedule_type', 'machine_id')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
// foreach ($laserStopFinalReport as $rule) {
|
||||
// switch ($rule->schedule_type) {
|
||||
// case 'Live':
|
||||
// // Run every minute
|
||||
// \Artisan::call('send:laser-stop-consolidate-report', [
|
||||
// 'schedule_type' => $rule->schedule_type,
|
||||
// 'plant' => $rule->plant,
|
||||
// 'machine_id' => $rule->machine_id,
|
||||
// ]);
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// if (now()->minute == 0) {
|
||||
// \Artisan::call('send:laser-stop-consolidate-report', [
|
||||
// 'schedule_type' => $rule->schedule_type,
|
||||
// 'plant' => $rule->plant,
|
||||
// 'machine_id' => $rule->machine_id,
|
||||
// ]);
|
||||
// }
|
||||
// break;
|
||||
// case 'Daily':
|
||||
// if (now()->format('H:i') == '08:00') {
|
||||
// \Artisan::call('send:laser-stop-consolidate-report', [
|
||||
// 'schedule_type' => $rule->schedule_type,
|
||||
// 'plant' => $rule->plant,
|
||||
// 'machine_id' => $rule->machine_id,
|
||||
// ]);
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
foreach ($laserStopFinalReport as $rule) {
|
||||
switch ($rule->schedule_type) {
|
||||
case 'Live':
|
||||
// Run every minute
|
||||
\Artisan::call('send:laser-stop-consolidate-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
'machine_id' => $rule->machine_id,
|
||||
]);
|
||||
break;
|
||||
case 'Hourly':
|
||||
if (now()->minute == 0) {
|
||||
\Artisan::call('send:laser-stop-consolidate-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
'machine_id' => $rule->machine_id,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '08:00') {
|
||||
\Artisan::call('send:laser-stop-consolidate-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
'machine_id' => $rule->machine_id,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//..Panel Box Final Report
|
||||
|
||||
@@ -511,75 +510,6 @@ class Scheduler extends Command
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//..Daily Task Report
|
||||
|
||||
$taskReports = AlertMailRule::where('module', 'DailyTaskReport')
|
||||
->where('rule_name', 'DailyTaskReportMail')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
foreach ($taskReports as $rule) {
|
||||
switch ($rule->schedule_type) {
|
||||
case 'Live':
|
||||
// Run every minute
|
||||
\Artisan::call('send:daily-task-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
]);
|
||||
break;
|
||||
case 'Hourly':
|
||||
if (now()->minute == 0) {
|
||||
\Artisan::call('send:daily-task-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '09:00') {
|
||||
\Artisan::call('send:daily-task-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//..Laser Idle Report
|
||||
|
||||
$laserIdleRules = AlertMailRule::where('module', 'LaserIdleHourReport')
|
||||
->where('rule_name', 'LaserIdleMail')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
foreach ($laserIdleRules as $rule) {
|
||||
switch ($rule->schedule_type) {
|
||||
case 'Live':
|
||||
// Run every minute
|
||||
\Artisan::call('send:laser-idle-hour-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
break;
|
||||
case 'Hourly':
|
||||
if (now()->minute == 0) {
|
||||
\Artisan::call('send:laser-idle-hour-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '07:59') {
|
||||
\Artisan::call('send:laser-idle-hour-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,253 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\DailyTaskReportMail;
|
||||
use App\Models\AlertMailRule;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Storage;
|
||||
use Smalot\PdfParser\Parser;
|
||||
|
||||
class SendDailyTaskReport extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'send:daily-task-report {schedule_type}';
|
||||
|
||||
|
||||
protected array $knownStatuses = [
|
||||
'in progress', 'new', 'closed', 'on hold', 'rejected',
|
||||
'done', 'resolved', 'confirmed', 'in specification', 'scheduled',
|
||||
];
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$directory = 'task_updates';
|
||||
$scheduleType = $this->argument('schedule_type');
|
||||
|
||||
$mailRules = AlertMailRule::where('module', 'DailyTaskReport')
|
||||
->where('rule_name', 'DailyTaskReportMail')
|
||||
->where('schedule_type', $scheduleType)
|
||||
->get();
|
||||
|
||||
if (!$mailRules) {
|
||||
$this->error('Daily Task Report mail rule not found.');
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
// Get all PDF files
|
||||
$pdfFiles = collect(Storage::disk('local')->files($directory))
|
||||
->filter(function ($file) {
|
||||
return strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'pdf';
|
||||
})
|
||||
->values();
|
||||
|
||||
if ($pdfFiles->isEmpty()) {
|
||||
$this->info('No PDF files found.');
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
$parser = new Parser();
|
||||
$attachments = [];
|
||||
$rows = [];
|
||||
$sno = 1;
|
||||
|
||||
$attachments = [];
|
||||
|
||||
foreach ($pdfFiles as $file) {
|
||||
$fullPath = Storage::disk('local')->path($file);
|
||||
$filename = basename($file, '.pdf');
|
||||
|
||||
$attachments[] = [
|
||||
'path' => Storage::disk('local')->path($file),
|
||||
'name' => basename($file),
|
||||
];
|
||||
|
||||
// Read PDF content for name/task/status
|
||||
try {
|
||||
$pdf = $parser->parseFile($fullPath);
|
||||
$text = $pdf->getText();
|
||||
|
||||
\Log::info('PDF RAW TEXT: ' . $text);
|
||||
} catch (\Throwable $e) {
|
||||
$text = '';
|
||||
}
|
||||
|
||||
$rows[] = [
|
||||
'sno' => $sno++,
|
||||
'name' => $this->extractNameFromFilename($filename),
|
||||
// 'project-name' => $this->extractProjectName($text),
|
||||
'project-name' => $pdf ? $this->extractProjectName($pdf) : 'Unknown project',
|
||||
'task' => $this->extractTaskTitle($text),
|
||||
'status' => $this->extractStatus($text),
|
||||
'completed' => $this->extractPercentComplete($text),
|
||||
];
|
||||
|
||||
$this->info('Attached: ' . basename($file));
|
||||
}
|
||||
|
||||
$toEmails = [];
|
||||
$ccEmails = [];
|
||||
|
||||
foreach ($mailRules as $mailRule) {
|
||||
|
||||
// TO email
|
||||
if (!empty($mailRule->email)) {
|
||||
$toEmails = array_merge(
|
||||
$toEmails,
|
||||
array_map(
|
||||
'trim',
|
||||
explode(',', $mailRule->email)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// CC emails
|
||||
if (!empty($mailRule->cc_emails)) {
|
||||
|
||||
$ccEmails = array_merge(
|
||||
$ccEmails,
|
||||
array_map(
|
||||
'trim',
|
||||
explode(',', $mailRule->cc_emails)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicate emails
|
||||
$toEmails = array_values(array_unique(array_filter($toEmails)));
|
||||
$ccEmails = array_values(array_unique(array_filter($ccEmails)));
|
||||
|
||||
|
||||
try {
|
||||
|
||||
$mail = Mail::to($toEmails);
|
||||
|
||||
if (!empty($ccEmails)) {
|
||||
$mail->cc($ccEmails);
|
||||
}
|
||||
|
||||
$mail->send(
|
||||
new DailyTaskReportMail($attachments, $rows)
|
||||
);
|
||||
|
||||
foreach ($pdfFiles as $file) {
|
||||
|
||||
if (Storage::disk('local')->exists($file)) {
|
||||
Storage::disk('local')->delete($file);
|
||||
|
||||
$this->info('Deleted: ' . basename($file));
|
||||
}
|
||||
}
|
||||
|
||||
$this->info(
|
||||
$pdfFiles->count() . ' PDF(s) mailed and deleted successfully.'
|
||||
);
|
||||
|
||||
return self::SUCCESS;
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
// Mail failed -> DO NOT delete PDFs
|
||||
$this->error('Mail sending failed.');
|
||||
$this->error($e->getMessage());
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
protected function extractNameFromFilename(string $filename): string
|
||||
{
|
||||
$name = preg_replace('/[-_]?task.*$/i', '', $filename);
|
||||
$name = preg_replace('/[-_]+/', ' ', $name);
|
||||
$name = preg_replace('/(?<!^)([A-Z])/', ' $1', $name);
|
||||
return trim(ucwords(strtolower($name)));
|
||||
}
|
||||
|
||||
protected function extractTaskTitle(string $text): string
|
||||
{
|
||||
if (preg_match('/Task\s*#\d+\s*-\s*(.+)/i', $text, $matches)) {
|
||||
$title = trim($matches[1]);
|
||||
foreach ($this->knownStatuses as $status) {
|
||||
$pos = stripos($title, $status);
|
||||
if ($pos != false) {
|
||||
$title = trim(substr($title, 0, $pos));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $title;
|
||||
}
|
||||
return 'Unknown task';
|
||||
}
|
||||
|
||||
protected function extractStatus(string $text): string
|
||||
{
|
||||
// Replace non-breaking spaces (common in OpenProject PDF exports) with regular spaces
|
||||
$normalized = str_replace("\xC2\xA0", ' ', $text);
|
||||
$normalized = preg_replace('/\s+/', ' ', $normalized);
|
||||
|
||||
foreach ($this->knownStatuses as $status) {
|
||||
if (stripos($normalized, $status) !== false) {
|
||||
return ucwords($status);
|
||||
}
|
||||
}
|
||||
return 'Unknown';
|
||||
}
|
||||
|
||||
protected function extractPercentComplete(string $text): string
|
||||
{
|
||||
$normalized = str_replace("\xC2\xA0", ' ', $text);
|
||||
$normalized = preg_replace('/[ \t]+/', ' ', $normalized);
|
||||
|
||||
if (preg_match('/%\s*Complete\s*([0-9]{1,3}\s*%)/i', $normalized, $matches)) {
|
||||
return trim(str_replace(' ', '', $matches[1]));
|
||||
}
|
||||
|
||||
return '0%';
|
||||
}
|
||||
|
||||
// protected function extractProjectName(string $text): string
|
||||
// {
|
||||
// $normalized = str_replace("\xC2\xA0", ' ', $text);
|
||||
|
||||
// // Footer pattern: <page#><date>\t<Project Name> at the very end of the PDF text
|
||||
// if (preg_match('/\d{1,2}-\d{2}-\d{4}\s*\t\s*(.+?)\s*$/s', $normalized, $matches)) {
|
||||
// return trim($matches[1]);
|
||||
// }
|
||||
|
||||
// return 'Unknown project';
|
||||
// }
|
||||
|
||||
protected function extractProjectName($pdf): string
|
||||
{
|
||||
$pages = $pdf->getPages();
|
||||
|
||||
if (empty($pages)) {
|
||||
return 'Unknown project';
|
||||
}
|
||||
|
||||
$firstPageText = str_replace("\xC2\xA0", ' ', $pages[0]->getText());
|
||||
|
||||
if (preg_match('/\d{1,2}-\d{2}-\d{4}\s*\t\s*(.+?)\s*$/s', $firstPageText, $matches)) {
|
||||
return trim($matches[1]);
|
||||
}
|
||||
|
||||
return 'Unknown project';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,282 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\LaserIdleMail;
|
||||
use App\Models\ClassCharacteristic;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SendLaserIdleHourReport extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'send:laser-idle-hour-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 = \App\Models\AlertMailRule::where('module', 'LaserIdleHourReport')
|
||||
->where('rule_name', 'LaserIdleMail')
|
||||
->where('schedule_type', $scheduleType)
|
||||
->where('plant', $plantId)
|
||||
->get();
|
||||
|
||||
$emails = $mailRules->pluck('email')->unique()->toArray();
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
$tableData = [];
|
||||
$no = 1;
|
||||
|
||||
foreach ($plants as $plant) {
|
||||
|
||||
$machineRecords = ClassCharacteristic::where('plant_id', $plant->id)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->get();
|
||||
|
||||
$machineNames = collect()
|
||||
->merge(
|
||||
$machineRecords
|
||||
->pluck('motor_machine_name')
|
||||
->filter()
|
||||
)
|
||||
->merge(
|
||||
$machineRecords
|
||||
->pluck('pump_machine_name')
|
||||
->filter()
|
||||
)
|
||||
->merge(
|
||||
$machineRecords
|
||||
->pluck('name_plate_machine_name')
|
||||
->filter()
|
||||
)
|
||||
->unique()
|
||||
->values();
|
||||
|
||||
foreach ($machineNames as $machineName) {
|
||||
|
||||
$motorCount = $machineRecords
|
||||
->where('motor_machine_name', $machineName)
|
||||
->where('motor_marked_status', 'Marked')
|
||||
->filter(function ($record) {
|
||||
return (float) ($record->motor_marked_physical_count ?? 0) > 0;
|
||||
})
|
||||
->count();
|
||||
// ->sum(function ($record) {
|
||||
// return (float) ($record->motor_marked_physical_count ?? 0);
|
||||
// });
|
||||
|
||||
$pumpRecords = $machineRecords
|
||||
->where('pump_machine_name', $machineName);
|
||||
$pumpCount = $pumpRecords
|
||||
// ->where('pump_machine_name', $machineName)
|
||||
// ->where('pump_marked_status', 'Marked')
|
||||
->sum(fn ($record) => (float) ($record->pump_marked_physical_count ?? 0));
|
||||
// ->filter(function ($record) {
|
||||
// return (float) ($record->pump_marked_physical_count ?? 0) > 0;
|
||||
// })
|
||||
// ->count();
|
||||
// ->sum(function ($record) {
|
||||
// return (float) ($record->pump_marked_physical_count ?? 0);
|
||||
// });
|
||||
|
||||
$namePlateCount = $machineRecords
|
||||
->where('name_plate_machine_name', $machineName)
|
||||
->where('name_plate_marked_status', 'Marked')
|
||||
->count();
|
||||
|
||||
$manualCount = $machineRecords
|
||||
->filter(function ($record) use ($machineName) {
|
||||
return $record->motor_machine_name == $machineName
|
||||
|| $record->pump_machine_name == $machineName
|
||||
|| $record->name_plate_machine_name == $machineName;
|
||||
})
|
||||
->sum(function ($record) {
|
||||
return (float) ($record->man_marked_status ?? 0);
|
||||
});
|
||||
|
||||
$totalExpectedMilliseconds =
|
||||
$machineRecords
|
||||
->where('motor_machine_name', $machineName)
|
||||
->sum(function ($record) {
|
||||
|
||||
$value = (string) ($record->motor_expected_time ?? '0');
|
||||
|
||||
[$seconds, $milliseconds] = array_pad(
|
||||
explode('.', $value, 2),
|
||||
2,
|
||||
'0'
|
||||
);
|
||||
|
||||
// Keep exactly 3 digits for milliseconds
|
||||
$milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
|
||||
|
||||
return ((int) $seconds * 1000) + (int) $milliseconds;
|
||||
})
|
||||
|
||||
+ $machineRecords
|
||||
->where('pump_machine_name', $machineName)
|
||||
->sum(function ($record) {
|
||||
|
||||
$value = (string) ($record->pump_expected_time ?? '0');
|
||||
|
||||
[$seconds, $milliseconds] = array_pad(
|
||||
explode('.', $value, 2),
|
||||
2,
|
||||
'0'
|
||||
);
|
||||
|
||||
$milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
|
||||
|
||||
return ((int) $seconds * 1000) + (int) $milliseconds;
|
||||
})
|
||||
|
||||
+ $machineRecords
|
||||
->where('name_plate_machine_name', $machineName)
|
||||
->sum(function ($record) {
|
||||
|
||||
$value = (string) ($record->name_plate_expected_time ?? '0');
|
||||
|
||||
[$seconds, $milliseconds] = array_pad(
|
||||
explode('.', $value, 2),
|
||||
2,
|
||||
'0'
|
||||
);
|
||||
|
||||
$milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
|
||||
|
||||
return ((int) $seconds * 1000) + (int) $milliseconds;
|
||||
})
|
||||
|
||||
+ $machineRecords
|
||||
->where('motor_machine_name', $machineName)
|
||||
->sum(function ($record) {
|
||||
|
||||
$value = (string) ($record->man_mark_expected_time ?? '0');
|
||||
|
||||
[$seconds, $milliseconds] = array_pad(
|
||||
explode('.', $value, 2),
|
||||
2,
|
||||
'0'
|
||||
);
|
||||
|
||||
$milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
|
||||
|
||||
return ((int) $seconds * 1000) + (int) $milliseconds;
|
||||
});
|
||||
|
||||
|
||||
// Convert total milliseconds to total seconds
|
||||
$totalExpectedSeconds = $totalExpectedMilliseconds / 1000;
|
||||
|
||||
|
||||
// Convert seconds to minutes
|
||||
$totalExpectedMinutes = $totalExpectedSeconds / 60;
|
||||
|
||||
|
||||
// Convert minutes to hours + minutes
|
||||
$totalHours = floor($totalExpectedMinutes / 60);
|
||||
|
||||
$totalMinutes = floor($totalExpectedMinutes % 60);
|
||||
|
||||
$totalLaserOnHours = "{$totalHours} hr {$totalMinutes} min";
|
||||
|
||||
|
||||
// Laser OFF
|
||||
$totalLaserOnHoursValue = $totalExpectedMinutes / 60;
|
||||
|
||||
$totalLaserOffHoursValue = max(0, 22.5 - $totalLaserOnHoursValue);
|
||||
|
||||
$offHours = floor($totalLaserOffHoursValue);
|
||||
|
||||
$offMinutes = floor(
|
||||
($totalLaserOffHoursValue - $offHours) * 60
|
||||
);
|
||||
|
||||
$totalLaserOffHours = "{$offHours} hr {$offMinutes} min";
|
||||
|
||||
$tableData[] = [
|
||||
'no' => $no++,
|
||||
'plant' => $plant->name,
|
||||
'machine' => $machineName,
|
||||
|
||||
'motorCount' => $motorCount,
|
||||
'pumpCount' => $pumpCount,
|
||||
'namePlateCount' => $namePlateCount,
|
||||
|
||||
'manualCount' => $manualCount,
|
||||
'totalLaserOnHours' => $totalLaserOnHours,
|
||||
'totalLaserOffHours' => $totalLaserOffHours,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($tableData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$mail = new LaserIdleMail($scheduleType, $tableData);
|
||||
|
||||
// $contentVars = $mail->content()->with;
|
||||
|
||||
foreach ($mailRules as $rule)
|
||||
{
|
||||
$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 ID {$rule->id} — no valid To emails found.");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send($mail);
|
||||
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,12 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\LaserStopMail;
|
||||
use App\Mail\LaserStopReportMail;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\ClassCharacteristic;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use App\Models\TempStopCharacteristic;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class SendLaserStopReport extends Command
|
||||
{
|
||||
@@ -22,7 +16,7 @@ class SendLaserStopReport extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'approval:laser-stop';
|
||||
protected $signature = 'send:laser-stop-report {schedule_type} {plant} {machine_id}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -31,194 +25,89 @@ class SendLaserStopReport extends Command
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
public $subjectLine;
|
||||
|
||||
// public $tempCharacteristics = [];
|
||||
|
||||
public $wfId;
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Approval mail job started');
|
||||
$scheduleType = $this->argument('schedule_type');
|
||||
$plantId = (int) $this->argument('plant');
|
||||
$machineId = (int) $this->argument('machine_id');
|
||||
|
||||
// .. Laser Stop Mail trigger logic
|
||||
|
||||
$stoppedRecords = 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');
|
||||
})
|
||||
$mailRules = \App\Models\AlertMailRule::where('module', 'LaserStopAlert')
|
||||
->where('rule_name', 'LaserStopAlertMail')
|
||||
->where('schedule_type', $scheduleType)
|
||||
->where('plant', $plantId)
|
||||
->where('machine_id', $machineId)
|
||||
->get();
|
||||
|
||||
$stoppedRecords = $stoppedRecords->filter(function ($item) {
|
||||
$approver = CharacteristicApproverMaster::find($item->characteristic_approver_master_id);
|
||||
return $approver && $approver->approver_type == 'Stop';
|
||||
});
|
||||
$emails = $mailRules
|
||||
->pluck('email')
|
||||
->filter()
|
||||
->flatMap(function ($email) {
|
||||
return array_map('trim', explode(',', $email));
|
||||
})
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$ccEmails = $mailRules
|
||||
->pluck('cc_emails')
|
||||
->filter()
|
||||
->flatMap(function ($email) {
|
||||
return array_map('trim', explode(',', $email));
|
||||
})
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
if ($stoppedRecords->isEmpty()) {
|
||||
$this->info('No laser stop pending approvals');
|
||||
$plants = $plantId == 0
|
||||
? Plant::all()
|
||||
: Plant::where('id', $plantId)->get();
|
||||
|
||||
if ($plants->isEmpty()) {
|
||||
$this->error('No valid plant(s) found.');
|
||||
return;
|
||||
}
|
||||
|
||||
$grouped = $stoppedRecords->groupBy(function ($item) {
|
||||
$this->wfId = $item->work_flow_id;
|
||||
return $item->plant_id . '|' . $item->machine_id . '|' . $item->aufnr . '|' . $item->work_flow_id;
|
||||
});
|
||||
$plant = Plant::find($plantId);
|
||||
|
||||
$pendingApprovers = RequestCharacteristic::where('work_flow_id', $this->wfId)->latest()->first();
|
||||
$plantName = $plant?->name ?? $plantId;
|
||||
|
||||
$approverNameFromMaster = null;
|
||||
if ($pendingApprovers && $pendingApprovers->characteristic_approver_master_id) {
|
||||
$approverNameFromMaster = CharacteristicApproverMaster::find($pendingApprovers->characteristic_approver_master_id);
|
||||
$machine = Machine::find($machineId);
|
||||
|
||||
$machineName = $machine?->work_center ?? $machineId;
|
||||
|
||||
$records = ClassCharacteristic::where('is_stopped', 2)
|
||||
->where('plant_id', $plantId)
|
||||
->where('machine_id', $machineId)
|
||||
->get();
|
||||
|
||||
if ($records->isEmpty()) {
|
||||
$this->info('No laser stop records found.');
|
||||
return;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$recordIds = $records->pluck('id');
|
||||
|
||||
foreach ($grouped as $groupRecords) {
|
||||
|
||||
$first = $groupRecords->first();
|
||||
|
||||
$approver = CharacteristicApproverMaster::where('plant_id', $first->plant_id)
|
||||
->where('machine_id', $first->machine_id)
|
||||
->where('id', $first->characteristic_approver_master_id)
|
||||
->first();
|
||||
|
||||
if (!$approver) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$columns = Schema::getColumnListing('temp_stop_characteristics');
|
||||
|
||||
$exclude = ['id', 'plant_id', 'machine_id', 'item_id', 'aufnr', 'class', 'arbid', 'gamng', 'lmnga', 'zz1_cn_bill_ord', 'created_at', 'updated_at', 'deleted_at', 'has_work_flow_id', 'created_by', 'updated_by' ];
|
||||
|
||||
$filteredColumns = array_diff($columns, $exclude);
|
||||
|
||||
$row1 = TempStopCharacteristic::where('plant_id', $first->plant_id)
|
||||
->where('machine_id', $first->machine_id)
|
||||
->where('aufnr', $first->aufnr)
|
||||
->where('model_type', $first->model_type)
|
||||
->where('gernr', $first->gernr)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
$stopDetails = [
|
||||
'samlight_logged_name' => $row1?->samlight_logged_name,
|
||||
'zmm_heading' => $row1?->zmm_heading,
|
||||
'machine_name' => $row1?->machine_name,
|
||||
'stopped_at' => $row1?->stopped_at,
|
||||
'stopped_by' => $row1?->stopped_by,
|
||||
];
|
||||
|
||||
$data = [];
|
||||
|
||||
if ($row1) {
|
||||
foreach ($filteredColumns as $column) {
|
||||
|
||||
$value = $row1->getAttribute($column);
|
||||
|
||||
if ($value != null && $value != '') {
|
||||
$data[$column] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$characteristics = $data;
|
||||
|
||||
$level = null;
|
||||
$mail = null;
|
||||
$name = null;
|
||||
$updateData = [];
|
||||
$now = Carbon::now();
|
||||
|
||||
// --- FIRST MAIL ---
|
||||
if (is_null($first->mail_status)){
|
||||
$level = 1;
|
||||
$mail = $approver->mail1;
|
||||
$name = $approver->name1;
|
||||
|
||||
$updateData['mail_status'] = 'Sent';
|
||||
|
||||
if ($approver->duration1 > 0)
|
||||
{
|
||||
|
||||
$duration = number_format((float)$approver->duration1, 2, '.', '');
|
||||
[$hours, $minutes] = explode('.', $duration);
|
||||
|
||||
$totalMinutes = ((int)$hours * 60) + (int)$minutes;
|
||||
|
||||
$updateData['trigger_at'] = $now
|
||||
->copy()
|
||||
->addMinutes($totalMinutes)
|
||||
->startOfMinute();
|
||||
}
|
||||
else
|
||||
{
|
||||
$updateData['trigger_at'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$level || !$mail) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$subjectLine = 'Laser Stop Approval Mail';
|
||||
|
||||
$emails = array_map('trim', explode(',', $mail));
|
||||
|
||||
Mail::to($emails)->send(
|
||||
new LaserStopMail(
|
||||
$first,
|
||||
$name,
|
||||
$level,
|
||||
$pendingApprovers,
|
||||
$approverNameFromMaster,
|
||||
$subjectLine,
|
||||
$characteristics,
|
||||
$stopDetails
|
||||
// Send mail to mapped email IDs
|
||||
Mail::to($emails)
|
||||
->cc($ccEmails)
|
||||
->send(
|
||||
new LaserStopReportMail(
|
||||
$records,
|
||||
$plantId,
|
||||
$machineId,
|
||||
$plantName,
|
||||
$machineName,
|
||||
)
|
||||
);
|
||||
|
||||
RequestCharacteristic::whereIn('id', $groupRecords->pluck('id'))
|
||||
->update($updateData);
|
||||
ClassCharacteristic::whereIn('id', $recordIds)
|
||||
->update([
|
||||
'is_stopped' => 1,
|
||||
]);
|
||||
|
||||
$rows[] = [
|
||||
$first->id,
|
||||
$first->plant_id,
|
||||
$first->machine_id,
|
||||
"Level $level",
|
||||
$mail,
|
||||
'SENT'
|
||||
];
|
||||
}
|
||||
|
||||
$this->table(
|
||||
['ID', 'Plant', 'Machine', 'Level', 'Mail', 'Status'],
|
||||
$rows
|
||||
);
|
||||
|
||||
$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;
|
||||
$this->info('Laser stop report mail sent successfully.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ class SendPanelBoxReport extends Command
|
||||
->where('machine_id', $machineId)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->where('status', 'NotOk')
|
||||
->select('serial_number', 'remark')
|
||||
->select('serial_number')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
|
||||
@@ -33,10 +33,13 @@ class SendProductionReport extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// ini_set('max_execution_time', 0); // disable limit
|
||||
// set_time_limit(0);
|
||||
|
||||
$scheduleType = $this->argument('schedule_type');
|
||||
$plantId = (int) $this->argument('plant');
|
||||
$plantId = (int) $this->argument('plant'); // cast to int for safety
|
||||
|
||||
// Fetch mail rules based on schedule type
|
||||
$mailRules = \App\Models\AlertMailRule::where('module', 'ProductionQuantities')
|
||||
->where('rule_name', 'ProductionMail')
|
||||
->where('schedule_type', $scheduleType)
|
||||
@@ -71,7 +74,7 @@ class SendProductionReport extends Command
|
||||
$tableData = [];
|
||||
$no = 1;
|
||||
|
||||
// ..
|
||||
// .
|
||||
|
||||
// foreach ($plants as $plant) {
|
||||
// $lines = Line::where('plant_id', $plant->id)->get();
|
||||
@@ -139,36 +142,10 @@ class SendProductionReport extends Command
|
||||
|
||||
foreach ($plants as $plant) {
|
||||
|
||||
// $lines = Line::where('plant_id', $plant->id)->get();
|
||||
// $lines = Line::where('plant_id', $plant->id)
|
||||
// ->orderByRaw("CASE WHEN LOWER(type) = 'fg line' THEN 0 ELSE 1 END")
|
||||
// ->get();
|
||||
|
||||
$lines = Line::where('plant_id', $plant->id)
|
||||
->whereIn('type', [
|
||||
'Base FG Line',
|
||||
'FG Line',
|
||||
'Process FG Line',
|
||||
'SFG Line',
|
||||
])
|
||||
->orderByRaw("
|
||||
CASE
|
||||
WHEN LOWER(type) = 'fg line' THEN 0
|
||||
WHEN LOWER(type) = 'base fg line' THEN 1
|
||||
WHEN LOWER(type) = 'process fg line' THEN 2
|
||||
WHEN LOWER(type) = 'sfg line' THEN 3
|
||||
ELSE 4
|
||||
END
|
||||
")
|
||||
->get();
|
||||
$lines = Line::where('plant_id', $plant->id)->get();
|
||||
|
||||
foreach ($lines as $line) {
|
||||
|
||||
$dayproductionQuantity = 0;
|
||||
$nightproductionQuantity = 0;
|
||||
$productionQuantity = 0;
|
||||
$nonPlannedproductionQuantity = 0;
|
||||
|
||||
$month = $startDate->month;
|
||||
$year = $startDate->year;
|
||||
|
||||
@@ -188,11 +165,53 @@ class SendProductionReport extends Command
|
||||
|
||||
$dailyTarget = round($dailyTarget, 2);
|
||||
|
||||
// $leaveDatesString = ProductionPlan::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereMonth('created_at', $month)
|
||||
// ->whereYear('created_at', $year)
|
||||
// ->value('leave_dates');
|
||||
$leaveDatesString = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->value('leave_dates');
|
||||
|
||||
$leaveDates = $leaveDatesString ? explode(',', $leaveDatesString) : [];
|
||||
|
||||
$monthStart = $startDate->copy()->startOfMonth();
|
||||
$yesterday = $startDate->copy()->subDay();
|
||||
|
||||
$completedDays = 0;
|
||||
$currentDate = $monthStart->copy();
|
||||
|
||||
while ($currentDate->lte($yesterday)) {
|
||||
|
||||
if (!in_array($currentDate->format('Y-m-d'), $leaveDates)) {
|
||||
$completedDays++;
|
||||
}
|
||||
|
||||
$currentDate->addDay();
|
||||
}
|
||||
|
||||
$expectedTillYesterday = $dailyTarget * $completedDays;
|
||||
|
||||
if (strtolower($line->type) == 'fg line') {
|
||||
|
||||
$producedTillYesterday = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->where('created_at', '<', $startDate)
|
||||
->count();
|
||||
|
||||
} else {
|
||||
|
||||
$producedTillYesterday = ProductionQuantity::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->where('created_at', '<', $startDate)
|
||||
->count();
|
||||
}
|
||||
|
||||
$previousRemaining = max(0, $expectedTillYesterday - $producedTillYesterday);
|
||||
|
||||
$totalTargetQuantity = round($dailyTarget + $previousRemaining, 2);
|
||||
|
||||
$itemIds = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
@@ -201,86 +220,19 @@ class SendProductionReport extends Command
|
||||
->distinct()
|
||||
->pluck('item_id');
|
||||
|
||||
// $leaveDates = $leaveDatesString ? explode(',', $leaveDatesString) : [];
|
||||
$totalHourlyQuantity = Item::whereIn('id', $itemIds)
|
||||
->sum('hourly_quantity');
|
||||
|
||||
// $monthStart = $startDate->copy()->startOfMonth();
|
||||
// $monthStart = $startDate->copy()->startOfMonth()->setTime(8, 0, 0);
|
||||
|
||||
// $yesterday = $startDate->copy()->subDay()->setTime(8, 0, 0);
|
||||
|
||||
// $completedDays = 0;
|
||||
// $currentDate = $monthStart->copy();
|
||||
|
||||
// while ($currentDate->lte($yesterday)) {
|
||||
|
||||
// if (!in_array($currentDate->format('Y-m-d'), $leaveDates)) {
|
||||
// $completedDays++;
|
||||
// }
|
||||
|
||||
// $currentDate->addDay();
|
||||
// }
|
||||
|
||||
// $expectedTillYesterday = $dailyTarget * $completedDays;
|
||||
|
||||
// if (strtolower($line->type) == 'fg line') {
|
||||
|
||||
// $producedTillYesterday = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereIn('item_id', $itemIds)
|
||||
// ->whereMonth('created_at', $month)
|
||||
// ->whereYear('created_at', $year)
|
||||
// ->where('created_at', '<', $startDate)
|
||||
// ->count();
|
||||
|
||||
// } else {
|
||||
|
||||
// $producedTillYesterday = ProductionQuantity::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereIn('item_id', $itemIds)
|
||||
// ->whereMonth('created_at', $month)
|
||||
// ->whereYear('created_at', $year)
|
||||
// ->where('created_at', '<', $startDate)
|
||||
// ->count();
|
||||
// }
|
||||
|
||||
// $previousRemaining = max(0, $expectedTillYesterday - $producedTillYesterday);
|
||||
|
||||
// $totalTargetQuantity = round($dailyTarget + $previousRemaining, 2);
|
||||
|
||||
|
||||
$totalTargetQuantity = round($dailyTarget, 2);
|
||||
|
||||
// $totalHourlyQuantity = Item::whereIn('id', $itemIds)
|
||||
// ->sum('hourly_quantity');
|
||||
|
||||
// $capacityQuan = $totalHourlyQuantity * 22.5;
|
||||
$capacityQuan = $totalHourlyQuantity * 22.5;
|
||||
|
||||
if (strtolower($line->type) == 'fg line') {
|
||||
|
||||
$productionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereHas('stickerMaster', function ($query) use ($itemIds) {
|
||||
$query->whereIn('item_id', $itemIds);
|
||||
})
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$nonPlannedproductionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereHas('stickerMaster', function ($query) use ($itemIds) {
|
||||
$query->whereNotIn('item_id', $itemIds);
|
||||
})
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
}
|
||||
else if(strtolower($line->type) == 'process fg line'){
|
||||
$productionQuantity = \App\Models\ProcessOrder::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->sum('received_quantity');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
$productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
@@ -288,71 +240,12 @@ class SendProductionReport extends Command
|
||||
->count();
|
||||
}
|
||||
|
||||
if ($totalTargetQuantity > 0) {
|
||||
$efficiency = ($productionQuantity / $totalTargetQuantity) * 100;
|
||||
if ($capacityQuan > 0) {
|
||||
$efficiency = ($productionQuantity / $capacityQuan) * 100;
|
||||
} else {
|
||||
$efficiency = 0;
|
||||
}
|
||||
|
||||
if($line->shift_flag == '0'){
|
||||
$dayShiftPlanQuan = ($totalTargetQuantity / 2);
|
||||
$nightShiftPlanQuan = ($totalTargetQuantity / 2);
|
||||
}
|
||||
elseif($line->shift_flag == '1'){
|
||||
$dayShiftPlanQuan = ($totalTargetQuantity);
|
||||
}
|
||||
elseif($line->shift_flag == '2'){
|
||||
$nightShiftPlanQuan = ($totalTargetQuantity);
|
||||
}
|
||||
|
||||
if (strtolower($line->type) == 'fg line') {
|
||||
|
||||
$dayproductionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereHas('stickerMaster', function ($query) use ($itemIds) {
|
||||
$query->whereIn('item_id', $itemIds);
|
||||
})
|
||||
->whereBetween('created_at', [
|
||||
$startDate->copy()->setTime(8, 0, 0),
|
||||
$startDate->copy()->setTime(19, 30, 0),
|
||||
])
|
||||
->count();
|
||||
|
||||
$nightproductionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereHas('stickerMaster', function ($query) use ($itemIds) {
|
||||
$query->whereIn('item_id', $itemIds);
|
||||
})
|
||||
->whereBetween('created_at', [
|
||||
$startDate->copy()->setTime(19, 30, 0),
|
||||
$endDate->copy()->setTime(8, 0, 0),
|
||||
])
|
||||
->count();
|
||||
}
|
||||
|
||||
if (strtolower($line->type) == 'process fg line') {
|
||||
|
||||
$dayproductionQuantity = \App\Models\ProcessOrder::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [
|
||||
$startDate->copy()->setTime(8, 0, 0),
|
||||
$startDate->copy()->setTime(19, 30, 0),
|
||||
])
|
||||
->sum('received_quantity');
|
||||
|
||||
$nightproductionQuantity = \App\Models\ProcessOrder::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [
|
||||
$startDate->copy()->setTime(19, 30, 0),
|
||||
$endDate->copy()->setTime(8, 0, 0),
|
||||
])
|
||||
->sum('received_quantity');
|
||||
}
|
||||
|
||||
$dayShiftEfficiency = $dayShiftPlanQuan > 0 ? ($dayproductionQuantity / $dayShiftPlanQuan) * 100 : 0;
|
||||
|
||||
$nightShiftEfficiency = $nightShiftPlanQuan > 0 ? ($nightproductionQuantity / $nightShiftPlanQuan) * 100 : 0;
|
||||
|
||||
$efficiency = round($efficiency, 2);
|
||||
|
||||
$tableData[] = [
|
||||
@@ -360,18 +253,10 @@ class SendProductionReport extends Command
|
||||
'plant' => $plant->name,
|
||||
'type' => $line->type,
|
||||
'line' => $line->name,
|
||||
// 'capacityQuantity' => floor($capacityQuan),
|
||||
'dayShiftPlanQuantity' => floor($dayShiftPlanQuan),
|
||||
'dayShiftActualQuantity' => floor($dayproductionQuantity),
|
||||
'dayShiftEfficiency' => floor($dayShiftEfficiency) . '%',
|
||||
'nightShiftPlanQuantity' => floor($nightShiftPlanQuan),
|
||||
'nightShiftActualQuantity' => floor($nightproductionQuantity),
|
||||
'nightShiftEfficiency' => floor($nightShiftEfficiency) . '%',
|
||||
'capacityQuantity' => floor($capacityQuan),
|
||||
'targetQuantity' => floor($totalTargetQuantity),
|
||||
'productionQuantity' => $productionQuantity,
|
||||
'uom' => $line->uom,
|
||||
'efficiency' => $efficiency . '%',
|
||||
'nonPlannedQuantity' => $nonPlannedproductionQuantity,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,15 +311,13 @@ class ClassCharacteristicExporter extends Exporter
|
||||
->label('ZMM OPERATING TEMPERATURE'),
|
||||
ExportColumn::make('zmm_axial_force')
|
||||
->label('ZMM AXIAL FORCE'),
|
||||
ExportColumn::make('zmm_mrp')
|
||||
->label('ZMM MRP'),
|
||||
// ExportColumn::make('is_stopped')
|
||||
// ->label('IS STOPPED')
|
||||
// ->formatStateUsing(fn ($state) => ($state == '0') ? 'No' : ($state == '1' ? 'Yes' : 'Yes (Alert Pending)')),
|
||||
// ExportColumn::make('stopped_datetime')
|
||||
// ->label('STOPPED DATETIME'),
|
||||
// ExportColumn::make('stopped_by')
|
||||
// ->label('STOPPED BY'),
|
||||
ExportColumn::make('is_stopped')
|
||||
->label('IS STOPPED')
|
||||
->formatStateUsing(fn ($state) => ($state == '0') ? 'No' : ($state == '1' ? 'Yes' : 'Yes (Alert Pending)')),
|
||||
ExportColumn::make('stopped_datetime')
|
||||
->label('STOPPED DATETIME'),
|
||||
ExportColumn::make('stopped_by')
|
||||
->label('STOPPED BY'),
|
||||
ExportColumn::make('mark_status')
|
||||
->label('MARKED STATUS'),
|
||||
ExportColumn::make('marked_physical_count')
|
||||
@@ -332,8 +330,6 @@ class ClassCharacteristicExporter extends Exporter
|
||||
->label('MARKED BY'),
|
||||
ExportColumn::make('man_marked_status')
|
||||
->label('MANUAL MARKED PHYSICAL COUNT'),
|
||||
ExportColumn::make('man_marked_expected_time')
|
||||
->label('MANUAL MARKED EXPECTED TIME'),
|
||||
ExportColumn::make('man_marked_datetime')
|
||||
->label('MANUAL MARKED DATETIME'),
|
||||
ExportColumn::make('man_marked_by')
|
||||
@@ -367,14 +363,7 @@ class ClassCharacteristicExporter extends Exporter
|
||||
ExportColumn::make('name_plate_marked_by')
|
||||
->label('NAME PLATE MARKED BY'),
|
||||
ExportColumn::make('motor_pump_pumpset_status')
|
||||
->label('MOTOR PUMP PUMPSET STATUS')
|
||||
->formatStateUsing(fn ($state): string => match ((string) $state) {
|
||||
'1' => 'Motor',
|
||||
'2' => 'Pump',
|
||||
'3' => 'PumpSet',
|
||||
'4' => 'Name Plate',
|
||||
default => 'NIL',
|
||||
}),
|
||||
->label('MOTOR PUMP PUMPSET STATUS'),
|
||||
ExportColumn::make('winded_serial_number')
|
||||
->label('WINDED SERIAL NUMBER'),
|
||||
ExportColumn::make('winded_rework_status')
|
||||
@@ -397,36 +386,6 @@ class ClassCharacteristicExporter extends Exporter
|
||||
->label('PENDING RELEASED STATUS'),
|
||||
ExportColumn::make('has_work_flow_id')
|
||||
->label('HAS WORK FLOW ID'),
|
||||
ExportColumn::make('motor_stop_flow_id')
|
||||
->label('MOTOR STOP FLOW ID')
|
||||
->formatStateUsing(fn ($state): string => match ((string) $state) {
|
||||
'5' => 'NIL',
|
||||
'4' => 'Has Master',
|
||||
'3' => 'Make Alert',
|
||||
'2' => 'Alert Pending',
|
||||
'1' => 'Alert Approved',
|
||||
default => '-',
|
||||
}),
|
||||
ExportColumn::make('pump_stop_flow_id')
|
||||
->label('PUMP STOP FLOW ID')
|
||||
->formatStateUsing(fn ($state): string => match ((string) $state) {
|
||||
'5' => 'NIL',
|
||||
'4' => 'Has Master',
|
||||
'3' => 'Make Alert',
|
||||
'2' => 'Alert Pending',
|
||||
'1' => 'Alert Approved',
|
||||
default => '-',
|
||||
}),
|
||||
ExportColumn::make('name_plate_stop_flow_id')
|
||||
->label('NAME PLATE STOP FLOW ID')
|
||||
->formatStateUsing(fn ($state): string => match ((string) $state) {
|
||||
'5' => 'NIL',
|
||||
'4' => 'Has Master',
|
||||
'3' => 'Make Alert',
|
||||
'2' => 'Alert Pending',
|
||||
'1' => 'Alert Approved',
|
||||
default => '-',
|
||||
}),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\CoilPacking;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class CoilPackingExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = CoilPacking::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('wire_packing_number')
|
||||
->label('WIRE PACKING NUMBER'),
|
||||
ExportColumn::make('process_order')
|
||||
->label('COIL NUMBER'),
|
||||
ExportColumn::make('coil_packing_status')
|
||||
->label('COIL PACKING STATUS'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('scanned_at')
|
||||
->label('SCANNED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('scanned_by')
|
||||
->label('SCANNED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your coil packing 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;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ class ItemCharacteristicExporter extends Exporter
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
@@ -248,8 +247,6 @@ class ItemCharacteristicExporter extends Exporter
|
||||
->label('ZMM NEWT PUMP'),
|
||||
ExportColumn::make('zmm_logo_nsf')
|
||||
->label('ZMM LOGO NSF'),
|
||||
ExportColumn::make('zmm_logo_eac')
|
||||
->label('ZMM LOGO EAC'),
|
||||
ExportColumn::make('zmm_packtype')
|
||||
->label('ZMM PACK TYPE'),
|
||||
ExportColumn::make('zmm_panel')
|
||||
@@ -285,13 +282,7 @@ class ItemCharacteristicExporter extends Exporter
|
||||
ExportColumn::make('zmm_motor_speed')
|
||||
->label('ZMM MOTOR SPEED'),
|
||||
ExportColumn::make('zqmm_qty')
|
||||
->label('ZQMM QTY'),
|
||||
ExportColumn::make('zmm_operating_temperature')
|
||||
->label('ZMM OPERATING TEMPERATURE'),
|
||||
ExportColumn::make('zmm_axial_force')
|
||||
->label('ZMM AXIAL FORCE'),
|
||||
ExportColumn::make('zmm_mrp')
|
||||
->label('ZMM MRP'),
|
||||
->label('ZMM QTY'),
|
||||
ExportColumn::make('zmm_1')
|
||||
->label('ZMM 1')
|
||||
->enabledByDefault(false),
|
||||
@@ -353,10 +344,10 @@ class ItemCharacteristicExporter extends Exporter
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your item characteristic export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
|
||||
$body = 'Your item characteristic 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.';
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
|
||||
@@ -26,8 +26,6 @@ class ItemExporter extends Exporter
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE NAME'),
|
||||
ExportColumn::make('category')
|
||||
->label('CATEGORY'),
|
||||
ExportColumn::make('code')
|
||||
|
||||
@@ -30,16 +30,6 @@ class LineExporter extends Exporter
|
||||
->label('LINE NAME'),
|
||||
ExportColumn::make('type')
|
||||
->label('LINE TYPE'),
|
||||
ExportColumn::make('uom')
|
||||
->label('UNIT OF MEASUREMENT'),
|
||||
ExportColumn::make('shift_flag')
|
||||
->label('SHIFT')
|
||||
->formatStateUsing(fn ($state) => match ((string) $state) {
|
||||
'0' => 'Day&Night',
|
||||
'1' => 'Day',
|
||||
'2' => 'Night',
|
||||
default => 'Unknown',
|
||||
}),
|
||||
ExportColumn::make('no_of_operation')
|
||||
->label('NO OF OPERATION'),
|
||||
ExportColumn::make('workGroup1.name')
|
||||
|
||||
@@ -59,8 +59,6 @@ class PanelBoxValidationExporter extends Exporter
|
||||
->label('PART VALIDATION 4'),
|
||||
ExportColumn::make('part_validation5')
|
||||
->label('PART VALIDATION 5'),
|
||||
ExportColumn::make('status')
|
||||
->label('STATUS'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
|
||||
@@ -31,7 +31,7 @@ class PlantExporter extends Exporter
|
||||
ExportColumn::make('name')
|
||||
->label('NAME'),
|
||||
ExportColumn::make('warehouse_number')
|
||||
->label('WAREHOUSE NUMBER'),
|
||||
->label('WAREHOUSE_NUMBER'),
|
||||
ExportColumn::make('address')
|
||||
->label('ADDRESS'),
|
||||
ExportColumn::make('created_at')
|
||||
|
||||
@@ -34,8 +34,6 @@ class ProductionPlanExporter extends Exporter
|
||||
->label('BLOCK NAME'),
|
||||
ExportColumn::make('shift.name')
|
||||
->label('SHIFT NAME'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('operator_id')
|
||||
|
||||
@@ -1,335 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\ProductionTemp;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class ProductionTempExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = ProductionTemp::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('aufnr')
|
||||
->label('AUFNR'),
|
||||
ExportColumn::make('class')
|
||||
->label('CLASS'),
|
||||
ExportColumn::make('arbid')
|
||||
->label('ARBID'),
|
||||
ExportColumn::make('gamng')
|
||||
->label('GAMNG'),
|
||||
ExportColumn::make('lmnga')
|
||||
->label('LMNGA'),
|
||||
ExportColumn::make('gernr')
|
||||
->label('GERNR'),
|
||||
ExportColumn::make('zz1_cn_bill_ord')
|
||||
->label('ZZ1 CN BILL ORD'),
|
||||
ExportColumn::make('zmm_amps')
|
||||
->label('ZMM AMPS'),
|
||||
ExportColumn::make('zmm_brand')
|
||||
->label('ZMM BRAND'),
|
||||
ExportColumn::make('zmm_degreeofprotection')
|
||||
->label('ZMM DEGREEOFPROTECTION'),
|
||||
ExportColumn::make('zmm_delivery')
|
||||
->label('ZMM DELIVERY'),
|
||||
ExportColumn::make('zmm_dir_rot')
|
||||
->label('ZMM DIR ROT'),
|
||||
ExportColumn::make('zmm_discharge')
|
||||
->label('ZMM DISCHARGE'),
|
||||
ExportColumn::make('zmm_discharge_max')
|
||||
->label('ZMM DISCHARGE MAX'),
|
||||
ExportColumn::make('zmm_discharge_min')
|
||||
->label('ZMM DISCHARGE MIN'),
|
||||
ExportColumn::make('zmm_duty')
|
||||
->label('ZMM DUTY'),
|
||||
ExportColumn::make('zmm_eff_motor')
|
||||
->label('ZMM EFF MOTOR'),
|
||||
ExportColumn::make('zmm_eff_pump')
|
||||
->label('ZMM EFF PUMP'),
|
||||
ExportColumn::make('zmm_frequency')
|
||||
->label('ZMM FREQUENCY'),
|
||||
ExportColumn::make('zmm_head')
|
||||
->label('ZMM HEAD'),
|
||||
ExportColumn::make('zmm_heading')
|
||||
->label('ZMM HEADING'),
|
||||
ExportColumn::make('zmm_head_max')
|
||||
->label('ZMM HEAD MAX'),
|
||||
ExportColumn::make('zmm_head_minimum')
|
||||
->label('ZMM HEAD MINIMUM'),
|
||||
ExportColumn::make('zmm_idx_eff_mtr')
|
||||
->label('ZMM IDX EFF MTR'),
|
||||
ExportColumn::make('zmm_idx_eff_pump')
|
||||
->label('ZMM IDX EFF PUMP'),
|
||||
ExportColumn::make('zmm_kvacode')
|
||||
->label('ZMM KVACODE'),
|
||||
ExportColumn::make('zmm_maxambtemp')
|
||||
->label('ZMM MAXAMBTEMP'),
|
||||
ExportColumn::make('zmm_mincoolingflow')
|
||||
->label('ZMM MINCOOLINGFLOW'),
|
||||
ExportColumn::make('zmm_motorseries')
|
||||
->label('ZMM MOTORSERIES'),
|
||||
ExportColumn::make('zmm_motor_model')
|
||||
->label('ZMM MOTOR MODEL'),
|
||||
ExportColumn::make('zmm_outlet')
|
||||
->label('ZMM OUTLET'),
|
||||
ExportColumn::make('zmm_phase')
|
||||
->label('ZMM PHASE'),
|
||||
ExportColumn::make('zmm_pressure')
|
||||
->label('ZMM PRESSURE'),
|
||||
ExportColumn::make('zmm_pumpflowtype')
|
||||
->label('ZMM PUMPFLOWTYPE'),
|
||||
ExportColumn::make('zmm_pumpseries')
|
||||
->label('ZMM PUMPSERIES'),
|
||||
ExportColumn::make('zmm_pump_model')
|
||||
->label('ZMM PUMP MODEL'),
|
||||
ExportColumn::make('zmm_ratedpower')
|
||||
->label('ZMM RATEDPOWER'),
|
||||
ExportColumn::make('zmm_region')
|
||||
->label('ZMM REGION'),
|
||||
ExportColumn::make('zmm_servicefactor')
|
||||
->label('ZMM SERVICEFACTOR'),
|
||||
ExportColumn::make('zmm_servicefactormaximumamps')
|
||||
->label('ZMM SERVICEFACTORMAXIMUMAMPS'),
|
||||
ExportColumn::make('zmm_speed')
|
||||
->label('ZMM SPEED'),
|
||||
ExportColumn::make('zmm_suction')
|
||||
->label('ZMM SUCTION'),
|
||||
ExportColumn::make('zmm_suctionxdelivery')
|
||||
->label('ZMM SUCTIONXDELIVERY'),
|
||||
ExportColumn::make('zmm_supplysource')
|
||||
->label('ZMM SUPPLYSOURCE'),
|
||||
ExportColumn::make('zmm_temperature')
|
||||
->label('ZMM TEMPERATURE'),
|
||||
ExportColumn::make('zmm_thrustload')
|
||||
->label('ZMM THRUSTLOAD'),
|
||||
ExportColumn::make('zmm_volts')
|
||||
->label('ZMM VOLTS'),
|
||||
ExportColumn::make('zmm_wire')
|
||||
->label('ZMM WIRE'),
|
||||
ExportColumn::make('zmm_package')
|
||||
->label('ZMM PACKAGE'),
|
||||
ExportColumn::make('zmm_pvarrayrating')
|
||||
->label('ZMM PVARRAYRATING'),
|
||||
ExportColumn::make('zmm_isi')
|
||||
->label('ZMM ISI'),
|
||||
ExportColumn::make('zmm_isimotor')
|
||||
->label('ZMM ISIMOTOR'),
|
||||
ExportColumn::make('zmm_isipump')
|
||||
->label('ZMM ISIPUMP'),
|
||||
ExportColumn::make('zmm_isipumpset')
|
||||
->label('ZMM ISIPUMPSET'),
|
||||
ExportColumn::make('zmm_pumpset_model')
|
||||
->label('ZMM PUMPSET MODEL'),
|
||||
ExportColumn::make('zmm_stages')
|
||||
->label('ZMM STAGES'),
|
||||
ExportColumn::make('zmm_headrange')
|
||||
->label('ZMM HEADRANGE'),
|
||||
ExportColumn::make('zmm_overall_efficiency')
|
||||
->label('ZMM OVERALL EFFICIENCY'),
|
||||
ExportColumn::make('zmm_connection')
|
||||
->label('ZMM CONNECTION'),
|
||||
ExportColumn::make('zmm_min_bore_size')
|
||||
->label('ZMM MIN BORE SIZE'),
|
||||
ExportColumn::make('zmm_isireference')
|
||||
->label('ZMM ISIREFERENCE'),
|
||||
ExportColumn::make('zmm_category')
|
||||
->label('ZMM CATEGORY'),
|
||||
ExportColumn::make('zmm_submergence')
|
||||
->label('ZMM SUBMERGENCE'),
|
||||
ExportColumn::make('zmm_capacitorstart')
|
||||
->label('ZMM CAPACITORSTART'),
|
||||
ExportColumn::make('zmm_capacitorrun')
|
||||
->label('ZMM CAPACITORRUN'),
|
||||
ExportColumn::make('zmm_inch')
|
||||
->label('ZMM INCH'),
|
||||
ExportColumn::make('zmm_motor_type')
|
||||
->label('ZMM MOTOR TYPE'),
|
||||
ExportColumn::make('zmm_dismantle_direction')
|
||||
->label('ZMM DISMANTLE DIRECTION'),
|
||||
ExportColumn::make('zmm_eff_ovrall')
|
||||
->label('ZMM EFF OVRALL'),
|
||||
ExportColumn::make('zmm_bodymoc')
|
||||
->label('ZMM BODYMOC'),
|
||||
ExportColumn::make('zmm_rotormoc')
|
||||
->label('ZMM ROTORMOC'),
|
||||
ExportColumn::make('zmm_dlwl')
|
||||
->label('ZMM DLWL'),
|
||||
ExportColumn::make('zmm_inputpower')
|
||||
->label('ZMM INPUTPOWER'),
|
||||
ExportColumn::make('zmm_imp_od')
|
||||
->label('ZMM IMP OD'),
|
||||
ExportColumn::make('zmm_ambtemp')
|
||||
->label('ZMM AMBTEMP'),
|
||||
ExportColumn::make('zmm_de')
|
||||
->label('ZMM DE'),
|
||||
ExportColumn::make('zmm_dischargerange')
|
||||
->label('ZMM DISCHARGERANGE'),
|
||||
ExportColumn::make('zmm_efficiency_class')
|
||||
->label('ZMM EFFICIENCY CLASS'),
|
||||
ExportColumn::make('zmm_framesize')
|
||||
->label('ZMM FRAMESIZE'),
|
||||
ExportColumn::make('zmm_impellerdiameter')
|
||||
->label('ZMM IMPELLERDIAMETER'),
|
||||
ExportColumn::make('zmm_insulationclass')
|
||||
->label('ZMM INSULATIONCLASS'),
|
||||
ExportColumn::make('zmm_maxflow')
|
||||
->label('ZMM MAXFLOW'),
|
||||
ExportColumn::make('zmm_minhead')
|
||||
->label('ZMM MINHEAD'),
|
||||
ExportColumn::make('zmm_mtrlofconst')
|
||||
->label('ZMM MTRLOFCONST'),
|
||||
ExportColumn::make('zmm_nde')
|
||||
->label('ZMM NDE'),
|
||||
ExportColumn::make('zmm_powerfactor')
|
||||
->label('ZMM POWERFACTOR'),
|
||||
ExportColumn::make('zmm_tagno')
|
||||
->label('ZMM TANGO'),
|
||||
ExportColumn::make('zmm_year')
|
||||
->label('ZMM YEAR'),
|
||||
ExportColumn::make('zmm_laser_name')
|
||||
->label('ZMM LASER NAME'),
|
||||
ExportColumn::make('zmm_logo_cp')
|
||||
->label('ZMM LOGO CP'),
|
||||
ExportColumn::make('zmm_logo_ce')
|
||||
->label('ZMM LOGO CE'),
|
||||
ExportColumn::make('zmm_logo_nsf')
|
||||
->label('ZMM LOGO NSF'),
|
||||
ExportColumn::make('zmm_logo_eac')
|
||||
->label('ZMM LOGO EAC'),
|
||||
ExportColumn::make('zmm_beenote')
|
||||
->label('ZMM BEENOTE'),
|
||||
ExportColumn::make('zmm_beenumber')
|
||||
->label('ZMM BEENUMBER'),
|
||||
ExportColumn::make('zmm_beestar')
|
||||
->label('ZMM BEESTAR'),
|
||||
ExportColumn::make('zmm_codeclass')
|
||||
->label('ZMM CODECLASS'),
|
||||
ExportColumn::make('zmm_colour')
|
||||
->label('ZMM COLOUR'),
|
||||
ExportColumn::make('zmm_grade')
|
||||
->label('ZMM GRADE'),
|
||||
ExportColumn::make('zmm_grwt_pset')
|
||||
->label('ZMM GRWT PSET'),
|
||||
ExportColumn::make('zmm_grwt_cable')
|
||||
->label('ZMM GRWT CABLE'),
|
||||
ExportColumn::make('zmm_grwt_motor')
|
||||
->label('ZMM GRWT MOTOR'),
|
||||
ExportColumn::make('zmm_grwt_pf')
|
||||
->label('ZMM GRWT PF'),
|
||||
ExportColumn::make('zmm_grwt_pump')
|
||||
->label('ZMM GRWT PUMP'),
|
||||
ExportColumn::make('zmm_isivalve')
|
||||
->label('ZMM ISIVALVE'),
|
||||
ExportColumn::make('zmm_isi_wc')
|
||||
->label('ZMM ISI WC'),
|
||||
ExportColumn::make('zmm_labelperiod')
|
||||
->label('ZMM LABELPERIOD'),
|
||||
ExportColumn::make('zmm_length')
|
||||
->label('ZMM LENGTH'),
|
||||
ExportColumn::make('zmm_license_cml_no')
|
||||
->label('ZMM LICENSE CML NO'),
|
||||
ExportColumn::make('zmm_mfgmonyr')
|
||||
->label('ZMM MFGMONYR'),
|
||||
ExportColumn::make('zmm_modelyear')
|
||||
->label('ZMM MODELYEAR'),
|
||||
ExportColumn::make('zmm_motoridentification')
|
||||
->label('ZMM MOTORIDENTIFICATION'),
|
||||
ExportColumn::make('zmm_newt_pset')
|
||||
->label('ZMM NEWT PSET'),
|
||||
ExportColumn::make('zmm_newt_cable')
|
||||
->label('ZMM NEWT CABLE'),
|
||||
ExportColumn::make('zmm_newt_motor')
|
||||
->label('ZMM NEWT MOTOR'),
|
||||
ExportColumn::make('zmm_newt_pf')
|
||||
->label('ZMM NEWT PF'),
|
||||
ExportColumn::make('zmm_newt_pump')
|
||||
->label('ZMM NEWT PUMP'),
|
||||
ExportColumn::make('zmm_packtype')
|
||||
->label('ZMM PACKTYPE'),
|
||||
ExportColumn::make('zmm_panel')
|
||||
->label('ZMM PANEL'),
|
||||
ExportColumn::make('zmm_performance_factor')
|
||||
->label('ZMM PERFORMANCE FACTOR'),
|
||||
ExportColumn::make('zmm_pumpidentification')
|
||||
->label('ZMM PUMPIDENTIFICATION'),
|
||||
ExportColumn::make('zmm_psettype')
|
||||
->label('ZMM PSETTYPE'),
|
||||
ExportColumn::make('zmm_size')
|
||||
->label('ZMM SIZE'),
|
||||
ExportColumn::make('zmm_eff_ttl')
|
||||
->label('ZMM EFF TTL'),
|
||||
ExportColumn::make('zmm_type')
|
||||
->label('ZMM TYPE'),
|
||||
ExportColumn::make('zmm_usp')
|
||||
->label('ZMM USP'),
|
||||
ExportColumn::make('zmm_operating_range')
|
||||
->label('ZMM OPERATING RANGE'),
|
||||
ExportColumn::make('zmm_intake_air')
|
||||
->label('ZMM INTAKE AIR'),
|
||||
ExportColumn::make('zmm_oxygen_transfer_rate')
|
||||
->label('ZMM OXYGEN TRANSFER RATE'),
|
||||
ExportColumn::make('zmm_air_inlet_pipesize')
|
||||
->label('ZMM AIR INLET PIPESIZE'),
|
||||
ExportColumn::make('zmm_sump_depth')
|
||||
->label('ZMM SUMP DEPTH'),
|
||||
ExportColumn::make('zmm_poles')
|
||||
->label('ZMM POLES'),
|
||||
ExportColumn::make('zmm_motor_heading')
|
||||
->label('ZMM MOTOR HEADING'),
|
||||
ExportColumn::make('zmm_motor_speed')
|
||||
->label('ZMM MOTOR SPEED'),
|
||||
ExportColumn::make('zqmm_qty')
|
||||
->label('ZQMM QTY'),
|
||||
ExportColumn::make('zmm_operating_temperature')
|
||||
->label('ZMM OPERATING TEMPERATURE'),
|
||||
ExportColumn::make('zmm_axial_force')
|
||||
->label('ZMM AXIAL FORCE'),
|
||||
ExportColumn::make('zmm_mrp')
|
||||
->label('ZMM MRP'),
|
||||
ExportColumn::make('pending_released_status')
|
||||
->label('PENDING RELEASED STATUS'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT')
|
||||
->enabledByDefault(true),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->enabledByDefault(true),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your production temp 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,15 +34,6 @@ class RequestCharacteristicExporter extends Exporter
|
||||
->label('MACHINE NAME'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('DESCRIPTION')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('item.category')
|
||||
->label('CATEGORY')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('item.uom')
|
||||
->label('UNIT OF MEASURE')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('aufnr')
|
||||
->label('JOB NUMBER'),
|
||||
ExportColumn::make('gernr')
|
||||
@@ -104,14 +95,12 @@ class RequestCharacteristicExporter extends Exporter
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT')
|
||||
->enabledByDefault(true),
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->enabledByDefault(true),
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\StickerOrder;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class StickerOrderExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = StickerOrder::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('sticker_id')
|
||||
->label('STICKER ID'),
|
||||
ExportColumn::make('production_order')
|
||||
->label('PRODUCTION ORDER'),
|
||||
ExportColumn::make('from_serial_number')
|
||||
->label('FROM SERIAL NUMBER'),
|
||||
ExportColumn::make('to_serial_number')
|
||||
->label('TO SERIAL NUMBER'),
|
||||
ExportColumn::make('print_status')
|
||||
->label('PRINT STATUS'),
|
||||
ExportColumn::make('reprint_count')
|
||||
->label('REPRINT COUNT'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
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 sticker order 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;
|
||||
}
|
||||
}
|
||||
@@ -28,15 +28,6 @@ class TempClassCharacteristicExporter extends Exporter
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('DESCRIPTION')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('item.category')
|
||||
->label('CATEGORY')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('item.uom')
|
||||
->label('UNIT OF MEASURE')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('aufnr')
|
||||
->label('AUFNR'),
|
||||
ExportColumn::make('class')
|
||||
@@ -311,8 +302,6 @@ class TempClassCharacteristicExporter extends Exporter
|
||||
->label('ZMM OPERATING TEMPERATURE'),
|
||||
ExportColumn::make('zmm_axial_force')
|
||||
->label('ZMM AXIAL FORCE'),
|
||||
ExportColumn::make('zmm_mrp')
|
||||
->label('ZMM MRP'),
|
||||
ExportColumn::make('winded_serial_number')
|
||||
->label('WINDED SERIAL NUMBER'),
|
||||
ExportColumn::make('model_type')
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\TempStopCharacteristic;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class TempStopCharacteristicExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = TempStopCharacteristic::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('machine_name')
|
||||
->label('MACHINE NAME'),
|
||||
ExportColumn::make('has_stop_flow_id')
|
||||
->label('HAS STOP FLOW ID'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('DESCRIPTION')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('item.category')
|
||||
->label('CATEGORY')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('item.uom')
|
||||
->label('UNIT OF MEASURE')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('aufnr')
|
||||
->label('JOB NUMBER'),
|
||||
ExportColumn::make('gernr')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('zmm_heading')
|
||||
->label('ZMM HEADING'),
|
||||
ExportColumn::make('model_type')
|
||||
->label('MODEL TYPE'),
|
||||
ExportColumn::make('characteristic_field')
|
||||
->label('MASTER CHARACTERISTIC FIELD'),
|
||||
ExportColumn::make('samlight_logged_name')
|
||||
->label('SAMLIGHT LOGGED NAME'),
|
||||
ExportColumn::make('stopped_at')
|
||||
->label('STOPPED AT'),
|
||||
ExportColumn::make('stopped_by')
|
||||
->label('STOPPED BY'),
|
||||
ExportColumn::make('has_stop_flow_id')
|
||||
->label('HAS STOP FLOW ID'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT')
|
||||
->enabledByDefault(true),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->enabledByDefault(true),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your temp stop characteristic 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;
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\TestApprovalMapping;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class TestApprovalMappingExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = TestApprovalMapping::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE NAME'),
|
||||
ExportColumn::make('workGroupMaster.name')
|
||||
->label('WORK GROUP CENTER'),
|
||||
ExportColumn::make('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('tested_by')
|
||||
->label('TESTED BY'),
|
||||
ExportColumn::make('verified_by')
|
||||
->label('VERIFIED BY'),
|
||||
ExportColumn::make('approved_by')
|
||||
->label('APPROVED BY'),
|
||||
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 test approval mapping 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;
|
||||
}
|
||||
}
|
||||
@@ -28,18 +28,16 @@ class TestingPanelReadingExporter extends Exporter
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE NAME'),
|
||||
ExportColumn::make('machine.workGroupMaster.name')
|
||||
->label('GROUP WORK CENTER'),
|
||||
ExportColumn::make('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('machine.name')
|
||||
->label('MACHINE NAME'),
|
||||
ExportColumn::make('motorTestingMaster.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('motorTestingMaster.item.description')
|
||||
->label('MODEL DESCRIPTION'),
|
||||
ExportColumn::make('output')
|
||||
->label('OUTPUT ID'),
|
||||
->label('OUTPUT NAME'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('MOTOR SERIAL NUMBER'),
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('winded_serial_number')
|
||||
->label('WINDED SERIAL NUMBER'),
|
||||
ExportColumn::make('motorTestingMaster.kw')
|
||||
@@ -53,7 +51,7 @@ class TestingPanelReadingExporter extends Exporter
|
||||
ExportColumn::make('motorTestingMaster.isi_model')
|
||||
->label('ISI MODEL'),
|
||||
ExportColumn::make('before_fr_volt')
|
||||
->label('BEFORE FR VOLTAGE'),
|
||||
->label('BEFORE FR VOLT'),
|
||||
ExportColumn::make('before_fr_cur')
|
||||
->label('BEFORE FR CURRENT'),
|
||||
ExportColumn::make('before_fr_pow')
|
||||
@@ -77,7 +75,7 @@ class TestingPanelReadingExporter extends Exporter
|
||||
ExportColumn::make('before_fr_speed')
|
||||
->label('BEFORE FR SPEED'),
|
||||
ExportColumn::make('after_fr_vol')
|
||||
->label('AFTER FR VOLTAGE'),
|
||||
->label('AFTER FR VOLT'),
|
||||
ExportColumn::make('after_fr_cur')
|
||||
->label('AFTER FR CURRENT'),
|
||||
ExportColumn::make('after_fr_pow')
|
||||
@@ -105,13 +103,13 @@ class TestingPanelReadingExporter extends Exporter
|
||||
ExportColumn::make('after_fr_leak_cur')
|
||||
->label('AFTER FR LEAK CURRENT'),
|
||||
ExportColumn::make('locked_rt_volt')
|
||||
->label('LOCKED RT VOLTAGE'),
|
||||
->label('LOCKED RT VOLT'),
|
||||
ExportColumn::make('locked_rt_cur')
|
||||
->label('LOCKED RT CURRENT'),
|
||||
ExportColumn::make('locked_rt_pow')
|
||||
->label('LOCKED RT POWER'),
|
||||
ExportColumn::make('no_load_pickup_volt')
|
||||
->label('NO LOAD PICKUP VOLTAGE'),
|
||||
->label('NO LOAD PICKUP VOLT'),
|
||||
ExportColumn::make('room_temperature')
|
||||
->label('ROOM TEMPERATURE'),
|
||||
ExportColumn::make('hv_test')
|
||||
@@ -124,14 +122,8 @@ class TestingPanelReadingExporter extends Exporter
|
||||
->label('RESULT'),
|
||||
ExportColumn::make('remark')
|
||||
->label('REMARK'),
|
||||
ExportColumn::make('test_sequence_flag')
|
||||
->label('TEST SEQUENCE FLAG'),
|
||||
ExportColumn::make('test_started_at')
|
||||
->label('TEST STARTED AT'),
|
||||
ExportColumn::make('rework_count')
|
||||
->label('REWORK COUNT'),
|
||||
ExportColumn::make('rework_winded')
|
||||
->label('REWORK WINDED STATUS'),
|
||||
ExportColumn::make('update_count')
|
||||
->label('UPDATED COUNT'),
|
||||
ExportColumn::make('output_flag')
|
||||
|
||||
@@ -153,14 +153,10 @@ class CharacteristicApproverMasterImporter extends Importer
|
||||
if (! is_numeric($apprDur1)) {
|
||||
$warnMsg[] = 'Duration 1 must be a numeric value (HH.MM)!';
|
||||
}
|
||||
if ($apprDur2 == null || $apprDur2 == '') {
|
||||
$apprDur2 = 0.00;
|
||||
} elseif ($apprDur2 != null && $apprDur2 != '' && ! is_numeric($apprDur2)) {
|
||||
if ($apprDur2 != null && $apprDur2 != '' && ! is_numeric($apprDur2)) {
|
||||
$warnMsg[] = 'Duration 2 must be a numeric value (HH.MM)!';
|
||||
}
|
||||
if ($apprDur3 == null || $apprDur3 == '') {
|
||||
$apprDur3 = 0.00;
|
||||
} elseif ($apprDur3 != null && $apprDur3 != '' && ! is_numeric($apprDur3)) {
|
||||
if ($apprDur3 != null && $apprDur3 != '' && ! is_numeric($apprDur3)) {
|
||||
$warnMsg[] = 'Duration 3 must be a numeric value (HH.MM)!';
|
||||
}
|
||||
|
||||
|
||||
@@ -544,8 +544,8 @@ class ClassCharacteristicImporter extends Importer
|
||||
->exampleHeader('ZMM OPERATING RANGE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_intake_air')
|
||||
->label('ZMM INTAKE AIR')
|
||||
->exampleHeader('ZMM INTAKE AIR')
|
||||
->label('ZMM USP')
|
||||
->exampleHeader('ZMM USP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_oxygen_transfer_rate')
|
||||
->label('ZMM OXYGEN TRANSFER RATE')
|
||||
@@ -583,9 +583,17 @@ class ClassCharacteristicImporter extends Importer
|
||||
->label('ZMM AXIAL FORCE')
|
||||
->exampleHeader('ZMM AXIAL FORCE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_mrp')
|
||||
->label('ZMM MRP')
|
||||
->exampleHeader('ZMM MRP')
|
||||
ImportColumn::make('is_stopped')
|
||||
->label('IS STOPPED')
|
||||
->exampleHeader('IS STOPPED')
|
||||
->example('0'),
|
||||
ImportColumn::make('stopped_datetime')
|
||||
->label('STOPPED DATETIME')
|
||||
->exampleHeader('STOPPED DATETIME')
|
||||
->example('01-01-2026 00:08:00'),
|
||||
ImportColumn::make('stopped_by')
|
||||
->label('STOPPED BY')
|
||||
->exampleHeader('STOPPED BY')
|
||||
->example(''),
|
||||
ImportColumn::make('mark_status')
|
||||
->label('MARKED STATUS')
|
||||
@@ -611,10 +619,6 @@ class ClassCharacteristicImporter extends Importer
|
||||
->label('MANUAL MARKED PHYSICAL COUNT')
|
||||
->exampleHeader('MANUAL MARKED STATUS')
|
||||
->example('0'),
|
||||
ImportColumn::make('man_marked_expected_time')
|
||||
->label('MANUAL MARKED EXPECTED TIME')
|
||||
->exampleHeader('MANUAL MARKED EXPECTED TIME')
|
||||
->example('0'),
|
||||
ImportColumn::make('man_marked_datetime')
|
||||
->label('MANUAL MARKED DATETIME')
|
||||
->exampleHeader('MANUAL MARKED DATETIME')
|
||||
@@ -727,18 +731,6 @@ class ClassCharacteristicImporter extends Importer
|
||||
->label('HAS WORK FLOW ID')
|
||||
->exampleHeader('HAS WORK FLOW ID')
|
||||
->example('0'),
|
||||
ImportColumn::make('motor_stop_flow_id')
|
||||
->label('MOTOR STOP FLOW ID')
|
||||
->exampleHeader('MOTOR STOP FLOW ID')
|
||||
->example('5'),
|
||||
ImportColumn::make('pump_stop_flow_id')
|
||||
->label('PUMP STOP FLOW ID')
|
||||
->exampleHeader('PUMP STOP FLOW ID')
|
||||
->example('5'),
|
||||
ImportColumn::make('name_plate_stop_flow_id')
|
||||
->label('NAME PLATE STOP FLOW ID')
|
||||
->exampleHeader('NAME PLATE STOP FLOW ID')
|
||||
->example('5'),
|
||||
ImportColumn::make('created_at')
|
||||
->label('CREATED AT')
|
||||
->exampleHeader('CREATED AT')
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\CoilPacking;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class CoilPackingImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = CoilPacking::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant_id')
|
||||
->requiredMapping()
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('item_id')
|
||||
->requiredMapping()
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('coil_packing_number'),
|
||||
ImportColumn::make('process_order'),
|
||||
ImportColumn::make('coil_packing_status'),
|
||||
ImportColumn::make('scanned_at')
|
||||
->requiredMapping()
|
||||
->rules(['required', 'datetime']),
|
||||
ImportColumn::make('created_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
ImportColumn::make('scanned_by'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?CoilPacking
|
||||
{
|
||||
// return CoilPacking::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new CoilPacking();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your coil packing 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;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
@@ -30,12 +29,6 @@ class ItemImporter extends Importer
|
||||
->example('123456')
|
||||
->label('Item Code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example('4 inch pump line')
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing: 'name'), // Lookup Plant by code column
|
||||
ImportColumn::make('description')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Description')
|
||||
@@ -72,7 +65,6 @@ class ItemImporter extends Importer
|
||||
Log::info('ResolveRecord triggered', $this->data);
|
||||
$iCode = trim($this->data['code']);
|
||||
$description = trim($this->data['description']);
|
||||
$lineName = trim($this->data['line']);
|
||||
|
||||
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
@@ -83,14 +75,6 @@ class ItemImporter extends Importer
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($lineName)){
|
||||
$lineId = Line::where('plant_id',$plant->id)->where('name', $lineName)->first();
|
||||
|
||||
if (! $lineId) {
|
||||
$warnMsg[] = 'Line name not found'; // '" . $plantCod . "'
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
}
|
||||
@@ -116,7 +100,6 @@ class ItemImporter extends Importer
|
||||
'description' => $description,
|
||||
'hourly_quantity' => $this->data['hourly_quantity'],
|
||||
'uom' => trim($this->data['uom']),
|
||||
'line_id' => $lineId->id ?? null,
|
||||
]
|
||||
);
|
||||
// return new Item;
|
||||
|
||||
@@ -38,9 +38,11 @@ class PlantImporter extends Importer
|
||||
->label('NAME')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('warehouse_number')
|
||||
->exampleHeader('WAREHOUSE NUMBER')
|
||||
->requiredMapping()
|
||||
->exampleHeader('WAREHOUSE_NUMBER')
|
||||
->example('001')
|
||||
->label('WAREHOUSE NUMBER'),
|
||||
->label('WAREHOUSE_NUMBER')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('address')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ADDRESS')
|
||||
@@ -79,12 +81,12 @@ class PlantImporter extends Importer
|
||||
} elseif (Str::length($name) < 5) {
|
||||
$warnMsg[] = 'Name should contain at least 5 characters!';
|
||||
}
|
||||
if ($wareHouseNo != null && $wareHouseNo != '' && $wareHouseNo) {
|
||||
if (! 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 ($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) {
|
||||
$warnMsg[] = "Address can't be empty!";
|
||||
@@ -127,12 +129,12 @@ class PlantImporter extends Importer
|
||||
|
||||
return Plant::updateOrCreate([
|
||||
'code' => $code,
|
||||
'name' => $name,
|
||||
],
|
||||
[
|
||||
'warehouse_number' => $wareHouseNo,
|
||||
'address' => $addr,
|
||||
'company_id' => $compId,
|
||||
'name' => $name,
|
||||
]
|
||||
);
|
||||
// return Plant::firstOrNew([
|
||||
|
||||
@@ -16,7 +16,6 @@ use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ProductionPlanImporter extends Importer
|
||||
{
|
||||
@@ -39,13 +38,13 @@ class ProductionPlanImporter extends Importer
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
// ImportColumn::make('line')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Line Name')
|
||||
// ->example(['4 inch pump line', '4 inch pump line'])
|
||||
// ->label('Line Name')
|
||||
// ->relationship(resolveUsing: 'name')
|
||||
// ->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example(['4 inch pump line', '4 inch pump line'])
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
@@ -114,6 +113,12 @@ class ProductionPlanImporter extends Importer
|
||||
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
|
||||
if (! $line) {
|
||||
$warnMsg[] = 'Line not found';
|
||||
}
|
||||
|
||||
if (Str::length($itemCod) < 6 || ! is_numeric($itemCod)) {
|
||||
@@ -133,26 +138,46 @@ class ProductionPlanImporter extends Importer
|
||||
if(!$itemAgaPlant){
|
||||
$warnMsg[] = 'Item not found against plant code';
|
||||
}
|
||||
else {
|
||||
$line = $itemAgaPlant->line_id;
|
||||
|
||||
if (!$line) {
|
||||
$warnMsg[] = 'Line not mapped for that item code';
|
||||
}
|
||||
}
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
if (!empty($this->data['plan_quantity'])) {
|
||||
if (Str::length($this->data['plan_quantity']) < 0 || ! is_numeric($this->data['plan_quantity']) || $this->data['plan_quantity'] <= 0) {
|
||||
$warnMsg[] = 'Invalid plan quantity found';
|
||||
}
|
||||
if (Str::length($this->data['plan_quantity']) < 0 || ! is_numeric($this->data['plan_quantity']) || $this->data['plan_quantity'] <= 0) {
|
||||
$warnMsg[] = 'Invalid plan quantity found';
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
} else {
|
||||
$productionPlan = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->where('item_id', $itemAgaPlant->id)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if ($productionPlan) {
|
||||
|
||||
$recordDate = now();
|
||||
$month = $recordDate->month;
|
||||
$year = $recordDate->year;
|
||||
|
||||
$previousRecord = ProductionPlan::where('plant_id', $plant->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->first();
|
||||
|
||||
$workingDays = $previousRecord?->working_days ?? null;
|
||||
|
||||
$productionPlan->update([
|
||||
'plan_quantity' => $this->data['plan_quantity'],
|
||||
'working_days' => $workingDays,
|
||||
'operator_id' => $operatorName,
|
||||
]);
|
||||
$productionPlan->save();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
$recordDate = now();
|
||||
@@ -166,44 +191,17 @@ class ProductionPlanImporter extends Importer
|
||||
|
||||
$workingDays = $previousRecord?->working_days ?? null;
|
||||
|
||||
$productionPlan1 = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('line_id', $line)
|
||||
->where('item_id', $itemAgaPlant->id)
|
||||
->whereYear('created_at', $recordDate->year)
|
||||
->whereMonth('created_at', $recordDate->month)
|
||||
->first();
|
||||
|
||||
if ($productionPlan1) {
|
||||
$productionPlan1->update([
|
||||
'plan_quantity' => $this->data['plan_quantity'],
|
||||
'working_days' => $workingDays,
|
||||
'operator_id' => $operatorName,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
} else {
|
||||
ProductionPlan::create([
|
||||
'plant_id' => $plant->id,
|
||||
'line_id' => $line,
|
||||
'item_id' => $itemAgaPlant->id,
|
||||
'plan_quantity' => $this->data['plan_quantity'],
|
||||
'working_days' => $workingDays,
|
||||
'operator_id' => $operatorName,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
// ProductionPlan::updateOrCreate([
|
||||
// 'plant_id' => $plant->id,
|
||||
// 'line_id' => $line,
|
||||
// 'item_id' => $itemAgaPlant->id,
|
||||
// // 'shift_id' => $shift->id,
|
||||
// 'plan_quantity' => $this->data['plan_quantity'],
|
||||
// 'working_days' => $workingDays,
|
||||
// 'created_at' =>now(),
|
||||
// 'updated_at' => now(),
|
||||
// 'operator_id' => $operatorName,
|
||||
// ]);
|
||||
ProductionPlan::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'line_id' => $line->id,
|
||||
'item_id' => $itemAgaPlant->id,
|
||||
// 'shift_id' => $shift->id,
|
||||
'plan_quantity' => $this->data['plan_quantity'],
|
||||
'working_days' => $workingDays,
|
||||
'created_at' =>now(),
|
||||
'updated_at' => now(),
|
||||
'operator_id' => $operatorName,
|
||||
]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,625 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\ProductionTemp;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class ProductionTempImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = ProductionTemp::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('aufnr')
|
||||
->label('AUFNR')
|
||||
->exampleHeader('AUFNR')
|
||||
->example('1234567'),
|
||||
ImportColumn::make('class')
|
||||
->label('CLASS')
|
||||
->exampleHeader('CLASS')
|
||||
->example('ZLASER'),
|
||||
ImportColumn::make('arbid')
|
||||
->label('ARBID')
|
||||
->exampleHeader('ARBID')
|
||||
->example('LASER'),
|
||||
ImportColumn::make('gamng')
|
||||
->label('GAMNG')
|
||||
->exampleHeader('GAMNG')
|
||||
->example('1.000'),
|
||||
ImportColumn::make('lmnga')
|
||||
->label('LMNGA')
|
||||
->exampleHeader('LMNGA')
|
||||
->example('1'),
|
||||
ImportColumn::make('gernr')
|
||||
->label('GERNR')
|
||||
->exampleHeader('GERNR')
|
||||
->example('12345678901234'),
|
||||
ImportColumn::make('zz1_cn_bill_ord')
|
||||
->label('ZZ1 CN BILL ORD')
|
||||
->exampleHeader('ZZ1 CN BILL ORD')
|
||||
->example('INDIA'),
|
||||
ImportColumn::make('zmm_amps')
|
||||
->label('ZMM AMPS')
|
||||
->exampleHeader('ZMM AMPS')
|
||||
->example('11A'),
|
||||
ImportColumn::make('zmm_brand')
|
||||
->label('ZMM BRAND')
|
||||
->exampleHeader('ZMM BRAND')
|
||||
->example('CRI'),
|
||||
ImportColumn::make('zmm_degreeofprotection')
|
||||
->label('ZMM DEGREEOFPROTECTION')
|
||||
->exampleHeader('ZMM DEGREEOFPROTECTION')
|
||||
->example('IP55'),
|
||||
ImportColumn::make('zmm_delivery')
|
||||
->label('ZMM DELIVERY')
|
||||
->exampleHeader('ZMM DELIVERY')
|
||||
->example('65MM'),
|
||||
ImportColumn::make('zmm_dir_rot')
|
||||
->label('ZMM DIR ROT')
|
||||
->exampleHeader('ZMM DIR ROT')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_discharge')
|
||||
->label('ZMM DISCHARGE')
|
||||
->exampleHeader('ZMM DISCHARGE')
|
||||
->example('17m³/h'),
|
||||
ImportColumn::make('zmm_discharge_max')
|
||||
->label('ZMM DISCHARGE MAX')
|
||||
->exampleHeader('ZMM DISCHARGE MAX')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_discharge_min')
|
||||
->label('ZMM DISCHARGE MIN')
|
||||
->exampleHeader('ZMM DISCHARGE MIN')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_duty')
|
||||
->label('ZMM DUTY')
|
||||
->exampleHeader('ZMM DUTY')
|
||||
->example('DUTY S1'),
|
||||
ImportColumn::make('zmm_eff_motor')
|
||||
->label('ZMM EFF MOTOR')
|
||||
->exampleHeader('ZMM EFF MOTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_eff_pump')
|
||||
->label('ZMM EFF PUMP')
|
||||
->exampleHeader('ZMM EFF PUMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_frequency')
|
||||
->label('ZMM FREQUENCY')
|
||||
->exampleHeader('ZMM FREQUENCY')
|
||||
->example('50Hz'),
|
||||
ImportColumn::make('zmm_head')
|
||||
->label('ZMM HEAD')
|
||||
->exampleHeader('ZMM HEAD')
|
||||
->example('77M'),
|
||||
ImportColumn::make('zmm_heading')
|
||||
->label('ZMM HEADING')
|
||||
->exampleHeader('ZMM HEADING')
|
||||
->example('PRESSURE BOOSTER SYSTEM'),
|
||||
ImportColumn::make('zmm_head_max')
|
||||
->label('ZMM HEAD MAX')
|
||||
->exampleHeader('ZMM HEAD MAX')
|
||||
->example('96m'),
|
||||
ImportColumn::make('zmm_head_minimum')
|
||||
->label('ZMM HEAD MINIMUM')
|
||||
->exampleHeader('ZMM HEAD MINIMUM')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_idx_eff_mtr')
|
||||
->label('ZMM IDX EFF MTR')
|
||||
->exampleHeader('ZMM IDX EFF MTR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_idx_eff_pump')
|
||||
->label('ZMM IDX EFF PUMP')
|
||||
->exampleHeader('ZMM IDX EFF PUMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_kvacode')
|
||||
->label('ZMM KVACODE')
|
||||
->exampleHeader('ZMM KVACODE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_maxambtemp')
|
||||
->label('ZMM MAXAMBTEMP')
|
||||
->exampleHeader('ZMM MAXAMBTEMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_mincoolingflow')
|
||||
->label('ZMM MINCOOLINGFLOW')
|
||||
->exampleHeader('ZMM MINCOOLINGFLOW')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motorseries')
|
||||
->label('ZMM MOTORSERIES')
|
||||
->exampleHeader('ZMM MOTORSERIES')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motor_model')
|
||||
->label('ZMM MOTOR MODEL')
|
||||
->exampleHeader('ZMM MOTOR MODEL')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_outlet')
|
||||
->label('ZMM OUTLET')
|
||||
->exampleHeader('ZMM OUTLET')
|
||||
->example('IE2'),
|
||||
ImportColumn::make('zmm_phase')
|
||||
->label('ZMM PHASE')
|
||||
->exampleHeader('ZMM PHASE')
|
||||
->example('3Ph'),
|
||||
ImportColumn::make('zmm_pressure')
|
||||
->label('ZMM PRESSURE')
|
||||
->exampleHeader('ZMM PRESSURE')
|
||||
->example('16bar'),
|
||||
ImportColumn::make('zmm_pumpflowtype')
|
||||
->label('ZMM PUMPFLOWTYPE')
|
||||
->exampleHeader('ZMM PUMPFLOWTYPE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pumpseries')
|
||||
->label('ZMM PUMPSERIES')
|
||||
->exampleHeader('ZMM PUMPSERIES')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pump_model')
|
||||
->label('ZMM PUMP MODEL')
|
||||
->exampleHeader('ZMM PUMP MODEL')
|
||||
->example('MVHS-15/07TR'),
|
||||
ImportColumn::make('zmm_ratedpower')
|
||||
->label('ZMM RATEDPOWER')
|
||||
->exampleHeader('ZMM RATEDPOWER')
|
||||
->example('5.5kW/7.5HP'),
|
||||
ImportColumn::make('zmm_region')
|
||||
->label('ZMM REGION')
|
||||
->exampleHeader('ZMM REGION')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_servicefactor')
|
||||
->label('ZMM SERVICEFACTOR')
|
||||
->exampleHeader('ZMM SERVICEFACTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_servicefactormaximumamps')
|
||||
->label('ZMM SERVICEFACTORMAXIMUMAMPS')
|
||||
->exampleHeader('ZMM SERVICEFACTORMAXIMUMAMPS')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_speed')
|
||||
->label('ZMM SPEED')
|
||||
->exampleHeader('ZMM SPEED')
|
||||
->example('2900rpm'),
|
||||
ImportColumn::make('zmm_suction')
|
||||
->label('ZMM SUCTION')
|
||||
->exampleHeader('ZMM SUCTION')
|
||||
->example('65mm'),
|
||||
ImportColumn::make('zmm_suctionxdelivery')
|
||||
->label('ZMM SUCTIONXDELIVERY')
|
||||
->exampleHeader('ZMM SUCTIONXDELIVERY')
|
||||
->example('50 x 50mm'),
|
||||
ImportColumn::make('zmm_supplysource')
|
||||
->label('ZMM SUPPLYSOURCE')
|
||||
->exampleHeader('ZMM SUPPLYSOURCE')
|
||||
->example('AC SUPPLY'),
|
||||
ImportColumn::make('zmm_temperature')
|
||||
->label('ZMM TEMPERATURE')
|
||||
->exampleHeader('ZMM TEMPERATURE')
|
||||
->example('90°C'),
|
||||
ImportColumn::make('zmm_thrustload')
|
||||
->label('ZMM THRUSTLOAD')
|
||||
->exampleHeader('ZMM THRUSTLOAD')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_volts')
|
||||
->label('ZMM VOLTS')
|
||||
->exampleHeader('ZMM VOLTS')
|
||||
->example('415V'),
|
||||
ImportColumn::make('zmm_wire')
|
||||
->label('ZMM WIRE')
|
||||
->exampleHeader('ZMM WIRE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_package')
|
||||
->label('ZMM PACKAGE')
|
||||
->exampleHeader('ZMM PACKAGE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pvarrayrating')
|
||||
->label('ZMM PVARRAYRATING')
|
||||
->exampleHeader('ZMM PVARRAYRATING')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isi')
|
||||
->label('ZMM ISI')
|
||||
->exampleHeader('ZMM ISI')
|
||||
->example('Y'),
|
||||
ImportColumn::make('zmm_isimotor')
|
||||
->label('ZMM ISIMOTOR')
|
||||
->exampleHeader('ZMM ISIMOTOR')
|
||||
->example('IS:12615'),
|
||||
ImportColumn::make('zmm_isipump')
|
||||
->label('ZMM ISIPUMP')
|
||||
->exampleHeader('ZMM ISIPUMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isipumpset')
|
||||
->label('ZMM ISIPUMPSET')
|
||||
->exampleHeader('ZMM ISIPUMPSET')
|
||||
->example('IS:12615'),
|
||||
ImportColumn::make('zmm_pumpset_model')
|
||||
->label('ZMM PUMPSET MODEL')
|
||||
->exampleHeader('ZMM PUMPSET MODEL')
|
||||
->example('MVHS-15/07TR'),
|
||||
ImportColumn::make('zmm_stages')
|
||||
->label('ZMM STAGES')
|
||||
->exampleHeader('ZMM STAGES')
|
||||
->example('7'),
|
||||
ImportColumn::make('zmm_headrange')
|
||||
->label('ZMM HEADRANGE')
|
||||
->exampleHeader('ZMM HEADRANGE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_overall_efficiency')
|
||||
->label('ZMM OVERALL EFFICIENCY')
|
||||
->exampleHeader('ZMM OVERALL EFFICIENCY')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_connection')
|
||||
->label('ZMM CONNECTION')
|
||||
->exampleHeader('ZMM CONNECTION')
|
||||
->example('STAR/DELTA'),
|
||||
ImportColumn::make('zmm_min_bore_size')
|
||||
->label('ZMM MIN BORE SIZE')
|
||||
->exampleHeader('ZMM MIN BORE SIZE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isireference')
|
||||
->label('ZMM ISIREFERENCE')
|
||||
->exampleHeader('ZMM ISIREFERENCE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_category')
|
||||
->label('ZMM CATEGORY')
|
||||
->exampleHeader('ZMM CATEGORY')
|
||||
->example('B'),
|
||||
ImportColumn::make('zmm_submergence')
|
||||
->label('ZMM SUBMERGENCE')
|
||||
->exampleHeader('ZMM SUBMERGENCE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_capacitorstart')
|
||||
->label('ZMM CAPACITORSTART')
|
||||
->exampleHeader('ZMM CAPACITORSTART')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_capacitorrun')
|
||||
->label('ZMM CAPACITORRUN')
|
||||
->exampleHeader('ZMM CAPACITORRUN')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_inch')
|
||||
->label('ZMM INCH')
|
||||
->exampleHeader('ZMM INCH')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motor_type')
|
||||
->label('ZMM MOTOR TYPE')
|
||||
->exampleHeader('ZMM MOTOR TYPE')
|
||||
->example('TEFC'),
|
||||
ImportColumn::make('zmm_dismantle_direction')
|
||||
->label('ZMM DISMANTLE DIRECTION')
|
||||
->exampleHeader('ZMM DISMANTLE DIRECTION')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_eff_ovrall')
|
||||
->label('ZMM EFF OVERALL')
|
||||
->exampleHeader('ZMM EFF OVERALL')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_bodymoc')
|
||||
->label('ZMM BODYMOC')
|
||||
->exampleHeader('ZMM BODYMOC')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_rotormoc')
|
||||
->label('ZMM ROTORMOC')
|
||||
->exampleHeader('ZMM ROTORMOC')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_dlwl')
|
||||
->label('ZMM DLWL')
|
||||
->exampleHeader('ZMM DLWL')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_inputpower')
|
||||
->label('ZMM INPUTPOWER')
|
||||
->exampleHeader('ZMM INPUTPOWER')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_imp_od')
|
||||
->label('ZMM IMP OD')
|
||||
->exampleHeader('ZMM IMP OD')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_ambtemp')
|
||||
->label('ZMM AMBTEMP')
|
||||
->exampleHeader('ZMM AMBTEMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_de')
|
||||
->label('ZMM DE')
|
||||
->exampleHeader('ZMM DE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_dischargerange')
|
||||
->label('ZMM DISCHARGERANGE')
|
||||
->exampleHeader('ZMM DISCHARGERANGE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_efficiency_class')
|
||||
->label('ZMM EFFICIENCY CLASS')
|
||||
->exampleHeader('ZMM EFFICIENCY CLASS')
|
||||
->example('IE2'),
|
||||
ImportColumn::make('zmm_framesize')
|
||||
->label('ZMM FRAMESIZE')
|
||||
->exampleHeader('ZMM FRAMESIZE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_impellerdiameter')
|
||||
->label('ZMM IMPELLERDIAMETER')
|
||||
->exampleHeader('ZMM IMPELLERDIAMETER')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_insulationclass')
|
||||
->label('ZMM INSULATIONCLASS')
|
||||
->exampleHeader('ZMM INSULATIONCLASS')
|
||||
->example('F'),
|
||||
ImportColumn::make('zmm_maxflow')
|
||||
->label('ZMM MAXFLOW')
|
||||
->exampleHeader('ZMM MAXFLOW')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_minhead')
|
||||
->label('ZMM MINHEAD')
|
||||
->exampleHeader('ZMM MINHEAD')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_mtrlofconst')
|
||||
->label('ZMM MTRLOFCONST')
|
||||
->exampleHeader('ZMM MTRLOFCONST')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_nde')
|
||||
->label('ZMM NDE')
|
||||
->exampleHeader('ZMM NDE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_powerfactor')
|
||||
->label('ZMM POWERFACTOR')
|
||||
->exampleHeader('ZMM POWERFACTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_tagno')
|
||||
->label('ZMM TAGNO')
|
||||
->exampleHeader('ZMM TAGNO')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_year')
|
||||
->label('ZMM YEAR')
|
||||
->exampleHeader('ZMM YEAR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_laser_name')
|
||||
->label('ZMM LASER NAME')
|
||||
->exampleHeader('ZMM LASER NAME')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_logo_cp')
|
||||
->label('ZMM LOGO CP')
|
||||
->exampleHeader('ZMM LOGO CP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_logo_ce')
|
||||
->label('ZMM LOGO CE')
|
||||
->exampleHeader('ZMM LOGO CE')
|
||||
->example('NO'),
|
||||
ImportColumn::make('zmm_logo_nsf')
|
||||
->label('ZMM LOGO NSF')
|
||||
->exampleHeader('ZMM LOGO NSF')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_logo_eac')
|
||||
->label('ZMM LOGO EAC')
|
||||
->exampleHeader('ZMM LOGO EAC')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_beenote')
|
||||
->label('ZMM BEENOTE')
|
||||
->exampleHeader('ZMM BEENOTE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_beenumber')
|
||||
->label('ZMM BEENUMBER')
|
||||
->exampleHeader('ZMM BEENUMBER')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_beestar')
|
||||
->label('ZMM BEESTAR')
|
||||
->exampleHeader('ZMM BEESTAR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_codeclass')
|
||||
->label('ZMM CODECLASS')
|
||||
->exampleHeader('ZMM CODECLASS')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_colour')
|
||||
->label('ZMM COLOUR')
|
||||
->exampleHeader('ZMM COLOUR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grade')
|
||||
->label('ZMM GRADE')
|
||||
->exampleHeader('ZMM GRADE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_pset')
|
||||
->label('ZMM GRWT PSET')
|
||||
->exampleHeader('ZMM GRWT PSET')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_cable')
|
||||
->label('ZMM GRWT CABLE')
|
||||
->exampleHeader('ZMM GRWT CABLE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_motor')
|
||||
->label('ZMM GRWT MOTOR')
|
||||
->exampleHeader('ZMM GRWT MOTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_pf')
|
||||
->label('ZMM GRWT PF')
|
||||
->exampleHeader('ZMM GRWT PF')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_pump')
|
||||
->label('ZMM GRWT PUMP')
|
||||
->exampleHeader('ZMM GRWT PUMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isivalve')
|
||||
->label('ZMM ISIVALVE')
|
||||
->exampleHeader('ZMM ISIVALVE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isi_wc')
|
||||
->label('ZMM ISI WC')
|
||||
->exampleHeader('ZMM ISI WC')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_labelperiod')
|
||||
->label('ZMM LABELPERIOD')
|
||||
->exampleHeader('ZMM LABELPERIOD')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_length')
|
||||
->label('ZMM LENGTH')
|
||||
->exampleHeader('ZMM LENGTH')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_license_cml_no')
|
||||
->label('ZMM LICENSE CML NO')
|
||||
->exampleHeader('ZMM LICENSE CML NO')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_mfgmonyr')
|
||||
->label('ZMM MFGMONYR')
|
||||
->exampleHeader('ZMM MFGMONYR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_modelyear')
|
||||
->label('ZMM MODELYEAR')
|
||||
->exampleHeader('ZMM MODELYEAR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motoridentification')
|
||||
->label('ZMM MOTORIDENTIFICATION')
|
||||
->exampleHeader('ZMM MOTORIDENTIFICATION')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_pset')
|
||||
->label('ZMM NEWT PSET')
|
||||
->exampleHeader('ZMM NEWT PSET')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_cable')
|
||||
->label('ZMM NEWT CABLE')
|
||||
->exampleHeader('ZMM NEWT CABLE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_motor')
|
||||
->label('ZMM NEWT MOTOR')
|
||||
->exampleHeader('ZMM NEWT MOTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_pf')
|
||||
->label('ZMM NEWT PF')
|
||||
->exampleHeader('ZMM NEWT PF')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_pump')
|
||||
->label('ZMM NEWT PUMP')
|
||||
->exampleHeader('ZMM NEWT PUMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_packtype')
|
||||
->label('ZMM PACKTYPE')
|
||||
->exampleHeader('ZMM PACKTYPE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_panel')
|
||||
->label('ZMM PANEL')
|
||||
->exampleHeader('ZMM PANEL')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_performance_factor')
|
||||
->label('ZMM PERFORMANCE FACTOR')
|
||||
->exampleHeader('ZMM PERFORMANCE FACTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pumpidentification')
|
||||
->label('ZMM PUMPIDENTIFICATION')
|
||||
->exampleHeader('ZMM PUMPIDENTIFICATION')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_psettype')
|
||||
->label('ZMM PSETTYPE')
|
||||
->exampleHeader('ZMM PSETTYPE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_size')
|
||||
->label('ZMM SIZE')
|
||||
->exampleHeader('ZMM SIZE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_eff_ttl')
|
||||
->label('ZMM EFF TTL')
|
||||
->exampleHeader('ZMM EFF TTL')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_type')
|
||||
->label('ZMM TYPE')
|
||||
->exampleHeader('ZMM TYPE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_usp')
|
||||
->label('ZMM USP')
|
||||
->exampleHeader('ZMM USP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_operating_range')
|
||||
->label('ZMM OPERATING RANGE')
|
||||
->exampleHeader('ZMM OPERATING RANGE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_intake_air')
|
||||
->label('ZMM USP')
|
||||
->exampleHeader('ZMM USP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_oxygen_transfer_rate')
|
||||
->label('ZMM OXYGEN TRANSFER RATE')
|
||||
->exampleHeader('ZMM OXYGEN TRANSFER RATE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_air_inlet_pipesize')
|
||||
->label('ZMM AIR INLET PIPESIZE')
|
||||
->exampleHeader('ZMM AIR INLET PIPESIZE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_sump_depth')
|
||||
->label('ZMM SUMP DEPTH')
|
||||
->exampleHeader('ZMM SUMP DEPTH')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_poles')
|
||||
->label('ZMM POLES')
|
||||
->exampleHeader('ZMM POLES')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motor_heading')
|
||||
->label('ZMM MOTOR HEADING')
|
||||
->exampleHeader('ZMM MOTOR HEADING')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motor_speed')
|
||||
->label('ZMM MOTOR SPEED')
|
||||
->exampleHeader('ZMM MOTOR SPEED')
|
||||
->example(''),
|
||||
ImportColumn::make('zqmm_qty')
|
||||
->label('ZQMM QTY')
|
||||
->exampleHeader('ZQMM QTY')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_operating_temperature')
|
||||
->label('ZMM OPERATING TEMPERATURE')
|
||||
->exampleHeader('ZMM OPERATING TEMPERATURE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_axial_force')
|
||||
->label('ZMM AXIAL FORCE')
|
||||
->exampleHeader('ZMM AXIAL FORCE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_mrp')
|
||||
->label('ZMM MRP')
|
||||
->exampleHeader('ZMM MRP')
|
||||
->example(''),
|
||||
ImportColumn::make('pending_released_status')
|
||||
->label('PENDING RELEASED STATUS')
|
||||
->exampleHeader('PENDING RELEASED STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('created_by')
|
||||
->label('CREATED BY')
|
||||
->exampleHeader('CREATED BY')
|
||||
->example(''),
|
||||
ImportColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->exampleHeader('UPDATED BY')
|
||||
->example(''),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ProductionTemp
|
||||
{
|
||||
// return ProductionTemp::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new ProductionTemp;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your production temp 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;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ class RequestCharacteristicImporter extends Importer
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example('TEST001')
|
||||
->example('630214')
|
||||
->label('ITEM CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
|
||||
@@ -177,8 +177,6 @@ class StickerDetailImporter extends Importer
|
||||
|
||||
$sticker = $this->data['sticker_structure_detail_id'] ?? null;
|
||||
|
||||
$stickerId = null;
|
||||
|
||||
$stickerCode = StickerStructureDetail::where('sticker_id', $sticker)->first();
|
||||
if (!$stickerCode) {
|
||||
$warnMsg[] = "Sticker Id not found in Sticker Structure Detail";
|
||||
|
||||
@@ -2,17 +2,10 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerMappingMaster;
|
||||
use App\Models\StickerStructureDetail;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Support\Str;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
|
||||
class StickerMappingMasterImporter extends Importer
|
||||
{
|
||||
@@ -21,110 +14,32 @@ class StickerMappingMasterImporter extends Importer
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
ImportColumn::make('plant_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->examples(['1000', '1000'])
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ITEM CODE')
|
||||
->examples(['123456', '246118'])
|
||||
->label('ITEM CODE')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('sticker_structure1_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('STICKER ID')
|
||||
->examples(['Test Certificate'])
|
||||
->label('STICKER ID')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('sticker1_machine_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('WORK CENTER')
|
||||
->examples(['RMI00213'])
|
||||
->label('WORK CENTER')
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('sticker1'),
|
||||
ImportColumn::make('sticker2'),
|
||||
ImportColumn::make('sticker3'),
|
||||
ImportColumn::make('sticker4'),
|
||||
ImportColumn::make('sticker5'),
|
||||
ImportColumn::make('created_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?StickerMappingMaster
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantId = null;
|
||||
$stickId = null;
|
||||
// return StickerMappingMaster::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
$plantCod = $this->data['plant'];
|
||||
$iCode = $this->data['item'];
|
||||
$stickId = trim($this->data['sticker_structure1_id']) ?? null;
|
||||
$workCenter = trim($this->data['sticker1_machine_id']) ?? null;
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif ($iCode == null || $iCode == '') {
|
||||
$warnMsg[] = "Item Code can't be empty!";
|
||||
} elseif ($stickId == null || $stickId == '') {
|
||||
$warnMsg[] = "Sticker ID can't be empty!";
|
||||
} elseif ($workCenter == null || $workCenter == '') {
|
||||
$warnMsg[] = "Work Center can't be empty!";
|
||||
}
|
||||
|
||||
if (Str::length($plantCod) > 0 && (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod))) {
|
||||
$warnMsg[] = 'Invalid plant code found!';
|
||||
} elseif (Str::length($plantCod) > 0) {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant code not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($iCode) > 0 && (Str::length($iCode) < 6 || ! ctype_alnum($iCode))) {
|
||||
$warnMsg[] = 'Invalid item code found!';
|
||||
} elseif ($plantId) {
|
||||
$itemCode = Item::where('code', $iCode)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in item master!';
|
||||
} else {
|
||||
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in item master for the given plant!';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$stickerId = StickerStructureDetail::where('sticker_id', $stickId)->first();
|
||||
|
||||
if(!$stickerId){
|
||||
$warnMsg[] = "Sticker ID '$stickId' not found in sticker structure detail!";
|
||||
}
|
||||
|
||||
$machineId = Machine::where('plant_id', $plantId)->where('work_center', $workCenter)->first();
|
||||
|
||||
if(!$machineId){
|
||||
$warnMsg[] = "Work center '$workCenter' not found in machines table against plant '$plant->code'!";
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
StickerMappingMaster::updateOrCreate([
|
||||
'plant_id' => $plantId,
|
||||
'item_id' => $itemCode->id,
|
||||
'sticker_structure1_id' => $stickerId->id,
|
||||
'sticker1_machine_id' => $machineId->id ?? null,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
|
||||
return null;
|
||||
return new StickerMappingMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\StickerOrder;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class StickerOrderImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = StickerOrder::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant_id')
|
||||
->requiredMapping()
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('item_id')
|
||||
->requiredMapping()
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('sticker_id'),
|
||||
ImportColumn::make('production_order'),
|
||||
ImportColumn::make('from_serial_number'),
|
||||
ImportColumn::make('to_serial_number'),
|
||||
ImportColumn::make('print_status'),
|
||||
ImportColumn::make('reprint_count'),
|
||||
ImportColumn::make('created_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?StickerOrder
|
||||
{
|
||||
// return StickerOrder::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new StickerOrder();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your sticker order 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;
|
||||
}
|
||||
}
|
||||
@@ -583,10 +583,6 @@ class TempClassCharacteristicImporter extends Importer
|
||||
->label('ZMM AXIAL FORCE')
|
||||
->exampleHeader('ZMM AXIAL FORCE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_mrp')
|
||||
->label('ZMM MRP')
|
||||
->exampleHeader('ZMM MRP')
|
||||
->example(''),
|
||||
ImportColumn::make('winded_serial_number')
|
||||
->label('WINDed SERIAL NUMBER')
|
||||
->exampleHeader('WINDED SERIAL NUMBER')
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\TempStopCharacteristic;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class TempStopCharacteristicImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = TempStopCharacteristic::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->label('PLANT CODE')
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('1000')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
->requiredMapping()
|
||||
->label('WORK CENTER')
|
||||
->exampleHeader('WORK CENTER')
|
||||
->example('RMGLAS01')
|
||||
->relationship(resolveUsing: 'work_center')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine_name')
|
||||
->label('MACHINE NAME')
|
||||
->exampleHeader('MACHINE NAME')
|
||||
->example('RMGLAS01')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example('630214')
|
||||
->label('ITEM CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('aufnr')
|
||||
->label('JOB NUMBER')
|
||||
->exampleHeader('JOB NUMBER')
|
||||
->example('1234567'),
|
||||
ImportColumn::make('gernr')
|
||||
->label('SERIAL NUMBER')
|
||||
->exampleHeader('SERIAL NUMBER')
|
||||
->example('1234567890123'),
|
||||
ImportColumn::make('zmm_heading')
|
||||
->exampleHeader('ZMM HEADING')
|
||||
->example('ZMM001')
|
||||
->label('ZMM HEADING'),
|
||||
ImportColumn::make('model_type')
|
||||
->label('MODEL TYPE')
|
||||
->exampleHeader('MODEL TYPE')
|
||||
->example('PUMP'),
|
||||
ImportColumn::make('characteristic_field')
|
||||
->label('MASTER CHARACTERISTIC FIELD')
|
||||
->exampleHeader('MASTER CHARACTERISTIC FIELD')
|
||||
->example('NIL'),
|
||||
ImportColumn::make('samlight_logged_name')
|
||||
->label('SAMLIGHT LOGGED NAME')
|
||||
->exampleHeader('SAMLIGHT LOGGED NAME')
|
||||
->example('User'),
|
||||
ImportColumn::make('stopped_at')
|
||||
->label('STOPPED AT')
|
||||
->exampleHeader('STOPPED AT')
|
||||
->example('01-09-2026 12:00:00')
|
||||
->rules(['datetime']),
|
||||
ImportColumn::make('stopped_by')
|
||||
->label('STOPPED BY')
|
||||
->exampleHeader('STOPPED BY')
|
||||
->example('RAW01234'),
|
||||
ImportColumn::make('has_stop_flow_id')
|
||||
->label('HAS STOP FLOW ID')
|
||||
->exampleHeader('HAS STOP FLOW ID')
|
||||
->example('2'),
|
||||
ImportColumn::make('created_by')
|
||||
->label('CREATED BY')
|
||||
->exampleHeader('CREATED BY')
|
||||
->example('RAW01234'),
|
||||
ImportColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->exampleHeader('UPDATED BY')
|
||||
->example('RAW01234'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?TempStopCharacteristic
|
||||
{
|
||||
// return TempStopCharacteristic::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new TempStopCharacteristic;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your temp stop 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;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\TestApprovalMapping;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class TestApprovalMappingImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = TestApprovalMapping::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('workGroupMaster')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('tested_by'),
|
||||
ImportColumn::make('verified_by'),
|
||||
ImportColumn::make('approved_by'),
|
||||
ImportColumn::make('created_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?TestApprovalMapping
|
||||
{
|
||||
// return TestApprovalMapping::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new TestApprovalMapping();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your test approval mapping 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;
|
||||
}
|
||||
}
|
||||
@@ -14,294 +14,88 @@ class TestingPanelReadingImporter extends Importer
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
ImportColumn::make('machine')
|
||||
->requiredMapping()
|
||||
->label('PLANT CODE')
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example(['1000'])
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->label('LINE NAME')
|
||||
->exampleHeader('LINE NAME')
|
||||
->example(['4 inch pump line'])
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine.workGroupMaster.name')
|
||||
->requiredMapping()
|
||||
->label('GROUP WORK CENTER')
|
||||
->exampleHeader('GROUP WORK CENTER')
|
||||
->example('TESTGMG01')
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine.work_center')
|
||||
->requiredMapping()
|
||||
->label('WORK CENTER')
|
||||
->exampleHeader('WORK CENTER')
|
||||
->example('TESTIMG01')
|
||||
->relationship() // resolveUsing: 'work_center'
|
||||
->rules(['required']),
|
||||
ImportColumn::make('motorTestingMaster.item.code')
|
||||
->requiredMapping()
|
||||
->label('ITEM CODE')
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example('ITEM001')
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('output')
|
||||
->requiredMapping()
|
||||
->label('OUTPUT ID')
|
||||
->exampleHeader('OUTPUT ID')
|
||||
->example('Output1')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->label('MOTOR SERIAL NUMBER')
|
||||
->exampleHeader('MOTOR SERIAL NUMBER')
|
||||
->example('12345678901234')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('winded_serial_number')
|
||||
->requiredMapping()
|
||||
->label('WINDED SERIAL NUMBER')
|
||||
->exampleHeader('WINDED SERIAL NUMBER')
|
||||
->example('98765432101234')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('before_fr_volt')
|
||||
->requiredMapping()
|
||||
->label('BEFORE FR VOLTAGE')
|
||||
->exampleHeader('BEFORE FR VOLTAGE')
|
||||
->example('0'),
|
||||
ImportColumn::make('before_fr_cur')
|
||||
->requiredMapping()
|
||||
->label('BEFORE FR CURRENT')
|
||||
->exampleHeader('BEFORE FR CURRENT')
|
||||
->example('0'),
|
||||
ImportColumn::make('before_fr_pow')
|
||||
->requiredMapping()
|
||||
->label('BEFORE FR POWER')
|
||||
->exampleHeader('BEFORE FR POWER')
|
||||
->example('0'),
|
||||
ImportColumn::make('before_fr_res_ry')
|
||||
->requiredMapping()
|
||||
->label('BEFORE FR RESISTANCE RY')
|
||||
->exampleHeader('BEFORE FR RESISTANCE RY')
|
||||
->example('0'),
|
||||
ImportColumn::make('before_fr_res_yb')
|
||||
->requiredMapping()
|
||||
->label('BEFORE FR RESISTANCE YB')
|
||||
->exampleHeader('BEFORE FR RESISTANCE YB')
|
||||
->example('0'),
|
||||
ImportColumn::make('before_fr_res_br')
|
||||
->requiredMapping()
|
||||
->label('BEFORE FR RESISTANCE BR')
|
||||
->exampleHeader('BEFORE FR RESISTANCE BR')
|
||||
->example('0'),
|
||||
ImportColumn::make('before_fr_ir')
|
||||
->requiredMapping()
|
||||
->label('BEFORE FR IR')
|
||||
->exampleHeader('BEFORE FR IR')
|
||||
->example('0'),
|
||||
ImportColumn::make('before_fr_ir_r')
|
||||
->requiredMapping()
|
||||
->label('BEFORE FR IR R')
|
||||
->exampleHeader('BEFORE FR IR R')
|
||||
->example('0'),
|
||||
ImportColumn::make('before_fr_ir_y')
|
||||
->requiredMapping()
|
||||
->label('BEFORE FR IR Y')
|
||||
->exampleHeader('BEFORE FR IR Y')
|
||||
->example('0'),
|
||||
ImportColumn::make('before_fr_ir_b')
|
||||
->requiredMapping()
|
||||
->label('BEFORE FR IR B')
|
||||
->exampleHeader('BEFORE FR IR B')
|
||||
->example('0'),
|
||||
ImportColumn::make('before_fr_freq')
|
||||
->requiredMapping()
|
||||
->label('BEFORE FR FREQUENCY')
|
||||
->exampleHeader('BEFORE FR FREQUENCY')
|
||||
->example('0'),
|
||||
ImportColumn::make('before_fr_speed')
|
||||
->requiredMapping()
|
||||
->label('BEFORE FR SPEED')
|
||||
->exampleHeader('BEFORE FR SPEED')
|
||||
->example('0'),
|
||||
ImportColumn::make('after_fr_vol')
|
||||
->requiredMapping()
|
||||
->label('AFTER FR VOLTAGE')
|
||||
->exampleHeader('AFTER FR VOLTAGE')
|
||||
->example('0'),
|
||||
ImportColumn::make('after_fr_cur')
|
||||
->requiredMapping()
|
||||
->label('AFTER FR CURRENT')
|
||||
->exampleHeader('AFTER FR CURRENT')
|
||||
->example('0'),
|
||||
ImportColumn::make('after_fr_pow')
|
||||
->requiredMapping()
|
||||
->label('AFTER FR POWER')
|
||||
->exampleHeader('AFTER FR POWER')
|
||||
->example('0'),
|
||||
ImportColumn::make('after_fr_ir_hot')
|
||||
->requiredMapping()
|
||||
->label('AFTER FR IR HOT')
|
||||
->exampleHeader('AFTER FR IR HOT')
|
||||
->example('0'),
|
||||
ImportColumn::make('after_fr_ir_hot_r')
|
||||
->requiredMapping()
|
||||
->label('AFTER FR IR HOT R')
|
||||
->exampleHeader('AFTER FR IR HOT R')
|
||||
->example('0'),
|
||||
ImportColumn::make('after_fr_ir_hot_y')
|
||||
->requiredMapping()
|
||||
->label('AFTER FR IR HOT Y')
|
||||
->exampleHeader('AFTER FR IR HOT Y')
|
||||
->example('0'),
|
||||
ImportColumn::make('after_fr_ir_hot_b')
|
||||
->requiredMapping()
|
||||
->label('AFTER FR IR HOT B')
|
||||
->exampleHeader('AFTER FR IR HOT B')
|
||||
->example('0'),
|
||||
ImportColumn::make('after_fr_ir_cool')
|
||||
->requiredMapping()
|
||||
->label('AFTER FR IR COOL')
|
||||
->exampleHeader('AFTER FR IR COOL')
|
||||
->example('0'),
|
||||
ImportColumn::make('after_fr_ir_cool_r')
|
||||
->requiredMapping()
|
||||
->label('AFTER FR IR COOL R')
|
||||
->exampleHeader('AFTER FR IR COOL R')
|
||||
->example('0'),
|
||||
ImportColumn::make('after_fr_ir_cool_y')
|
||||
->requiredMapping()
|
||||
->label('AFTER FR IR COOL Y')
|
||||
->exampleHeader('AFTER FR IR COOL Y')
|
||||
->example('0'),
|
||||
ImportColumn::make('after_fr_ir_cool_b')
|
||||
->requiredMapping()
|
||||
->label('AFTER FR IR COOL B')
|
||||
->exampleHeader('AFTER FR IR COOL B')
|
||||
->example('0'),
|
||||
ImportColumn::make('after_fr_freq')
|
||||
->requiredMapping()
|
||||
->label('AFTER FR FREQUENCY')
|
||||
->exampleHeader('AFTER FR FREQUENCY')
|
||||
->example('0'),
|
||||
ImportColumn::make('after_fr_speed')
|
||||
->requiredMapping()
|
||||
->label('AFTER FR SPEED')
|
||||
->exampleHeader('AFTER FR SPEED')
|
||||
->example('0'),
|
||||
ImportColumn::make('after_fr_leak_cur')
|
||||
->requiredMapping()
|
||||
->label('AFTER FR LEAK CURRENT')
|
||||
->exampleHeader('AFTER FR LEAK CURRENT')
|
||||
->example('0'),
|
||||
ImportColumn::make('locked_rt_volt')
|
||||
->requiredMapping()
|
||||
->label('LOCKED RT VOLTAGE')
|
||||
->exampleHeader('LOCKED RT VOLTAGE')
|
||||
->example('0'),
|
||||
ImportColumn::make('locked_rt_cur')
|
||||
->requiredMapping()
|
||||
->label('LOCKED RT CURRENT')
|
||||
->exampleHeader('LOCKED RT CURRENT')
|
||||
->example('0'),
|
||||
ImportColumn::make('locked_rt_pow')
|
||||
->requiredMapping()
|
||||
->label('LOCKED RT POWER')
|
||||
->exampleHeader('LOCKED RT POWER')
|
||||
->example('0'),
|
||||
ImportColumn::make('no_load_pickup_volt')
|
||||
->requiredMapping()
|
||||
->label('NO LOAD PICKUP VOLTAGE')
|
||||
->exampleHeader('NO LOAD PICKUP VOLTAGE')
|
||||
->example('0'),
|
||||
ImportColumn::make('room_temperature')
|
||||
->requiredMapping()
|
||||
->label('ROOM TEMPERATURE')
|
||||
->exampleHeader('ROOM TEMPERATURE')
|
||||
->example('0'),
|
||||
ImportColumn::make('hv_test')
|
||||
->requiredMapping()
|
||||
->label('HIGH VOLTAGE TEST')
|
||||
->exampleHeader('HIGH VOLTAGE TEST')
|
||||
->example('Not With Stood')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('batch_number')
|
||||
->requiredMapping()
|
||||
->label('BATCH NUMBER')
|
||||
->exampleHeader('BATCH NUMBER')
|
||||
->example('261231B001')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('before_fr_volt'),
|
||||
ImportColumn::make('before_fr_cur'),
|
||||
ImportColumn::make('before_fr_pow'),
|
||||
ImportColumn::make('before_fr_res_ry'),
|
||||
ImportColumn::make('before_fr_res_yb'),
|
||||
ImportColumn::make('before_fr_res_br'),
|
||||
ImportColumn::make('before_fr_ir'),
|
||||
ImportColumn::make('before_fr_ir_r'),
|
||||
ImportColumn::make('before_fr_ir_y'),
|
||||
ImportColumn::make('before_fr_ir_b'),
|
||||
ImportColumn::make('before_fr_freq'),
|
||||
ImportColumn::make('before_fr_speed'),
|
||||
ImportColumn::make('after_fr_vol'),
|
||||
ImportColumn::make('after_fr_cur'),
|
||||
ImportColumn::make('after_fr_pow'),
|
||||
ImportColumn::make('after_fr_ir_hot'),
|
||||
ImportColumn::make('after_fr_ir_hot_r'),
|
||||
ImportColumn::make('after_fr_ir_hot_y'),
|
||||
ImportColumn::make('after_fr_ir_hot_b'),
|
||||
ImportColumn::make('after_fr_ir_cool'),
|
||||
ImportColumn::make('after_fr_ir_cool_r'),
|
||||
ImportColumn::make('after_fr_ir_cool_y'),
|
||||
ImportColumn::make('after_fr_ir_cool_b'),
|
||||
ImportColumn::make('after_fr_freq'),
|
||||
ImportColumn::make('after_fr_speed'),
|
||||
ImportColumn::make('after_fr_leak_cur'),
|
||||
ImportColumn::make('locked_rt_volt'),
|
||||
ImportColumn::make('locked_rt_cur'),
|
||||
ImportColumn::make('locked_rt_pow'),
|
||||
ImportColumn::make('no_load_pickup_volt'),
|
||||
ImportColumn::make('room_temperature'),
|
||||
ImportColumn::make('hv_test'),
|
||||
ImportColumn::make('batch_number'),
|
||||
ImportColumn::make('batch_count')
|
||||
->requiredMapping()
|
||||
->label('BATCH COUNT')
|
||||
->exampleHeader('BATCH COUNT')
|
||||
->example('1')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('result')
|
||||
->requiredMapping()
|
||||
->label('RESULT')
|
||||
->exampleHeader('RESULT')
|
||||
->example('FAIL')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('remark')
|
||||
->requiredMapping()
|
||||
->label('REMARK')
|
||||
->exampleHeader('REMARK')
|
||||
->example('Testing Remark'),
|
||||
ImportColumn::make('test_sequence_flag')
|
||||
->requiredMapping()
|
||||
->label('TEST SEQUENCE FLAG')
|
||||
->exampleHeader('TEST SEQUENCE FLAG')
|
||||
->example('0')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('test_started_at')
|
||||
->requiredMapping()
|
||||
->label('TEST STARTED AT')
|
||||
->exampleHeader('TEST STARTED AT')
|
||||
->example('01-01-2026 00:08:00'),
|
||||
ImportColumn::make('result'),
|
||||
ImportColumn::make('remark'),
|
||||
ImportColumn::make('rework_count')
|
||||
->requiredMapping()
|
||||
->label('REWORK COUNT')
|
||||
->exampleHeader('REWORK COUNT')
|
||||
->example('0')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('rework_winded')
|
||||
->requiredMapping()
|
||||
->label('REWORK WINDED STATUS')
|
||||
->exampleHeader('REWORK WINDED STATUS')
|
||||
->example('0')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('update_count')
|
||||
->requiredMapping()
|
||||
->label('UPDATED COUNT')
|
||||
->exampleHeader('UPDATED COUNT')
|
||||
->example('0')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('output_flag')
|
||||
->requiredMapping()
|
||||
->label('OUTPUT FLAG')
|
||||
->exampleHeader('OUTPUT FLAG')
|
||||
->example('0')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('tested_by')
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->label('TESTED BY')
|
||||
->exampleHeader('TESTED BY')
|
||||
->example('RAW01234')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Line Name')
|
||||
->example(['4 inch pump line'])
|
||||
->label('Line Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_by')
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->label('UPDATED BY')
|
||||
->exampleHeader('UPDATED BY')
|
||||
->example('RAW01234'),
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Code')
|
||||
->example(['1000'])
|
||||
->label('Plant Code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('tested_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
ImportColumn::make('scanned_at')
|
||||
->requiredMapping()
|
||||
->label('SCANNED AT')
|
||||
->exampleHeader('SCANNED AT')
|
||||
->example('01-01-2026 00:08:00')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,544 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Line;
|
||||
use App\Models\PanelBoxValidation;
|
||||
use App\Models\Plant;
|
||||
use App\Models\Item;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class PanelBoxInspectionStock extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.panel-box-inspection-stock';
|
||||
|
||||
protected static ?string $navigationGroup = 'Panel Box';
|
||||
|
||||
use InteractsWithActions;
|
||||
use InteractsWithForms;
|
||||
|
||||
public $plantId;
|
||||
|
||||
public $lineId;
|
||||
|
||||
public array $filters = [];
|
||||
|
||||
public $state = [];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id' => $this->plantId,
|
||||
'line_id' => $this->lineId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, $state) {
|
||||
$set('item_id', null);
|
||||
$set('line_id', null);
|
||||
|
||||
$set('plant', $state);
|
||||
|
||||
$pId = $get('plant_id');
|
||||
if (! $pId) {
|
||||
$set('pqPlantError', 'Please select a plant first.');
|
||||
} else {
|
||||
$set('pqPlantError', null);
|
||||
}
|
||||
|
||||
$pId = $get('line_id');
|
||||
if (! $pId) {
|
||||
$set('pqLineError', null);
|
||||
}
|
||||
})
|
||||
->required()
|
||||
->default(fn ($get) => $get('plant') ?? session('last_selected_plant_id'))
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('pqPlantError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Select::make('line_id')
|
||||
->label('Line Name')
|
||||
->relationship('line', titleAttribute: 'name')
|
||||
->reactive()
|
||||
->required()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $plantId)
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, $state) {
|
||||
$set('item_id', null);
|
||||
|
||||
$set('line', $state);
|
||||
|
||||
$pId = $get('line_id');
|
||||
if (! $pId) {
|
||||
$set('pqLineError', 'Please select a line.');
|
||||
} else {
|
||||
$set('pqLineError', null);
|
||||
}
|
||||
})
|
||||
->default(fn ($get) => $get('line') ?? session('last_selected_line'))
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('pqLineError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('pqLineError') ? $get('pqLineError') : null)
|
||||
->hintColor('danger'),
|
||||
TextInput::make('item_id')
|
||||
->label('Scan QR Code')
|
||||
->reactive()
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter' => 'processScan($event.target.value)',
|
||||
]),
|
||||
])
|
||||
->columns(3),
|
||||
]);
|
||||
}
|
||||
|
||||
public function processScan($value)
|
||||
{
|
||||
$plantId = $this->filters['plant_id'];
|
||||
|
||||
$plantId = trim($plantId) ?? null;
|
||||
|
||||
$lineId = $this->filters['line_id'];
|
||||
|
||||
$lineId = trim($lineId) ?? null;
|
||||
|
||||
$itemId = $this->filters['item_id'];
|
||||
|
||||
$itemId = trim($itemId) ?? null;
|
||||
|
||||
if (! $plantId) {
|
||||
Notification::make()
|
||||
->title('Unknown Plant')
|
||||
->body('Please select a plant.')
|
||||
->warning()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (! $lineId) {
|
||||
Notification::make()
|
||||
->title('Unknown Line')
|
||||
->body('Please select a line.')
|
||||
->warning()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$plaCode = Plant::find($plantId)?->code;
|
||||
|
||||
// Check if QR format contains '|'
|
||||
|
||||
// if ($itemId && str_contains($itemId, '|'))
|
||||
// {
|
||||
// if (strpos($itemId, '|') == false) {
|
||||
|
||||
// Notification::make()
|
||||
// ->title('Unknown Qr Code')
|
||||
// ->body('Scan valid QR code. (Ex: Item_Code|Serial_Number)')
|
||||
// ->warning()
|
||||
// ->send();
|
||||
|
||||
// return;
|
||||
// }
|
||||
// if (! preg_match('/^[a-zA-Z0-9]{6,}+\|[1-9][a-zA-Z0-9]{8,}+(\|)?$/', $itemId)) {
|
||||
// $splits = explode('|', $itemId);
|
||||
// $iCode = trim($splits[0]);
|
||||
// $sNumber = isset($splits[1]) ? trim($splits[1]) : null;
|
||||
|
||||
// if (! ctype_alnum($iCode)) {
|
||||
// Notification::make()
|
||||
// ->title('Invalid Item Code')
|
||||
// ->body('Item code must contain alpha-numeric values.')
|
||||
// ->warning()
|
||||
// ->send();
|
||||
// return;
|
||||
// } elseif (strlen($iCode) < 6) {
|
||||
// Notification::make()
|
||||
// ->title('Invalid Item Code')
|
||||
// ->body('Item code must be at least 6 digits.')
|
||||
// ->warning()
|
||||
// ->send();
|
||||
// return;
|
||||
// } elseif (! ctype_alnum($sNumber)) {
|
||||
// Notification::make()
|
||||
// ->title('Invalid Serial Number')
|
||||
// ->body('Serial number must contain alpha-numeric values.')
|
||||
// ->warning()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// $iId = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||
|
||||
// if(!$iId){
|
||||
// Notification::make()
|
||||
// ->title('Item not found')
|
||||
// ->body("Item code'{$iCode}' not found against plant code '{$plaCode}' in item master.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// $sticker = StickerMaster::where('plant_id', $plantId)->where('item_id', $iId->id)->first();
|
||||
|
||||
// if(!$sticker){
|
||||
// Notification::make()
|
||||
// ->title('Unknown Item Code')
|
||||
// ->body("Item code not found '{$iId->code}' in sticker master.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (str_contains($itemId, '|')) {
|
||||
|
||||
// $parts = array_map('trim', explode('|', $itemId));
|
||||
|
||||
// if (count($parts) != 2) {
|
||||
// Notification::make()
|
||||
// ->title('Invalid QR Format')
|
||||
// ->body('Expected format: ItemCode|SerialNumber')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
// $itemCode = $parts[0];
|
||||
// $serialNumber = $parts[1];
|
||||
|
||||
// if($serialNumber == '' || $serialNumber == null){
|
||||
// Notification::make()
|
||||
// ->title('Unknown Serial number')
|
||||
// ->body("Serial number can't be empty!")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
// elseif (! ctype_alnum($serialNumber)) {
|
||||
// Notification::make()
|
||||
// ->title('Unknown Serial number')
|
||||
// ->body("Serial Number should contain alpha-numeric values.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// $iId = Item::where('code', $itemCode)->where('plant_id', $plantId)->first();
|
||||
|
||||
// if(!$iId){
|
||||
// Notification::make()
|
||||
// ->title('Item not found')
|
||||
// ->body("Item code'{$itemCode}' not found against plant code '{$plaCode}' in item master.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (str_contains($itemId, '/'))
|
||||
{
|
||||
$parts = explode('/', $itemId);
|
||||
|
||||
if (count($parts) < 3) {
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid QR Format')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber (Or) plantcode/panelboxcode/serialnumber')
|
||||
->danger()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$supplier = $parts[0];
|
||||
$panelBoxCode = $parts[1];
|
||||
$panelBoxSerialNo = implode('/', array_slice($parts, 2));
|
||||
|
||||
$itemCode = $panelBoxCode;
|
||||
$serialNumber = $panelBoxSerialNo;
|
||||
|
||||
if (strlen($serialNumber) > 30) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Number')
|
||||
->body("Serial number cannot be greater than 30 characters. Current length: " . strlen($panelBoxSerialNo))
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$iId = Item::where('code', $itemCode)->where('plant_id', $plantId)->first();
|
||||
|
||||
if(!$iId){
|
||||
Notification::make()
|
||||
->title('Item not found')
|
||||
->body("Item code'{$itemCode}' not found against plant code '{$plaCode}' in item master.")
|
||||
->danger()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$sticker = StickerMaster::where('plant_id', $plantId)->where('item_id', $iId->id)->first();
|
||||
|
||||
if(!$sticker){
|
||||
Notification::make()
|
||||
->title('Unknown Item Code')
|
||||
->body("Item code not found '{$iId->code}' in sticker master.")
|
||||
->danger()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Notification::make()
|
||||
->title('Invalid QR Format')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber (Or) plantcode/panelboxcode/serialnumber')
|
||||
->danger()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen($itemCode) < 6) {
|
||||
Notification::make()
|
||||
->title('Unknown Item Code')
|
||||
->body('Item code must be at least 6 digits.')
|
||||
->danger()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
return;
|
||||
} elseif (! ctype_alnum($itemCode)) {
|
||||
Notification::make()
|
||||
->title('Unknown Item Code')
|
||||
->body('Item Code should contain alpha-numeric values.')
|
||||
->danger()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $plantId) {
|
||||
Notification::make()
|
||||
->title('Unknown Plant')
|
||||
->body('Please select a plant first.')
|
||||
->danger()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
// Check if the item exists for the selected plant
|
||||
$stickerMaster = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($itemCode) {
|
||||
$query->where('code', $itemCode);
|
||||
})->first();
|
||||
|
||||
if (! $stickerMaster) {
|
||||
Notification::make()
|
||||
->title('Unknown Item Code')
|
||||
->body('Item code does not exist in master data.')
|
||||
->danger()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
return;
|
||||
} else {
|
||||
if (! $stickerMaster->item->uom) {
|
||||
Notification::make()
|
||||
->title('Unknown Item Code')
|
||||
->body("Item code does not have 'UOM' in master data.")
|
||||
->danger()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$serialExists = PanelBoxValidation::where('plant_id', $plantId)->where('serial_number', $serialNumber)->where('panel_box_supplier', $supplier)->first();
|
||||
|
||||
if ($serialExists) {
|
||||
Notification::make()
|
||||
->title('Duplicate Serial Number')
|
||||
->body("Serial number already exists '$serialNumber' with supplier number '$supplier'.")
|
||||
->danger()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$item = Item::where('code', $itemCode)->where('plant_id', $plantId)->first();
|
||||
|
||||
if (! $item) {
|
||||
Notification::make()
|
||||
->title('Unknown Item Code')
|
||||
->body("Item code '{$itemCode}' not found against plant code '{$plaCode}' in item master.")
|
||||
->danger()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Find sticker master
|
||||
$sticker = StickerMaster::where('plant_id', $plantId)->where('item_id', $item->id)->first();
|
||||
|
||||
if (! $sticker) {
|
||||
Notification::make()
|
||||
->title('Unknown Sticker')
|
||||
->body("Sticker master not found for the selected item.")
|
||||
->danger()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a new PanelBoxValidation record
|
||||
|
||||
$userName = Filament::auth()->user()->name;
|
||||
|
||||
$panelBoxValidation = PanelBoxValidation::create([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'sticker_master_id' => $sticker->id,
|
||||
'serial_number' => $serialNumber,
|
||||
'panel_box_code' => $itemCode ?? null,
|
||||
'panel_box_supplier' => $supplier ?? null,
|
||||
'panel_box_serial_number' => $serialNumber ?? null,
|
||||
'status' => 'Ok',
|
||||
'created_by' => $userName,
|
||||
'updated_by' => $userName,
|
||||
]);
|
||||
|
||||
if($panelBoxValidation){
|
||||
Notification::make()
|
||||
->title('Success')
|
||||
->body("Panel Box with Serial Number '{$serialNumber}' has been successfully inserted.")
|
||||
->success()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
return;
|
||||
} else {
|
||||
Notification::make()
|
||||
->title('Error')
|
||||
->body("Failed to insert Panel Box with Serial Number '{$serialNumber}'.")
|
||||
->danger()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view panel box inspection stock page');
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ class ProductionTarget extends Page
|
||||
Select::make('line_id')
|
||||
->label('Line')
|
||||
->required()
|
||||
// ->relationship('line', 'name')
|
||||
->relationship('line', 'name')
|
||||
// ->searchable()
|
||||
->columnSpan(1)
|
||||
->options(function (callable $get) {
|
||||
@@ -137,16 +137,16 @@ class ProductionTarget extends Page
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->reactive(),
|
||||
// ->afterStateUpdated(function ($state, callable $get, $set) {
|
||||
// $plantId = $get('plant_id');
|
||||
// $lineId = $state;
|
||||
// // $month = $get('month');
|
||||
// $year = $get('year');
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $get, $set) {
|
||||
$plantId = $get('plant_id');
|
||||
$lineId = $get('line_id');
|
||||
// $month = $get('month');
|
||||
$year = $get('year');
|
||||
|
||||
// $month = (int) $get('month');
|
||||
// $this->dispatch('loadData',$year, $month, $plantId, $lineId, '');
|
||||
// }),
|
||||
$month = (int) $get('month');
|
||||
$this->dispatch('loadData',$year, $month, $plantId, $lineId, '');
|
||||
}),
|
||||
|
||||
TextInput::make('category')
|
||||
->label('Category')
|
||||
@@ -208,16 +208,6 @@ class ProductionTarget extends Page
|
||||
}
|
||||
|
||||
$this->dispatch('loadData1' ,$plantId, $lineId, $year, $month);
|
||||
|
||||
// $this->dispatch('loadDataMonthly' ,$plantId, $lineId, $year, $month);
|
||||
}
|
||||
|
||||
public function generate(){
|
||||
$plantId = $this->filters['plant_id'] ?? null;
|
||||
$lineId = $this->filters['line_id'] ?? null;
|
||||
$year = $this->filters['year'] ?? null;
|
||||
$month = (int) $this->filters['month'] ?? null;
|
||||
$this->dispatch('loadData',$year, $month, $plantId, $lineId, '');
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,7 +29,7 @@ class StickerPrint extends Page implements HasForms
|
||||
|
||||
protected static string $view = 'filament.pages.sticker-print';
|
||||
|
||||
protected static ?string $navigationGroup = 'Sticker Printing';
|
||||
protected static ?string $navigationGroup = 'Customized Sticker Printing';
|
||||
|
||||
public array $filters = [];
|
||||
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
<?php
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Storage;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class UploadDailyReport extends Page implements HasForms
|
||||
{
|
||||
use InteractsWithForms;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-arrow-up';
|
||||
protected static string $view = 'filament.pages.upload-daily-report';
|
||||
|
||||
protected static ?string $navigationGroup = 'Task Upload';
|
||||
|
||||
public ?array $data = [];
|
||||
|
||||
public array $filters = [];
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->form->fill();
|
||||
}
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form->schema([
|
||||
Forms\Components\Section::make('Upload Daily Task Report')
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('file_name')
|
||||
->label('File Name')
|
||||
->reactive(),
|
||||
Forms\Components\FileUpload::make('report_pdf')
|
||||
->label('Daily Report PDF')
|
||||
->disk('local')
|
||||
->directory('task_updates')
|
||||
->acceptedFileTypes(['application/pdf'])
|
||||
->required()
|
||||
->maxSize(10240)
|
||||
->preserveFilenames(),
|
||||
])
|
||||
->columns(2),
|
||||
])->statePath('filters');
|
||||
}
|
||||
|
||||
public function uploadTaskPdf(): void
|
||||
{
|
||||
$state = $this->form->getState(); // triggers upload/validation
|
||||
$currentFile = $state['report_pdf'];
|
||||
$directory = 'task_updates';
|
||||
$filename = trim(basename($currentFile));
|
||||
|
||||
$path = 'task_updates/' . $filename;
|
||||
|
||||
// $duplicateExists = Storage::disk('local')->exists($path);
|
||||
|
||||
// if ($duplicateExists) {
|
||||
// // Remove the just-uploaded file since it's a duplicate
|
||||
// // Storage::disk('local')->delete($currentFile);
|
||||
|
||||
// Notification::make()
|
||||
// ->title('File already exists')
|
||||
// ->body("A file named \"{$filename}\" is already uploaded.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
|
||||
// $this->form->fill(['report_pdf' => null]);
|
||||
// return;
|
||||
// }
|
||||
// else{
|
||||
Notification::make()
|
||||
->title('PDF uploaded successfully')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
$this->form->fill(['report_pdf' => null]);
|
||||
// }
|
||||
}
|
||||
|
||||
public function removeTaskPdf(){
|
||||
$fileName = $this->filters['file_name'] ?? null;
|
||||
|
||||
if (!$fileName) {
|
||||
Notification::make()
|
||||
->title('File Name Required')
|
||||
->body('Please enter a file name before removing the PDF.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$filePath = "task_updates/{$fileName}.pdf";
|
||||
|
||||
if (!Storage::disk('local')->exists($filePath)) {
|
||||
Notification::make()
|
||||
->title('PDF Not Found')
|
||||
->body('The selected PDF does not exist.')
|
||||
->danger()
|
||||
->send();
|
||||
$this->form->fill(['file_name' => null]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Storage::disk('local')->exists($filePath)) {
|
||||
if (Storage::disk('local')->delete($filePath)) {
|
||||
Notification::make()
|
||||
->title('PDF Removed Successfully')
|
||||
->body('The PDF was removed successfully.')
|
||||
->success()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else{
|
||||
Notification::make()
|
||||
->title('PDF Removed Failed')
|
||||
->body('Unable to remove the PDF. Please try again...')
|
||||
->success()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view upload daily report page');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -86,8 +86,6 @@ class AlertMailRuleResource extends Resource
|
||||
'LaserStopReport' => 'LaserStopReport',
|
||||
'PanelBoxAlert' => 'PanelBoxAlert',
|
||||
'PanelBoxReport' => 'PanelBoxReport',
|
||||
'DailyTaskReport' => 'DailyTaskReport',
|
||||
'LaserIdleHourReport' => 'LaserIdleHourReport',
|
||||
]),
|
||||
Forms\Components\Select::make('rule_name')
|
||||
->label('Rule Name')
|
||||
@@ -106,9 +104,7 @@ class AlertMailRuleResource extends Resource
|
||||
'LaserStopAlertMail' => 'Laser Stop Alert Mail',
|
||||
'LaserStopMail' => 'Laser Stop Report Mail',
|
||||
'PanelBoxAlertMail' => 'Panel Box Alert Mail',
|
||||
'PanelBoxNotOkReportMail' => 'Panel Box Not Ok Report Mail',
|
||||
'DailyTaskReportMail' => 'Daily Task Report Mail',
|
||||
'LaserIdleMail' => 'Laser Idle Report Mail',
|
||||
'PanelBoxNotOkReportMail' => 'Panel Box Not Ok Report Mail'
|
||||
])
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('email')
|
||||
|
||||
@@ -11,7 +11,6 @@ use App\Models\Line;
|
||||
use App\Models\Machine;
|
||||
use App\Models\MotorTestingMaster;
|
||||
use App\Models\Plant;
|
||||
use Closure;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
@@ -27,7 +26,6 @@ use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class BeforeTestReadingResource extends Resource
|
||||
{
|
||||
@@ -49,29 +47,33 @@ class BeforeTestReadingResource extends Resource
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->columnSpan(1) // (['default' => 1, 'sm' => 2])
|
||||
->reactive()
|
||||
->searchable()
|
||||
->required()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(BeforeTestReading::latest()->first())->plant_id ?? null;
|
||||
return optional(BeforeTestReading::latest()->first())->plant_id ?? null;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
$set('line_id', null);
|
||||
$set('motor_testing_master_id', null);
|
||||
$set('machine_id', null);
|
||||
$set('tPrError', 'Please select a plant first.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
$set('line_id', null);
|
||||
$set('motor_testing_master_id', null);
|
||||
$set('machine_id', null);
|
||||
$set('tPrError', null);
|
||||
}
|
||||
$set('line_id', null);
|
||||
$set('motor_testing_master_id', null);
|
||||
$set('machine_id', null);
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
@@ -79,12 +81,10 @@ class BeforeTestReadingResource extends Resource
|
||||
'class' => $get('tPrError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('tPrError') ? $get('tPrError') : null)
|
||||
->hintColor('danger')
|
||||
->required(),
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('line_id')
|
||||
->label('Line Name')
|
||||
// ->relationship('line', 'name')
|
||||
->columnSpan(1)
|
||||
// ->relationship('line', 'name')
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
@@ -92,29 +92,24 @@ class BeforeTestReadingResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $plantId)->pluck('name', 'id')->toArray();
|
||||
return Line::where('plant_id', $plantId)
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(BeforeTestReading::latest()->first())->line_id ?? null;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->default(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return BeforeTestReading::where('plant_id', $plantId)->latest()->first()->line_id ?? null;
|
||||
})
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('motor_testing_master_id', null);
|
||||
$set('machine_id', null);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
}),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
->label('Work Center')
|
||||
// ->relationship('machine', 'work_center')
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
// ->relationship('machine', 'work_center')
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$lineId = $get('line_id');
|
||||
@@ -123,39 +118,34 @@ class BeforeTestReadingResource extends Resource
|
||||
}
|
||||
|
||||
// Only show machines for the selected line
|
||||
return Machine::where('line_id', $lineId)->pluck('work_center', 'id')->toArray();
|
||||
return Machine::where('line_id', $lineId)
|
||||
->pluck('work_center', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(BeforeTestReading::latest()->first())->machine_id ?? null;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->default(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return BeforeTestReading::where('plant_id', $plantId)->latest()->first()->machine_id ?? null;
|
||||
})
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
}),
|
||||
Forms\Components\Select::make('motor_testing_master_id')
|
||||
->label('Item Code')
|
||||
// ->relationship('motorTestingMaster', 'item.code')
|
||||
->columnSpan(1)
|
||||
// ->options(function (callable $get) {
|
||||
// $plantId = $get('plant_id');
|
||||
// if (!$plantId) {
|
||||
// return [];
|
||||
// }
|
||||
// return MotorTestingMaster::with('item')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->get()
|
||||
// //->filter(fn ($mtm) => $mtm->item)
|
||||
// ->pluck('item.code', 'id')
|
||||
// ->toArray();
|
||||
// })
|
||||
->reactive()
|
||||
->searchable()
|
||||
// ->relationship('motorTestingMaster', 'item.code')
|
||||
// ->options(function (callable $get) {
|
||||
// $plantId = $get('plant_id');
|
||||
// if (!$plantId) {
|
||||
// return [];
|
||||
// }
|
||||
// return MotorTestingMaster::with('item')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->get()
|
||||
// //->filter(fn ($mtm) => $mtm->item)
|
||||
// ->pluck('item.code', 'id')
|
||||
// ->toArray();
|
||||
// })
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
@@ -169,83 +159,42 @@ class BeforeTestReadingResource extends Resource
|
||||
->pluck('items.code', 'motor_testing_masters.id')
|
||||
->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
// ->getOptionLabelUsing(fn ($value) =>
|
||||
// MotorTestingMaster::with('item')->find($value)?->item?->code
|
||||
// )
|
||||
// ->getOptionLabelUsing(fn ($value) =>
|
||||
// MotorTestingMaster::with('item')->find($value)?->item?->code
|
||||
// )
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
}),
|
||||
Forms\Components\TextInput::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->readOnly(fn (Get $get) => $get('id'))
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->rule(function (callable $get) {
|
||||
return function (string $attribute, $value, Closure $fail) use ($get) {
|
||||
|
||||
$plantId = $get('plant_id');
|
||||
$lineId = $get('line_id');
|
||||
$machineId = $get('machine_id');
|
||||
$itemId = $get('motor_testing_master_id');
|
||||
$serialNumber = trim($value);
|
||||
// $currentId = $get('id'); // current editing record id
|
||||
|
||||
if (! $plantId || ! $lineId || ! $machineId || ! $itemId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($serialNumber == null || $serialNumber == '' || ! $serialNumber) {
|
||||
$fail("Serial number can't be empty!");
|
||||
} elseif (Str::length($serialNumber) < 9) {
|
||||
$fail('Serial number should contain minimum 9 digits!');
|
||||
} elseif (! ctype_alnum($serialNumber)) {
|
||||
$fail('Serial number should contain only alpha-numeric values!');
|
||||
} elseif (! preg_match('/^[1-9][a-zA-Z0-9]{8,}$/', $serialNumber)) {
|
||||
$fail("Serial number should not begin with '0' or letter!");
|
||||
}
|
||||
};
|
||||
})
|
||||
->required(),
|
||||
}),
|
||||
Forms\Components\TextInput::make('before_fr_res_ry')
|
||||
->label('Before FR Resistance RY')
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->readOnly(fn (Get $get) => $get('id'))
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('before_fr_res_yb')
|
||||
->label('Before FR Resistance YB')
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->readOnly(fn (Get $get) => $get('id'))
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('before_fr_res_br')
|
||||
->label('Before FR Resistance BR')
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->readOnly(fn (Get $get) => $get('id'))
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('before_fr_ir')
|
||||
->label('Before FR IR')
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->readOnly(fn (Get $get) => $get('id'))
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('tested_by')
|
||||
->label('Tested By')
|
||||
->columnSpan(1)
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->readOnly()
|
||||
->required(),
|
||||
@@ -283,9 +232,6 @@ class BeforeTestReadingResource extends Resource
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line Name')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('machine.workGroupMaster.name')
|
||||
->label('Group Work Center')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
->label('Work Center')
|
||||
->alignCenter(),
|
||||
@@ -298,20 +244,9 @@ class BeforeTestReadingResource extends Resource
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.item.description')
|
||||
->label('Model')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.item.category')
|
||||
->label('Category')
|
||||
->default('-')
|
||||
->alignCenter()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.item.uom')
|
||||
->label('Unit of Measure')
|
||||
->default('-')
|
||||
->alignCenter()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.kw')
|
||||
->label('KW')
|
||||
@@ -353,7 +288,8 @@ class BeforeTestReadingResource extends Resource
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('tested_by')
|
||||
->label('Tested By')
|
||||
->alignCenter(),
|
||||
->alignCenter()
|
||||
->numeric(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
@@ -361,7 +297,8 @@ class BeforeTestReadingResource extends Resource
|
||||
->dateTime(),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter(),
|
||||
->alignCenter()
|
||||
->numeric(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->alignCenter()
|
||||
@@ -369,7 +306,6 @@ class BeforeTestReadingResource extends Resource
|
||||
->dateTime()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->searchPlaceholder('Search by Serial Number')
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
@@ -377,9 +313,8 @@ class BeforeTestReadingResource extends Resource
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->nullable()
|
||||
->options(function () {
|
||||
// return Plant::pluck('name', 'id');
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
@@ -394,6 +329,7 @@ class BeforeTestReadingResource extends Resource
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Line', null);
|
||||
$set('item_code', null);
|
||||
@@ -401,25 +337,26 @@ class BeforeTestReadingResource extends Resource
|
||||
}),
|
||||
Select::make('Line')
|
||||
->label('Search by Line Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $plantId)->pluck('name', 'id')->toArray();
|
||||
return Line::where('plant_id', $plantId)
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('item_code', null);
|
||||
}),
|
||||
Select::make('machine_name')
|
||||
->label('Search by Work Center')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
$lineId = $get('Line');
|
||||
@@ -428,26 +365,31 @@ class BeforeTestReadingResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::where('plant_id', $plantId)->where('line_id', $lineId)->pluck('work_center', 'id')->toArray();
|
||||
}),
|
||||
return Machine::where('plant_id', $plantId)
|
||||
->where('line_id', $lineId)
|
||||
->pluck('work_center', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->reactive(),
|
||||
Select::make('item_code')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
if ($plantId) {
|
||||
return Item::where('plant_id', $plantId)
|
||||
->whereHas('motorTestingMasters')
|
||||
->pluck('code', 'id')
|
||||
->toArray();
|
||||
} else {
|
||||
return [];
|
||||
// return Item::whereHas('motorTestingMasters')
|
||||
// ->pluck('code', 'id')
|
||||
// ->toArray();
|
||||
}
|
||||
|
||||
return Item::whereHas('motorTestingMasters', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('code', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('item_description', null);
|
||||
}),
|
||||
@@ -457,52 +399,57 @@ class BeforeTestReadingResource extends Resource
|
||||
->placeholder('Enter Serial Number'),
|
||||
Select::make('subassembly_code')
|
||||
->label('Search by Subassembly Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
if ($plantId) {
|
||||
return MotorTestingMaster::whereHas('beforeTestReadings', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->whereNotNull('subassembly_code')->orderBy('subassembly_code')->pluck('subassembly_code', 'id');
|
||||
} else {
|
||||
return [];
|
||||
// return Item::whereHas('motorTestingMasters')
|
||||
// ->pluck('code', 'id')
|
||||
// ->toArray();
|
||||
}
|
||||
|
||||
return MotorTestingMaster::whereHas('beforeTestReadings', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
$query->whereNotNull('id');
|
||||
})->whereNotNull('subassembly_code')->orderBy('subassembly_code')->pluck('subassembly_code', 'id');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('item_description', null);
|
||||
}),
|
||||
Select::make('item_description')
|
||||
->label('Search by Model')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
// $query = Item::query();
|
||||
// if ($plantId) {
|
||||
// $query->where('plant_id', $plantId);
|
||||
// }
|
||||
|
||||
return Item::whereHas('motorTestingMasters', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('description', 'id')->toArray();
|
||||
$plantId = $get('Plant');
|
||||
if ($plantId) {
|
||||
return Item::where('plant_id', $plantId)
|
||||
->whereHas('motorTestingMasters')
|
||||
->pluck('description', 'id')
|
||||
->toArray();
|
||||
} else {
|
||||
return [];
|
||||
// return Item::whereHas('motorTestingMasters')
|
||||
// ->pluck('description', 'id')
|
||||
// ->toArray();
|
||||
}
|
||||
// return $query->pluck('description', 'description')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('item_code', null);
|
||||
}),
|
||||
Select::make('connection')
|
||||
->label('Connection')
|
||||
->nullable()
|
||||
->reactive()
|
||||
->selectablePlaceholder(false)
|
||||
->required()
|
||||
->default('Star')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
@@ -519,12 +466,11 @@ class BeforeTestReadingResource extends Resource
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->required(),
|
||||
->selectablePlaceholder(false)
|
||||
->reactive(),
|
||||
Select::make('tested_by')
|
||||
->label('Tested By')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
@@ -532,22 +478,22 @@ class BeforeTestReadingResource extends Resource
|
||||
} else {
|
||||
return BeforeTestReading::where('plant_id', $plantId)->whereNotNull('tested_by')->select('tested_by')->distinct()->pluck('tested_by', 'tested_by');
|
||||
}
|
||||
}),
|
||||
DateTimePicker::make('created_from')
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder('Select From DateTime')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder('Select To DateTime')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
Select::make('updated_by')
|
||||
->label('Updated By')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
@@ -555,15 +501,17 @@ class BeforeTestReadingResource extends Resource
|
||||
} else {
|
||||
return BeforeTestReading::where('plant_id', $plantId)->whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
|
||||
}
|
||||
}),
|
||||
DateTimePicker::make('updated_from')
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
DateTimePicker::make(name: 'updated_from')
|
||||
->label('Updated From')
|
||||
->placeholder('Select From DateTime')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('updated_to')
|
||||
->label('Updated To')
|
||||
->placeholder('Select To DateTime')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
|
||||
@@ -33,7 +33,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Laser Marking';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
@@ -399,7 +399,6 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->searchPlaceholder('Search Approver Type')
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,468 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\CoilPackingResource\Pages;
|
||||
use App\Filament\Resources\CoilPackingResource\RelationManagers;
|
||||
use App\Models\CoilPacking;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use App\Filament\Exports\CoilPackingExporter;
|
||||
use App\Filament\Imports\CoilPackingImporter;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
|
||||
class CoilPackingResource extends Resource
|
||||
{
|
||||
protected static ?string $model = CoilPacking::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Coil Packing';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->relationship('plant', 'name')
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('coil_packing_number', null);
|
||||
$set('process_order', null);
|
||||
}),
|
||||
Forms\Components\TextInput::make('coil_packing_number')
|
||||
->label('Scan Coil Packing No')
|
||||
->reactive()
|
||||
->required()
|
||||
->readonly()
|
||||
->extraAttributes([
|
||||
'x-data' => '{ value: "" }',
|
||||
'x-model' => 'value',
|
||||
'x-on:keydown.enter.prevent' => '$wire.processPalletNo()',
|
||||
])
|
||||
->suffixAction(fn ($get, $set) => Forms\Components\Actions\Action::make('addWirePackNo')
|
||||
->label('')
|
||||
->button()
|
||||
->icon('heroicon-o-plus')
|
||||
->color('primary')
|
||||
->extraAttributes([
|
||||
'class' => 'p-1 w-7 h-7',
|
||||
])
|
||||
->action(function ($get, $set, $livewire) {
|
||||
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
$year = now()->format('y');
|
||||
$month = now()->format('m');
|
||||
$prefix = "CP-{$year}{$month}";
|
||||
|
||||
$lastPallet = CoilPacking::where('coil_packing_number', 'like', "{$prefix}%")
|
||||
->orderByDesc('coil_packing_number')
|
||||
->first();
|
||||
|
||||
if ($lastPallet) {
|
||||
$lastNumber = (int) substr(
|
||||
$lastPallet->coil_packing_number,
|
||||
strlen($prefix)
|
||||
);
|
||||
|
||||
$newNumber = $lastNumber + 1;
|
||||
|
||||
$newNumber = $newNumber < 1000
|
||||
? str_pad($newNumber, 3, '0', STR_PAD_LEFT)
|
||||
: (string) $newNumber;
|
||||
} else {
|
||||
$newNumber = '001';
|
||||
}
|
||||
|
||||
$newPalletNumber = "{$prefix}{$newNumber}";
|
||||
|
||||
$set('coil_packing_number', $newPalletNumber);
|
||||
$set('plant_id', $plantId);
|
||||
|
||||
$livewire->redirectToCoilQrPdf($newPalletNumber);
|
||||
})
|
||||
),
|
||||
Forms\Components\TextInput::make('process_order')
|
||||
->label('Coil No')
|
||||
->reactive()
|
||||
->readOnly(fn (callable $get) => ! $get('coil_packing_number') || $get('removeSno_number'))
|
||||
->extraAttributes([
|
||||
'x-on:keydown.enter.prevent' => '$wire.processOrderSNo()',
|
||||
]),
|
||||
Forms\Components\TextInput::make('removeSno_number')
|
||||
->label('Remove Coil No')
|
||||
->reactive()
|
||||
->minLength(9)
|
||||
->readOnly(fn (callable $get) => ! $get('coil_packing_number') || $get('process_order'))
|
||||
->extraAttributes([
|
||||
'x-data' => '{ value: "" }',
|
||||
'x-model' => 'value',
|
||||
'x-on:keydown.enter.prevent' => '$wire.processRemoveSNo()',
|
||||
]),
|
||||
Forms\Components\TextInput::make('Sno_quantity')
|
||||
->label('SNo. Quantity')
|
||||
->readOnly()
|
||||
->default('0'),
|
||||
Forms\Components\Select::make('pending_pallet_list')
|
||||
->label('Pending Pallet List')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('coil_packing_number', $state);
|
||||
$set('pallet_number_locked', false);
|
||||
})
|
||||
->options(function ($get) {
|
||||
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return CoilPacking::query()
|
||||
->where('plant_id', $plantId)
|
||||
->where(function ($query) {
|
||||
$query->whereNull('coil_packing_status')
|
||||
->orWhere('coil_packing_status', '');
|
||||
})
|
||||
->whereNotNull('coil_packing_number')
|
||||
->orderBy('coil_packing_number', 'asc')
|
||||
->pluck('coil_packing_number')
|
||||
->unique()
|
||||
->mapWithKeys(fn ($number) => [$number => $number])
|
||||
->toArray();
|
||||
}),
|
||||
Forms\Components\View::make('forms.components.save-coil-processorder-button'),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By'),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By'),
|
||||
])
|
||||
->columns(5),
|
||||
]);
|
||||
}
|
||||
|
||||
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('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Item')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.description')
|
||||
->label('Description')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('coil_packing_number')
|
||||
->label('Coil Packing Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('process_order')
|
||||
->label('Coil Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('coil_packing_status')
|
||||
->label('Coil Packing Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->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')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('scanned_at')
|
||||
->label('Scanned At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('scanned_by')
|
||||
->label('Scanned By')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
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('coilPacking', 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('coilPacking', 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('coil_packing_number')
|
||||
->label('Coil Packing Number')
|
||||
->reactive()
|
||||
->placeholder('Enter Coil Packing Number')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('process_order', null);
|
||||
}),
|
||||
TextInput::make('process_order')
|
||||
->label('Coil No')
|
||||
->reactive()
|
||||
->placeholder('Enter Coil No')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Rework', null);
|
||||
}),
|
||||
Select::make('coil_packing_status')
|
||||
->label('Coil 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['coil_packing_number']) && empty($data['coil_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['coil_packing_number'])) {
|
||||
$query->where('coil_packing_number', 'like', '%'.$data['coil_packing_number'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['coil_packing_status'])) {
|
||||
if ($data['coil_packing_status'] == 'Pending') {
|
||||
$query->where(function ($q) {
|
||||
$q->whereNull('coil_packing_status')
|
||||
->orWhere('coil_packing_status', '');
|
||||
});
|
||||
} else {
|
||||
$query->where('coil_packing_status', $data['coil_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[] = 'Coil No: '.$data['process_order'];
|
||||
}
|
||||
|
||||
if (! empty($data['coil_packing_number'])) {
|
||||
$indicators[] = 'Coil Packing Number: '.$data['coil_packing_number'];
|
||||
}
|
||||
|
||||
if (! empty($data['coil_packing_status'])) {
|
||||
$indicators[] = 'Coil Packing Status: '.$data['coil_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([
|
||||
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([
|
||||
ImportAction::make()
|
||||
->label('Import Coil Packing')
|
||||
->color('warning')
|
||||
->importer(CoilPackingImporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import coil packing');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Coil Packing')
|
||||
->color('warning')
|
||||
->exporter(CoilPackingExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export coil packing');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListCoilPackings::route('/'),
|
||||
'create' => Pages\CreateCoilPacking::route('/create'),
|
||||
'view' => Pages\ViewCoilPacking::route('/{record}'),
|
||||
'edit' => Pages\EditCoilPacking::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,800 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CoilPackingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CoilPackingResource;
|
||||
use App\Models\CoilPacking;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCoilPacking extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CoilPackingResource::class;
|
||||
|
||||
protected static string $view = 'filament.resources.coil-packing-resource.create-coil-packing';
|
||||
|
||||
public $processOrder;
|
||||
|
||||
public $plantId;
|
||||
|
||||
public $count = 0;
|
||||
|
||||
public $snoCount = 0;
|
||||
|
||||
public $pendingPallet;
|
||||
|
||||
public $palletNo;
|
||||
|
||||
protected $listeners = [
|
||||
'updateSnoQuantity' => 'handleUpdateSnoQuantity',
|
||||
];
|
||||
|
||||
public function handleUpdateSnoQuantity($newValue)
|
||||
{
|
||||
$this->form->fill([
|
||||
'Sno_quantity' => $newValue,
|
||||
]);
|
||||
}
|
||||
|
||||
public function processOrderSNo(){
|
||||
|
||||
$plantId = $this->form->getState()['plant_id'];
|
||||
|
||||
$plantId = trim($plantId) ?? null;
|
||||
|
||||
$processOrder = trim($this->form->getState()['process_order'])?? null;
|
||||
|
||||
$coilPackNo = trim($this->form->getState()['coil_packing_number'])?? null;
|
||||
|
||||
$coilPackNo = trim($coilPackNo) ?? null;
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
if (empty($processOrder) || $processOrder == '')
|
||||
{
|
||||
Notification::make()
|
||||
->title("Coil No can't be empty")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'process_order' => null,
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => $coilPackNo,
|
||||
'Sno_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$pattern = '/^([^|]+)\|([^|]+)$/';
|
||||
|
||||
if (!preg_match($pattern, $processOrder, $matches))
|
||||
{
|
||||
Notification::make()
|
||||
->title("Scan Valid Qr code ")
|
||||
->body("Expected Format: ItemCode|CoilNo")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'process_order' => null,
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => $coilPackNo,
|
||||
'Sno_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$materialCode = $matches[1];
|
||||
$coilNo = $matches[2];
|
||||
|
||||
$icode = Item::where('code', $materialCode)->first();
|
||||
|
||||
if(!$icode)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Unknown Item Code")
|
||||
->body("Item Code not found '$materialCode'")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => $coilPackNo,
|
||||
'process_order' => null,
|
||||
'Sno_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$icodeAgaPlant = Item::where('code', $materialCode)->where('plant_id', $plantId)->first();
|
||||
|
||||
$plantCode = Plant::where('id', $plantId)->first();
|
||||
|
||||
$plantcode = $plantCode->code;
|
||||
|
||||
$itemId = $icodeAgaPlant->id;
|
||||
|
||||
if(!$icodeAgaPlant)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Unknown Item Code")
|
||||
->body("Item Code not found '$materialCode' against Plant Code '$plantcode'")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => $coilPackNo,
|
||||
'process_order' => null,
|
||||
'Sno_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$processOrderAgaPlant = CoilPacking::where('process_order', $coilNo)->where('plant_id', $plantId)->first();
|
||||
|
||||
if($processOrderAgaPlant)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Duplicate Coil No")
|
||||
->body("Duplicate coil number found '$coilNo' against Plant Code '$plantcode'")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => $coilPackNo,
|
||||
'process_order' => null,
|
||||
'Sno_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$existingPallet = CoilPacking::where('plant_id', $plantId)
|
||||
->where('coil_packing_number', $coilPackNo)
|
||||
->first();
|
||||
|
||||
$count = CoilPacking::where('plant_id', $plantId)
|
||||
->where('coil_packing_number', $coilPackNo)
|
||||
->count('coil_packing_number');
|
||||
|
||||
$createdAt = $existingPallet ? $existingPallet->created_at : $clickedAt ?? now();
|
||||
|
||||
$createdBy = $existingPallet ? $existingPallet->created_by : $clickedBy ?? $operatorName;
|
||||
|
||||
$record = CoilPacking::create([
|
||||
'plant_id' => $plantId,
|
||||
'item_id' => $itemId,
|
||||
'coil_packing_number' => $coilPackNo,
|
||||
'process_order' => $coilNo,
|
||||
'created_by' => $createdBy,
|
||||
'scanned_by' => $operatorName,
|
||||
'created_at' => $createdAt,
|
||||
'scanned_at' => now(),
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
|
||||
if ($record)
|
||||
{
|
||||
|
||||
$this->snoCount = CoilPacking::where('plant_id', $plantId)
|
||||
->where('coil_packing_number', $coilPackNo)
|
||||
->count();
|
||||
|
||||
$this->dispatch('loadData', $coilPackNo, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'item_id' => $itemId,
|
||||
'coil_packing_number' => $coilPackNo,
|
||||
'process_order' => null,
|
||||
'Sno_quantity' => $this->snoCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title("Failed to insert scanned serial number '$coilNo' into coil packing table!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $coilPackNo, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'item_id' => $itemId,
|
||||
'coil_packing_number' => $coilPackNo,
|
||||
'process_order' => null,
|
||||
'Sno_quantity' => $count,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Error: Serial not inserted.')
|
||||
->body("Something went wrong while inserting process order '{$coilNo}' into pallet table!\nScan the new process order to proceed...")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $coilPackNo, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => $coilPackNo,
|
||||
'process_order' => null,
|
||||
'Sno_quantity' => $count,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->dispatch('loadData', $coilPackNo, $plantId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function markAsComplete()
|
||||
{
|
||||
|
||||
$plantId = $this->form->getState()['plant_id'];
|
||||
|
||||
$plantId = trim($plantId) ?? null;
|
||||
|
||||
$pendingPallet = $this->form->getState()['pending_pallet_list'];
|
||||
|
||||
$palletNumber = trim($this->form->getState()['coil_packing_number'])?? null;
|
||||
|
||||
$palletNumber = trim($palletNumber) ?? null;
|
||||
|
||||
$processOrder = trim($this->form->getState()['process_order'])?? null;
|
||||
|
||||
$processOrder = trim($processOrder) ?? null;
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
$isCompleted = $this->data['is_completed'] ?? false;
|
||||
|
||||
// $this->pendingPallet = $this->form->getState()['pending_pallet_list'];
|
||||
|
||||
if (! ($this->data['is_completed'] ?? false)) {
|
||||
Notification::make()
|
||||
->title('Completion required')
|
||||
->body('Please check the "Is Completed" checkbox to finish master packing.')
|
||||
->warning()
|
||||
->duration(3000)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$palletExist = CoilPacking::where('coil_packing_number', $palletNumber)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
if (!$palletExist)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNumber' does not have process orders to save!<br>Add the valid process order into pallet number to proceed...")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'process_order' => null,
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => $palletNumber,
|
||||
'pending_pallet_list' => $pendingPallet,
|
||||
'Sno_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$allCompleted = CoilPacking::where('plant_id', $plantId)
|
||||
->where('coil_packing_number', $palletNumber)
|
||||
->where('coil_packing_status', '=','Completed')
|
||||
->first();
|
||||
|
||||
if ($allCompleted)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Coil Packing pallet number '$palletNumber' already completed the master packing!<br>Generate the new Coil Packing Pallet number or choose from pending pallet list!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'process_order' => null,
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => null,
|
||||
'pending_pallet_list' => null,//$pendingPallet
|
||||
'Sno_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$isCompleted)
|
||||
{
|
||||
$updated = CoilPacking::where('coil_packing_number', $palletNumber)
|
||||
->where('plant_id', $plantId)
|
||||
->update([
|
||||
'updated_at' => now(),
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
|
||||
if ($updated > 0)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNumber' records saved successfully!")
|
||||
->success()
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'process_order' => null,
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => null,//$palletNumber
|
||||
'pending_pallet_list' => null,//$pendingPallet
|
||||
'Sno_quantity' => 0,//$count,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$updated = CoilPacking::where('coil_packing_number', $palletNumber)
|
||||
->where('plant_id', $plantId)
|
||||
->update([
|
||||
'coil_packing_status' => 'Completed',
|
||||
'updated_at' => now(),
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
|
||||
if ($updated > 0)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNumber' completed the coil packing successfully!")
|
||||
->success()
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'process_order' => null,
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => null,//$palletNumber
|
||||
'pending_pallet_list' => null,//$pendingPallet
|
||||
'Sno_quantity' => 0,//$count
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function processPalletNo()
|
||||
{
|
||||
$plantId = $this->form->getState()['plant_id'];
|
||||
|
||||
$plantId = trim($plantId) ?? null;
|
||||
|
||||
$pendingPallet = $this->form->getState()['pending_pallet_list'];
|
||||
|
||||
$palletNumber = trim($this->form->getState()['coil_packing_number']) ?? null;
|
||||
|
||||
$palletNumber = trim($palletNumber) ?? null;
|
||||
|
||||
$processOrder = trim($this->form->getState()['process_order']) ?? null;
|
||||
|
||||
$processOrder = trim($processOrder) ?? null;
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
//$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'process_order' => null,
|
||||
'plant_id' => $plantId,
|
||||
'pallet_number' => $palletNumber,
|
||||
'pending_pallet_list' => $pendingPallet,
|
||||
'Sno_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
|
||||
if (!$palletNumber)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Pallet number is required.')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'process_order' => null,
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => $palletNumber,
|
||||
'pending_pallet_list' => $pendingPallet,
|
||||
'Sno_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen($palletNumber) < 10)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNumber' must be at least 10 digits.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadLocator' ,'',$plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
'plant_id' => $plantId,
|
||||
'pallet_number' => $palletNumber,
|
||||
'pending_pallet_list' => $pendingPallet,
|
||||
'Sno_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$count = CoilPacking::where('plant_id', $plantId)
|
||||
->where('coil_packing_number', $palletNumber)
|
||||
->count('coil_packing_number');
|
||||
|
||||
|
||||
$palletNotCompleted = CoilPacking::where('plant_id', $plantId)
|
||||
->where('coil_packing_number', $palletNumber)
|
||||
->where('coil_packing_status', '=','')
|
||||
->orWhere('coil_packing_status', '=',null)
|
||||
->first();
|
||||
|
||||
if (!$palletNotCompleted)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Already completed for pallet number $palletNumber!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'process_order' => null,
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => $palletNumber,
|
||||
'pending_pallet_list' => $pendingPallet,
|
||||
'Sno_quantity' => $count,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'process_order' => null,
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => $palletNumber,
|
||||
'pending_pallet_list' => $pendingPallet,
|
||||
'Sno_quantity' => $count,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
|
||||
}
|
||||
|
||||
public function processRemoveSNo()
|
||||
{
|
||||
$plantId = $this->form->getState()['plant_id'];
|
||||
|
||||
$plantId = trim($plantId) ?? null;
|
||||
|
||||
$pendingPallet = $this->form->getState()['pending_pallet_list'];
|
||||
|
||||
$palletNumber = trim($this->form->getState()['coil_packing_number']) ?? null;
|
||||
|
||||
$palletNumber = trim($palletNumber) ?? null;
|
||||
|
||||
$processOrder = trim($this->form->getState()['removeSno_number']) ?? null;
|
||||
|
||||
$processOrder = trim($processOrder) ?? null;
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
if (!$palletNumber)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Coil Pallet number is required to remove.')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$pattern = '/^([^|]+)\|([^|]+)$/';
|
||||
|
||||
if (!preg_match($pattern, $processOrder, $matches))
|
||||
{
|
||||
Notification::make()
|
||||
->title("Scan Valid Qr code ")
|
||||
->body("Expected Format : (MaterialCode|Coil Number)")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'removeSno_number' => null,
|
||||
'Sno_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$materialCode = $matches[1];
|
||||
$coilNo = $matches[2];
|
||||
|
||||
$count = CoilPacking::where('plant_id', $plantId)
|
||||
->where('coil_packing_number', $palletNumber)
|
||||
->count('coil_packing_number');
|
||||
|
||||
|
||||
if (!$coilNo)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Coil number is required to remove.')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'removeSno_number' => null,
|
||||
'coil_packing_number' => $palletNumber,
|
||||
'pending_pallet_list' => $pendingPallet,
|
||||
'Sno_quantity' => $count,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$item = Item::where('plant_id', $plantId)->where('code', $materialCode)->first();
|
||||
|
||||
if(!$item){
|
||||
Notification::make()
|
||||
->title('Unknown Item Code')
|
||||
->body("Item code {$materialCode} was not found in the Item Master.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => $palletNumber,
|
||||
'removeSno_number' => null,
|
||||
'Sno_quantity' => $count,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$itemCodeInPallet = CoilPacking::where('plant_id', $plantId)->where('item_id', $item->id)->where('coil_packing_number', $palletNumber)->first();
|
||||
|
||||
if(!$itemCodeInPallet){
|
||||
Notification::make()
|
||||
->title('Unknown Item Code')
|
||||
->body("Item code {$materialCode} was not found in the pallet number '$palletNumber'.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => $palletNumber,
|
||||
'removeSno_number' => null,
|
||||
'Sno_quantity' => $count,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$itemCodeInPalletSerial = CoilPacking::where('plant_id', $plantId)->where('item_id', $item->id)->where('coil_packing_number', $palletNumber)->where('process_order', $coilNo)->first();
|
||||
|
||||
if(!$itemCodeInPalletSerial){
|
||||
Notification::make()
|
||||
->title('Mismatch Item Code')
|
||||
->body("Item code {$materialCode} mismatch with serial number was not found in the pallet number '$palletNumber'.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => $palletNumber,
|
||||
'removeSno_number' => null,
|
||||
'Sno_quantity' => $count,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$processOrderexist = CoilPacking::where('plant_id', $plantId)
|
||||
->where('process_order', $coilNo)
|
||||
->first();
|
||||
if (!$processOrderexist)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Coil Number not exists in pallet table.')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'removeSno_number' => null,
|
||||
'coil_packing_number' => $palletNumber,
|
||||
'pending_pallet_list' => $pendingPallet,
|
||||
'Sno_quantity' => $count,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$palletExist = CoilPacking::where('plant_id', $plantId)
|
||||
->where('process_order', $coilNo)
|
||||
->where('coil_packing_number', '!=', '')
|
||||
->where('coil_packing_number', '!=', null)
|
||||
->first();
|
||||
|
||||
if ($palletExist && $palletExist->coil_packing_number != $palletNumber)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Scanned coil number exist in pallet number '$palletExist->coil_packing_number'.<br>Scan the valid exist coil number to remove!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'removeSno_number' => null,
|
||||
'coil_packing_number' => $palletNumber,
|
||||
'pending_pallet_list' => $pendingPallet,
|
||||
'Sno_quantity' => $count,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$deleted = CoilPacking::where('plant_id', $plantId)
|
||||
->where('coil_packing_number', $palletNumber)
|
||||
->where('process_order', $coilNo)
|
||||
->forceDelete();
|
||||
|
||||
if ($deleted)
|
||||
{
|
||||
// Notification::make()
|
||||
// ->title("Scanned serial number '$serialNumber' successfully removed from pallet table!<br>Scan the next exist serial number to remove...")
|
||||
// ->success()
|
||||
// ->duration(600)
|
||||
// ->send();
|
||||
|
||||
$this->snoCount = CoilPacking::where('plant_id', $plantId)
|
||||
->where('coil_packing_number', $palletNumber)
|
||||
->count();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'coil_packing_number' => $palletNumber,
|
||||
'removeSno_number' => null,
|
||||
'pending_pallet_list' => $this->pendingPallet,
|
||||
'Sno_quantity' => $this->snoCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title("Failed to remove scanned process order '$processOrder' from master pallet!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'removeSno_number' => null,
|
||||
'coil_packing_number' => $palletNumber,
|
||||
'pending_pallet_list' => $pendingPallet,
|
||||
'Sno_quantity' => $count,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function redirectToCoilQrPdf($palletNo)
|
||||
{
|
||||
$this->palletNo = $this->form->getState()['coil_packing_number'];
|
||||
|
||||
//return redirect()->route('download-qr-pdf', ['palletNo' => $this->palletNo]);
|
||||
$url = route('download-coil-qr-pdf', ['palletNo' => $this->palletNo]);
|
||||
$this->js(<<<JS
|
||||
window.dispatchEvent(new CustomEvent('open-pdf', {
|
||||
detail: {
|
||||
url: "{$url}"
|
||||
}
|
||||
}));
|
||||
JS);
|
||||
|
||||
}
|
||||
|
||||
public function getFormActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CoilPackingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CoilPackingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCoilPacking extends EditRecord
|
||||
{
|
||||
protected static string $resource = CoilPackingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CoilPackingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CoilPackingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListCoilPackings extends ListRecords
|
||||
{
|
||||
protected static string $resource = CoilPackingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CoilPackingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CoilPackingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewCoilPacking extends ViewRecord
|
||||
{
|
||||
protected static string $resource = CoilPackingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ use App\Filament\Resources\InvoiceValidationResource;
|
||||
use App\Imports\ExcelImport;
|
||||
use App\Mail\InvalidSerialMail;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\CoilPacking;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
@@ -2552,93 +2551,19 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
|
||||
|
||||
$pattern6 = '/^(?<item_code>[^|]+)\|(?<batch_number>[^|]*)\|(?<batch_id>[^|]+)\|(?<batch_count>[^|]+)\|(?<batch_quantity>[^|]+)$/i';
|
||||
$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';
|
||||
$pattern2 = '/^(?<item_code>[^|]+)\|(?<batch_number>[^|]+)\|(?<batch_id>[^|]+)\|(?<batch_count>.+)$/i';
|
||||
$pattern3 = '/^(?<item_code>[^|]+)\|(?<batch_id>[^|]+)-(?<batch_count>.+)$/i';
|
||||
$pattern4 = '/^MP-(?<code>.+)$/i';
|
||||
$pattern5 = '/^CP-(?<code>.+)$/i';
|
||||
$itemCode = '';
|
||||
$batchNumber = '';
|
||||
$curScanQty = '';
|
||||
$wirePallet = '';
|
||||
$coilPallet = '';
|
||||
$curMaterialQty = '';
|
||||
$curMaterialSer = '';
|
||||
|
||||
if (preg_match($pattern6, $serNo, $matches) && substr_count($serNo, '|') == 4) {
|
||||
$itemCode = $matches['item_code'];
|
||||
$this->currentItemCode = $itemCode;
|
||||
$batchNumber = $matches['batch_number'];
|
||||
$curScanQty = trim($matches['batch_quantity']);
|
||||
$batchCount = str_replace('-', '', $matches['batch_count']);
|
||||
$serialNumber = $matches['batch_id'].'-'.$batchCount;
|
||||
$serNo = null;
|
||||
|
||||
// if (empty($matches['batch_number']) || ! $matches['batch_number']) {
|
||||
// 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 (or) <br>657204|26091200|200000266831|001|650.000')
|
||||
// ->seconds(2)
|
||||
// ->send();
|
||||
// $this->dispatch('playWarnSound');
|
||||
|
||||
// $this->form->fill([
|
||||
// 'plant_id' => $plantId,
|
||||
// 'invoice_number' => $invoiceNumber,
|
||||
// 'serial_number' => null,
|
||||
// 'total_quantity' => $totMatQuan,
|
||||
// 'update_invoice' => false,
|
||||
// 'scanned_quantity' => $scanMatQuan,
|
||||
// ]);
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
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 (or) <br>657204|26091200|200000266831|001|650.000')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
]);
|
||||
|
||||
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 (or) <br>657204|26091200|200000266831|001|650.000')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
} elseif (preg_match($pattern0, $serNo, $matches)) {
|
||||
if (preg_match($pattern0, $serNo, $matches)) {
|
||||
$itemCode = $matches['item_code'];
|
||||
$this->currentItemCode = $itemCode;
|
||||
$curScanQty = trim($matches['batch_quantity']);
|
||||
@@ -2649,7 +2574,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
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 (or) <br>657204|26091200|200000266831|001|650.000')
|
||||
->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');
|
||||
|
||||
@@ -2667,7 +2593,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
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 (or) <br>657204|26091200|200000266831|001|650.000')
|
||||
->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');
|
||||
@@ -2695,7 +2621,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
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 (or) <br>657204|26091200|200000266831|001|650.000')
|
||||
->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');
|
||||
@@ -2729,7 +2655,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
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 (or) <br>657204|26091200|200000266831|001|650.000')
|
||||
->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');
|
||||
@@ -2763,7 +2689,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
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 (or) <br>657204|26091200|200000266831|001|650.000')
|
||||
->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');
|
||||
@@ -2808,7 +2734,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
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 (or) <br>657204|26091200|200000266831|001|650.000')
|
||||
->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');
|
||||
@@ -2841,7 +2767,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
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 (or) <br>657204|26091200|200000266831|001|650.000')
|
||||
->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');
|
||||
@@ -2874,7 +2800,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
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 (or) <br>657204|26091200|200000266831|001|650.000')
|
||||
->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');
|
||||
@@ -2914,7 +2840,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
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 (or) <br>657204|26091200|200000266831|001|650.000')
|
||||
->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');
|
||||
@@ -2948,7 +2874,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
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 (or) <br>657204|26091200|200000266831|001|650.000')
|
||||
->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');
|
||||
@@ -3271,305 +3197,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
]);
|
||||
|
||||
return;
|
||||
} elseif (preg_match($pattern5, $serNo, $matches)) {
|
||||
$coilPallet = 'CP-'.$matches['code'];
|
||||
$coilPattern = '/^CP-(?<code>\d+)$/i';
|
||||
|
||||
if (! preg_match($coilPattern, $serNo, $matches)) {
|
||||
Notification::make()
|
||||
->title('Invalid Coil Packing QR Format')
|
||||
->body("Scan valid Coil Packing QR code proceed!<br>Sample format : 'CP-2601001'")
|
||||
->danger()
|
||||
->seconds(1)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$coilMaster = CoilPacking::where('plant_id', $plantId)->where('coil_packing_number', $coilPallet)->first();
|
||||
|
||||
if (! $coilMaster) {
|
||||
Notification::make()
|
||||
->title('Master Pallet Not Found')
|
||||
->body("No record found for this Master Packing QR $coilPallet")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$coilItemCodes = CoilPacking::join('items', 'items.id', '=', 'coil_packings.item_id')
|
||||
->where('coil_packings.plant_id', $plantId)
|
||||
->where('coil_packings.coil_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($coilItemCodes, $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 = [];
|
||||
$invalidMaterialItems = [];
|
||||
|
||||
$coilItems1 = CoilPacking::join('items', 'items.id', '=', 'coil_packings.item_id')
|
||||
->where('coil_packings.plant_id', $plantId)
|
||||
->where('coil_packings.coil_packing_number', $wirePallet)
|
||||
->select(
|
||||
'items.code as item_code',
|
||||
'coil_packings.process_order',
|
||||
DB::raw('COUNT(*) as pallet_weight')
|
||||
)
|
||||
->groupBy('items.code', 'coil_packings.process_order')
|
||||
->get();
|
||||
|
||||
foreach ($coilItems1 as $coilItem) {
|
||||
$processOrder = $coilItem->process_order;
|
||||
$palletWeight = $coilItem->pallet_weight;
|
||||
$itemCode = $coilItem->item_code;
|
||||
|
||||
$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 = CoilPacking::where('coil_packings.plant_id', $plantId)
|
||||
->where('coil_packings.coil_packing_number', $coilPallet)
|
||||
->join('items', 'items.id', '=', 'coil_packings.item_id')
|
||||
->select(
|
||||
'items.code as item_code',
|
||||
DB::raw('COUNT(*) 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 coil count exceeds remaining quantity for invoice number '$invoiceNumber'for below item codes <br>$items")
|
||||
->danger()
|
||||
->seconds(5)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$wireItems = CoilPacking::join('items', 'items.id', '=', 'coil_packings.item_id')
|
||||
->where('coil_packings.coil_packing_number', $coilPallet)
|
||||
->select(
|
||||
'items.code as item_code',
|
||||
'coil_packings.process_order',
|
||||
DB::raw('COUNT(*) as pallet_weight')
|
||||
)
|
||||
->groupBy(
|
||||
'items.code',
|
||||
'coil_packings.process_order'
|
||||
)
|
||||
->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();
|
||||
|
||||
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
|
||||
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
|
||||
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
|
||||
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
|
||||
} else {
|
||||
$totMatQuan = $totQuan;
|
||||
$scanMatQuan = $scanMQuan;
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$itemCode = null;
|
||||
$this->currentItemCode = '';
|
||||
$batchNumber = null;
|
||||
@@ -3579,7 +3207,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
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 (or) <br>657204|26091200|200000266831|001|650.000')
|
||||
->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)
|
||||
->send();
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,6 @@ use App\Filament\Resources\ItemResource\Pages;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\Line;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Actions\Exports\Enums\ExportFormat;
|
||||
use Filament\Facades\Filament;
|
||||
@@ -126,41 +125,6 @@ class ItemResource extends Resource
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
}),
|
||||
Forms\Components\Select::make('line_id')
|
||||
->label('Line Name')
|
||||
// ->relationship('line', 'name')
|
||||
->searchable()
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
if (! $get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $get('plant_id'))->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$lineId = $get('line_id');
|
||||
if (! $lineId) {
|
||||
$set('mLineError', 'Please select a line first.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
// $grpWrkCnr = Line::find($lineId)->group_work_center;
|
||||
// if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
|
||||
// {
|
||||
// $set('mLineError', 'Please select a group work center line.');
|
||||
// $set('line_id', null);
|
||||
// return;
|
||||
// }
|
||||
$set('mLineError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('mLineError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('mLineError') ? $get('mLineError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('hourly_quantity')
|
||||
->required()
|
||||
->label('Hourly Quantity')
|
||||
@@ -205,13 +169,6 @@ class ItemResource extends Resource
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
// Forms\Components\Select::make('type')
|
||||
// ->label('Type')
|
||||
// ->reactive()
|
||||
// ->options([
|
||||
// 'internal_serial_number' => 'Internal Serial Number',
|
||||
// 'fes_serial_number' => 'FES Serial Number',
|
||||
// ]),
|
||||
])
|
||||
->columns(3),
|
||||
]);
|
||||
@@ -251,11 +208,6 @@ class ItemResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('description')
|
||||
->label('Description')
|
||||
->alignCenter()
|
||||
@@ -271,11 +223,6 @@ class ItemResource extends Resource
|
||||
->default('-')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
// Tables\Columns\TextColumn::make('type')
|
||||
// ->label('Type')
|
||||
// ->default('-')
|
||||
// ->alignCenter()
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
|
||||
@@ -202,9 +202,6 @@ class LineResource extends Resource
|
||||
'Welding Cell' => 'Welding Cell',
|
||||
'Die-Casting Cell' => 'Die-Casting Cell',
|
||||
'Brazzing Cell' => 'Brazzing Cell',
|
||||
'SFG-Int' => 'SFG-Int',
|
||||
'FG-Int' => 'FG-Int',
|
||||
'Base-FG Int' => 'Base-FG Int',
|
||||
])
|
||||
->searchable()
|
||||
->reactive()
|
||||
@@ -225,18 +222,6 @@ class LineResource extends Resource
|
||||
->hint(fn ($get) => $get('lTypeError') ? $get('lTypeError') : null)
|
||||
->hintColor('danger'),
|
||||
|
||||
Forms\Components\TextInput::make('uom')
|
||||
->label('Unit of Measure')
|
||||
->placeholder('Scan the valid uom'),
|
||||
|
||||
Forms\Components\Select::make('shift_flag')
|
||||
->label('Shift')
|
||||
->options([
|
||||
'1' => 'Day',
|
||||
'2' => 'Night',
|
||||
'0' => 'Day&Night',
|
||||
]),
|
||||
|
||||
Forms\Components\TextInput::make('no_of_operation')
|
||||
->label('No of Operation')
|
||||
->required()
|
||||
@@ -1081,22 +1066,6 @@ class LineResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('uom')
|
||||
->label('Unit of Measure')
|
||||
->default('-')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('shift_flag')
|
||||
->label('Shift')
|
||||
->formatStateUsing(fn ($state) => match ((string) $state) {
|
||||
'0' => 'Day&Night',
|
||||
'1' => 'Day',
|
||||
'2' => 'Night',
|
||||
default => 'Unknown',
|
||||
})
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('no_of_operation')
|
||||
->label('No of Operation')
|
||||
->alignCenter()
|
||||
@@ -1234,7 +1203,7 @@ class LineResource extends Resource
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('lines', function ($query) {
|
||||
return Plant::whereHas('items', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
@@ -1242,11 +1211,8 @@ class LineResource extends Resource
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('name', null);
|
||||
$set('type', null);
|
||||
$set('work_group_id', null);
|
||||
$set('created_from', null);
|
||||
$set('created_to', null);
|
||||
$set('code', null);
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
Select::make('name')
|
||||
->label('Search by Line Name')
|
||||
|
||||
@@ -28,7 +28,7 @@ class ModelMasterResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Laser Marking';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
@@ -335,7 +335,6 @@ class ModelMasterResource extends Resource
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->searchPlaceholder('Search Model Heading')
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
|
||||
@@ -38,15 +38,15 @@ class ModuleListResource extends Resource
|
||||
Forms\Components\TextInput::make('filter_name')
|
||||
->label('Filter Name')
|
||||
->required(),
|
||||
// Forms\Components\TextInput::make('file_name')
|
||||
// ->label('File Name')
|
||||
// ->required()
|
||||
// ->reactive()
|
||||
// ->extraAttributes([
|
||||
// 'x-data' => '{ value: "" }',
|
||||
// 'x-model' => 'value',
|
||||
// 'x-on:keydown.enter.prevent' => '$wire.process(value)',
|
||||
// ]),
|
||||
Forms\Components\TextInput::make('file_name')
|
||||
->label('File Name')
|
||||
->required()
|
||||
->reactive()
|
||||
->extraAttributes([
|
||||
'x-data' => '{ value: "" }',
|
||||
'x-model' => 'value',
|
||||
'x-on:keydown.enter.prevent' => '$wire.process(value)',
|
||||
]),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
|
||||
@@ -38,7 +38,7 @@ class PanelBoxValidationResource extends Resource
|
||||
{
|
||||
protected static ?string $model = PanelBoxValidation::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-clipboard-document-check';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Panel Box';
|
||||
|
||||
@@ -581,19 +581,6 @@ class PanelBoxValidationResource extends Resource
|
||||
$itemCode = $panelBoxCode;
|
||||
$serialNumber = $panelBoxSerialNo;
|
||||
|
||||
if (strlen($serialNumber) > 30) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Number')
|
||||
->body("Serial number cannot be greater than 30 characters. Current length: " . strlen($panelBoxSerialNo))
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$set('item_id', null);
|
||||
$set('serial_exists', false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$existInMasterPo = PanelGrMaster::where('document_number', $pOrder)->where('plant_id', $plantId)->first();
|
||||
|
||||
if(!$existInMasterPo){
|
||||
@@ -620,19 +607,6 @@ class PanelBoxValidationResource extends Resource
|
||||
return;
|
||||
}
|
||||
|
||||
$sticker = StickerMaster::where('plant_id', $plantId)->where('item_id', $iId->id)->first();
|
||||
|
||||
if(!$sticker){
|
||||
Notification::make()
|
||||
->title('Unknown Item Code')
|
||||
->body("Item code not found '{$iId->code}' in sticker master.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
$set('serial_exists', false);
|
||||
return;
|
||||
}
|
||||
|
||||
$existInMaster = PanelGrMaster::where('document_number', $pOrder)->where('inspection_lot_number', $inspecLotNo)->where('item_id', $iId->id)->where('plant_id', $plantId)->first();
|
||||
|
||||
if(!$existInMaster){
|
||||
@@ -696,6 +670,19 @@ class PanelBoxValidationResource extends Resource
|
||||
return;
|
||||
}
|
||||
|
||||
$sticker = StickerMaster::where('plant_id', $plantId)->where('item_id', $iId->id)->first();
|
||||
|
||||
if(!$sticker){
|
||||
Notification::make()
|
||||
->title('Unknown Item Code')
|
||||
->body("Item code not found '{$iId->code}' in sticker master.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
$set('serial_exists', false);
|
||||
return;
|
||||
}
|
||||
|
||||
$existQuanInPanel = PanelBoxValidation::where('plant_id', $plantId)->where('production_order', $pOrder)->where('inspection_lot_number', $inspecLotNo)->where('sticker_master_id', $sticker->id)->count();
|
||||
|
||||
if ($existQuanInPanel >= (int) $existInMaster->quantity) {
|
||||
@@ -717,7 +704,7 @@ class PanelBoxValidationResource extends Resource
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid QR Format')
|
||||
->body('QR must be in either PlantCode/ItemCode/SerialNumber or PlantCode/ItemCode/YearMM/SerialNumber format.')
|
||||
->body('QR must be in either ItemCode|SerialNumber or PlantCode/ItemCode/YearMM/SerialNumber format.')
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
@@ -825,7 +812,7 @@ class PanelBoxValidationResource extends Resource
|
||||
}
|
||||
}
|
||||
|
||||
$serialExists = PanelBoxValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->where('panel_box_supplier', $supplier)->first();
|
||||
$serialExists = PanelBoxValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->first();
|
||||
|
||||
if ($serialExists) {
|
||||
$set('serial_exists', true);
|
||||
@@ -989,6 +976,7 @@ class PanelBoxValidationResource extends Resource
|
||||
->hint(fn ($get) => $get('validationError') ? $get('validationError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Hidden::make('serial_exists')
|
||||
// ->default(false)
|
||||
->live()
|
||||
->dehydrated()
|
||||
->id('serial_exists'),
|
||||
@@ -1008,30 +996,19 @@ class PanelBoxValidationResource extends Resource
|
||||
$plantId = $get('plant_id');
|
||||
$pOrder = $get('production_order');
|
||||
$inspecLotNo = $get('inspection_lot_number');
|
||||
$supplierNo = $get('panel_box_supplier');
|
||||
|
||||
// $alreadyExists = PanelBoxValidation::where('serial_number', $serialNumber)
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->where('production_order', $pOrder)
|
||||
// ->where('inspection_lot_number', $inspecLotNo)
|
||||
// ->first();
|
||||
|
||||
$alreadyExists = PanelBoxValidation::where('serial_number', $serialNumber)
|
||||
->where('plant_id', $plantId)
|
||||
->where(function ($query) use ($pOrder, $inspecLotNo) {
|
||||
$query->where('production_order', $pOrder)
|
||||
->orWhere('inspection_lot_number', $inspecLotNo);
|
||||
})
|
||||
->first();
|
||||
|
||||
$alreadyExistsSupplier = PanelBoxValidation::where('plant_id', $plantId)->where('serial_number', $serialNumber)
|
||||
->where('panel_box_supplier', $supplierNo)
|
||||
->where('plant_id', $plantId)
|
||||
->where('production_order', $pOrder)
|
||||
->where('inspection_lot_number', $inspecLotNo)
|
||||
->first();
|
||||
|
||||
if ($alreadyExists) {
|
||||
Notification::make()
|
||||
->title('Duplicate Found')
|
||||
->body('This document number and inspection lot number have already been used for this serial number. Please provide a new document number and inspection lot number for rework...')
|
||||
->body(
|
||||
'This document number and inspection lot number have already been used for this serial number. Please provide a new document number and inspection lot number for rework...'
|
||||
)
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
@@ -1039,29 +1016,18 @@ class PanelBoxValidationResource extends Resource
|
||||
|
||||
return;
|
||||
}
|
||||
if($alreadyExistsSupplier)
|
||||
{
|
||||
if($alreadyExistsSupplier->panel_box_supplier != $supplierNo){
|
||||
Notification::make()
|
||||
->title('Supplier Mismatch')
|
||||
->body(
|
||||
'Supplier number does not match the existing record for this serial number. Please check the supplier number.'
|
||||
)
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$livewire->showChecklist = false;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$data = $get();
|
||||
|
||||
$hasCharacteristics = $livewire->checkIfHasCharacteristics($data);
|
||||
|
||||
\Log::info('CHARACTERISTICS RESULT', [
|
||||
'hasCharacteristics' => $hasCharacteristics,
|
||||
]);
|
||||
|
||||
if ($hasCharacteristics) {
|
||||
|
||||
\Log::info('SETTING SHOW CHECKLIST TRUE');
|
||||
|
||||
$livewire->showChecklist = true;
|
||||
$livewire->dispatch('close-modal');
|
||||
return;
|
||||
@@ -1140,8 +1106,7 @@ class PanelBoxValidationResource extends Resource
|
||||
return;
|
||||
}
|
||||
|
||||
// $extracted = trim(end($parts));
|
||||
$extracted = trim(implode('/', array_slice($parts, 2)));
|
||||
$extracted = trim(end($parts));
|
||||
|
||||
$expected = $get('serial_number');
|
||||
|
||||
@@ -1198,22 +1163,18 @@ class PanelBoxValidationResource extends Resource
|
||||
return;
|
||||
}
|
||||
|
||||
$parts = explode('/', $state);
|
||||
|
||||
if (count($parts) < 3) {
|
||||
|
||||
if (!preg_match('/^\d+\/\d+\/\d+\/\d+$/', $state)) {
|
||||
Notification::make()
|
||||
->title('Invalid QR Format')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber (Or) plantcode/panelboxcode/serialnumber')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber')
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
$set('pack_slip_panel_qr', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$extracted = trim(implode('/', array_slice($parts, 2)));
|
||||
|
||||
$expected = $get('serial_number');
|
||||
$parts = explode('/', $state);
|
||||
$extracted = trim(end($parts));
|
||||
|
||||
if ($extracted == '') {
|
||||
$set('packSlipPanelError', "SerialNumber can't be empty!");
|
||||
@@ -1221,6 +1182,8 @@ class PanelBoxValidationResource extends Resource
|
||||
return;
|
||||
}
|
||||
|
||||
$expected = $get('serial_number');
|
||||
|
||||
if ($extracted != $expected) {
|
||||
$set('packSlipPanelError', 'Pack Slip Panel serial does not match.');
|
||||
$set('pack_slip_panel', null);
|
||||
@@ -1230,13 +1193,13 @@ class PanelBoxValidationResource extends Resource
|
||||
$set('packSlipPanelError', null);
|
||||
$set('pack_slip_panel_qr', $extracted);
|
||||
$set('pack_slip_panel', '1');
|
||||
$panelParts = explode('/', $state);
|
||||
$panelParts = array_map('trim', explode('/', $state));
|
||||
|
||||
if (count($panelParts) < 3) {
|
||||
if (count($panelParts) != 4) {
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid QR Format')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber (Or) plantcode/panelboxcode/serialnumber')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber')
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
@@ -1245,7 +1208,9 @@ class PanelBoxValidationResource extends Resource
|
||||
|
||||
$supplier = $panelParts[0];
|
||||
$panelBoxCode = $panelParts[1];
|
||||
$panelBoxSerialNo = implode('/', array_slice($panelParts, 2));
|
||||
$yearMonth = $panelParts[2];
|
||||
$serialNumber = $panelParts[3];
|
||||
$panelBoxSerialNo = $yearMonth . $serialNumber;
|
||||
|
||||
$set('panel_box_supplier', $supplier);
|
||||
$set('panel_box_serial_number', $panelBoxSerialNo);
|
||||
@@ -1273,22 +1238,18 @@ class PanelBoxValidationResource extends Resource
|
||||
return;
|
||||
}
|
||||
|
||||
$parts = explode('/', $state);
|
||||
|
||||
if (count($parts) < 3) {
|
||||
|
||||
if (!preg_match('/^\d+\/\d+\/\d+\/\d+$/', $state)) {
|
||||
Notification::make()
|
||||
->title('Invalid QR Format')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber (Or) plantcode/panelboxcode/serialnumber')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber')
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
$set('serial_number_panel_qr', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$extracted = trim(implode('/', array_slice($parts, 2)));
|
||||
|
||||
$expected = $get('serial_number');
|
||||
$parts = explode('/', $state);
|
||||
$extracted = trim(end($parts));
|
||||
|
||||
if ($extracted == '') {
|
||||
$set('namePlatePanelError', "SerialNumber cant't be empty!");
|
||||
@@ -1307,13 +1268,13 @@ class PanelBoxValidationResource extends Resource
|
||||
$set('namePlatePanelError', null);
|
||||
$set('name_plate_panel_qr', $extracted);
|
||||
$set('name_plate_panel', '1');
|
||||
$panelParts = explode('/', $state);
|
||||
$panelParts = array_map('trim', explode('/', $state));
|
||||
|
||||
if (count($panelParts) < 3) {
|
||||
if (count($panelParts) != 4) {
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid QR Format')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber (Or) plantcode/panelboxcode/serialnumber')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber')
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
@@ -1322,7 +1283,9 @@ class PanelBoxValidationResource extends Resource
|
||||
|
||||
$supplier = $panelParts[0];
|
||||
$panelBoxCode = $panelParts[1];
|
||||
$panelBoxSerialNo = implode('/', array_slice($panelParts, 2));
|
||||
$yearMonth = $panelParts[2];
|
||||
$serialNumber = $panelParts[3];
|
||||
$panelBoxSerialNo = $yearMonth . $serialNumber;
|
||||
|
||||
$set('panel_box_supplier', $supplier);
|
||||
$set('panel_box_serial_number', $panelBoxSerialNo);
|
||||
@@ -1350,20 +1313,18 @@ class PanelBoxValidationResource extends Resource
|
||||
return;
|
||||
}
|
||||
|
||||
$parts = explode('/', $state);
|
||||
|
||||
if (count($parts) < 3) {
|
||||
|
||||
if (!preg_match('/^\d+\/\d+\/\d+\/\d+$/', $state)) {
|
||||
Notification::make()
|
||||
->title('Invalid QR Format')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber (Or) plantcode/panelboxcode/serialnumber')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber')
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
$set('serial_number_panel_qr', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$extracted = trim(implode('/', array_slice($parts, 2)));
|
||||
$parts = explode('/', $state);
|
||||
$extracted = trim(end($parts));
|
||||
|
||||
if ($extracted == '') {
|
||||
$set('tubeStickerPanelError', "SerialNumber can't be empty!");
|
||||
@@ -1382,13 +1343,13 @@ class PanelBoxValidationResource extends Resource
|
||||
$set('tubeStickerPanelError', null);
|
||||
$set('tube_sticker_panel_qr', $extracted);
|
||||
$set('tube_sticker_panel', '1');
|
||||
$panelParts = explode('/', $state);
|
||||
$panelParts = array_map('trim', explode('/', $state));
|
||||
|
||||
if (count($panelParts) < 3) {
|
||||
if (count($panelParts) != 4) {
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid QR Format')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber (Or) plantcode/panelboxcode/serialnumber')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber')
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
@@ -1397,7 +1358,9 @@ class PanelBoxValidationResource extends Resource
|
||||
|
||||
$supplier = $panelParts[0];
|
||||
$panelBoxCode = $panelParts[1];
|
||||
$panelBoxSerialNo = implode('/', array_slice($panelParts, 2));
|
||||
$yearMonth = $panelParts[2];
|
||||
$serialNumber = $panelParts[3];
|
||||
$panelBoxSerialNo = $yearMonth . $serialNumber;
|
||||
|
||||
$set('panel_box_supplier', $supplier);
|
||||
$set('panel_box_serial_number', $panelBoxSerialNo);
|
||||
@@ -1426,20 +1389,18 @@ class PanelBoxValidationResource extends Resource
|
||||
return;
|
||||
}
|
||||
|
||||
$parts = explode('/', $state);
|
||||
|
||||
if (count($parts) < 3) {
|
||||
|
||||
if (!preg_match('/^\d+\/\d+\/\d+\/\d+$/', $state)) {
|
||||
Notification::make()
|
||||
->title('Invalid QR Format')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber (Or) plantcode/panelboxcode/serialnumber')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber')
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
$set('serial_number_panel_qr', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$extracted = trim(implode('/', array_slice($parts, 2)));
|
||||
$parts = explode('/', $state);
|
||||
$extracted = trim(end($parts));
|
||||
|
||||
if ($extracted == '') {
|
||||
$set('warrantyCardPanelError', "SerialNumber can't be empty!");
|
||||
@@ -1458,13 +1419,13 @@ class PanelBoxValidationResource extends Resource
|
||||
$set('warrantyCardPanelError', null);
|
||||
$set('warranty_card_qr', $extracted);
|
||||
$set('warranty_card_panel', '1');
|
||||
$panelParts = explode('/', $state);
|
||||
$panelParts = array_map('trim', explode('/', $state));
|
||||
|
||||
if (count($panelParts) < 3) {
|
||||
if (count($panelParts) != 4) {
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid QR Format')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber (Or) plantcode/panelboxcode/serialnumber')
|
||||
->body('Expected format: plantcode/itemcode/yearmm/serialnumber')
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
@@ -1473,7 +1434,9 @@ class PanelBoxValidationResource extends Resource
|
||||
|
||||
$supplier = $panelParts[0];
|
||||
$panelBoxCode = $panelParts[1];
|
||||
$panelBoxSerialNo = implode('/', array_slice($panelParts, 2));
|
||||
$yearMonth = $panelParts[2];
|
||||
$serialNumber = $panelParts[3];
|
||||
$panelBoxSerialNo = $yearMonth . $serialNumber;
|
||||
|
||||
$set('panel_box_supplier', $supplier);
|
||||
$set('panel_box_serial_number', $panelBoxSerialNo);
|
||||
@@ -1905,16 +1868,6 @@ class PanelBoxValidationResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->label('Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'Ok' => 'success',
|
||||
'NotOk' => 'danger',
|
||||
default => 'gray',
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
@@ -2018,10 +1971,6 @@ class PanelBoxValidationResource extends Resource
|
||||
->label('Serial Number')
|
||||
->reactive()
|
||||
->placeholder('Enter Serial Number'),
|
||||
TextInput::make('panel_box_supplier')
|
||||
->label('Supplier Number')
|
||||
->reactive()
|
||||
->placeholder('Enter Supplier Number'),
|
||||
TextInput::make('inspection_lot_number')
|
||||
->label('Inspection Lot Number')
|
||||
->reactive()
|
||||
@@ -2037,13 +1986,6 @@ class PanelBoxValidationResource extends Resource
|
||||
0 => 'No',
|
||||
])
|
||||
->reactive(),
|
||||
Select::make('status')
|
||||
->label('Status')
|
||||
->options([
|
||||
'Ok' => 'Ok',
|
||||
'NotOk' => 'Not Ok',
|
||||
])
|
||||
->reactive(),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder('Select From DateTime')
|
||||
@@ -2057,7 +1999,7 @@ class PanelBoxValidationResource extends Resource
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['Line']) && empty($data['Item']) && empty($data['production_order']) && empty($data['serial_number']) && empty($data['panel_box_supplier']) && empty($data['inspection_lot_number']) && empty($data['panel_box_code']) && empty($data['rework_count']) && empty($data['status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
if (empty($data['Plant']) && empty($data['Line']) && empty($data['Item']) && empty($data['production_order']) && empty($data['serial_number']) && empty($data['inspection_lot_number']) && empty($data['panel_box_code']) && empty($data['rework_count']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
@@ -2093,16 +2035,12 @@ class PanelBoxValidationResource extends Resource
|
||||
$query->where('serial_number', 'like', '%'.$data['serial_number'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['panel_box_supplier'])) {
|
||||
$query->where('panel_box_supplier', $data['panel_box_supplier']);
|
||||
}
|
||||
|
||||
if (! empty($data['inspection_lot_number'])) {
|
||||
$query->where('inspection_lot_number', $data['inspection_lot_number']);
|
||||
$query->where('inspection_lot_number', 'like', '%'.$data['inspection_lot_number'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['panel_box_code'])) {
|
||||
$query->where('panel_box_code', $data['panel_box_code']);
|
||||
$query->where('panel_box_code', 'like', '%'.$data['panel_box_code'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['rework_count'])) {
|
||||
@@ -2114,10 +2052,6 @@ class PanelBoxValidationResource extends Resource
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['status'])) {
|
||||
$query->where('status', $data['status']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
@@ -2156,10 +2090,6 @@ class PanelBoxValidationResource extends Resource
|
||||
$indicators[] = 'Serial Number: '.$data['serial_number'];
|
||||
}
|
||||
|
||||
if (! empty($data['panel_box_supplier'])) {
|
||||
$indicators[] = 'Supplier No: '.$data['panel_box_supplier'];
|
||||
}
|
||||
|
||||
if (! empty($data['inspection_lot_number'])) {
|
||||
$indicators[] = 'Inspection Lot No: '.$data['inspection_lot_number'];
|
||||
}
|
||||
@@ -2168,10 +2098,6 @@ class PanelBoxValidationResource extends Resource
|
||||
$indicators[] = 'Panel Box Code: '.$data['panel_box_code'];
|
||||
}
|
||||
|
||||
if (! empty($data['status'])) {
|
||||
$indicators[] = 'Status: '.$data['status'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
@@ -165,6 +165,7 @@ class PanelGrMasterResource extends Resource
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('scanned_quantity')
|
||||
->label('Scanned Quantity')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->getStateUsing(function ($record) {
|
||||
|
||||
@@ -95,7 +95,7 @@ class ProductionOrderResource extends Resource
|
||||
return ($userHas && strlen($userHas) > 0) ? optional(ProductionOrder::where('plant_id', $userHas)->latest()->first())->item_id : optional(ProductionOrder::latest()->first())->item_id;
|
||||
})
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set, $get) {
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('quantity', null);
|
||||
$set('show_extra_fields', false);
|
||||
$set('start_date', null);
|
||||
@@ -291,11 +291,6 @@ class ProductionOrderResource extends Resource
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('print_status')
|
||||
->label('Status')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ProductionTempResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductionTempResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateProductionTemp extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ProductionTempResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ProductionTempResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductionTempResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditProductionTemp extends EditRecord
|
||||
{
|
||||
protected static string $resource = ProductionTempResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ProductionTempResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductionTempResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListProductionTemps extends ListRecords
|
||||
{
|
||||
protected static string $resource = ProductionTempResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ProductionTempResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductionTempResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewProductionTemp extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ProductionTempResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ class RequestCharacteristicResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Laser Marking';
|
||||
|
||||
protected static ?int $navigationSort = 4;
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
@@ -246,11 +246,11 @@ class RequestCharacteristicResource extends Resource
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
// ->default(function () {
|
||||
// $userHas = Filament::auth()->user()->plant_id;
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->aufnr ?? null;
|
||||
// })
|
||||
return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->aufnr ?? null;
|
||||
})
|
||||
->readOnly(fn ($get) => ($get('item_id') == null))
|
||||
->disabled(fn (Get $get) => ! empty($get('id'))),
|
||||
Forms\Components\TextInput::make('gernr')
|
||||
@@ -311,24 +311,19 @@ class RequestCharacteristicResource extends Resource
|
||||
$set('update_value', null);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
// ->default(function () {
|
||||
// $machineName = '';
|
||||
// $reqId = RequestCharacteristic::latest()->first()?->characteristic_approver_master_id;
|
||||
// if ($reqId) {
|
||||
// $reqMac = CharacteristicApproverMaster::where('id', $reqId)->first()?->machine_name;
|
||||
// $machineName = $reqMac ?? null;
|
||||
// } else {
|
||||
// $machineName = null;
|
||||
// }
|
||||
|
||||
// $userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? null : $machineName ?? null;
|
||||
// })
|
||||
->default(function () {
|
||||
$machineName = '';
|
||||
$reqId = RequestCharacteristic::latest()->first()?->characteristic_approver_master_id;
|
||||
if ($reqId) {
|
||||
$reqMac = CharacteristicApproverMaster::where('id', $reqId)->first()?->machine_name;
|
||||
$machineName = $reqMac ?? null;
|
||||
} else {
|
||||
$machineName = null;
|
||||
}
|
||||
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->characteristicApproverMaster->machine_name ?? null;
|
||||
return ($userHas && strlen($userHas) > 0) ? null : $machineName ?? null;
|
||||
})
|
||||
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
||||
if ($get('id')) {
|
||||
@@ -382,15 +377,21 @@ class RequestCharacteristicResource extends Resource
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
// ->default(function () {
|
||||
// $userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? null : 'Characteristic';
|
||||
// })
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->characteristicApproverMaster->approver_type ?? null;
|
||||
return ($userHas && strlen($userHas) > 0) ? null : 'Characteristic';
|
||||
// $approverType = null;
|
||||
// $reqId = RequestCharacteristic::latest()->first()?->characteristic_approver_master_id;
|
||||
// if ($reqId) {
|
||||
// $reqTyp = CharacteristicApproverMaster::where('id', $reqId)->first()?->approver_type;
|
||||
// $approverType = $reqTyp ?? null;
|
||||
// } else {
|
||||
// $approverType = null;
|
||||
// }
|
||||
|
||||
// // return optional(CharacteristicApproverMaster::latest()->first())->approver_type ?? null;
|
||||
// return $approverType ?? null;
|
||||
})
|
||||
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
||||
if ($get('id')) {
|
||||
@@ -436,31 +437,17 @@ class RequestCharacteristicResource extends Resource
|
||||
})
|
||||
->required()
|
||||
->disabled(fn (Get $get) => ! empty($get('id'))),
|
||||
Forms\Components\Select::make('model_type')
|
||||
Forms\Components\TextInput::make('model_type')
|
||||
->label('Model Type')
|
||||
->reactive()
|
||||
->nullable()
|
||||
->searchable()
|
||||
->required()
|
||||
->options(function () {
|
||||
return [
|
||||
'MOTOR' => 'MOTOR',
|
||||
'PUMP' => 'PUMP',
|
||||
'NAME_PLATE' => 'NAME_PLATE',
|
||||
'UNKNOWN' => 'UNKNOWN',
|
||||
];
|
||||
})
|
||||
->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);
|
||||
})
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->model_type ?? null;
|
||||
})
|
||||
->required()
|
||||
->disabled(fn (Get $get) => ! empty($get('id'))),
|
||||
Section::make('Request Characteristic Details')
|
||||
// ->columnSpan(['default' => 2, 'sm' => 4])
|
||||
@@ -580,21 +567,11 @@ class RequestCharacteristicResource extends Resource
|
||||
->label('Approver Status')
|
||||
->reactive()
|
||||
// ->live()
|
||||
->options(function (callable $set, callable $get) {
|
||||
$apprTyp = $get('approver_type');
|
||||
|
||||
if ($apprTyp && $apprTyp == 'Stop') {
|
||||
return [
|
||||
'Approved' => 'Approved',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
'Rejected' => 'Rejected',
|
||||
];
|
||||
})
|
||||
->options([
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
'Rejected' => 'Rejected',
|
||||
])
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if ($state) {// && empty($get('approved1_at'))
|
||||
$set('approved1_at', now()->toDateTimeString()); // now()->format('d-m-Y H:i:s')
|
||||
@@ -631,7 +608,7 @@ class RequestCharacteristicResource extends Resource
|
||||
}),
|
||||
Forms\Components\TextInput::make('approver_remark1')
|
||||
->label('Approver Remark')
|
||||
->reactive()
|
||||
->live()
|
||||
->maxLength(60)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$appStat = $get('approver_status1');
|
||||
@@ -706,21 +683,11 @@ class RequestCharacteristicResource extends Resource
|
||||
Forms\Components\Select::make('approver_status2')
|
||||
->label('Approver Status')
|
||||
->reactive()
|
||||
->options(function (callable $set, callable $get) {
|
||||
$apprTyp = $get('approver_type');
|
||||
|
||||
if ($apprTyp && $apprTyp == 'Stop') {
|
||||
return [
|
||||
'Approved' => 'Approved',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
'Rejected' => 'Rejected',
|
||||
];
|
||||
})
|
||||
->options([
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
'Rejected' => 'Rejected',
|
||||
])
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if ($state) {
|
||||
$set('approved2_at', now()->toDateTimeString());
|
||||
@@ -757,7 +724,7 @@ class RequestCharacteristicResource extends Resource
|
||||
}),
|
||||
Forms\Components\TextInput::make('approver_remark2')
|
||||
->label('Approver Remark')
|
||||
->reactive()
|
||||
->live()
|
||||
->maxLength(60)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$appStat = $get('approver_status2');
|
||||
@@ -830,21 +797,11 @@ class RequestCharacteristicResource extends Resource
|
||||
Forms\Components\Select::make('approver_status3')
|
||||
->label('Approver Status')
|
||||
->reactive()
|
||||
->options(function (callable $set, callable $get) {
|
||||
$apprTyp = $get('approver_type');
|
||||
|
||||
if ($apprTyp && $apprTyp == 'Stop') {
|
||||
return [
|
||||
'Approved' => 'Approved',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
'Rejected' => 'Rejected',
|
||||
];
|
||||
})
|
||||
->options([
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
'Rejected' => 'Rejected',
|
||||
])
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if ($state) {
|
||||
$set('approved3_at', now()->toDateTimeString());
|
||||
@@ -880,7 +837,7 @@ class RequestCharacteristicResource extends Resource
|
||||
}),
|
||||
Forms\Components\TextInput::make('approver_remark3')
|
||||
->label('Approver Remark')
|
||||
->reactive()
|
||||
->live()
|
||||
->maxLength(60)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$appStat = $get('approver_status3');
|
||||
@@ -1049,27 +1006,6 @@ class RequestCharacteristicResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.description')
|
||||
->label('Description')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('item.category')
|
||||
->label('Category')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('item.uom')
|
||||
->label('Unit of Measure')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('aufnr')
|
||||
->label('Job Number')
|
||||
->alignCenter()
|
||||
@@ -1372,23 +1308,9 @@ class RequestCharacteristicResource extends Resource
|
||||
TextInput::make('master_characteristic_field')
|
||||
->label('Master Characteristic Field')
|
||||
->placeholder('Enter Master Characteristic Field'),
|
||||
Select::make('model_type')
|
||||
->label('Search by Model Type')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return RequestCharacteristic::where('plant_id', $userHas)->pluck('model_type', 'model_type')->toArray();
|
||||
} elseif ($plantId) {
|
||||
return RequestCharacteristic::where('plant_id', $plantId)->select('model_type')->distinct()->pluck('model_type', 'model_type');
|
||||
} else {
|
||||
return RequestCharacteristic::select('model_type')->distinct()->pluck('model_type', 'model_type');
|
||||
}
|
||||
}),
|
||||
TextInput::make('model_type')
|
||||
->label('Model Type')
|
||||
->placeholder('Enter Model Type'),
|
||||
Select::make('approver_status')
|
||||
->label('Approver Status')
|
||||
->options([
|
||||
@@ -1475,7 +1397,7 @@ class RequestCharacteristicResource extends Resource
|
||||
}
|
||||
|
||||
if (! empty($data['model_type'])) {
|
||||
$query->where('model_type', $data['model_type']);
|
||||
$query->where('model_type', 'like', '%'.$data['model_type'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['work_flow_id'])) {
|
||||
|
||||
@@ -6,9 +6,7 @@ use App\Filament\Exports\StickerDetailExporter;
|
||||
use App\Filament\Imports\StickerDetailImporter;
|
||||
use App\Filament\Resources\StickerDetailResource\Pages;
|
||||
use App\Filament\Resources\StickerDetailResource\RelationManagers;
|
||||
use App\Models\Item;
|
||||
use App\Models\ClassCharacteristic;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ItemCharacteristic;
|
||||
use App\Models\StickerDetail;
|
||||
use App\Models\StickerStructureDetail;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
@@ -24,10 +22,6 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
|
||||
class StickerDetailResource extends Resource
|
||||
{
|
||||
@@ -96,7 +90,7 @@ class StickerDetailResource extends Resource
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(
|
||||
collect(Schema::getColumnListing('class_characteristics'))
|
||||
collect(Schema::getColumnListing('item_characteristics'))
|
||||
->reject(fn ($column) => in_array($column, [
|
||||
'id',
|
||||
'plant_id',
|
||||
@@ -117,14 +111,6 @@ class StickerDetailResource extends Resource
|
||||
->prepend('Plant Name', 'plant_name')
|
||||
->prepend('Plant Address', 'plant_address')
|
||||
->prepend('Current Date', 'current_date')
|
||||
->prepend('Tested By', 'tested_by')
|
||||
->prepend('Verified By', 'verified_by')
|
||||
->prepend('Approved By', 'approved_by')
|
||||
->prepend('Date Of Test', 'date_of_test')
|
||||
->prepend('Gross Wt Dual', 'zmm_grwt_pump_dual')
|
||||
->prepend('Net Wt Dual', 'zmm_newt_pump_dual')
|
||||
->prepend('MRP Dual', 'mrp_dual')
|
||||
->prepend('To Serial Number Dual', 'to_serial_number')
|
||||
->toArray()
|
||||
),
|
||||
Forms\Components\TextInput::make('string_value')
|
||||
@@ -135,7 +121,7 @@ class StickerDetailResource extends Resource
|
||||
->label('String Font')
|
||||
->reactive()
|
||||
->options(function () {
|
||||
$files = File::files(storage_path('app/private/fonts'));
|
||||
$files = File::files(storage_path('app/fonts'));
|
||||
|
||||
return collect($files)
|
||||
->mapWithKeys(function ($file) {
|
||||
@@ -410,49 +396,7 @@ class StickerDetailResource extends Resource
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('sticker_id')
|
||||
->label('Sticker ID')
|
||||
->reactive()
|
||||
->options(
|
||||
StickerStructureDetail::query()
|
||||
->pluck('sticker_id', 'id')
|
||||
->toArray()
|
||||
)
|
||||
->searchable()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('process_order', null);
|
||||
}),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['sticker_id'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (! empty($data['sticker_id'])) {
|
||||
|
||||
$stickerDetail = StickerStructureDetail::find($data['sticker_id']);
|
||||
|
||||
if ($stickerDetail) {
|
||||
$query->where('sticker_structure_detail_id',$stickerDetail->id);
|
||||
}
|
||||
}
|
||||
// $query->orderBy('created_at', 'asc');
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (!empty($data['sticker_id'])) {
|
||||
$indicators[] = 'Sticker ID: ' . StickerStructureDetail::where('id',$data['sticker_id'])->value('sticker_id');
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
|
||||
@@ -7,7 +7,7 @@ use App\Filament\Imports\StickerMappingMasterImporter;
|
||||
use App\Filament\Resources\StickerMappingMasterResource\Pages;
|
||||
use App\Filament\Resources\StickerMappingMasterResource\RelationManagers;
|
||||
use App\Models\Item;
|
||||
use App\Models\ClassCharacteristic;
|
||||
use App\Models\ItemCharacteristic;
|
||||
use App\Models\Machine;
|
||||
use App\Models\StickerMappingMaster;
|
||||
use App\Models\StickerStructureDetail;
|
||||
@@ -74,7 +74,7 @@ class StickerMappingMasterResource extends Resource
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
|
||||
Select::make('item_id')
|
||||
Select::make('item_characteristic_id')
|
||||
->label('Item Code')
|
||||
->reactive()
|
||||
//->relationship('item', 'code')
|
||||
@@ -85,8 +85,15 @@ class StickerMappingMasterResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
|
||||
return ItemCharacteristic::query()
|
||||
->whereHas('item', function ($query) use ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
})
|
||||
->with('item')
|
||||
->get()
|
||||
->mapWithKeys(fn ($ic) => [
|
||||
$ic->id => $ic->item->code,
|
||||
]);
|
||||
})
|
||||
->searchable()
|
||||
->required(),
|
||||
@@ -319,7 +326,7 @@ class StickerMappingMasterResource extends Resource
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
Tables\Columns\TextColumn::make('itemCharacteristic.item.code')
|
||||
->label('Item')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
|
||||
@@ -1,440 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\StickerOrderResource\Pages;
|
||||
use App\Filament\Resources\StickerOrderResource\RelationManagers;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerOrder;
|
||||
use App\Models\StickerStructureDetail;
|
||||
use App\Models\ItemCharacteristic;
|
||||
use App\Models\StickerMappingMaster;
|
||||
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\Get;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use App\Filament\Exports\StickerOrderExporter;
|
||||
use App\Filament\Imports\StickerOrderImporter;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
|
||||
class StickerOrderResource extends Resource
|
||||
{
|
||||
protected static ?string $model = StickerOrder::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Customized Sticker Printing';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->disabled(fn (string $context): bool => $context == 'edit')
|
||||
->dehydrated(true)
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(StickerOrder::latest()->first())->plant_id;
|
||||
})
|
||||
->reactive()
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('poPlantError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('poPlantError') ? $get('poPlantError') : null)
|
||||
->hintColor('danger')
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('item_id', null);
|
||||
$set('quantity', null);
|
||||
$set('start_date', null);
|
||||
$set('end_date', null);
|
||||
$set('production_order', null);
|
||||
$set('from_serial_number', null);
|
||||
$set('to_serial_number', null);
|
||||
}),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? optional(StickerOrder::where('plant_id', $userHas)->latest()->first())->item_id : optional(StickerOrder::latest()->first())->item_id;
|
||||
})
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set, $get) {
|
||||
$set('quantity', null);
|
||||
$set('start_date', null);
|
||||
$set('end_date', null);
|
||||
$set('production_order', null);
|
||||
$set('from_serial_number', null);
|
||||
$set('to_serial_number', null);
|
||||
}),
|
||||
Forms\Components\TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('serial_number')
|
||||
->label('Serial Number'),
|
||||
// Forms\Components\TextInput::make('print_status')
|
||||
// ->label('Print Status'),
|
||||
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.')
|
||||
->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('plant.name')
|
||||
->label('Plant Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Item Code')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->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('production_order')
|
||||
->label('Production Order')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('sticker_id')
|
||||
->label('Sticker ID')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('print_status')
|
||||
->label('Status')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('reprint_count')
|
||||
->label('Reprint Count')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
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('stickerOrder', 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);
|
||||
$set('Line', 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('stickerOrder', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('code', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('production_order', null);
|
||||
}),
|
||||
TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
->reactive()
|
||||
->placeholder('Enter Production Order')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Rework', null);
|
||||
}),
|
||||
TextInput::make('sticker_id')
|
||||
->label('Sticker ID')
|
||||
->reactive()
|
||||
->placeholder('Enter Sticker ID'),
|
||||
TextInput::make('from_serial_number')
|
||||
->label('From Serial Number')
|
||||
->reactive()
|
||||
->placeholder('Enter From Serial Number'),
|
||||
TextInput::make('to_serial_number')
|
||||
->label('To Serial Number')
|
||||
->reactive()
|
||||
->placeholder('Enter To Serial Number'),
|
||||
Select::make('print_status')
|
||||
->label('Status')
|
||||
->options([
|
||||
'Printed' => 'Printed',
|
||||
'Pending' => 'Pending',
|
||||
])
|
||||
->reactive(),
|
||||
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['Item']) && empty($data['production_order']) && empty($data['sticker_id']) && empty($data['from_serial_number']) && empty($data['to_serial_number']) && empty($data['print_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['production_order'])) {
|
||||
$query->where('production_order', 'like', '%'.$data['production_order'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['sticker_id'])) {
|
||||
$query->where('sticker_id', $data['sticker_id']);
|
||||
}
|
||||
|
||||
if (!empty($data['from_serial_number']) && !empty($data['to_serial_number'])) {
|
||||
|
||||
$from = $data['from_serial_number'];
|
||||
$to = $data['to_serial_number'];
|
||||
|
||||
$query->where(function ($q) use ($from, $to) {
|
||||
$q->whereBetween('from_serial_number', [$from, $to])
|
||||
->orWhereBetween('to_serial_number', [$from, $to]);
|
||||
});
|
||||
}
|
||||
|
||||
if(! empty($data['print_status'])){
|
||||
if($data['print_status'] == 'Printed'){
|
||||
$query->where('print_status', $data['print_status']);
|
||||
}
|
||||
else{
|
||||
$query->where(function ($q) {
|
||||
$q->whereNull('print_status')
|
||||
->orWhere('print_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['production_order'])) {
|
||||
$indicators[] = 'Production Order: '.$data['production_order'];
|
||||
}
|
||||
|
||||
if (! empty($data['sticker_id'])) {
|
||||
$indicators[] = 'Sticker ID: '.$data['sticker_id'];
|
||||
}
|
||||
|
||||
if (! empty($data['from_serial_number'])) {
|
||||
$indicators[] = 'From Serial Number: '.$data['from_serial_number'];
|
||||
}
|
||||
|
||||
if (! empty($data['to_serial_number'])) {
|
||||
$indicators[] = 'To Serial Number: '.$data['to_serial_number'];
|
||||
}
|
||||
|
||||
if (! empty($data['print_status'])) {
|
||||
$indicators[] = 'Status: '.$data['print_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([
|
||||
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([
|
||||
ImportAction::make()
|
||||
->label('Import Sticker Order')
|
||||
->color('warning')
|
||||
->importer(StickerOrderImporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import sticker order');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Sticker Order')
|
||||
->color('warning')
|
||||
->exporter(StickerOrderExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export sticker order');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListStickerOrders::route('/'),
|
||||
'create' => Pages\CreateStickerOrder::route('/create'),
|
||||
'view' => Pages\ViewStickerOrder::route('/{record}'),
|
||||
'edit' => Pages\EditStickerOrder::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\StickerOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\StickerOrderResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateStickerOrder extends CreateRecord
|
||||
{
|
||||
protected static string $resource = StickerOrderResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\StickerOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\StickerOrderResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditStickerOrder extends EditRecord
|
||||
{
|
||||
protected static string $resource = StickerOrderResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\StickerOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\StickerOrderResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListStickerOrders extends ListRecords
|
||||
{
|
||||
protected static string $resource = StickerOrderResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\StickerOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\StickerOrderResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewStickerOrder extends ViewRecord
|
||||
{
|
||||
protected static string $resource = StickerOrderResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -39,14 +39,10 @@ class StickerStructureDetailResource extends Resource
|
||||
->label('Sticker ID')
|
||||
->reactive()
|
||||
->required()
|
||||
->unique(
|
||||
table: 'sticker_structure_details',
|
||||
column: 'sticker_id',
|
||||
ignoreRecord: true
|
||||
)
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('sticker_id_live', $state);
|
||||
}),
|
||||
//\Log::info('Sticker ID typed:', ['sticker_id' => $state]);
|
||||
$set('sticker_id_live', $state);
|
||||
}),
|
||||
Forms\Components\TextInput::make('sticker_width')
|
||||
->label('Sticker Width')
|
||||
->required(),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,815 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\TempStopCharacteristicExporter;
|
||||
use App\Filament\Imports\TempStopCharacteristicImporter;
|
||||
use App\Filament\Resources\TempStopCharacteristicResource\Pages;
|
||||
use App\Models\Item;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use App\Models\TempStopCharacteristic;
|
||||
use Filament\Facades\Filament;
|
||||
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\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TempStopCharacteristicResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TempStopCharacteristic::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Laser Marking';
|
||||
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->required()
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? null : optional(TempStopCharacteristic::latest()->first())->plant_id ?? null;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('item_id', null);
|
||||
$set('aufnr', null);
|
||||
$set('gernr', null);
|
||||
$set('machine_id', null);
|
||||
$set('machine_name', null);
|
||||
$set('has_stop_flow_id', '2');
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id'))),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
// ->relationship('item', 'id')
|
||||
->reactive()
|
||||
->required()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('aufnr', null);
|
||||
$set('gernr', null);
|
||||
$set('has_stop_flow_id', '2');
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? null : optional(TempStopCharacteristic::latest()->first())->item_id ?? null;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id'))),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
->label('Work Center')
|
||||
// ->relationship('machine', 'name')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
})
|
||||
->required()
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? null : optional(TempStopCharacteristic::latest()->first())->machine_id ?? null;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('machine_name', null);
|
||||
$set('has_stop_flow_id', '2');
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id'))),
|
||||
Forms\Components\TextInput::make('machine_name')
|
||||
->label('Machine Name')
|
||||
->reactive()
|
||||
->nullable()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('has_stop_flow_id', '2');
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required()
|
||||
->readonly(fn (Get $get) => ! empty($get('id'))),
|
||||
Forms\Components\TextInput::make('aufnr')
|
||||
->label('Job Number')
|
||||
->reactive()
|
||||
->numeric()
|
||||
->minlength(7)
|
||||
->maxlength(10)
|
||||
->required(function (callable $get) {
|
||||
$item = $get('item_id');
|
||||
if ($item) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('gernr', null);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? null : optional(TempStopCharacteristic::latest()->first())->aufnr ?? null;
|
||||
})
|
||||
->readonly(fn (Get $get) => ! empty($get('id')) || ! $get('item_id')),
|
||||
Forms\Components\TextInput::make('gernr')
|
||||
->label('Serial Number')
|
||||
->reactive()
|
||||
->minLength(13)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required()
|
||||
->readonly(fn (Get $get) => ! empty($get('id')) || ! $get('aufnr')),
|
||||
Forms\Components\TextInput::make('zmm_heading')
|
||||
->label('Zmm Heading')
|
||||
->reactive()
|
||||
->nullable()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required()
|
||||
->readonly(fn (Get $get) => ! empty($get('id'))),
|
||||
Forms\Components\Select::make('model_type')
|
||||
->label('Model Type')
|
||||
->reactive()
|
||||
->nullable()
|
||||
->searchable()
|
||||
->required()
|
||||
->options(function () {
|
||||
return [
|
||||
'MOTOR' => 'MOTOR',
|
||||
'PUMP' => 'PUMP',
|
||||
'NAME_PLATE' => 'NAME_PLATE',
|
||||
'UNKNOWN' => 'UNKNOWN',
|
||||
];
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default('MOTOR')
|
||||
->disabled(fn (Get $get) => ! empty($get('id'))),
|
||||
Forms\Components\TextInput::make('characteristic_field')
|
||||
->label('Master Characteristic Field')
|
||||
->reactive()
|
||||
->nullable()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required()
|
||||
->readonly(fn (Get $get) => ! empty($get('id'))),
|
||||
Forms\Components\TextInput::make('samlight_logged_name')
|
||||
->label('SAMLight Logged Name')
|
||||
->reactive()
|
||||
->nullable()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->readonly(fn (Get $get) => ! empty($get('id'))),
|
||||
Forms\Components\DateTimePicker::make('stopped_at')
|
||||
->label('Stopped At')
|
||||
->default(now())
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required()
|
||||
->disabled(fn (Get $get) => ! empty($get('id'))),
|
||||
Forms\Components\TextInput::make('stopped_by')
|
||||
->label('Stopped By')
|
||||
->reactive()
|
||||
->default(Filament::auth()->user()?->name)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required()
|
||||
->readonly(fn (Get $get) => ! empty($get('id'))),
|
||||
Forms\Components\TextInput::make('has_stop_flow_id')
|
||||
->label('Has Stop Flow ID')
|
||||
->reactive()
|
||||
->default('2')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$curId = $get('id');
|
||||
if (! $curId) {
|
||||
$set('has_stop_flow_id', '2');
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required()
|
||||
->readonly(fn (Get $get) => ! empty($get('id'))),
|
||||
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),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
])
|
||||
->columns(['default' => 1, 'sm' => 2]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->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('plant.name')
|
||||
->label('Plant Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
->label('Work Center')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine_name')
|
||||
->label('Machine Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Item Code')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.description')
|
||||
->label('Description')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('item.category')
|
||||
->label('Category')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('item.uom')
|
||||
->label('Unit of Measure')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('aufnr')
|
||||
->label('Job Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('gernr')
|
||||
->label('Serial Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('zmm_heading')
|
||||
->label('Zmm Heading')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('model_type')
|
||||
->label('Model Type')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristic_field')
|
||||
->label('Master Characteristic Field')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->formatStateUsing(fn (string $state): string => strtoupper(__($state)))
|
||||
->extraAttributes(['class' => 'uppercase'])
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('samlight_logged_name')
|
||||
->label('SAMLIGHT LOGGED NAME')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stopped_at')
|
||||
->label('Stopped At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stopped_by')
|
||||
->label('Stopped By')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('has_stop_flow_id')
|
||||
->label('Has Stop Flow ID')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->searchPlaceholder('Search Job / Serial No')
|
||||
->filters([
|
||||
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('tempStopCharacteristics', 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('item_id', 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('tempStopCharacteristics', 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);
|
||||
}),
|
||||
TextInput::make('machine_name')
|
||||
->label('Machine Name')
|
||||
->placeholder('Enter Machine Name'),
|
||||
Select::make('item_id')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::whereHas('tempStopCharacteristics', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('code', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
// $set('aufnr', null);
|
||||
}),
|
||||
TextInput::make('aufnr')
|
||||
->label('Job Number')
|
||||
->placeholder('Enter Job Number')
|
||||
->numeric()
|
||||
->maxlength(10),
|
||||
TextInput::make('gernr')
|
||||
->label('Serial Number')
|
||||
->placeholder('Enter Serial Number')
|
||||
->numeric(),
|
||||
TextInput::make('zmm_heading')
|
||||
->label('Zmm Heading')
|
||||
->placeholder('Enter Zmm Heading'),
|
||||
Select::make('model_type')
|
||||
->label('Search by Model Type')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return TempStopCharacteristic::where('plant_id', $userHas)->pluck('model_type', 'model_type')->toArray();
|
||||
} elseif ($plantId) {
|
||||
return TempStopCharacteristic::where('plant_id', $plantId)->select('model_type')->distinct()->pluck('model_type', 'model_type');
|
||||
} else {
|
||||
return TempStopCharacteristic::select('model_type')->distinct()->pluck('model_type', 'model_type');
|
||||
}
|
||||
}),
|
||||
TextInput::make('characteristic_field')
|
||||
->label('Master Characteristic Field')
|
||||
->placeholder('Enter Master Characteristic Field'),
|
||||
TextInput::make('samlight_logged_name')
|
||||
->label('Samlight Logged Name')
|
||||
->placeholder('Enter Samlight Logged Name'),
|
||||
Select::make('stopped_by')
|
||||
->label('Search by Stopped By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
return TempStopCharacteristic::whereNotNull('stopped_by')->select('stopped_by')->distinct()->pluck('stopped_by', 'stopped_by');
|
||||
} else {
|
||||
return TempStopCharacteristic::where('plant_id', $plantId)->whereNotNull('stopped_by')->select('stopped_by')->distinct()->pluck('stopped_by', 'stopped_by');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
DateTimePicker::make('stopped_from')
|
||||
->label('Stopped From')
|
||||
->placeholder('Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('stopped_to')
|
||||
->label('Stopped To')
|
||||
->placeholder('Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
Select::make('created_by')
|
||||
->label('Search by Created By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
return TempStopCharacteristic::whereNotNull('created_by')->select('created_by')->distinct()->pluck('created_by', 'created_by');
|
||||
} else {
|
||||
return TempStopCharacteristic::where('plant_id', $plantId)->whereNotNull('created_by')->select('created_by')->distinct()->pluck('created_by', 'created_by');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
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),
|
||||
Select::make('updated_by')
|
||||
->label('Search by Updated By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
return TempStopCharacteristic::whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
|
||||
} else {
|
||||
return TempStopCharacteristic::where('plant_id', $plantId)->whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
DateTimePicker::make(name: 'updated_from')
|
||||
->label('Updated From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('updated_to')
|
||||
->label('Updated To')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
TextInput::make('has_stop_flow_id')
|
||||
->label('Has Stop Flow ID')
|
||||
->placeholder('Enter Has Stop Flow ID'),
|
||||
])
|
||||
->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['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['zmm_heading']) && empty($data['model_type']) && empty($data['characteristic_field']) && empty($data['samlight_logged_name']) && empty($data['stopped_by']) && empty($data['stopped_from']) && empty($data['stopped_to']) && empty($data['created_by']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_by']) && empty($data['updated_from']) && empty($data['updated_to']) && empty($data['has_stop_flow_id'])) {
|
||||
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['item_id'])) {
|
||||
$query->where('item_id', $data['item_id']);
|
||||
}
|
||||
|
||||
if (! empty($data['aufnr'])) {
|
||||
$query->where('aufnr', 'like', '%'.$data['aufnr'].'%');
|
||||
}
|
||||
|
||||
if (! empty($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', $data['model_type']);
|
||||
}
|
||||
|
||||
if (! empty($data['characteristic_field'])) {
|
||||
$query->where('characteristic_field', 'like', '%'.$data['characteristic_field'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['samlight_logged_name'])) {
|
||||
$query->where('samlight_logged_name', 'like', '%'.$data['samlight_logged_name'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['stopped_by'])) {
|
||||
$query->where('stopped_by', $data['stopped_by']);
|
||||
}
|
||||
|
||||
if (! empty($data['stopped_from'])) {
|
||||
$query->where('stopped_at', '>=', $data['stopped_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['stopped_to'])) {
|
||||
$query->where('stopped_at', '<=', $data['stopped_to']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_by'])) {
|
||||
$query->where('created_by', $data['created_by']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_by'])) {
|
||||
$query->where('updated_by', $data['updated_by']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_from'])) {
|
||||
$query->where('updated_at', '>=', $data['updated_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_to'])) {
|
||||
$query->where('updated_at', '<=', $data['updated_to']);
|
||||
}
|
||||
|
||||
if (! empty($data['has_stop_flow_id'])) {
|
||||
$query->where('has_stop_flow_id', 'like', '%'.$data['has_stop_flow_id'].'%');
|
||||
}
|
||||
|
||||
})
|
||||
->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['item_id'])) {
|
||||
$indicators[] = 'Item Code: '.Item::where('id', $data['item_id'])->value('code');
|
||||
}
|
||||
|
||||
if (! empty($data['aufnr'])) {
|
||||
$indicators[] = 'Job No: '.$data['aufnr'];
|
||||
}
|
||||
|
||||
if (! empty($data['gernr'])) {
|
||||
$indicators[] = 'Serial No: '.$data['gernr'];
|
||||
}
|
||||
|
||||
if (! empty($data['zmm_heading'])) {
|
||||
$indicators[] = 'Zmm Heading: '.$data['zmm_heading'];
|
||||
}
|
||||
|
||||
if (! empty($data['model_type'])) {
|
||||
$indicators[] = 'Model Type: '.$data['model_type'];
|
||||
}
|
||||
|
||||
if (! empty($data['characteristic_field'])) {
|
||||
$indicators[] = 'Master Characteristic Field: '.$data['characteristic_field'];
|
||||
}
|
||||
|
||||
if (! empty($data['work_flow_id'])) {
|
||||
$indicators[] = 'Work Flow ID: '.$data['work_flow_id'];
|
||||
}
|
||||
|
||||
if (! empty($data['samlight_logged_name'])) {
|
||||
$indicators[] = 'Samlight Logged Name: '.$data['samlight_logged_name'];
|
||||
}
|
||||
|
||||
if (! empty($data['stopped_by'])) {
|
||||
$indicators[] = 'Stopped By: '.$data['stopped_by'];
|
||||
}
|
||||
|
||||
if (! empty($data['stopped_from'])) {
|
||||
$indicators[] = 'Stopped From: '.$data['stopped_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['stopped_to'])) {
|
||||
$indicators[] = 'Stopped To: '.$data['stopped_to'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_by'])) {
|
||||
$indicators[] = 'Created By: '.$data['created_by'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'Created From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$indicators[] = 'Created To: '.$data['created_to'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_by'])) {
|
||||
$indicators[] = 'Updated By: '.$data['updated_by'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_from'])) {
|
||||
$indicators[] = 'Updated From: '.$data['updated_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_to'])) {
|
||||
$indicators[] = 'Updated To: '.$data['updated_to'];
|
||||
}
|
||||
|
||||
if (! empty($data['has_stop_flow_id'])) {
|
||||
$indicators[] = 'Stop Flow ID: '.$data['has_stop_flow_id'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->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([
|
||||
ImportAction::make()
|
||||
->label('Import Temp Stop Characteristics')
|
||||
->color('warning')
|
||||
->importer(TempStopCharacteristicImporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import temp stop characteristics');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Temp Stop Characteristics')
|
||||
->color('warning')
|
||||
->exporter(TempStopCharacteristicExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export temp stop characteristics');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListTempStopCharacteristics::route('/'),
|
||||
'create' => Pages\CreateTempStopCharacteristic::route('/create'),
|
||||
'view' => Pages\ViewTempStopCharacteristic::route('/{record}'),
|
||||
'edit' => Pages\EditTempStopCharacteristic::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TempStopCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TempStopCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTempStopCharacteristic extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TempStopCharacteristicResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TempStopCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TempStopCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTempStopCharacteristic extends EditRecord
|
||||
{
|
||||
protected static string $resource = TempStopCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TempStopCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TempStopCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTempStopCharacteristics extends ListRecords
|
||||
{
|
||||
protected static string $resource = TempStopCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TempStopCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TempStopCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewTempStopCharacteristic extends ViewRecord
|
||||
{
|
||||
protected static string $resource = TempStopCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,293 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\TestApprovalMappingExporter;
|
||||
use App\Filament\Imports\TestApprovalMappingImporter;
|
||||
use App\Filament\Resources\TestApprovalMappingResource\Pages;
|
||||
use App\Filament\Resources\TestApprovalMappingResource\RelationManagers;
|
||||
use App\Models\Line;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use App\Models\TestApprovalMapping;
|
||||
use App\Models\WorkGroupMaster;
|
||||
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\Get;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
|
||||
class TestApprovalMappingResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TestApprovalMapping::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Customized Sticker Printing';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->searchable()
|
||||
->required()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(TestApprovalMapping::latest()->first())->plant_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
$set('line_id', null);
|
||||
$set('work_group_master_id', null);
|
||||
$set('machine_id', null);
|
||||
$set('tPrError', 'Please select a plant first.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
$set('line_id', null);
|
||||
$set('machine_id', null);
|
||||
$set('tPrError', null);
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('tPrError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('tPrError') ? $get('tPrError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('line_id')
|
||||
->label('Line Name')
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $plantId)
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(TestApprovalMapping::latest()->first())->line_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('work_group_master_id', null);
|
||||
$set('machine_id', null);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Select::make('work_group_master_id')
|
||||
->label('Work Group Center')
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return WorkGroupMaster::where('plant_id', $plantId)
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(TestApprovalMapping::latest()->first())->work_group_master_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('machine_id', null);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
->label('Work Center')
|
||||
// ->relationship('machine', 'work_center')
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$lineId = $get('line_id');
|
||||
if (! $plantId || ! $lineId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Only show machines for the selected line
|
||||
return Machine::where('plant_id', $plantId)
|
||||
->where('line_id', $lineId)
|
||||
->pluck('work_center', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(TestApprovalMapping::latest()->first())->machine_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('tested_by')
|
||||
->label('Tested By'),
|
||||
Forms\Components\TextInput::make('verified_by')
|
||||
->label('Verified By'),
|
||||
Forms\Components\TextInput::make('approved_by')
|
||||
->label('Approved By'),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(fn () => Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(fn () => Filament::auth()->user()?->name),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
]);
|
||||
}
|
||||
|
||||
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('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroupMaster.name')
|
||||
->label('Work Group Center')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
->label('Machine')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('tested_by')
|
||||
->label('Tested By')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('verified_by')
|
||||
->label('Verified By')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('approved_by')
|
||||
->label('Approved By')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->sortable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->label('Import Test Approval Mapping')
|
||||
->color('warning')
|
||||
->importer(TestApprovalMappingImporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import test approval mapping');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Test Approval Mapping')
|
||||
->color('warning')
|
||||
->exporter(TestApprovalMappingExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export test approval mapping');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListTestApprovalMappings::route('/'),
|
||||
'create' => Pages\CreateTestApprovalMapping::route('/create'),
|
||||
'view' => Pages\ViewTestApprovalMapping::route('/{record}'),
|
||||
'edit' => Pages\EditTestApprovalMapping::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TestApprovalMappingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TestApprovalMappingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTestApprovalMapping extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TestApprovalMappingResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TestApprovalMappingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TestApprovalMappingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTestApprovalMapping extends EditRecord
|
||||
{
|
||||
protected static string $resource = TestApprovalMappingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TestApprovalMappingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TestApprovalMappingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTestApprovalMappings extends ListRecords
|
||||
{
|
||||
protected static string $resource = TestApprovalMappingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TestApprovalMappingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TestApprovalMappingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewTestApprovalMapping extends ViewRecord
|
||||
{
|
||||
protected static string $resource = TestApprovalMappingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,7 @@ class WindedSerialValidationErrorResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Laser Marking';
|
||||
|
||||
protected static ?int $navigationSort = 7;
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
@@ -141,8 +141,7 @@ class WindedSerialValidationErrorResource extends Resource
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->readOnly(fn (Get $get) => $get('id')),
|
||||
}),
|
||||
Forms\Components\TextInput::make('aufnr')
|
||||
->label('AUFNR')
|
||||
->placeholder('Scan the AUFNR')
|
||||
@@ -151,8 +150,7 @@ class WindedSerialValidationErrorResource extends Resource
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->readOnly(fn (Get $get) => $get('id')),
|
||||
}),
|
||||
Forms\Components\TextInput::make('gernr')
|
||||
->label('GERNR')
|
||||
->placeholder('Scan the GERNR')
|
||||
@@ -161,8 +159,7 @@ class WindedSerialValidationErrorResource extends Resource
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->readOnly(fn (Get $get) => $get('id')),
|
||||
}),
|
||||
Forms\Components\TextInput::make('model_type')
|
||||
->label('Model Type')
|
||||
->placeholder('Scan the Model Type')
|
||||
@@ -171,8 +168,7 @@ class WindedSerialValidationErrorResource extends Resource
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->readOnly(fn (Get $get) => $get('id')),
|
||||
}),
|
||||
Forms\Components\TextInput::make('winded_qr')
|
||||
->label('Winded QR')
|
||||
->placeholder('Scan the Winded QR')
|
||||
@@ -180,8 +176,7 @@ class WindedSerialValidationErrorResource extends Resource
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->readOnly(fn (Get $get) => $get('id')),
|
||||
}),
|
||||
Forms\Components\TextInput::make('winded_code')
|
||||
->label('Winded Code')
|
||||
->placeholder('Scan the Winded Code')
|
||||
@@ -189,8 +184,7 @@ class WindedSerialValidationErrorResource extends Resource
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->readOnly(fn (Get $get) => $get('id')),
|
||||
}),
|
||||
Forms\Components\TextInput::make('winded_serial_number')
|
||||
->label('Winded Serial Number')
|
||||
->placeholder('Scan the Winded Serial Number')
|
||||
@@ -198,8 +192,7 @@ class WindedSerialValidationErrorResource extends Resource
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->readOnly(fn (Get $get) => $get('id')),
|
||||
}),
|
||||
Forms\Components\TextInput::make('winded_status')
|
||||
->label('Winded Status')
|
||||
->placeholder('Scan the Winded Status')
|
||||
@@ -208,8 +201,7 @@ class WindedSerialValidationErrorResource extends Resource
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->readOnly(fn (Get $get) => $get('id')),
|
||||
}),
|
||||
Forms\Components\TextInput::make('created_by')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->readOnly()
|
||||
@@ -340,7 +332,6 @@ class WindedSerialValidationErrorResource extends Resource
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->searchPlaceholder('Search Job / Serial No')
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
|
||||
@@ -424,93 +424,6 @@ class CharacteristicApprovalController extends Controller
|
||||
return response()->json(['status' => true, 'message' => 'Status updated successfully']);
|
||||
}
|
||||
|
||||
//..Laser Stop
|
||||
|
||||
public function laserApproveForm(Request $request)
|
||||
{
|
||||
$id = $request->query('id');
|
||||
$level = (int) $request->query('level');
|
||||
|
||||
$record = RequestCharacteristic::findOrFail($id);
|
||||
|
||||
[$statusColumn, $approvedAtColumn, $remarkColumn] = match ($level) {
|
||||
1 => ['approver_status1', 'approved1_at', 'approver_remark1'],
|
||||
2 => ['approver_status2', 'approved2_at', 'approver_remark2'],
|
||||
3 => ['approver_status3', 'approved3_at', 'approver_remark3'],
|
||||
default => abort(403, 'Invalid approver level'),
|
||||
};
|
||||
|
||||
$levels = [
|
||||
1 => 'approver_status1',
|
||||
2 => 'approver_status2',
|
||||
3 => 'approver_status3',
|
||||
];
|
||||
|
||||
$currentStatusColumn = $levels[$level];
|
||||
|
||||
$currentStatus = $record->$statusColumn;
|
||||
|
||||
if (in_array($currentStatus, ['Approved', 'Rejected'])) {
|
||||
return view('approval.already-processed', [
|
||||
'status' => $currentStatus,
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($levels as $lvl => $column) {
|
||||
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
|
||||
return view('approval.already-processed', [
|
||||
'status' => $record->$column,
|
||||
'message' => 'Your request has already been processed by another approver',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// foreach ($levels as $lvl => $column) {
|
||||
// if ($record->$column == 'Hold') {
|
||||
|
||||
// if ($lvl == $level) {
|
||||
// return view('approval.reject-form', compact('id', 'level'));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return view('approval.already-processed', [
|
||||
// 'status' => 'Hold',
|
||||
// 'message' => 'On Hold',
|
||||
// ]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
$allowedMailStatusByLevel = [
|
||||
1 => 'Sent',
|
||||
2 => 'Sent-Mail2',
|
||||
3 => 'Sent-Mail3',
|
||||
];
|
||||
|
||||
$expectedMailStatus = $allowedMailStatusByLevel[$level] ?? null;
|
||||
|
||||
if ($record->mail_status != $expectedMailStatus) {
|
||||
return view('approval.approve-level', [
|
||||
'status' => $currentStatus,
|
||||
'message' => 'Your approval time limit has expired.',
|
||||
]);
|
||||
}
|
||||
|
||||
return view('approval.approve-form', compact('id', 'level'));
|
||||
}
|
||||
|
||||
|
||||
public function laserApproveSave(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'id' => 'required|integer',
|
||||
'level' => 'required|integer',
|
||||
'remark' => 'nullable|string',
|
||||
]);
|
||||
|
||||
return $this->updateStatus($request, 'Approved', false);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -288,52 +288,6 @@ class PalletController extends Controller
|
||||
// $mpdf->Output('qr-label.pdf', 'I');
|
||||
}
|
||||
|
||||
|
||||
public function downloadCoilQrPdf($palletNo)
|
||||
{
|
||||
$qrCode = new QrCode($palletNo);
|
||||
$output = new Output\Png;
|
||||
$qrBinary = $output->output($qrCode, 100);
|
||||
$qrBase64 = base64_encode($qrBinary);
|
||||
|
||||
$htmlBlock = '
|
||||
<table class="sticker-table">
|
||||
<tr>
|
||||
<td class="qr-cell">
|
||||
<img class="qr" src="data:image/png;base64,'.$qrBase64.'" alt="QR" />
|
||||
</td>
|
||||
<td class="text-cell">
|
||||
'.htmlspecialchars($palletNo).'
|
||||
</td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
return '
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body { margin: 0; padding: 0; width: 50mm; height: auto; font-size: 10pt; font-family: DejaVu Sans, sans-serif; }
|
||||
.sticker-table { width: 50mm; height: 60mm; border-collapse: collapse; page-break-after: always; }
|
||||
.qr-cell { width: 50mm; text-align: right; vertical-align: bottom; padding-left: -8mm; padding-top: 0mm; }
|
||||
.text-cell { text-align: left; vertical-align: middle; font-size: 22pt; padding-left: 1mm; padding-top: 18mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; }
|
||||
img.qr { width: 40mm; height: 40mm; display: block; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
'.$htmlBlock.$htmlBlock.'
|
||||
<script>
|
||||
window.onload = function () {
|
||||
window.print();
|
||||
setTimeout(function () {
|
||||
window.close();
|
||||
}, 1000); // Wait 1 second before closing
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
|
||||
@@ -535,8 +535,6 @@ class PdfController extends Controller
|
||||
|
||||
$processOrder = $request->header('process-order');
|
||||
|
||||
// $machineName = $request->header('machine-name');
|
||||
|
||||
if (! $plantCode) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
@@ -871,7 +869,6 @@ class PdfController extends Controller
|
||||
|
||||
$alreadyReceived = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('machine_name', $machineId)
|
||||
->where('item_id', $itemId)
|
||||
->sum('received_quantity');
|
||||
|
||||
@@ -939,7 +936,6 @@ class PdfController extends Controller
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineNamePlantId)
|
||||
->where('coil_number', $coilMain)
|
||||
// ->where('machine_name', $machineId)
|
||||
->first();
|
||||
|
||||
if (! $existingCoil) {
|
||||
@@ -965,7 +961,6 @@ class PdfController extends Controller
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineNamePlantId)
|
||||
->where('coil_number', $coilNo)
|
||||
// ->where('machine_name', $machineId)
|
||||
->first();
|
||||
|
||||
if (! $existingCoil) {
|
||||
@@ -1008,20 +1003,20 @@ class PdfController extends Controller
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
// if ($coilNo > 1) {
|
||||
// $prevCoilNo = (string) ($coilNo - 1);
|
||||
// $existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
// ->where('process_order', $processOrder)
|
||||
// ->where('coil_number', $prevCoilNo)
|
||||
// ->first();
|
||||
if ($coilNo > 1) {
|
||||
$prevCoilNo = (string) ($coilNo - 1);
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $prevCoilNo)
|
||||
->first();
|
||||
|
||||
// if (! $existPrevCoil) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Previous coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
|
||||
// ], 404);
|
||||
// }
|
||||
// }
|
||||
if (! $existPrevCoil) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Previous coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
|
||||
], 404);
|
||||
}
|
||||
}
|
||||
|
||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
@@ -1053,7 +1048,6 @@ class PdfController extends Controller
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineNamePlantId)
|
||||
->where('coil_number', $coilNo)
|
||||
// ->where('machine_name', $machineId)
|
||||
->update([
|
||||
// 'order_quantity' => $orderQty,
|
||||
'received_quantity' => $receivedQty,
|
||||
@@ -1081,7 +1075,7 @@ class PdfController extends Controller
|
||||
if ($coilNo && Str::contains($coilNo, '.')) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Rework value should be 'Yes' for rework coil number '{$coilNo}'!",
|
||||
'status_description1' => "Rework value should be 'Yes' for rework coil number '{$coilNo}'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
@@ -1098,20 +1092,20 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
// if ($coilNo > 1) {
|
||||
// $prevCoilNo = (string) ($coilNo - 1);
|
||||
// $existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
// ->where('process_order', $processOrder)
|
||||
// ->where('coil_number', $prevCoilNo)
|
||||
// ->first();
|
||||
if ($coilNo > 1) {
|
||||
$prevCoilNo = (string) ($coilNo - 1);
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $prevCoilNo)
|
||||
->first();
|
||||
|
||||
// if (! $existPrevCoil) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Previous coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
|
||||
// ], 404);
|
||||
// }
|
||||
// }
|
||||
if (! $existPrevCoil) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Previous coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
|
||||
], 404);
|
||||
}
|
||||
}
|
||||
|
||||
if ($total > $updatedOrderQty) {
|
||||
return response()->json([
|
||||
|
||||
@@ -48,67 +48,21 @@ class TestingPanelController extends Controller
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
$plantCode = $data['plant_code'] ?? null;
|
||||
$groupWorkCenter = $data['line_name'] ?? null;
|
||||
$workCenter = $data['machine_name'] ?? null;
|
||||
|
||||
if ($plantCode == null || $plantCode == '' || ! $plantCode) {
|
||||
if ($data['plant_code'] == null || $data['plant_code'] == '') {
|
||||
// return response("ERROR: Please provide a valid plant code.", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!",
|
||||
], 400);
|
||||
} elseif (! is_numeric($plantCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code '{$plantCode}' should contain only numeric values!",
|
||||
], 400);
|
||||
} elseif (Str::length($plantCode) < 4 || Str::length($plantCode) > 7) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code '{$plantCode}' must be between 4 and 7 digits only!",
|
||||
], 400);
|
||||
} elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid plant code '{$plantCode}' found!",
|
||||
], 400);
|
||||
}
|
||||
|
||||
if ($groupWorkCenter == null || $groupWorkCenter == '' || ! $groupWorkCenter) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($groupWorkCenter) < 6) {
|
||||
} elseif (Str::length($data['plant_code']) < 4 || ! is_numeric($data['plant_code']) || ! preg_match('/^[1-9]\d{3,}$/', $data['plant_code'])) {// !ctype_digit($data['plant_code'])
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center '{$groupWorkCenter}' should contain minimum 6 characters!",
|
||||
], 404);
|
||||
} elseif (! ctype_alnum($groupWorkCenter)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center '{$groupWorkCenter}' should contain only alpha-numeric values!",
|
||||
'status_description' => 'Invalid plant code found!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($workCenter == null || $workCenter == '' || ! $workCenter) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($workCenter) < 6) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center '{$workCenter}' should contain minimum 6 characters!",
|
||||
], 404);
|
||||
} elseif (! ctype_alnum($workCenter)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center '{$workCenter}' should contain only alpha-numeric values!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
$plant = Plant::where('code', $data['plant_code'])->first();
|
||||
if (! $plant) {
|
||||
// return response("Plant not found.", 400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
@@ -120,7 +74,19 @@ class TestingPanelController extends Controller
|
||||
$plantId = $plant->id;
|
||||
$plantName = $plant->name;
|
||||
|
||||
$gWorkCenter = WorkGroupMaster::where('name', $groupWorkCenter)->first();
|
||||
if ($data['line_name'] == null || $data['line_name'] == '') {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($data['line_name']) < 0) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid group work center found!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$gWorkCenter = WorkGroupMaster::where('name', $data['line_name'])->first();
|
||||
if (! $gWorkCenter) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
@@ -128,18 +94,30 @@ class TestingPanelController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
$gWorkCenter = WorkGroupMaster::where('name', $groupWorkCenter)->where('plant_id', $plantId)->first();
|
||||
$gWorkCenter = WorkGroupMaster::where('name', $data['line_name'])->where('plant_id', $plantId)->first();
|
||||
if (! $gWorkCenter) {
|
||||
// return response( "Line not found for the specified plant : {$plantCode}",400)->header('Content-Type', 'text/plain');
|
||||
// return response( "Line not found for the specified plant : {$data['plant_code']}",400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center not found for the specified plant : '{$plantCode}'!",
|
||||
'status_description' => "Group work center not found for the specified plant : '{$data['plant_code']}'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$gWorkCenterId = $gWorkCenter->id;
|
||||
|
||||
$machine = Machine::where('work_center', $workCenter)->first();
|
||||
if ($data['machine_name'] == null || $data['machine_name'] == '') {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($data['machine_name']) < 0) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid work center found!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->first();
|
||||
if (! $machine) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
@@ -147,29 +125,29 @@ class TestingPanelController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $workCenter)->where('plant_id', $plantId)->first();
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('plant_id', $plantId)->first();
|
||||
if (! $machine) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center not found for the specified plant : '{$plantCode}'!",
|
||||
'status_description' => "Work center not found for the specified plant : '{$data['plant_code']}'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $workCenter)->where('work_group_master_id', $gWorkCenterId)->first();
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('work_group_master_id', $gWorkCenterId)->first();
|
||||
if (! $machine) {
|
||||
// return response("Machine not found for the specified line : {$groupWorkCenter}", 400)->header('Content-Type', 'text/plain');
|
||||
// return response("Machine not found for the specified line : {$data['line_name']}", 400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center not found for the specified Group work center : '{$groupWorkCenter}'!",
|
||||
'status_description' => "Work center not found for the specified Group work center : '{$data['line_name']}'!",
|
||||
], 404);
|
||||
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $workCenter)->where('plant_id', $plantId)->where('work_group_master_id', $gWorkCenterId)->first();
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('plant_id', $plantId)->where('work_group_master_id', $gWorkCenterId)->first();
|
||||
if (! $machine) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center not found for the specified Plant : '{$plantCode}' and Group work center : '{$groupWorkCenter}'!",
|
||||
'status_description' => "Work center not found for the specified Plant : '{$data['plant_code']}' and Group work center : '{$data['line_name']}'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
@@ -277,7 +255,7 @@ class TestingPanelController extends Controller
|
||||
|
||||
$newUpdateCount = ($lastUpdateCount == null || $lastUpdateCount == '') ? 0 : (int) $lastUpdateCount?->update_count + 1; // $maxUpdateCount?->update_count
|
||||
|
||||
// $updateCountString = (string) $newUpdateCount;
|
||||
$updateCountString = (string) $newUpdateCount;
|
||||
|
||||
$row = [
|
||||
'plant_id' => $plantId,
|
||||
@@ -324,16 +302,13 @@ class TestingPanelController extends Controller
|
||||
'result' => $serial['result'] ?? null,
|
||||
'remark' => $serial['remark'] ?? null,
|
||||
'rework_count' => $serial['rework_count'] ?? 0,
|
||||
'rework_winded' => $serial['rework_winded'] ?? 0,
|
||||
'test_sequence_flag' => $serial['test_sequence_flag'] ?? '4',
|
||||
'test_started_at' => $serial['test_started_at'] ?? null,
|
||||
'output_flag' => $serial['output_flag'] ?? 0,
|
||||
'tested_by' => (($serial['tested_by'] == 'jothi') ? 'Admin' : $serial['tested_by']) ?? null,
|
||||
'updated_by' => (($serial['updated_by'] == 'jothi') ? 'Admin' : $serial['updated_by']) ?? null,
|
||||
'tested_by' => $serial['tested_by'] ?? null,
|
||||
'updated_by' => $serial['updated_by'] ?? null,
|
||||
'created_at' => $serial['created_at'] ?? null,
|
||||
'updated_at' => $serial['updated_at'] ?? $serial['created_at'],
|
||||
'scanned_at' => $serial['scanned_at'] ?? null,
|
||||
'update_count' => (string) $newUpdateCount,
|
||||
'update_count' => $updateCountString,
|
||||
];
|
||||
|
||||
// Insert the new record
|
||||
@@ -390,9 +365,9 @@ class TestingPanelController extends Controller
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
$plantCode = $data['plant_code'] ?? null;
|
||||
$itemCode = $data['item_code'] ?? null;
|
||||
$serialNumber = $data['serial_number'] ?? null;
|
||||
$plantCode = $data['plant_code'] ?? '';
|
||||
$itemCode = $data['item_code'] ?? '';
|
||||
$serialNumber = $data['serial_number'] ?? '';
|
||||
$testStatus = $data['test_status'] ?? 'F';
|
||||
|
||||
if ($plantCode == null || $plantCode == '' || ! $plantCode) {
|
||||
@@ -711,67 +686,22 @@ class TestingPanelController extends Controller
|
||||
}
|
||||
|
||||
$data = $request->all();
|
||||
$plantCode = $data['plant_code'] ?? null;
|
||||
$groupWorkCenter = $data['line_name'] ?? null;
|
||||
$workCenter = $data['machine_name'] ?? null;
|
||||
|
||||
if ($plantCode == null || $plantCode == '' || ! $plantCode) {
|
||||
if ($data['plant_code'] == null || $data['plant_code'] == '') {
|
||||
// return response("ERROR: Please provide a valid plant code.", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!",
|
||||
], 400);
|
||||
} elseif (! is_numeric($plantCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code '{$plantCode}' should contain only numeric values!",
|
||||
], 400);
|
||||
} elseif (Str::length($plantCode) < 4 || Str::length($plantCode) > 7) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code '{$plantCode}' must be between 4 and 7 digits only!",
|
||||
], 400);
|
||||
} elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid plant code '{$plantCode}' found!",
|
||||
], 400);
|
||||
}
|
||||
|
||||
if ($groupWorkCenter == null || $groupWorkCenter == '' || ! $groupWorkCenter) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($groupWorkCenter) < 6) {
|
||||
} elseif (Str::length($data['plant_code']) < 4 || ! is_numeric($data['plant_code']) || ! preg_match('/^[1-9]\d{3,}$/', $data['plant_code'])) {// !ctype_digit($data['plant_code'])
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center '{$groupWorkCenter}' should contain minimum 6 characters!",
|
||||
], 404);
|
||||
} elseif (! ctype_alnum($groupWorkCenter)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center '{$groupWorkCenter}' should contain only alpha-numeric values!",
|
||||
'status_description' => 'Invalid plant code found!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($workCenter == null || $workCenter == '' || ! $workCenter) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($workCenter) < 6) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center '{$workCenter}' should contain minimum 6 characters!",
|
||||
], 404);
|
||||
} elseif (! ctype_alnum($workCenter)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center '{$workCenter}' should contain only alpha-numeric values!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
$plant = Plant::where('code', $data['plant_code'])->first();
|
||||
if (! $plant) {
|
||||
// return response("Plant not found.", 400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
@@ -783,7 +713,19 @@ class TestingPanelController extends Controller
|
||||
$plantId = $plant->id;
|
||||
$plantName = $plant->name;
|
||||
|
||||
$gWorkCenter = WorkGroupMaster::where('name', $groupWorkCenter)->first();
|
||||
if ($data['line_name'] == null || $data['line_name'] == '') {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($data['line_name']) < 0) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid group work center found!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$gWorkCenter = WorkGroupMaster::where('name', $data['line_name'])->first();
|
||||
if (! $gWorkCenter) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
@@ -791,18 +733,30 @@ class TestingPanelController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
$gWorkCenter = WorkGroupMaster::where('name', $groupWorkCenter)->where('plant_id', $plantId)->first();
|
||||
$gWorkCenter = WorkGroupMaster::where('name', $data['line_name'])->where('plant_id', $plantId)->first();
|
||||
if (! $gWorkCenter) {
|
||||
// return response( "Line not found for the specified plant : {$plantCode}",400)->header('Content-Type', 'text/plain');
|
||||
// return response( "Line not found for the specified plant : {$data['plant_code']}",400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center not found for the specified plant : '{$plantCode}'!",
|
||||
'status_description' => "Group work center not found for the specified plant : '{$data['plant_code']}'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$gWorkCenterId = $gWorkCenter->id;
|
||||
|
||||
$machine = Machine::where('work_center', $workCenter)->first();
|
||||
if ($data['machine_name'] == null || $data['machine_name'] == '') {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($data['machine_name']) < 0) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid work center found!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->first();
|
||||
if (! $machine) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
@@ -810,29 +764,29 @@ class TestingPanelController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $workCenter)->where('plant_id', $plantId)->first();
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('plant_id', $plantId)->first();
|
||||
if (! $machine) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center not found for the specified plant : '{$plantCode}'!",
|
||||
'status_description' => "Work center not found for the specified plant : '{$data['plant_code']}'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $workCenter)->where('work_group_master_id', $gWorkCenterId)->first();
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('work_group_master_id', $gWorkCenterId)->first();
|
||||
if (! $machine) {
|
||||
// return response("Machine not found for the specified line : {$groupWorkCenter}", 400)->header('Content-Type', 'text/plain');
|
||||
// return response("Machine not found for the specified line : {$data['line_name']}", 400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center not found for the specified Group work center : '{$groupWorkCenter}'!",
|
||||
'status_description' => "Work center not found for the specified Group work center : '{$data['line_name']}'!",
|
||||
], 404);
|
||||
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $workCenter)->where('plant_id', $plantId)->where('work_group_master_id', $gWorkCenterId)->first();
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('plant_id', $plantId)->where('work_group_master_id', $gWorkCenterId)->first();
|
||||
if (! $machine) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center not found for the specified Plant : '{$plantCode}' and Group work center : '{$groupWorkCenter}'!",
|
||||
'status_description' => "Work center not found for the specified Plant : '{$data['plant_code']}' and Group work center : '{$data['line_name']}'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
@@ -1524,7 +1478,7 @@ class TestingPanelController extends Controller
|
||||
'flow_reading' => $entry['flow_reading'] ?? '0',
|
||||
'current' => $entry['current'] ?? '0',
|
||||
'watt' => $entry['watt'] ?? '0',
|
||||
'tested_by' => (($entry['created_by'] == 'Admin') ? 'jothi' : $entry['created_by']) ?? $userName,
|
||||
'tested_by' => $entry['created_by'] ?? $userName,
|
||||
'created_datetime' => ! empty($entry['created_at']) ? Carbon::parse($entry['created_at'])->setTimezone('Asia/Kolkata')->format('Y-m-d H:i:s') : now('Asia/Kolkata')->format('Y-m-d H:i:s'),
|
||||
];
|
||||
}, $pumpTestingEntries ?? []),
|
||||
@@ -1750,7 +1704,8 @@ class TestingPanelController extends Controller
|
||||
$flow_reading = $entry['flow_reading'] ?? '0';
|
||||
$current = $entry['current'] ?? '0';
|
||||
$watt = $entry['watt'] ?? '0';
|
||||
$tested_by = (($entry['tested_by'] == 'jothi') ? 'Admin' : $entry['tested_by']) ?? $userName;
|
||||
$tested_by = $entry['tested_by'] ?? $userName;
|
||||
$tested_by = ($tested_by == 'jothi') ? 'Admin' : $tested_by;
|
||||
// $pendingExists = PumpTestingEntry::where('plant_id', $plantId)->where('pump_serial_number', $pumpSerial)->where('pump_testing_master_id', $pumpMasterId)->where('tested_type', $testedType)->where('sl_no', $sl_no)->first();
|
||||
|
||||
$cnt++;
|
||||
@@ -1825,7 +1780,8 @@ class TestingPanelController extends Controller
|
||||
$flow_reading = $entry['flow_reading'] ?? '0';
|
||||
$current = $entry['current'] ?? '0';
|
||||
$watt = $entry['watt'] ?? '0';
|
||||
$tested_by = (($entry['tested_by'] == 'jothi') ? 'Admin' : $entry['tested_by']) ?? $userName;
|
||||
$tested_by = $entry['tested_by'] ?? $userName;
|
||||
$tested_by = ($tested_by == 'jothi') ? 'Admin' : $tested_by;
|
||||
|
||||
$createdRows++;
|
||||
PumpTestingEntry::create([
|
||||
@@ -2087,7 +2043,7 @@ class TestingPanelController extends Controller
|
||||
'flow_reading' => $result['discharge'] ?? '0',
|
||||
'current' => $result['current'] ?? '0',
|
||||
'watt' => (string) (($result['watt'] ?? '0') * 1000),
|
||||
'tested_by' => (($result['created_by'] == 'Admin') ? 'jothi' : $result['created_by']) ?? $userName,
|
||||
'tested_by' => $result['created_by'] ?? $userName,
|
||||
'created_datetime' => ! empty($result['created_at']) ? Carbon::parse($result['created_at'])->setTimezone('Asia/Kolkata')->format('Y-m-d H:i:s') : now('Asia/Kolkata')->format('Y-m-d H:i:s'),
|
||||
];
|
||||
}, $pumpTestingResults ?? []),
|
||||
@@ -2321,7 +2277,8 @@ class TestingPanelController extends Controller
|
||||
$power_p2 = $result['power_p2'] ?? '0';
|
||||
$overall_efficiency = $result['overall_efficiency'] ?? '0';
|
||||
$pump_efficiency = $result['pump_efficiency'] ?? '0';
|
||||
$tested_by = (($result['tested_by'] == 'jothi') ? 'Admin' : $result['tested_by']) ?? $userName;
|
||||
$tested_by = $result['tested_by'] ?? $userName;
|
||||
$tested_by = ($tested_by == 'jothi') ? 'Admin' : $tested_by;
|
||||
// $pendingExists = PumpTestingResult::where('plant_id', $plantId)->where('pump_serial_number', $pumpSerial)->where('pump_testing_master_id', $pumpMasterId)->where('tested_type', $testedType)->where('sl_no', $sl_no)->first();
|
||||
|
||||
$cnt++;
|
||||
@@ -2411,7 +2368,8 @@ class TestingPanelController extends Controller
|
||||
$power_p2 = $result['power_p2'] ?? '0';
|
||||
$overall_efficiency = $result['overall_efficiency'] ?? '0';
|
||||
$pump_efficiency = $result['pump_efficiency'] ?? '0';
|
||||
$tested_by = (($result['tested_by'] == 'jothi') ? 'Admin' : $result['tested_by']) ?? $userName;
|
||||
$tested_by = $result['tested_by'] ?? $userName;
|
||||
$tested_by = ($tested_by == 'jothi') ? 'Admin' : $tested_by;
|
||||
|
||||
$createdRows++;
|
||||
PumpTestingResult::create([
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\CoilPacking;
|
||||
use Livewire\Component;
|
||||
|
||||
class CoilPackDataTable extends Component
|
||||
{
|
||||
|
||||
public $plantId;
|
||||
|
||||
public $coilPackNo;
|
||||
|
||||
public $snoCount = 0;
|
||||
|
||||
public $records = [];
|
||||
|
||||
protected $listeners = [
|
||||
'loadData' => 'loadCoilData',
|
||||
];
|
||||
|
||||
public function loadCoilData($coilPackNo, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->coilPackNo = $coilPackNo;
|
||||
$this->records = [];
|
||||
|
||||
$this->records = CoilPacking::query()
|
||||
->where('plant_id', $this->plantId)
|
||||
->where('coil_packing_number', $this->coilPackNo)
|
||||
->orderBy('scanned_at')
|
||||
->get()
|
||||
->map(function ($record) {
|
||||
return [
|
||||
'created_at' => $record->created_at,
|
||||
'created_by' => $record->created_by ?? '',
|
||||
'coil_packing_number' => $record->coil_packing_number,
|
||||
'item_code' => $record->item?->code ?? '',
|
||||
'item_description' => $record->item?->description ?? '',
|
||||
'process_order' => $record->process_order,
|
||||
'scanned_at' => $record->scanned_at,
|
||||
'scanned_by' => $record->scanned_by ?? '',
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.coil-pack-data-table');
|
||||
}
|
||||
}
|
||||
@@ -846,43 +846,24 @@ class InvoiceDataTable extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
$categoryExist = Item::where('code', $itemCode)->where('plant_id', $this->plantId)->first();
|
||||
// $categoryExist = Item::where('code', $itemCode)->first();
|
||||
|
||||
if($categoryExist?->category == 'Panel Box'){
|
||||
// if($categoryExist?->category == 'Panel Box'){
|
||||
|
||||
$panelExist = PanelBoxValidation::where('plant_id', $this->plantId)->where('panel_box_serial_number', $serialNumber)->where('panel_box_code', $itemCode)->where('panel_box_supplier', $supplier)->first();
|
||||
// $panelExist = PanelBoxValidation::where('panel_box_serial_number', $serialNumber)->where('panel_box_code', $itemCode)->where('panel_box_supplier', $supplier)->first();
|
||||
|
||||
if(!$panelExist){
|
||||
Notification::make()
|
||||
->title('Panel Not Verified')
|
||||
->body("Panel Quality Inspection failed.<br>Panel Box Code: $itemCode, Item Code: {$this->currentItemCode}, Serial Number: $serialNumber.</br>")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->capacitorInput = '';
|
||||
// if(!$panelExist){
|
||||
// Notification::make()
|
||||
// ->title('Panel Not Verified')
|
||||
// ->body("Panel Quality Inspection failed.<br>Panel Box Code: $itemCode, Item Code: {$this->currentItemCode}, Serial Number: $serialNumber.</br>")
|
||||
// ->danger()
|
||||
// ->seconds(2)
|
||||
// ->send();
|
||||
// $this->capacitorInput = '';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$panelExistsInvoice = InvoiceValidation::where('plant_id', $this->plantId)
|
||||
->where('panel_box_serial_number', $serialNumber)
|
||||
->where('panel_box_code', $itemCode)
|
||||
->where('panel_box_supplier', $supplier)
|
||||
->first();
|
||||
|
||||
if ($panelExistsInvoice) {
|
||||
Notification::make()
|
||||
->title('Duplicate Panel')
|
||||
->body("Duplicate panel already exists.<br>Panel Box Code: $itemCode, Item Code: {$this->currentItemCode}, Serial Number: $serialNumber.")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->capacitorInput = '';
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
$this->package = InvoiceValidation::with('stickerMasterRelation')
|
||||
->where('invoice_number', $this->invoiceNumber)
|
||||
|
||||
@@ -32,8 +32,6 @@ public $records = [];
|
||||
|
||||
public bool $selectForNotOk = false;
|
||||
|
||||
public $remark;
|
||||
|
||||
// public $skipChecklistValidation = false;
|
||||
|
||||
// protected $listeners = ['focus-item-id' => 'handleFocus', 'trigger-create' => 'doCreate',];
|
||||
@@ -85,18 +83,6 @@ public $records = [];
|
||||
}
|
||||
}
|
||||
|
||||
if($this->selectForNotOk){
|
||||
|
||||
if (empty($this->remark) || $this->remark == '') {
|
||||
Notification::make()
|
||||
->title('Remark Mandatory')
|
||||
->body("Remark can't be empty!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$item = Item::where('code', $this->data['item_id'])->first();
|
||||
|
||||
if (! $item) {
|
||||
@@ -218,7 +204,6 @@ public $records = [];
|
||||
'panel_box_code' => $this->data['panel_box_code'] ?? null,
|
||||
'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null,
|
||||
'rework_count' => $latestReworkRecord ? ((int) $latestReworkRecord->rework_count + 1) : 0,
|
||||
'status' => $this->selectForNotOk ? 'NotOk' : 'Ok',
|
||||
'created_by' => $this->data['created_by'] ?? null,
|
||||
'updated_by' => $this->data['updated_by'] ?? null,
|
||||
]);
|
||||
@@ -233,7 +218,7 @@ public $records = [];
|
||||
}
|
||||
}
|
||||
else{
|
||||
$qualityValidation = PanelBoxValidation::create([
|
||||
$qualityValidation = PanelBoxValidation::create([
|
||||
'plant_id' => $this->data['plant_id'] ?? null,
|
||||
'line_id' => $this->data['line_id'] ?? null,
|
||||
'sticker_master_id' => $this->data['sticker_master_id'] ?? null,
|
||||
@@ -253,12 +238,36 @@ public $records = [];
|
||||
'panel_box_serial_number' => $this->data['panel_box_serial_number'] ?? null,
|
||||
'panel_box_code' => $this->data['panel_box_code'] ?? null,
|
||||
'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null,
|
||||
'status' => $this->selectForNotOk ? 'NotOk' : 'Ok',
|
||||
'created_by' => $this->data['created_by'] ?? null,
|
||||
'updated_by' => $this->data['updated_by'] ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
// $qualityValidation = PanelBoxValidation::create([
|
||||
// 'plant_id' => $this->data['plant_id'] ?? null,
|
||||
// 'line_id' => $this->data['line_id'] ?? null,
|
||||
// 'sticker_master_id' => $this->data['sticker_master_id'] ?? null,
|
||||
// 'production_order' => $this->data['production_order'] ?? null,
|
||||
// 'serial_number' => $this->data['serial_number'] ?? null,
|
||||
// 'serial_number_panel' => $this->data['serial_number_panel'] ?? null,
|
||||
// 'pack_slip_panel' => $this->data['pack_slip_panel'] ?? null,
|
||||
// 'name_plate_panel' => $this->data['name_plate_panel'] ?? null,
|
||||
// 'tube_sticker_panel' => $this->data['tube_sticker_panel'] ?? null,
|
||||
// 'warranty_card_panel' => $this->data['warranty_card_panel'] ?? null,
|
||||
// 'part_validation1' => $this->data['part_validation1'] ?? null,
|
||||
// 'part_validation2' => $this->data['part_validation2'] ?? null,
|
||||
// 'part_validation3' => $this->data['part_validation3'] ?? null,
|
||||
// 'part_validation4' => $this->data['part_validation4'] ?? null,
|
||||
// 'part_validation5' => $this->data['part_validation5'] ?? null,
|
||||
// 'panel_box_supplier' => $this->data['panel_box_supplier'] ?? null,
|
||||
// 'panel_box_serial_number' => $this->data['panel_box_serial_number'] ?? null,
|
||||
// 'panel_box_code' => $this->data['panel_box_code'] ?? null,
|
||||
// 'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null,
|
||||
// 'created_by' => $this->data['created_by'] ?? null,
|
||||
// 'updated_by' => $this->data['updated_by'] ?? null,
|
||||
// ]);
|
||||
|
||||
|
||||
if (! $qualityValidation || ! $qualityValidation->exists) {
|
||||
Notification::make()
|
||||
->title('Failed to save Panel Box Validation')
|
||||
@@ -365,7 +374,6 @@ public $records = [];
|
||||
'status' => $status,
|
||||
'inspection_status' => $finalInspectionStatus ?? null,
|
||||
'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null,
|
||||
'remark' => $this->remark ?? null,
|
||||
'created_by' => $this->data['created_by'] ?? null,
|
||||
'updated_by' => $this->data['updated_by'] ?? null,
|
||||
]);
|
||||
@@ -392,12 +400,15 @@ public $records = [];
|
||||
|
||||
if ($mailRule && !empty($mailRule->email)) {
|
||||
|
||||
// $mail = Mail::to($mailRule->email);
|
||||
|
||||
$toEmails = array_filter(
|
||||
array_map('trim', explode(',', $mailRule->email))
|
||||
);
|
||||
|
||||
$mail = Mail::to($toEmails);
|
||||
|
||||
|
||||
if (!empty($mailRule->cc_emails)) {
|
||||
$ccEmails = array_filter(
|
||||
array_map('trim', explode(',', $mailRule->cc_emails))
|
||||
@@ -409,7 +420,6 @@ public $records = [];
|
||||
$mail->send(new PanelBoxNotOkAlert(
|
||||
$plantName,
|
||||
$code ?? null,
|
||||
$this->remark ?? null,
|
||||
$this->data['serial_number'] ?? null,
|
||||
$this->data['panel_box_supplier'] ?? null,
|
||||
$notOkCharacteristics
|
||||
|
||||
@@ -5,8 +5,6 @@ namespace App\Livewire;
|
||||
use App\Exports\ProductionPlanExport;
|
||||
use App\Models\ProductionPlan;
|
||||
use App\Models\ProductionQuantity;
|
||||
use App\Models\QualityValidation;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Livewire\Component;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
@@ -21,18 +19,14 @@ class ProductionTargetPlan extends Component
|
||||
|
||||
public $dates = [];
|
||||
|
||||
public $monthlyRecords = [];
|
||||
|
||||
public $efficiency = [];
|
||||
|
||||
public $monthlyActualQuantity = [];
|
||||
|
||||
public $leaveDates = [];
|
||||
|
||||
public $productionPlanDates = '';
|
||||
|
||||
|
||||
protected $listeners = [
|
||||
'loadData' => 'loadProductionData',
|
||||
'loadCategoryData' => 'loadProductionDataCategory',
|
||||
'loadData1' => 'exportProductionData',
|
||||
];
|
||||
|
||||
@@ -181,161 +175,132 @@ class ProductionTargetPlan extends Component
|
||||
// }
|
||||
|
||||
|
||||
// public function loadProductionData($year, $month, $plantId, $lineId, $category)
|
||||
// {
|
||||
// if (!$plantId || !$lineId || !$month || !$year) {
|
||||
// $this->records = [];
|
||||
// $this->dates = [];
|
||||
// $this->leaveDates = [];
|
||||
// return;
|
||||
// }
|
||||
|
||||
// $dates = $this->getMonthDates($month, $year);
|
||||
// $this->dates = $dates;
|
||||
public function loadProductionData($year, $month, $plantId, $lineId, $category)
|
||||
{
|
||||
if (!$plantId || !$lineId || !$month || !$year) {
|
||||
$this->records = [];
|
||||
$this->dates = [];
|
||||
$this->leaveDates = [];
|
||||
return;
|
||||
}
|
||||
|
||||
// $plans = ProductionPlan::query()
|
||||
// ->join('items', 'items.id', '=', 'production_plans.item_id')
|
||||
// ->join('lines', 'lines.id', '=', 'production_plans.line_id')
|
||||
// ->join('plants', 'plants.id', '=', 'production_plans.plant_id')
|
||||
// ->where('production_plans.plant_id', $plantId)
|
||||
// ->where('production_plans.line_id', $lineId)
|
||||
// ->whereMonth('production_plans.created_at', $month)
|
||||
// ->whereYear('production_plans.created_at', $year)
|
||||
// ->when($category, function ($query) use ($category) {
|
||||
// $query->where('items.category', $category);
|
||||
// })
|
||||
// ->select(
|
||||
// 'production_plans.item_id',
|
||||
// 'production_plans.plant_id',
|
||||
// 'production_plans.line_id',
|
||||
// 'production_plans.plan_quantity',
|
||||
// 'production_plans.working_days',
|
||||
// 'production_plans.leave_dates',
|
||||
// 'items.code as item_code',
|
||||
// 'items.category as category',
|
||||
// 'items.description as item_description',
|
||||
// 'items.hourly_quantity as hourly_quantity',
|
||||
// 'lines.name as line_name',
|
||||
// // 'lines.line_capacity as line_capacity',
|
||||
// 'plants.name as plant_name'
|
||||
// )
|
||||
// ->get();
|
||||
$dates = $this->getMonthDates($month, $year);
|
||||
$this->dates = $dates;
|
||||
|
||||
// $leaveDates = [];
|
||||
$plans = ProductionPlan::query()
|
||||
->join('items', 'items.id', '=', 'production_plans.item_id')
|
||||
->join('lines', 'lines.id', '=', 'production_plans.line_id')
|
||||
->join('plants', 'plants.id', '=', 'production_plans.plant_id')
|
||||
->where('production_plans.plant_id', $plantId)
|
||||
->where('production_plans.line_id', $lineId)
|
||||
->whereMonth('production_plans.created_at', $month)
|
||||
->whereYear('production_plans.created_at', $year)
|
||||
->when($category, function ($query) use ($category) {
|
||||
$query->where('items.category', $category);
|
||||
})
|
||||
->select(
|
||||
'production_plans.item_id',
|
||||
'production_plans.plant_id',
|
||||
'production_plans.line_id',
|
||||
'production_plans.plan_quantity',
|
||||
'production_plans.working_days',
|
||||
'production_plans.leave_dates',
|
||||
'items.code as item_code',
|
||||
'items.category as category',
|
||||
'items.description as item_description',
|
||||
'items.hourly_quantity as hourly_quantity',
|
||||
'lines.name as line_name',
|
||||
// 'lines.line_capacity as line_capacity',
|
||||
'plants.name as plant_name'
|
||||
)
|
||||
->get();
|
||||
|
||||
// if ($plans->isNotEmpty() && $plans[0]->leave_dates) {
|
||||
// $leaveDates = array_map('trim', explode(',', $plans[0]->leave_dates));
|
||||
// }
|
||||
$leaveDates = [];
|
||||
|
||||
// $this->leaveDates = $leaveDates;
|
||||
if ($plans->isNotEmpty() && $plans[0]->leave_dates) {
|
||||
$leaveDates = array_map('trim', explode(',', $plans[0]->leave_dates));
|
||||
}
|
||||
|
||||
// // $producedData = QualityValidation::selectRaw("
|
||||
// // plant_id,
|
||||
// // line_id,
|
||||
// // sticker_master_id,
|
||||
// // DATE(created_at) as prod_date,
|
||||
// // COUNT(*) as total_qty
|
||||
// // ")
|
||||
// // ->where('plant_id', $plantId)
|
||||
// // ->where('line_id', $lineId)
|
||||
// // ->whereMonth('created_at', $month)
|
||||
// // ->whereYear('created_at', $year)
|
||||
// // ->when($category, function ($query) use ($category) {
|
||||
// // $query->whereHas('item', function ($q) use ($category) {
|
||||
// // $q->where('category', $category);
|
||||
// // });
|
||||
// // })
|
||||
// // ->groupBy('plant_id', 'line_id', 'sticker_master_id', DB::raw('DATE(created_at)'))
|
||||
// // ->get()
|
||||
// // ->groupBy(fn($row) =>
|
||||
// // $row->plant_id . '_' . $row->line_id . '_' . $row->item_id
|
||||
// // )
|
||||
// // ->map(fn($group) => $group->keyBy('prod_date'));
|
||||
$this->leaveDates = $leaveDates;
|
||||
|
||||
// $producedData = QualityValidation::selectRaw("
|
||||
// quality_validations.plant_id,
|
||||
// quality_validations.line_id,
|
||||
// quality_validations.sticker_master_id,
|
||||
// sticker_masters.item_id,
|
||||
// DATE(quality_validations.created_at) as prod_date,
|
||||
// COUNT(*) as total_qty
|
||||
// ")
|
||||
// ->join('sticker_masters', 'sticker_masters.id', '=', 'quality_validations.sticker_master_id')
|
||||
// ->where('quality_validations.plant_id', $plantId)
|
||||
// ->where('quality_validations.line_id', $lineId)
|
||||
// ->whereMonth('quality_validations.created_at', $month)
|
||||
// ->whereYear('quality_validations.created_at', $year)
|
||||
// ->when($category, function ($query) use ($category) {
|
||||
// $query->whereHas('item', function ($q) use ($category) {
|
||||
// $q->where('category', $category);
|
||||
// });
|
||||
// })
|
||||
// ->groupBy(
|
||||
// 'quality_validations.plant_id',
|
||||
// 'quality_validations.line_id',
|
||||
// 'quality_validations.sticker_master_id',
|
||||
// 'sticker_masters.item_id',
|
||||
// DB::raw('DATE(quality_validations.created_at)')
|
||||
// )
|
||||
// ->get()
|
||||
// ->groupBy(fn($row) =>
|
||||
// $row->plant_id . '_' . $row->line_id . '_' . $row->item_id
|
||||
// )
|
||||
// ->map(fn($group) => $group->keyBy('prod_date'));
|
||||
$producedData = ProductionQuantity::selectRaw("
|
||||
plant_id,
|
||||
line_id,
|
||||
item_id,
|
||||
DATE(created_at) as prod_date,
|
||||
COUNT(*) as total_qty
|
||||
")
|
||||
->where('plant_id', $plantId)
|
||||
->where('line_id', $lineId)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->when($category, function ($query) use ($category) {
|
||||
$query->whereHas('item', function ($q) use ($category) {
|
||||
$q->where('category', $category);
|
||||
});
|
||||
})
|
||||
->groupBy('plant_id', 'line_id', 'item_id', DB::raw('DATE(created_at)'))
|
||||
->get()
|
||||
->groupBy(fn($row) =>
|
||||
$row->plant_id . '_' . $row->line_id . '_' . $row->item_id
|
||||
)
|
||||
->map(fn($group) => $group->keyBy('prod_date'));
|
||||
|
||||
|
||||
// $records = [];
|
||||
$records = [];
|
||||
|
||||
// foreach ($plans as $plan) {
|
||||
foreach ($plans as $plan) {
|
||||
|
||||
// $row = $plan->toArray();
|
||||
$row = $plan->toArray();
|
||||
|
||||
// $remainingQty = (float) $row['plan_quantity'];
|
||||
// $remainingDays = (int) ($row['working_days'] ?? 0);
|
||||
$remainingQty = (float) $row['plan_quantity'];
|
||||
$remainingDays = (int) ($row['working_days'] ?? 0);
|
||||
|
||||
// $lineCapacity = (float) ($row['line_capacity'] ?? 0);
|
||||
// $dailyHourlyQuantity = (float) ($row['hourly_quantity'] ?? 0);
|
||||
$lineCapacity = (float) ($row['line_capacity'] ?? 0);
|
||||
$dailyHourlyQuantity = (float) ($row['hourly_quantity'] ?? 0);
|
||||
|
||||
// $row['category'] = $row['category'] ?? '-';
|
||||
// $row['daily_hourly_quantity'] = [];
|
||||
// $row['daily_target_dynamic'] = [];
|
||||
// $row['produced_quantity'] = [];
|
||||
$row['category'] = $row['category'] ?? '-';
|
||||
$row['daily_hourly_quantity'] = [];
|
||||
$row['daily_target_dynamic'] = [];
|
||||
$row['produced_quantity'] = [];
|
||||
|
||||
// $key = $row['plant_id'].'_'.$row['line_id'].'_'.$row['item_id'];
|
||||
$key = $row['plant_id'].'_'.$row['line_id'].'_'.$row['item_id'];
|
||||
|
||||
// foreach ($dates as $date) {
|
||||
foreach ($dates as $date) {
|
||||
|
||||
// // Skip leave dates fast
|
||||
// if (isset($leaveDates) && in_array($date, $leaveDates)) {
|
||||
// $row['daily_hourly_quantity'][$date] = '-';
|
||||
// $row['daily_target_dynamic'][$date] = '-';
|
||||
// $row['produced_quantity'][$date] = '-';
|
||||
// continue;
|
||||
// }
|
||||
// Skip leave dates fast
|
||||
if (isset($leaveDates) && in_array($date, $leaveDates)) {
|
||||
$row['daily_hourly_quantity'][$date] = '-';
|
||||
$row['daily_target_dynamic'][$date] = '-';
|
||||
$row['produced_quantity'][$date] = '-';
|
||||
continue;
|
||||
}
|
||||
|
||||
// $todayTarget = $remainingDays > 0
|
||||
// ? round($remainingQty / $remainingDays, 2)
|
||||
// : 0;
|
||||
$todayTarget = $remainingDays > 0
|
||||
? round($remainingQty / $remainingDays, 2)
|
||||
: 0;
|
||||
|
||||
// $producedQty = $producedData[$key][$date]->total_qty ?? 0;
|
||||
$producedQty = $producedData[$key][$date]->total_qty ?? 0;
|
||||
|
||||
// $row['daily_target_dynamic'][$date] = $todayTarget;
|
||||
// $row['produced_quantity'][$date] = $producedQty;
|
||||
// $row['daily_hourly_quantity'][$date] = $dailyHourlyQuantity * 22.5;
|
||||
$row['daily_target_dynamic'][$date] = $todayTarget;
|
||||
$row['produced_quantity'][$date] = $producedQty;
|
||||
$row['daily_hourly_quantity'][$date] = $dailyHourlyQuantity * 22.5;
|
||||
|
||||
// // Carry forward remaining qty
|
||||
// $remainingQty = max(0, $remainingQty - $producedQty);
|
||||
// Carry forward remaining qty
|
||||
$remainingQty = max(0, $remainingQty - $producedQty);
|
||||
|
||||
// if ($remainingDays > 0) {
|
||||
// $remainingDays--;
|
||||
// }
|
||||
// }
|
||||
if ($remainingDays > 0) {
|
||||
$remainingDays--;
|
||||
}
|
||||
}
|
||||
|
||||
// $records[] = $row;
|
||||
// }
|
||||
$records[] = $row;
|
||||
}
|
||||
|
||||
$this->records = $records;
|
||||
}
|
||||
|
||||
// $this->records = $records;
|
||||
// }
|
||||
|
||||
// public function loadProductionDataCategory($year, $month, $plantId, $lineId, $category)
|
||||
// {
|
||||
@@ -453,211 +418,6 @@ class ProductionTargetPlan extends Component
|
||||
// }
|
||||
|
||||
|
||||
|
||||
public function loadProductionData($year, $month, $plantId, $lineId)
|
||||
{
|
||||
|
||||
$this->records = [];
|
||||
$this->monthlyRecords = 0;
|
||||
$this->dates = [];
|
||||
$this->leaveDates = [];
|
||||
|
||||
if (!$plantId || !$lineId || !$month || !$year) {
|
||||
// $this->records = [];
|
||||
// $this->dates = [];
|
||||
// $this->leaveDates = [];
|
||||
return;
|
||||
}
|
||||
|
||||
$dates = $this->getMonthDates($month, $year);
|
||||
$this->dates = $dates;
|
||||
|
||||
$plans = ProductionPlan::query()
|
||||
->join('items', 'items.id', '=', 'production_plans.item_id')
|
||||
->join('lines', 'lines.id', '=', 'production_plans.line_id')
|
||||
->join('plants', 'plants.id', '=', 'production_plans.plant_id')
|
||||
->where('production_plans.plant_id', $plantId)
|
||||
->where('production_plans.line_id', $lineId)
|
||||
->whereMonth('production_plans.created_at', $month)
|
||||
->whereYear('production_plans.created_at', $year)
|
||||
->select(
|
||||
'production_plans.item_id',
|
||||
'production_plans.plant_id',
|
||||
'production_plans.line_id',
|
||||
'production_plans.plan_quantity',
|
||||
'production_plans.working_days',
|
||||
'production_plans.leave_dates',
|
||||
'items.code as item_code',
|
||||
'items.category as category',
|
||||
'items.description as item_description',
|
||||
'items.hourly_quantity as hourly_quantity',
|
||||
'lines.name as line_name',
|
||||
// 'lines.line_capacity as line_capacity',
|
||||
'plants.name as plant_name'
|
||||
)
|
||||
->get();
|
||||
|
||||
$leaveDates = [];
|
||||
|
||||
if ($plans->isNotEmpty() && $plans[0]->leave_dates) {
|
||||
$leaveDates = array_map('trim', explode(',', $plans[0]->leave_dates));
|
||||
}
|
||||
|
||||
$this->leaveDates = $leaveDates;
|
||||
|
||||
$start = microtime(true);
|
||||
|
||||
$producedData = QualityValidation::selectRaw("
|
||||
quality_validations.plant_id,
|
||||
quality_validations.line_id,
|
||||
sticker_masters.item_id,
|
||||
DATE(quality_validations.created_at) as prod_date,
|
||||
COUNT(*) as total_qty
|
||||
")
|
||||
->join(
|
||||
'sticker_masters',
|
||||
'sticker_masters.id',
|
||||
'=',
|
||||
'quality_validations.sticker_master_id'
|
||||
)
|
||||
->where('quality_validations.plant_id', $plantId)
|
||||
->where('quality_validations.line_id', $lineId)
|
||||
->whereMonth('quality_validations.created_at', $month)
|
||||
->whereYear('quality_validations.created_at', $year)
|
||||
->groupBy(
|
||||
'quality_validations.plant_id',
|
||||
'quality_validations.line_id',
|
||||
'sticker_masters.item_id',
|
||||
DB::raw('DATE(quality_validations.created_at)')
|
||||
)
|
||||
->get()
|
||||
->groupBy(fn($row) =>
|
||||
$row->plant_id . '_' . $row->line_id . '_' . $row->item_id
|
||||
)
|
||||
->map(fn($group) => $group->keyBy('prod_date'));
|
||||
|
||||
Log::info('Quality: ' . ((microtime(true) - $start) * 1000) . ' ms');
|
||||
|
||||
$records = [];
|
||||
|
||||
foreach ($plans as $plan) {
|
||||
|
||||
$row = $plan->toArray();
|
||||
|
||||
/*
|
||||
* Calculate the normal daily target.
|
||||
*
|
||||
* Example:
|
||||
* Plan quantity = 60
|
||||
* Working days = 3
|
||||
*
|
||||
* Normal daily target = 60 / 3 = 20
|
||||
*/
|
||||
$workingDays = (int) ($row['working_days'] ?? 0);
|
||||
|
||||
$normalDailyTarget = $workingDays > 0
|
||||
? round((float) $row['plan_quantity'] / $workingDays, 2)
|
||||
: 0;
|
||||
|
||||
/*
|
||||
* This stores the uncompleted quantity from the previous
|
||||
* working day and carries it to the next working day.
|
||||
*/
|
||||
$pendingQty = 0;
|
||||
|
||||
$lineCapacity = (float) ($row['line_capacity'] ?? 0);
|
||||
$dailyHourlyQuantity = (float) ($row['hourly_quantity'] ?? 0);
|
||||
|
||||
$row['category'] = $row['category'] ?? '-';
|
||||
$row['daily_hourly_quantity'] = [];
|
||||
$row['daily_target_dynamic'] = [];
|
||||
$row['produced_quantity'] = [];
|
||||
|
||||
$key = $row['plant_id'] . '_' . $row['line_id'] . '_' . $row['item_id'];
|
||||
|
||||
foreach ($dates as $date) {
|
||||
|
||||
/*
|
||||
* Skip leave dates.
|
||||
*
|
||||
* Pending quantity is NOT changed here.
|
||||
* Therefore it will carry forward to the next working day.
|
||||
*/
|
||||
if (in_array($date, $leaveDates)) {
|
||||
|
||||
$row['daily_hourly_quantity'][$date] = '-';
|
||||
$row['daily_target_dynamic'][$date] = '-';
|
||||
$row['produced_quantity'][$date] = '-';
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Today's target:
|
||||
*
|
||||
* Normal daily target
|
||||
* +
|
||||
* Previous day's pending quantity
|
||||
*/
|
||||
$todayTarget = round(
|
||||
$normalDailyTarget + $pendingQty,
|
||||
2
|
||||
);
|
||||
|
||||
/*
|
||||
* Get actual produced quantity for this item/date.
|
||||
*/
|
||||
$producedQty = $producedData[$key][$date]->total_qty ?? 0;
|
||||
|
||||
/*
|
||||
* Store today's values.
|
||||
*/
|
||||
$row['daily_target_dynamic'][$date] = $todayTarget;
|
||||
$row['produced_quantity'][$date] = $producedQty;
|
||||
$row['daily_hourly_quantity'][$date] = $dailyHourlyQuantity * 22.5;
|
||||
|
||||
/*
|
||||
* Calculate today's pending quantity.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* Target = 40
|
||||
* Produced = 30
|
||||
*
|
||||
* Pending = 10
|
||||
*
|
||||
* This 10 will be added to tomorrow's target.
|
||||
*/
|
||||
$pendingQty = max(
|
||||
0,
|
||||
$todayTarget - $producedQty
|
||||
);
|
||||
}
|
||||
|
||||
$records[] = $row;
|
||||
}
|
||||
|
||||
$this->records = $records;
|
||||
|
||||
$this->monthlyRecords = ProductionPlan::where('plant_id', $plantId)
|
||||
->where('line_id', $lineId)
|
||||
->whereYear('created_at', $year)
|
||||
->whereMonth('created_at', $month)
|
||||
->sum('plan_quantity');
|
||||
|
||||
$this->monthlyActualQuantity = QualityValidation::where('plant_id', $plantId)
|
||||
->where('line_id', $lineId)
|
||||
->whereYear('created_at', $year)
|
||||
->whereMonth('created_at', $month)
|
||||
->count();
|
||||
|
||||
$this->efficiency = $this->monthlyRecords > 0
|
||||
? ($this->monthlyActualQuantity / $this->monthlyRecords) * 100
|
||||
: 0;
|
||||
|
||||
//$this->monthlyRecords = $plans->sum('plan_quantity');
|
||||
}
|
||||
|
||||
public function exportProductionData()
|
||||
{
|
||||
return Excel::download(
|
||||
@@ -671,9 +431,6 @@ class ProductionTargetPlan extends Component
|
||||
// return view('livewire.production-target-plan');
|
||||
return view('livewire.production-target-plan', [
|
||||
'records' => $this->records,
|
||||
'monthlyRecords' => $this->monthlyRecords,
|
||||
'monthlyActualRecords' => $this->monthlyActualQuantity,
|
||||
'monthlyEfficiency' => $this->efficiency,
|
||||
'dates' => $this->dates,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
<?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;
|
||||
use Illuminate\Mail\Mailables\Attachment;
|
||||
|
||||
class DailyTaskReportMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public array $pdfAttachments;
|
||||
|
||||
public array $rows = [];
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct(array $pdfAttachments, array $rows)
|
||||
{
|
||||
$this->pdfAttachments = $pdfAttachments;
|
||||
$this->rows = $rows;
|
||||
}
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Daily Task Report Mail',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mail.daily-task-report',
|
||||
with: [
|
||||
'rows' => $this->rows,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return collect($this->pdfAttachments)
|
||||
->map(function ($attachment) {
|
||||
|
||||
return Attachment::fromPath($attachment['path'])
|
||||
->as($attachment['name'])
|
||||
->withMime('application/pdf');
|
||||
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
<?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;
|
||||
use DateTime;
|
||||
|
||||
class LaserIdleMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tableData;
|
||||
|
||||
public $scheduleType;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($scheduleType, $tableData = [])
|
||||
{
|
||||
$this->scheduleType = $scheduleType;
|
||||
$this->tableData = $tableData ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Laser Idle Report',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
$greeting = "Dear Sir/Madam,<br><br>Kindly find the attached Laser Idle Report status details ,";
|
||||
|
||||
if ($this->scheduleType == 'Daily') {
|
||||
$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';
|
||||
$reportPeriod = "The following report presents results from: $fromDate to $toDate.";
|
||||
$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 .= "The following report presents results from: $reportDate, $fromHour to $toHour.";
|
||||
}
|
||||
|
||||
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 .= "The following report presents results from: $fromMinute to $toMinute.";
|
||||
}
|
||||
|
||||
return new Content(
|
||||
view: 'mail.laser_idle_hour_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 [];
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user