48 Commits
qds ... master

Author SHA1 Message Date
dhanabalan
8813567f0b Add missing created_at and updated_at fields to fillable attributes in ProductionQuantity model 2025-09-09 19:03:13 +05:30
dhanabalan
ffa2b1f783 Remove redundant 'asc' parameter from created_at orderBy in QualityValidationResource table query 2025-09-09 18:01:19 +05:30
dhanabalan
e29c16c79a Add sorting by created_at in QualityValidationResource table query 2025-09-09 17:55:53 +05:30
dhanabalan
4d516e955c added created_at and updated_at column in quality validation model 2025-09-09 10:56:22 +05:30
dhanabalan
b0d73dbbc6 Add searchable functionality to line name column in QualityValidationResource table 2025-09-09 10:39:20 +05:30
dhanabalan
37c91afe25 Rename subassembly_code to mot_subassembly_code in get_motor_master method for clarity 2025-09-09 10:23:58 +05:30
dhanabalan
77064399cd Update example header for line column in ConfigurationImporter 2025-09-09 08:41:22 +05:30
dhanabalan
3398a60d1b Update label for laser part validation input in StickerMasterResource 2025-09-06 16:25:52 +05:30
dhanabalan
65aafbeb65 Add required validation to load rate input in StickerMasterResource resource 2025-09-06 16:16:35 +05:30
dhanabalan
ad72d38193 Update plant column references in ConfigurationExporter and ConfigurationImporter to use 'code' instead of 'name' 2025-09-06 11:30:07 +05:30
dhanabalan
cac91722c3 Refactor form schema in StickerMasterResource for improved clarity and organization 2025-09-05 17:27:24 +05:30
dhanabalan
bb2b81d0f2 updated header name for leak current limit in motor testing master 2025-09-05 14:41:27 +05:30
dhanabalan
2150f6098f Added required isi model column for motor testing importer and exporter 2025-09-05 14:32:47 +05:30
dhanabalan
a0a1e87440 Added subassembly code to motor master output in TestingPanelController 2025-09-05 14:03:54 +05:30
dhanabalan
8da3c746b9 Added sub assembly column in import and export 2025-09-05 09:35:06 +05:30
dhanabalan
d05623f920 Added subassembly code in resource page of motor testing master 2025-09-05 09:33:16 +05:30
dhanabalan
e3d29cba81 Added subassembly code in model file in motor testing master 2025-09-05 09:31:06 +05:30
dhanabalan
5cbae18532 Added subassembly code column motor testing master 2025-09-05 09:28:50 +05:30
dhanabalan
7e688683d7 corrected bundle logic for invoice quantity 2025-08-27 08:37:21 +05:30
dhanabalan
ab5a8c0874 Removed unwanted column in bundle data in invoice mail 2025-08-26 19:06:51 +05:30
dhanabalan
19e1f12f5d Refactor invoice report generation to include quantity metrics and enhance email content structure 2025-08-26 18:08:06 +05:30
dhanabalan
e57962f023 Merge branch 'master' of ssh://172.31.31.31:2222/poc/pds 2025-08-26 18:01:43 +05:30
dhanabalan
c5a730b71d Added roles column in view reports and Refactor User table columns for improved sorting and searching functionality 2025-08-26 17:57:16 +05:30
root
967a429595 Merge branch 'master' of https://git.iotsignin.com/poc/pds 2025-08-26 16:35:02 +05:30
root
7f0d138383 WIP: local changes before pull 2025-08-26 16:21:53 +05:30
dhanabalan
d5c0303be4 Merge branch 'master' of ssh://172.31.31.31:2222/poc/pds 2025-08-26 16:10:31 +05:30
dhanabalan
c2f9b77e1f Create motor_testing_masters table with comprehensive fields for motor testing data 2025-08-26 16:09:10 +05:30
3053098cfb Updated file name to work migration functionality in order 2025-08-26 10:32:46 +00:00
a5ded4a20a Added plant column with BIGINT type and its default value as 0 2025-08-26 10:25:05 +00:00
dhanabalan
d419973ab5 Add getRedirectUrl method to resource creation classes for consistent redirection 2025-08-26 15:44:51 +05:30
dhanabalan
86e458037f Removed unnecessary lines in alert_mail_rules table 2025-08-25 20:09:24 +05:30
dhanabalan
e6ba543589 Added roles on UserExporter and UserImporter for consistency and enhanced functionality 2025-08-25 17:00:00 +05:30
dhanabalan
1cee8dc71d Enhance item description field to auto-populate based on selected item ID 2025-08-25 12:17:49 +05:30
dhanabalan
3a009543ea Update MachineResource refine line selection logic 2025-08-25 11:43:09 +05:30
dhanabalan
d4045b7b0f Update validation for line stop code to require a minimum length of 3 characters 2025-08-22 14:47:01 +05:30
dhanabalan
a831f6e787 Testing 2025-08-21 18:07:08 +05:30
dhanabalan
b399141c7e Add UserExporter and UserImporter classes with export/import functionality 2025-08-21 17:07:34 +05:30
dhanabalan
8fd2212ec4 Refactor PermissionSeeder to update permissions for user, plant, and block views 2025-08-21 16:32:32 +05:30
dhanabalan
e6f78c60d5 Fix email address for admin in UserSeeder 2025-08-21 16:07:43 +05:30
dhanabalan
a3a421af88 Added logic in quality validation screen to scan capacitor qr code in part validation 5 2025-08-21 14:06:23 +05:30
dhanabalan
d4eeee7d05 Refactor root redirect logic to simplify default behavior 2025-08-20 19:53:01 +05:30
dhanabalan
bd17af8945 Update root redirect logic to handle specific host 2025-08-20 19:49:28 +05:30
dhanabalan
95f1e09304 Added policy file for eb reading 2025-08-12 17:27:36 +05:30
dhanabalan
fc42e7db6c Add TempLiveReadingResource files from qds branch 2025-08-12 17:21:22 +05:30
dhanabalan
0d3e58e7af Add EbReadingImporter and EbReadingExporter from qds branch 2025-08-12 17:18:02 +05:30
dhanabalan
658d7cb42c Add EbReadingResource related files from qds branch 2025-08-12 17:14:40 +05:30
dhanabalan
679d532b17 Add EbReading.php model file from qds branch 2025-08-12 17:07:54 +05:30
dhanabalan
50ddd51f04 Add eb_readings migration from qds branch 2025-08-12 16:52:39 +05:30
78 changed files with 1121 additions and 1755 deletions

View File

@@ -30,252 +30,11 @@ class SendInvoiceReport extends Command
* Execute the console command.
*/
// public function handle()
// {
// $schedule = $this->argument('schedule_type');
// $plantid = $this->argument('plant');
// $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
// $startDate = now()->setTime(8, 0, 0);
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
// $plants = InvoiceValidation::select('plant_id')->distinct()->pluck('plant_id');
// $serialTableData = [];
// $materialTableData = [];
// $bundleTableData = [];
// $noSerial = 1;
// $noMaterial = 1;
// $noBundle = 1;
// foreach ($plants as $plantId) {
// $plant = Plant::find($plantId);
// $plantName = $plant ? $plant->name : $plantId;
// //..Serial Invoice
// $totalSerialCount = InvoiceValidation::where('plant_id', $plantId)
// ->whereNull('quantity')
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedSerialCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->whereNull('quantity')
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
// )
// ->count();
// $serialTableData[] = [
// 'no' => $noSerial++,
// 'plant' => $plantName,
// 'totalInvoice' => $totalSerialCount,
// 'scannedInvoice' => $scannedSerialCount,
// ];
// //..Individual Invoice
// $TotalMatCount = InvoiceValidation::where('plant_id', $plantId)
// ->where('quantity', 1)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedMatCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->where('quantity', 1)
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
// )
// ->count();
// $materialTableData[] = [
// 'no' => $noMaterial++,
// 'plant' => $plantName,
// 'totalInvoice' => $TotalMatCount,
// 'scannedInvoice' => $scannedMatCount,
// ];
// //..BUndle Invoice
// $totalBundleCount = InvoiceValidation::where('plant_id', $plantId)
// ->where('quantity', '>', 1)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedBundleCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->where('quantity', '>', 1)
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
// )
// ->count();
// $bundleTableData[] = [
// 'no' => $noBundle++,
// 'plant' => $plantName,
// 'totalInvoice' => $totalBundleCount,
// 'scannedInvoice' => $scannedBundleCount,
// ];
// }
// // Send to SerialInvoiceMail recipients
// if ($mailRules->has('SerialInvoiceMail')) {
// $emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test($serialTableData, [], []));
// }
// }
// // Send to MaterialInvoiceMail recipients (material + bundle table)
// if ($mailRules->has('MaterialInvoiceMail')) {
// $emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
// }
// }
// // Send to InvoiceMail recipients (all three tables)
// if ($mailRules->has('InvoiceMail')) {
// $emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData));
// }
// }
// //$this->info(json_encode($materialTableData));
// }
// public function handle()
// {
// $schedule = $this->argument('schedule_type');
// $plantId = $this->argument('plant');
// $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
// $startDate = now()->setTime(8, 0, 0);
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
// $serialTableData = [];
// $materialTableData = [];
// $bundleTableData = [];
// $plant = Plant::find($plantId);
// $plantName = $plant ? $plant->name : $plantId;
// // Serial Invoice
// $totalSerialCount = InvoiceValidation::where('plant_id', $plantId)
// ->whereNull('quantity')
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedSerialCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->whereNull('quantity')
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
// )
// ->count();
// $serialTableData[] = [
// 'no' => 1,
// 'plant' => $plantName,
// 'totalInvoice' => $totalSerialCount,
// 'scannedInvoice' => $scannedSerialCount,
// ];
// // Individual Material Invoice
// $TotalMatCount = InvoiceValidation::where('plant_id', $plantId)
// ->where('quantity', 1)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedMatCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->where('quantity', 1)
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
// )
// ->count();
// $materialTableData[] = [
// 'no' => 1,
// 'plant' => $plantName,
// 'totalInvoice' => $TotalMatCount,
// 'scannedInvoice' => $scannedMatCount,
// ];
// // Bundle Invoice
// $totalBundleCount = InvoiceValidation::where('plant_id', $plantId)
// ->where('quantity', '>', 1)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedBundleCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->where('quantity', '>', 1)
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
// )
// ->count();
// $bundleTableData[] = [
// 'no' => 1,
// 'plant' => $plantName,
// 'totalInvoice' => $totalBundleCount,
// 'scannedInvoice' => $scannedBundleCount,
// ];
// // Send to SerialInvoiceMail recipients
// if ($mailRules->has('SerialInvoiceMail')) {
// $emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test($serialTableData, [], []));
// }
// }
// // Send to MaterialInvoiceMail recipients (material + bundle table)
// if ($mailRules->has('MaterialInvoiceMail')) {
// $emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
// }
// }
// // Send to InvoiceMail recipients (all three tables)
// if ($mailRules->has('InvoiceMail')) {
// $emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData));
// }
// }
// // $this->table(
// // ['No', 'Plant', 'Total Invoice', 'Scanned Invoice'],
// // $serialTableData
// // );
// }
public function handle()
{
$schedule = $this->argument('schedule_type');
//$scheduleType = $this->argument('scheduleType');
$plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
@@ -303,7 +62,8 @@ class SendInvoiceReport extends Command
$startDate = now()->setTime(8, 0, 0);
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
}
foreach ($plantIds as $plantId) {
foreach ($plantIds as $plantId)
{
$plant = Plant::find($plantId);
$plantName = $plant ? $plant->name : $plantId;
@@ -322,11 +82,27 @@ class SendInvoiceReport extends Command
->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)")
->count();
$serialInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
->where('quantity', null)
->whereBetween('created_at', [$startDate, $endDate])
->count();
$scannedInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
->where('scanned_status', 'Scanned')
->where(function($query) {
$query->whereNull('quantity')
->orWhere('quantity', 0);
})
->whereBetween('updated_at', [$startDate, $endDate])
->count();
$serialTableData[] = [
'no' => $no,
'plant' => $plantName,
'totalInvoice' => $totalSerialCount,
'scannedInvoice' => $scannedSerialCount,
'totalInvoiceQuan' => $serialInvoiceQuan,
'scannedInvoiceQuan' => $scannedInvoiceQuan,
];
// Material Invoice
@@ -344,11 +120,25 @@ class SendInvoiceReport extends Command
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
->count();
$totalMatInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
->where('quantity', 1)
->whereBetween('created_at', [$startDate, $endDate])
->count();
$scannedMatInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
->where('quantity', 1)
->whereNotNull('serial_number')
->where('serial_number','!=', '')
->whereBetween('updated_at', [$startDate, $endDate])
->count();
$materialTableData[] = [
'no' => $no,
'plant' => $plantName,
'totalInvoice' => $totalMatCount,
'scannedInvoice' => $scannedMatCount,
'totalInvoiceQuan' => $totalMatInvoiceQuan,
'scannedInvoiceQuan' => $scannedMatInvoiceQuan,
];
// Bundle Invoice
@@ -366,29 +156,49 @@ class SendInvoiceReport extends Command
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
->count();
$totalBundleInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
->where('quantity', '>', 1)
->whereBetween('created_at', [$startDate, $endDate])
->count();
$scannedBundleInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
->where('quantity', '>', 1)
->whereNotNull('serial_number')
->where('serial_number','!=', '')
->whereBetween('updated_at', [$startDate, $endDate])
->count();
$bundleTableData[] = [
'no' => $no,
'plant' => $plantName,
'totalInvoice' => $totalBundleCount,
'scannedInvoice' => $scannedBundleCount,
'totalInvoiceQuan' => $totalBundleInvoiceQuan,
'scannedInvoiceQuan' => $scannedBundleInvoiceQuan,
];
$no++;
}
$mail = new test($serialTableData, $materialTableData, $bundleTableData, $schedule);
$contentVars = $mail->content()->with;
$this->info($contentVars['greeting'] ?? 'Invoice Report');
// Send to SerialInvoiceMail recipients
if ($mailRules->has('SerialInvoiceMail')) {
$emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
foreach ($emails as $email) {
Mail::to($email)->send(new test($serialTableData, [], []));
Mail::to($email)->send(new test($serialTableData, [], [], $schedule));
}
}
// Send to MaterialInvoiceMail recipients (material + bundle table)
if ($mailRules->has('MaterialInvoiceMail')) {
$emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
foreach ($emails as $email) {
Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
Mail::to($email)->send(new test([], $materialTableData, $bundleTableData, $schedule));
}
}
@@ -396,19 +206,21 @@ class SendInvoiceReport extends Command
if ($mailRules->has('InvoiceMail')) {
$emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
foreach ($emails as $email) {
Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData));
Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
}
}
// Show preview in console
$this->info('--- Serial Invoice Table ---');
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $serialTableData);
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $serialTableData);
$this->info('--- Material Invoice Table ---');
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $materialTableData);
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $materialTableData);
$this->info('--- Bundle Invoice Table ---');
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $bundleTableData);
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $bundleTableData);
$this->info($contentVars['wishes'] ?? '');
}

View File

@@ -33,77 +33,6 @@ class SendProductionReport extends Command
* Execute the console command.
*/
// public function handle()
// {
// $scheduleType = $this->argument('schedule_type');
// $plantId = $this->argument('plant');
// $mailRules = \App\Models\AlertMailRule::where('module', 'ProductionQuantities')
// ->where('rule_name', 'ProductionMail')
// ->where('plant', $plantId)
// ->where('schedule_type', $scheduleType)
// ->get();
// $emails = $mailRules->pluck('email')->unique()->toArray();
// $plant = Plant::find($plantId);
// if (!$plant) {
// $this->error("Invalid plant ID: $plantId");
// return;
// }
// $lines = Line::where('plant_id', $plantId)->get();
// $startDate = now()->setTime(8, 0, 0);
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
// $PlanstartDate = now()->setTime(8, 0, 0);
// $planendDate = now()->copy()->addDay()->setTime(7, 59, 00);
// $tableData = [];
// $no = 1;
// foreach ($lines as $line) {
// $lineId = $line->id;
// $lineName = $line->name;
// $targetQuantity = ProductionPlan::where('plant_id', $plantId)
// ->where('line_id', $lineId)
// ->whereBetween('created_at', [$PlanstartDate, $planendDate])
// ->sum('plan_quantity');
// $productionQuantity = ProductionQuantity::where('plant_id', $plantId)
// ->where('line_id', $lineId)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->count();
// $tableData[] = [
// 'no' => $no++,
// 'plant' => $plant->name,
// 'line' => $lineName,
// 'targetQuantity' => $targetQuantity,
// 'productionQuantity' => $productionQuantity,
// ];
// }
// // $this->table(
// // ['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'],
// // $tableData
// // );
// if (!empty($emails)) {
// foreach ($emails as $email) {
// Mail::to($email)->send(new ProductionMail($tableData));
// }
// } else {
// $this->info('No recipients found for ProductionMailAlert.');
// }
// $this->info("Production report sent to " . count($emails) . " recipient(s).");
// }
public function handle()
{
$scheduleType = $this->argument('schedule_type');
@@ -146,55 +75,6 @@ class SendProductionReport extends Command
$tableData = [];
$no = 1;
// foreach ($plants as $plant) {
// $lines = Line::where('plant_id', $plant->id)->get();
// foreach ($lines as $line) {
// $targetQuantity = ProductionPlan::where('plant_id', $plant->id)
// ->where('line_id', $line->id)
// ->whereBetween('created_at', [$PlanstartDate, $planendDate])
// ->sum('plan_quantity');
// $productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
// ->where('line_id', $line->id)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->count();
// $tableData[] = [
// 'no' => $no++,
// 'plant' => $plant->name,
// 'line' => $line->name,
// 'targetQuantity' => $targetQuantity,
// 'productionQuantity' => $productionQuantity,
// ];
// }
// }
// $fgTableData = []; // store FG Line related data
// foreach ($plants as $plant) {
// // ✅ Only get FG Lines
// $fgLines = Line::where('plant_id', $plant->id)
// ->where('type', 'FG Line')
// ->get();
// foreach ($fgLines as $line) {
// $validationCount = \App\Models\QualityValidation::where('plant_id', $plant->id)
// ->where('line_id', $line->id)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->count();
// $fgTableData[] = [
// 'no' => $no++,
// 'plant' => $plant->name,
// 'line' => $line->name,
// 'targetQuantity' => $targetQuantity,
// 'productionQuantity' => $validationCount,
// ];
// }
// }
//..
//.
foreach ($plants as $plant)
@@ -232,20 +112,38 @@ class SendProductionReport extends Command
///$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $fgTableData);
//$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $fgTableData);
$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $tableData);
// $this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $tableData);
// if (!empty($emails)) {
// foreach ($emails as $email) {
// Mail::to($email)->send(new ProductionMail($tableData));
// }
// } else {
// $this->info('No recipients found for ProductionMailAlert.');
// }
// $this->info("Production report sent to " . count($emails) . " recipient(s).");
// Preview in console
$mail = new ProductionMail($scheduleType, $tableData);
$contentVars = $mail->content()->with;
$this->info($contentVars['greeting'] ?? 'Production Report');
$this->table(
['No', 'Plant', 'Line', 'Type', 'Target Quantity', 'Production Quantity'],
$tableData
);
$this->info($contentVars['wishes'] ?? '');
// Send mails
if (!empty($emails)) {
foreach ($emails as $email) {
Mail::to($email)->send(new ProductionMail($tableData));
Mail::to($email)->send(new ProductionMail($scheduleType, $tableData));
}
$this->info("Production report sent to " . count($emails) . " recipient(s).");
} else {
$this->info('No recipients found for ProductionMailAlert.');
$this->warn('No recipients found for ProductionMailAlert.');
}
$this->info("Production report sent to " . count($emails) . " recipient(s).");
}
}

View File

@@ -22,7 +22,7 @@ class ConfigurationExporter extends Exporter
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
ExportColumn::make('plant.code')
->label('PLANT'),
ExportColumn::make('line.name')
->label('LINE'),

View File

@@ -1,92 +0,0 @@
<?php
namespace App\Filament\Exports;
use App\Models\MfmReading;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class MfmReadingExporter extends Exporter
{
protected static ?string $model = MfmReading::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.name')
->label('PLANT'),
ExportColumn::make('mfmMeter.name')
->label('MFM METER NAME'),
ExportColumn::make('apparent_energy_received')
->label('APPARENT ENERGY RECEIVED'),
ExportColumn::make('reactive_energy_received')
->label('REACTIVE ENERGY RECEIVED'),
ExportColumn::make('active_energy_received')
->label('ACTIVE ENERGY RECEIVED'),
ExportColumn::make('active_power_r')
->label('ACTIVE POWER R'),
ExportColumn::make('active_power_y')
->label('ACTIVE POWER Y'),
ExportColumn::make('active_power_b')
->label('ACTIVE POWER B'),
ExportColumn::make('active_power_total')
->label('ACTIVE POWER TOTAL'),
ExportColumn::make('voltage_ry')
->label('VOLTAGE RY'),
ExportColumn::make('voltage_yb')
->label('VOLTAGE YB'),
ExportColumn::make('voltage_br')
->label('VOLTAGE BR'),
ExportColumn::make('current_r')
->label('CURRENT R'),
ExportColumn::make('current_y')
->label('CURRENT Y'),
ExportColumn::make('current_b')
->label('CURRENT B'),
ExportColumn::make('current_n')
->label('CURRENT N'),
ExportColumn::make('voltage_r_n')
->label('VOLTAGE R N'),
ExportColumn::make('voltage_y_n')
->label('VOLTAGE Y N'),
ExportColumn::make('voltage_b_n')
->label('VOLTAGE B N'),
ExportColumn::make('frequency')
->label('FREQUENCY'),
ExportColumn::make('power_factor_r')
->label('POWER FACTOR R'),
ExportColumn::make('power_factor_y')
->label('POWER FACTOR Y'),
ExportColumn::make('power_factor_b')
->label('POWER FACTOR B'),
ExportColumn::make('power_factor_total')
->label('POWER FACTOR TOTAL'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->label('DELETED AT')
->enabledByDefault(false),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your mfm reading 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;
}
}

View File

@@ -28,6 +28,8 @@ class MotorTestingMasterExporter extends Exporter
->label('CATEGORY'),
ExportColumn::make('item.code')
->label('ITEM CODE'),
ExportColumn::make('subassembly_code')
->label('SUBASSEMBLY CODE'),
ExportColumn::make('item.description')
->label('DESCRIPTION'),
ExportColumn::make('isi_model')
@@ -69,9 +71,9 @@ class MotorTestingMasterExporter extends Exporter
ExportColumn::make('res_br_ul')
->label('RESISTANCE BR UL'),
ExportColumn::make('lock_volt_limit')
->label('LOCK VOLT Limit'),
->label('LOCK VOLT LIMIT'),
ExportColumn::make('leak_cur_limit')
->label('Leak CURRENT Limit'),
->label('LEAK CURRENT LIMIT'),
ExportColumn::make('lock_cur_ll')
->label('LOCK CURRENT LL'),
ExportColumn::make('lock_cur_ul')

View File

@@ -1,51 +0,0 @@
<?php
namespace App\Filament\Exports;
use App\Models\TempLiveReading;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class TempLiveReadingExporter extends Exporter
{
protected static ?string $model = TempLiveReading::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('mfmMeter.name')
->label('MFM METER NAME'),
ExportColumn::make('register_data')
->label('REGISTER DATA'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->label('DELETED AT')
->enabledByDefault(false),
ExportColumn::make('created_by')
->label('CREATED BY'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your temp live reading 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;
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace App\Filament\Exports;
use App\Models\User;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class UserExporter extends Exporter
{
protected static ?string $model = User::class;
public static function getColumns(): array
{
static $rowNumber = 0;
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('name')
->label('NAME'),
ExportColumn::make('email')
->label('E-MAIL'),
ExportColumn::make('password')
->label('PASSWORD'),
ExportColumn::make('roles')
->label('ROLES')
->state(function ($record) {
// Assuming Spatie\Permission: roles() relationship
return $record->roles->pluck('name')->join(', ');
}),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your user 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;
}
}

View File

@@ -41,15 +41,15 @@ class ConfigurationImporter extends Importer
ImportColumn::make('line')
->requiredMapping()
->relationship(resolveUsing: 'name')
->exampleHeader('Plant')
->exampleHeader('Line')
->example(['4 inch pump line'])
->label('Line')
->rules(['required']),
ImportColumn::make('plant')
->requiredMapping()
->relationship(resolveUsing: 'name')
->relationship(resolveUsing: 'code')
->exampleHeader('Plant')
->example(['Ransar Industries-I'])
->example(['1000'])
->label('Plant')
->rules(['required']),
];

View File

@@ -36,7 +36,6 @@ class DeviceMasterImporter extends Importer
->requiredMapping()
->exampleHeader('IP Address')
->label('IP Address')
->example('172.31.76.67')
->rules(['required', 'ip']),
ImportColumn::make('created_by')
->requiredMapping()

View File

@@ -35,7 +35,7 @@ class LineStopImporter extends Importer
public function resolveRecord(): ?LineStop
{
$warnMsg = [];
if (Str::length($this->data['code']) < 6 || !ctype_alnum($this->data['code'])) {
if (Str::length($this->data['code']) < 3 || !ctype_alnum($this->data['code'])) {
$warnMsg[] = "Invalid line stop code found";
}
if (Str::length($this->data['reason']) < 5) {

View File

@@ -15,13 +15,13 @@ class MfmMeterImporter extends Importer
{
return [
ImportColumn::make('plant')
->requiredMapping()
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('devicemaster')
ImportColumn::make('Device Name')
->requiredMapping()
->exampleHeader('Device Name')
->example('REG001')

View File

@@ -1,186 +0,0 @@
<?php
namespace App\Filament\Imports;
use App\Models\MfmReading;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
class MfmReadingImporter extends Importer
{
protected static ?string $model = MfmReading::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('mfmMeter')
->requiredMapping()
->exampleHeader('Mfm Meter Name')
->example('Display SSB')
->label('Display SSB')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('apparent_energy_received')
->requiredMapping()
->exampleHeader('Apparent Energy Received')
->example('1084610')
->label('Apparent Energy Received')
->rules(['required']),
ImportColumn::make('reactive_energy_received')
->requiredMapping()
->exampleHeader('Reactive Energy Received')
->example('347496.9')
->label('Reactive Energy Received')
->rules(['required']),
ImportColumn::make('active_energy_received')
->requiredMapping()
->exampleHeader('Active Energy Received')
->example('611717.1')
->label('Active Energy Received')
->rules(['required']),
ImportColumn::make('active_power_r')
->requiredMapping()
->exampleHeader('Active Power R')
->example('3.974')
->label('Active Power R')
->rules(['required']),
ImportColumn::make('active_power_y')
->requiredMapping()
->exampleHeader('Active Power Y')
->example('0.796')
->label('Active Power Y')
->rules(['required']),
ImportColumn::make('active_power_b')
->requiredMapping()
->exampleHeader('Active Power B')
->example('1.397')
->label('Active Power B')
->rules(['required']),
ImportColumn::make('active_power_total')
->requiredMapping()
->exampleHeader('Active Power Total')
->example('6.433')
->label('Active Power Total')
->rules(['required']),
ImportColumn::make('voltage_ry')
->requiredMapping()
->exampleHeader('Voltage RY')
->example('413.308')
->label('Voltage RY')
->rules(['required']),
ImportColumn::make('voltage_yb')
->requiredMapping()
->exampleHeader('Voltage YB')
->example('415.305')
->label('Voltage YB')
->rules(['required']),
ImportColumn::make('voltage_br')
->requiredMapping()
->exampleHeader('Voltage BR')
->example('415.216')
->label('Voltage BR')
->rules(['required']),
ImportColumn::make('current_r')
->requiredMapping()
->exampleHeader('Current R')
->example('17.446')
->label('Current R')
->rules(['required']),
ImportColumn::make('current_y')
->requiredMapping()
->exampleHeader('Current Y')
->example('4.801')
->label('Current Y')
->rules(['required']),
ImportColumn::make('current_b')
->requiredMapping()
->exampleHeader('Current B')
->example('7.04')
->label('Current B')
->rules(['required']),
ImportColumn::make('current_n')
->requiredMapping()
->exampleHeader('Current N')
->example('14.063')
->label('Current N')
->rules(['required']),
ImportColumn::make('voltage_r_n')
->requiredMapping()
->exampleHeader('Voltage R N')
->example('237.898')
->label('Voltage R N')
->rules(['required']),
ImportColumn::make('voltage_y_n')
->requiredMapping()
->exampleHeader('Voltage Y N')
->example('239.518')
->label('Voltage Y N')
->rules(['required']),
ImportColumn::make('voltage_b_n')
->requiredMapping()
->exampleHeader('Voltage B N')
->example('240.798')
->label('Voltage B N')
->rules(['required']),
ImportColumn::make('frequency')
->requiredMapping()
->exampleHeader('Frequency')
->example('50.228')
->label('Frequency')
->rules(['required']),
ImportColumn::make('power_factor_r')
->requiredMapping()
->exampleHeader('Power Factor R')
->example('0.988')
->label('Power Factor R')
->rules(['required']),
ImportColumn::make('power_factor_y')
->requiredMapping()
->exampleHeader('Power Factor Y')
->example('0.764')
->label('Power Factor Y')
->rules(['required']),
ImportColumn::make('power_factor_b')
->requiredMapping()
->exampleHeader('Power Factor B')
->example('0.849')
->label('Power Factor B')
->rules(['required']),
ImportColumn::make('power_factor_total')
->requiredMapping()
->exampleHeader('Power Factor Total')
->example('0.919')
->label('Power Factor Total')
->rules(['required']),
];
}
public function resolveRecord(): ?MfmReading
{
// return MfmReading::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new MfmReading();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your mfm reading 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;
}
}

View File

@@ -22,7 +22,14 @@ class MotorTestingMasterImporter extends Importer
->label('Item Code')
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('subassembly_code')
->requiredMapping()
->exampleHeader('SubAssembly Code')
->example(['123456'])
->label('SubAssembly Code')
->rules(['required']),
ImportColumn::make('isi_model')
->requiredMapping()
->boolean()
->exampleHeader('ISI Model')
->example(['Y','N','Y'])
@@ -144,8 +151,8 @@ class MotorTestingMasterImporter extends Importer
->rules(['required']),
ImportColumn::make('leak_cur_limit')
->requiredMapping()
->exampleHeader('Leakage Current Limit')
->label('Leakage Current Limit')
->exampleHeader('Leak Current Limit')
->label('Leak Current Limit')
->example(['50','50','50'])
->rules(['required']),
ImportColumn::make('lock_cur_ll')

View File

@@ -1,66 +0,0 @@
<?php
namespace App\Filament\Imports;
use App\Models\TempLiveReading;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
class TempLiveReadingImporter extends Importer
{
protected static ?string $model = TempLiveReading::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('mfmMeter')
->requiredMapping()
->exampleHeader('Mfm Meter Name')
->example('Display SSB')
->label('Mfm Meter Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('register_data')
->requiredMapping()
->exampleHeader('Register Data')
->example('65165,5646,561,561')
->label('Register Data')
->rules(['required']),
ImportColumn::make('created_by')
->requiredMapping()
->exampleHeader('Created By')
->example('Admin')
->label('Created By')
->rules(['required']),
];
}
public function resolveRecord(): ?TempLiveReading
{
// return TempLiveReading::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new TempLiveReading();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your temp live reading 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;
}
}

View File

@@ -0,0 +1,114 @@
<?php
namespace App\Filament\Imports;
use App\Models\User;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Spatie\Permission\Models\Role;
use Str;
class UserImporter extends Importer
{
protected static ?string $model = User::class;
public static function getColumns(): array
{
return [
ImportColumn::make('name')
->requiredMapping()
->exampleHeader('Name')
->example('RAW00001')
->label('Name')
->rules(['required']),//, 'max:255'
ImportColumn::make('email')
->requiredMapping()
->exampleHeader('E-mail')
->example('RAW00001@cripumps.com')
->label('E-mail')
->rules(['required', 'email']),//, 'max:255'
ImportColumn::make('password')
->requiredMapping()
->exampleHeader('Password')
->example('RAW00001')
->label('Password')
->rules(['required']),//, 'max:255'
ImportColumn::make('roles')
->requiredMapping()
->exampleHeader('Roles')
->example('Employee')
->label('Roles')
->rules(['nullable', 'string']), // Optional roles
];
}
public function resolveRecord(): ?User
{
$warnMsg = [];
if (Str::length($this->data['name']) < 1) {
$warnMsg[] = "User name not found!";
}
// || !is_numeric($this->data['code']) || !preg_match('/^[1-9]\d{3,}$/', $this->data['code'])
if (Str::length($this->data['email']) < 5) {
$warnMsg[] = "Invalid email found!";
}
if (Str::length($this->data['password']) < 3) {
$warnMsg[] = "Invalid password found!";
}
// Validate roles if provided
$roles = [];
if (!empty($this->data['roles'])) {
$roles = collect(explode(',', $this->data['roles']))
->map(fn($role) => trim($role))
->filter()
->toArray();
foreach ($roles as $roleName) {
if (!Role::where('name', $roleName)->exists()) {
$warnMsg[] = "Role : '{$roleName}' does not exist!";
}
}
}
else {
$warnMsg[] = "User roles not found!";
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
$user = User::updateOrCreate([
'email' => $this->data['email'],
],
[
'name' => $this->data['name'],
'password' => $this->data['password'],
]);
// Assign roles
if (!empty($roles)) {
$user->syncRoles($roles);
}
return null;
// return User::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
//return new User();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your user 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;
}
}

View File

@@ -12,11 +12,15 @@ class CreateAlertMailRule extends CreateRecord
protected function mutateFormDataBeforeCreate(array $data): array
{
if ($data['is_active']) {
$data['plant'] = 0;
}
return $data;
}
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateBlock extends CreateRecord
{
protected static string $resource = BlockResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateCompany extends CreateRecord
{
protected static string $resource = CompanyResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateConfiguration extends CreateRecord
{
protected static string $resource = ConfigurationResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateDeviceMaster extends CreateRecord
{
protected static string $resource = DeviceMasterResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateEbReading extends CreateRecord
{
protected static string $resource = EbReadingResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -61,6 +61,11 @@ class CreateInvoiceValidation extends CreateRecord
];
}
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
public function processInvoice($invoiceNumber)
{
$invoiceNumber = trim($invoiceNumber);

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateItem extends CreateRecord
{
protected static string $resource = ItemResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateLine extends CreateRecord
{
protected static string $resource = LineResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateLineStop extends CreateRecord
{
protected static string $resource = LineStopResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -21,7 +21,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
protected static string $view = 'filament.resources.pallet-validation-resource.pages.create-locator-invoice-validation';
public $plantId;
public $invoice_number;
public $pallet_number;
public $serial_number, $snoCount;
@@ -29,8 +31,13 @@ class CreateLocatorInvoiceValidation extends CreateRecord
public $locator_number;
public array $matchedSerialNumbersForRemoval = [];
public bool $showRemoveSerialsModal = false;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
public function processinvoiceSNo()
{

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateLocator extends CreateRecord
{
protected static string $resource = LocatorResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -71,9 +71,7 @@ class MachineResource extends Resource
return [];
}
return Line::where('plant_id', $get('plant_id'))
->pluck('name', 'id')
->toArray();
return Line::where('plant_id', $get('plant_id'))->where('no_of_operation', '>', 0)->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(Machine::latest()->first())->line_id;
@@ -87,13 +85,13 @@ class MachineResource extends Resource
}
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;
}
// $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);
}
})

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateMachine extends CreateRecord
{
protected static string $resource = MachineResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -116,7 +116,7 @@ class MfmMeterResource extends Resource
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
->headerActions([
ImportAction::make()
->importer(MfmMeterImporter::class)
->visible(function() {

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateMfmMeter extends CreateRecord
{
protected static string $resource = MfmMeterResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateMfmParameter extends CreateRecord
{
protected static string $resource = MfmParameterResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -2,8 +2,6 @@
namespace App\Filament\Resources;
use App\Filament\Exports\MfmReadingExporter;
use App\Filament\Imports\MfmReadingImporter;
use App\Filament\Resources\MfmReadingResource\Pages;
use App\Filament\Resources\MfmReadingResource\RelationManagers;
use App\Models\MfmReading;
@@ -14,9 +12,6 @@ use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
use Filament\Facades\Filament;
class MfmReadingResource extends Resource
{
@@ -201,18 +196,6 @@ class MfmReadingResource extends Resource
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
ImportAction::make()
->importer(MfmReadingImporter::class)
->visible(function() {
return Filament::auth()->user()->can('view import mfm reading');
}),
ExportAction::make()
->exporter(MfmReadingExporter::class)
->visible(function() {
return Filament::auth()->user()->can('view export mfm reading');
}),
]);
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateMfmReading extends CreateRecord
{
protected static string $resource = MfmReadingResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateModuleList extends CreateRecord
{
protected static string $resource = ModuleListResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -28,9 +28,9 @@ class MotorTestingMasterResource extends Resource
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Master Entries';
protected static ?string $navigationGroup = 'Testing Panel';
protected static ?int $navigationSort = 12;
protected static ?int $navigationSort = 1;
public static function form(Form $form): Form
{
@@ -61,6 +61,11 @@ class MotorTestingMasterResource extends Resource
])
->hint(fn ($get) => $get('mTmError') ? $get('mTmError') : null)
->hintColor('danger'),
Forms\Components\TimePicker::make('routine_test_time')
->label('Routine Test Time')
->default('00:40:00')
->required()
->reactive(),
Forms\Components\Select::make('item_id')
->label('Item Code')
//->relationship('item', 'name')
@@ -82,11 +87,40 @@ class MotorTestingMasterResource extends Resource
->where('plant_id', $get('plant_id'))
->ignore($get('id')); // Ignore current record during updates
}),
Forms\Components\TimePicker::make('routine_test_time')
->label('Routine Test Time')
->default('00:40:00')
Forms\Components\TextInput::make('subassembly_code')
->label('Subassembly Code')
->required()
->reactive(),
->placeholder('Scan the valid code')
->reactive()
->alphaNum()
->minLength(6)
->afterStateUpdated(function ($state, callable $set, callable $get) {
$code = $get('subassembly_code');
// Ensure `linestop_id` is not cleared
if (!$code) {
$set('iCodeError', 'Scan the valid Subassembly Code.');
return;
}
else
{
if (strlen($code) < 6) {
$set('iCodeError', 'Subassembly code must be at least 6 digits.');
return;
}
else if (!preg_match('/^[a-zA-Z0-9]{6,}$/', $code)) {
$set('code',null);
$set('iCodeError', 'Subassembly code must contain only alpha-numeric characters.');
return;
}
$set('iCodeError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('iCodeError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('iCodeError') ? $get('iCodeError') : null)
->hintColor('danger'),
Forms\Components\Select::make('isi_model')
->label('ISI Model')
->options([
@@ -296,6 +330,11 @@ class MotorTestingMasterResource extends Resource
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('subassembly_code')
->label('SubAssembly Code')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('item.description')
->label('Model')
->alignCenter()

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateMotorTestingMaster extends CreateRecord
{
protected static string $resource = MotorTestingMasterResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -14,17 +14,22 @@ use Illuminate\View\View;
class CreatePalletValidation extends CreateRecord
{
public $plantId;
public $pallet_number;
public $palletNo;
public $pendingPallet;
public $snoCount = 0;
public $pallet_number_locked = false;
public $serial_number;
protected static string $view = 'filament.resources.pallet-validation-resource.pages.create-pallet-validation';
protected static string $resource = PalletValidationResource::class;
protected static string $view = 'filament.resources.pallet-validation-resource.pages.create-pallet-validation';
protected static string $resource = PalletValidationResource::class;
protected $listeners = [
'updateSnoQuantity' => 'handleUpdateSnoQuantity',
@@ -32,6 +37,10 @@ class CreatePalletValidation extends CreateRecord
public ?array $data = null;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
public function processPalletSNo()
{

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreatePlant extends CreateRecord
{
protected static string $resource = PlantResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -2093,10 +2093,52 @@ class QualityValidationResource extends Resource
return;
}
// if ($state == $expectedValue)
// {
// $set('part_validation5_error', null);
// }
// else if (strpos($state, '/') != false) {
// $parts = explode('/', $state);
// if (count($parts) >= 2) {
// $segmentToValidate = $parts[1];
// }
// else
// {
// $segmentToValidate = null;
// }
// }
// else
// {
// $set('part_validation5_error', "Invalid input for part validation 5.");
// $set('part_validation5', null);
// return;
// }
if ($state == $expectedValue)
{
$set('part_validation5_error', null);
}
else if (strpos($state, '/') != false)
{
$parts = explode('/', $state);
if (count($parts) >= 2)
{
$segmentToValidate = $parts[1];
if ($segmentToValidate == $expectedValue) {
$set('part_validation5_error', null);
$set('part_validation5', $segmentToValidate);
} else {
$set('part_validation5_error', "Invalid input for part validation 5.");
$set('part_validation5', null);
return;
}
}
else
{
$set('part_validation5_error', "Invalid input format for part validation 5.");
$set('part_validation5', null);
return;
}
}
else
{
$set('part_validation5_error', "Invalid input for part validation 5.");
@@ -2141,6 +2183,7 @@ class QualityValidationResource extends Resource
->sortable(),
Tables\Columns\TextColumn::make('line.name')
->label('Line')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('production_order')
@@ -2417,6 +2460,8 @@ class QualityValidationResource extends Resource
$query->whereIn('sticker_master_id', $stickerMasterIds);
}
}
$query->orderBy('created_at');
})
->indicateUsing(function (array $data) {
$indicators = [];
@@ -2487,7 +2532,8 @@ class QualityValidationResource extends Resource
}),
]);
}
//,,
// public static function mutateFormDataBeforeCreate(array $data): array
// {
// $user =Filament::auth()->user();

View File

@@ -21,6 +21,11 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
protected static string $resource = ReworkLocatorInvoiceValidationResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
public function processInvoiceRework($invoiceNo)
{
$plantId = $this->form->getState()['plant'];

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateShift extends CreateRecord
{
protected static string $resource = ShiftResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -3,12 +3,12 @@
namespace App\Filament\Resources;
use App\Filament\Exports\StickerMasterExporter;
use App\Filament\Imports\ShiftImporter;
//use App\Filament\Imports\ShiftImporter;
use App\Filament\Imports\StickerMasterImporter;
use App\Filament\Resources\StickerMasterResource\Pages;
use App\Filament\Resources\StickerMasterResource\RelationManagers;
//use App\Filament\Resources\StickerMasterResource\RelationManagers;
use App\Models\StickerMaster;
use Closure;
//use Closure;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Form;
@@ -18,6 +18,7 @@ use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Get;
use Filament\Forms\Set;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
// use Illuminate\Validation\Rule;
@@ -35,383 +36,401 @@ class StickerMasterResource extends Resource
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('plant_id')
->relationship('plant', 'name')
->reactive()
->nullable()
->default(function () {
return optional(StickerMaster::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id'))) //disable in edit if user try to change
->afterStateUpdated(fn (callable $set) =>
$set('item_id', null) & //when plant changed remove all the data which is in text input box
$set('item_description', null) &
$set('item_error', null) &
$set('panel_box_code', null) &
$set('load_rate', null) &
$set('bundle_quantity', null) &
$set('material_type', null) &
$set('part_validation1', null) &
$set('part_validation2', null) &
$set('part_validation3', null) &
$set('part_validation4', null) &
$set('part_validation5', null) &
$set('laser_part_validation1', null) &
$set('laser_part_validation2', null) &
$set('serial_number_motor', false) &
$set('serial_number_pump', false) &
$set('serial_number_pumpset', false) &
$set('pack_slip_motor', false) &
$set('pack_slip_pump', false) &
$set('pack_slip_pumpset', false) &
$set('name_plate_motor', false) &
$set('name_plate_pump', false) &
$set('name_plate_pumpset', false) &
$set('tube_sticker_motor', false) &
$set('tube_sticker_pump', false) &
$set('tube_sticker_pumpset', false) &
$set('warranty_card', false)
)
->required(),
->schema([
Forms\Components\Select::make('plant_id')
->relationship('plant', 'name')
->reactive()
->nullable()
->default(function () {
return optional(StickerMaster::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id'))) //disable in edit if user try to change
->afterStateUpdated(fn (callable $set) =>
$set('item_id', null) & //when plant changed remove all the data which is in text input box
$set('item_description', null) &
$set('item_error', null) &
$set('panel_box_code', null) &
$set('load_rate', null) &
$set('bundle_quantity', null) &
$set('material_type', null) &
$set('part_validation1', null) &
$set('part_validation2', null) &
$set('part_validation3', null) &
$set('part_validation4', null) &
$set('part_validation5', null) &
$set('laser_part_validation1', null) &
$set('laser_part_validation2', null) &
$set('serial_number_motor', false) &
$set('serial_number_pump', false) &
$set('serial_number_pumpset', false) &
$set('pack_slip_motor', false) &
$set('pack_slip_pump', false) &
$set('pack_slip_pumpset', false) &
$set('name_plate_motor', false) &
$set('name_plate_pump', false) &
$set('name_plate_pumpset', false) &
$set('tube_sticker_motor', false) &
$set('tube_sticker_pump', false) &
$set('tube_sticker_pumpset', false) &
$set('warranty_card', false)
)
->required(),
Forms\Components\Select::make('item_id')
->label('Item Code')
->options(function (callable $get) {
if (!$get('plant_id')) {
return [];
}
Forms\Components\Select::make('item_id')
->label('Item Code')
->options(function (callable $get) {
if (!$get('plant_id')) {
return [];
}
return \App\Models\Item::where('plant_id', $get('plant_id'))
->pluck('code', 'id')
->toArray();
})
// ->rule(function (callable $get) {
// return Rule::unique('items', 'code')
// ->where('plant_id', $get('plant_id'))
// ->ignore($get('id')); // Ignore current record during updates
// })
->required()
->nullable()
->searchable()
->reactive()
// ->disabled(fn (Get $get) => !empty($get('id')))
->live(debounce: 500) // Enable live updates
->afterStateUpdated(function ($state, callable $set, callable $get) {
return \App\Models\Item::where('plant_id', $get('plant_id'))
->pluck('code', 'id')
->toArray();
})
// ->rule(function (callable $get) {
// return Rule::unique('items', 'code')
// ->where('plant_id', $get('plant_id'))
// ->ignore($get('id')); // Ignore current record during updates
// })
->required()
->nullable()
->searchable()
->reactive()
// ->disabled(fn (Get $get) => !empty($get('id')))
->live(debounce: 500) // Enable live updates
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
$itemId = $get('item_id');
$plantId = $get('plant_id');
$itemId = $get('item_id');
//If plant_id is changed or empty, reset everything
if (blank($plantId)) {
$set('item_id', null);
$set('item_error', null);
$set('item_description', null);
return;
}
//If plant_id is changed or empty, reset everything
if (blank($plantId)) {
$set('item_id', null);
$set('item_error', null);
$set('item_description', null);
return;
}
if (blank($itemId)) {
$set('item_error', null);
$set('item_description', null);
return;
}
if (blank($itemId)) {
$set('item_error', null);
$set('item_description', null);
return;
}
$availableItems = \App\Models\Item::where('plant_id', $plantId)->exists();
if (!$availableItems) {
$set('item_error', null);
return;
}
$availableItems = \App\Models\Item::where('plant_id', $plantId)->exists();
if (!$availableItems) {
$set('item_error', null);
return;
}
// Ensure `item_id` is not cleared
if (!$plantId || !$itemId) {
$set('item_description', null);
return;
}
// Ensure `item_id` is not cleared
if (!$plantId || !$itemId) {
$set('item_description', null);
return;
}
// Check if item exists for the selected plant
$item = \App\Models\Item::where('plant_id', $plantId)
->where('id', $itemId)
->first();
// Check if item exists for the selected plant
$item = \App\Models\Item::where('plant_id', $plantId)
->where('id', $itemId)
->first();
if ($item) {
$set('item_description', $item->description);
} else {
$set('item_description', null);
}
if ($item) {
$set('item_description', $item->description);
} else {
$set('item_description', null);
}
$duplicateSticker = StickerMaster::where('plant_id', $plantId)
->where('item_id', $itemId)
->exists();
if(!$get('id'))
{
$set('item_error', $duplicateSticker ? 'Item Code already exists for the selected plant.' : null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('item_error') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('item_error') ? $get('item_error') : null)
->hintColor('danger'),
$duplicateSticker = StickerMaster::where('plant_id', $plantId)
->where('item_id', $itemId)
->exists();
if(!$get('id'))
{
$set('item_error', $duplicateSticker ? 'Item Code already exists for the selected plant.' : null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('item_error') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('item_error') ? $get('item_error') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('item_description')
->label('Description')
->required()
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
if ($get('id')) {
$itemId = StickerMaster::where('id', $get('id'))->first()?->item_id;
if ($itemId) {
$item = \App\Models\Item::where('id', $itemId)->first()?->description;
if ($item) {
$set('item_description', $item);
} else {
$set('item_description', null);
}
} else {
$set('item_description', null);
}
}
})
->reactive()
->readOnly(true),
Forms\Components\TextInput::make('part_validation1')
->label('Part Validation 1')
->nullable(),
Forms\Components\TextInput::make('item_description')
->label('Description')
->required()
->reactive()
->readOnly(true),
Forms\Components\TextInput::make('part_validation2')
->label('Part Validation 2')
->nullable(),
Forms\Components\TextInput::make('part_validation1')
->nullable(),
Forms\Components\TextInput::make('part_validation3')
->label('Part Validation 3')
->nullable(),
Forms\Components\TextInput::make('part_validation2')
->nullable(),
Forms\Components\TextInput::make('part_validation4')
->label('Part Validation 4')
->nullable(),
Forms\Components\TextInput::make('part_validation3')
->nullable(),
Forms\Components\TextInput::make('part_validation5')
->label('Part Validation 5 (Capacitor QR)')
->nullable(),
Forms\Components\TextInput::make('part_validation4')
->nullable(),
Forms\Components\TextInput::make('laser_part_validation1')
->label('Laser Part Validation 1')
->nullable(),
Forms\Components\TextInput::make('part_validation5')
->nullable(),
Forms\Components\TextInput::make('laser_part_validation2')
->label('Laser Part Validation 2')
->nullable(),
Forms\Components\TextInput::make('laser_part_validation1')
->nullable(),
Forms\Components\TextInput::make('panel_box_code')
->label('Panel Box Code')
->readOnly(fn (callable $get) => $get('material_type'))
->nullable(),
Forms\Components\TextInput::make('laser_part_validation2')
->nullable(),
Forms\Components\TextInput::make('load_rate')
->label('Load Rate')
->default(0)
->required()
->disabled(function ($get) {
return $get('material_type');
})
->integer(),
Forms\Components\TextInput::make('panel_box_code')
->label('Panel Box Code')
->readOnly(fn (callable $get) => $get('material_type'))
->nullable(),
Forms\Components\Select::make('material_type')
->label('Material Type')
->options([
'1' => 'Individual',
'2' => 'Bundle',
'3' => 'Quantity',
])
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
Forms\Components\TextInput::make('load_rate')
->label('Load Rate')
->default(0)
->disabled(function ($get) {
return $get('material_type');
})
->integer()
->nullable(),
if ($state)
{
$set('panel_box_code', null);
$set('load_rate', 0);
}
if ($state !== "2")
{
$set('bundle_quantity', null);
}
else
{
$set('bundle_quantity', 2);
}
//$plantId = $get('plant_id');
})
->nullable(),
Forms\Components\Select::make('material_type')
->label('Material Type')
->options([
'1' => 'Individual',
'2' => 'Bundle',
'3' => 'Quantity',
])
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
Forms\Components\TextInput::make('bundle_quantity')
->label('Bundle Quantity')
->integer()
->readOnly(fn (callable $get) => $get('material_type') !== "2")
->nullable()
->minValue(2)
->reactive()
->afterStateUpdated(function ($state, callable $set,callable $get) {
if($get('material_type') !== "2")
{
$set('bundle_quantity', null);
}
else if ($get('bundle_quantity') < 2)
{
$set('bundle_quantity', 2);
}
}),
if ($state)
{
$set('panel_box_code', null);
$set('load_rate', 0);
}
Forms\Components\Checkbox::make('serial_number_motor')
->reactive()
->disabled(function ($get) {
return $get('serial_number_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('serial_number_pumpset'))
{
$set('serial_number_motor', false);
}
})
->dehydrateStateUsing(fn ($state): mixed => $state ? $state : null),
if ($state !== "2")
{
$set('bundle_quantity', null);
}
else
{
$set('bundle_quantity', 2);
}
//$plantId = $get('plant_id');
})
->nullable(),
Forms\Components\Checkbox::make('serial_number_pump')
->reactive()
->disabled(function ($get) {
return $get('serial_number_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('serial_number_pumpset'))
{
$set('serial_number_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\TextInput::make('bundle_quantity')
->label('Bundle Quantity')
->integer()
->readOnly(fn (callable $get) => $get('material_type') !== "2")
->nullable()
->minValue(2)
->reactive()
->afterStateUpdated(function ($state, callable $set,callable $get) {
if($get('material_type') !== "2")
{
$set('bundle_quantity', null);
}
else if ($get('bundle_quantity') < 2)
{
$set('bundle_quantity', 2);
}
}),
Forms\Components\Checkbox::make('serial_number_pumpset')
->reactive()
->disabled(function ($get) {
return $get('serial_number_motor') || $get('serial_number_pump');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('serial_number_pumpset'))
{
$set('serial_number_motor', false);
$set('serial_number_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('serial_number_motor')
->reactive()
->disabled(function ($get) {
return $get('serial_number_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('serial_number_pumpset'))
{
$set('serial_number_motor', false);
}
})
->dehydrateStateUsing(fn ($state): mixed => $state ? $state : null),
Forms\Components\Checkbox::make('pack_slip_motor')
->reactive()
->disabled(function ($get) {
return $get('pack_slip_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('pack_slip_pumpset'))
{
$set('pack_slip_motor', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('serial_number_pump')
->reactive()
->disabled(function ($get) {
return $get('serial_number_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('serial_number_pumpset'))
{
$set('serial_number_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('pack_slip_pump')
->reactive()
->disabled(function ($get) {
return $get('pack_slip_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('pack_slip_pumpset'))
{
$set('pack_slip_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('serial_number_pumpset')
->reactive()
->disabled(function ($get) {
return $get('serial_number_motor') || $get('serial_number_pump');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('serial_number_pumpset'))
{
$set('serial_number_motor', false);
$set('serial_number_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('pack_slip_pumpset')
->reactive()
->disabled(function ($get) {
return $get('pack_slip_motor') || $get('pack_slip_pump');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('pack_slip_pumpset'))
{
$set('pack_slip_motor', false);
$set('pack_slip_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('pack_slip_motor')
->reactive()
->disabled(function ($get) {
return $get('pack_slip_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('pack_slip_pumpset'))
{
$set('pack_slip_motor', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('name_plate_motor')
->reactive()
->disabled(function ($get) {
return $get('name_plate_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('name_plate_pumpset'))
{
$set('name_plate_motor', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('pack_slip_pump')
->reactive()
->disabled(function ($get) {
return $get('pack_slip_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('pack_slip_pumpset'))
{
$set('pack_slip_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('name_plate_pump')
->reactive()
->disabled(function ($get) {
return $get('name_plate_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('name_plate_pumpset'))
{
$set('name_plate_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('pack_slip_pumpset')
->reactive()
->disabled(function ($get) {
return $get('pack_slip_motor') || $get('pack_slip_pump');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('pack_slip_pumpset'))
{
$set('pack_slip_motor', false);
$set('pack_slip_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('name_plate_pumpset')
->reactive()
->disabled(function ($get) {
return $get('name_plate_motor') || $get('name_plate_pump');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('name_plate_pumpset'))
{
$set('name_plate_motor', false);
$set('name_plate_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('name_plate_motor')
->reactive()
->disabled(function ($get) {
return $get('name_plate_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('name_plate_pumpset'))
{
$set('name_plate_motor', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('tube_sticker_motor')
->reactive()
->disabled(function ($get) {
return $get('tube_sticker_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('tube_sticker_pumpset'))
{
$set('tube_sticker_motor', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('name_plate_pump')
->reactive()
->disabled(function ($get) {
return $get('name_plate_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('name_plate_pumpset'))
{
$set('name_plate_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('tube_sticker_pump')
->reactive()
->disabled(function ($get) {
return $get('tube_sticker_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('tube_sticker_pumpset'))
{
$set('tube_sticker_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('name_plate_pumpset')
->reactive()
->disabled(function ($get) {
return $get('name_plate_motor') || $get('name_plate_pump');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('name_plate_pumpset'))
{
$set('name_plate_motor', false);
$set('name_plate_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('tube_sticker_pumpset')
->nullable()
->reactive()
->disabled(function ($get) {
return $get('tube_sticker_motor') || $get('tube_sticker_pump');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('tube_sticker_pumpset'))
{
$set('tube_sticker_motor', false);
$set('tube_sticker_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null), //to pass null value
Forms\Components\Checkbox::make('tube_sticker_motor')
->reactive()
->disabled(function ($get) {
return $get('tube_sticker_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('tube_sticker_pumpset'))
{
$set('tube_sticker_motor', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('warranty_card')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('tube_sticker_pump')
->reactive()
->disabled(function ($get) {
return $get('tube_sticker_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('tube_sticker_pumpset'))
{
$set('tube_sticker_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('tube_sticker_pumpset')
->nullable()
->reactive()
->disabled(function ($get) {
return $get('tube_sticker_motor') || $get('tube_sticker_pump');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('tube_sticker_pumpset'))
{
$set('tube_sticker_motor', false);
$set('tube_sticker_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null), //to pass null value
Forms\Components\Checkbox::make('warranty_card')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
]);
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
]);
}
public static function table(Table $table): Table
@@ -424,13 +443,13 @@ class StickerMasterResource extends Resource
// ->numeric()
// ->sortable(),
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;
}),
->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')
->alignCenter()

View File

@@ -21,4 +21,9 @@ class CreateStickerMaster extends CreateRecord
]);
}
}
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -14,4 +14,9 @@ class CreateTempLiveReading extends CreateRecord
{
return 'Create Live Readings';
}
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -2,13 +2,18 @@
namespace App\Filament\Resources;
use App\Filament\Exports\UserExporter;
use App\Filament\Imports\UserImporter;
use App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource\RelationManagers;
use App\Models\User;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
@@ -80,6 +85,7 @@ class UserResource extends Resource
// ->label('ID')
// ->numeric()
// ->sortable(),
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
@@ -91,18 +97,23 @@ class UserResource extends Resource
Tables\Columns\TextColumn::make('name')
->label('User Name')
->alignCenter()
->sortable()
->searchable(),
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('email')
->label('Email')
->alignCenter()
->sortable()
->searchable(),
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('email_verified_at')
->label('Email Verified At')
->dateTime()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('roles.name')
->label('Roles')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->dateTime()
@@ -134,6 +145,18 @@ class UserResource extends Resource
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
ImportAction::make()
->importer(UserImporter::class)
->visible(function() {
return Filament::auth()->user()->can('view import user');
}),
ExportAction::make()
->exporter(UserExporter::class)
->visible(function() {
return Filament::auth()->user()->can('view export user');
}),
]);
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateUser extends CreateRecord
{
protected static string $resource = UserResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -1,90 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Gemini\Laravel\Facades\Gemini;
class ChatbotController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
/**
* Store a newly created resource in storage.
*/
// public function handleMessage(Request $request)
// {
// $request->validate(['message' => 'required|string']);
// $userMessage = $request->input('message');
// try {
// $result = Gemini::geminiPro()->generateContent($userMessage);
// $reply = $result->text() ?? 'Sorry, no response from Gemini AI.';
// } catch (\Exception $e) {
// \Log::error('Gemini API Exception: ' . $e->getMessage(), ['trace' => $e->getTraceAsString()]);
// if (config('app.debug')) {
// return response()->json(['reply' => 'Error: ' . $e->getMessage()], 500);
// }
// return response()->json(['reply' => 'Error communicating with Gemini AI. Please try again later.'], 500);
// }
// return response()->json(['reply' => $reply]);
// }
// public function handleMessage(Request $request)
// {
// $request->validate([
// 'message' => 'required|string'
// ]);
// $apiKey = env('GEMINI_API_KEY'); // Put this in .env
// $response = Http::withHeaders([
// 'Content-Type' => 'application/json',
// 'x-goog-api-key' => $apiKey
// ])->post('https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent', [
// 'contents' => [
// ['parts' => [['text' => $request->message]]]
// ]
// ]);
// if ($response->successful()) {
// return response()->json([
// 'reply' => $response->json()['candidates'][0]['content']['parts'][0]['text'] ?? 'No response.'
// ]);
// }
// return response()->json(['reply' => 'Failed to fetch response.'], 500);
// }
/**
* Display the specified resource.
*/
public function show(string $id)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(string $id)
{
//
}
}

View File

@@ -40,18 +40,6 @@ class InvoiceValidationController extends Controller
try
{
$plantCode = $request->header('plant-code');
$invoiceNo = $request->header('invoice-number');
$lineQuan = $request->header('line-quantity');
if (!$plantCode) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Plant Code value can't be empty"
], 404);
}
$data = $request->all();
if (!isset($data['plant_code']) || trim($data['plant_code']) == '')
@@ -70,8 +58,7 @@ class InvoiceValidationController extends Controller
}
$plant = Plant::where('code', $data['plant_code'])->first();
if (!$plant)
{
if (!$plant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => 'Plant not found!'

View File

@@ -73,68 +73,6 @@ class PalletController extends Controller
// $mpdf->Output('qr-label.pdf', 'I');
}
// public function downloadQrPdf($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: 60mm; height: auto; font-size: 10pt; font-family: DejaVu Sans, sans-serif; }
// .sticker-table { width: 60mm; height: 14mm; border-collapse: collapse;}
// .qr-cell { width: 14mm;}
// .text-cell { text-align: left; vertical-align: middle; font-size: 22pt; padding-left: 1mm; padding-top: 2mm; white-space: nowrap; font-weight: bold; }
// img.qr { width: 19mm; height: 19mm; display: block; margin-left: -2mm;}
// </style>
// </head>
// <body>
// ' . $htmlBlock . $htmlBlock . '
// <script>
// window.onload = function () {
// window.print();
// setTimeout(function () {
// window.close();
// }, 1000); // Wait 1 second before closing
// };
// </script>
// </body>
// </html>';
// // $mpdf = new Mpdf([
// // 'mode' => 'utf-8',
// // 'format' => [60, 14],
// // 'margin_left' => 0,
// // 'margin_right' => 0,
// // 'margin_top' => 0,
// // 'margin_bottom' => 0,
// // // 'tempDir' => '/var/www/storage/mpdf-tmp',
// // ]);
// // $mpdf->WriteHTML($html);
// // // Output PDF to browser for printing
// // $mpdf->Output('qr-label.pdf', 'I');
// }
/**
* Store a newly created resource in storage.
*/
public function downloadQrPdf($palletNo)
{
$qrCode = new QrCode($palletNo);
@@ -142,7 +80,7 @@ class PalletController extends Controller
$qrBinary = $output->output($qrCode, 100);
$qrBase64 = base64_encode($qrBinary);
$htmlBlock = '
$htmlBlock = '
<table class="sticker-table">
<tr>
<td class="qr-cell">
@@ -154,43 +92,48 @@ class PalletController extends Controller
</tr>
</table>';
$html = '
<html>
<head>
<style>
body { margin: 0; padding: 0; width: 60mm; height: auto; font-size: 10pt; font-family: DejaVu Sans, sans-serif; }
.sticker-table { width: 60mm; height: 14mm; border-collapse: collapse; page-break-after: always; }
.qr-cell { width: 14mm; text-align: right; vertical-align: bottom; padding-left: 0mm; padding-top: 0mm; }
.text-cell { text-align: left; vertical-align: middle; font-size: 22pt; padding-left: 1mm; padding-top: 2mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; }
img.qr { width: 16mm; height: 16mm; display: block; margin-left: -2mm;}
</style>
</head>
<body>
' . $htmlBlock . $htmlBlock . '
<script>
window.onload = function () {
window.print();
setTimeout(function () {
window.close();
}, 1000); // Wait 1 second before closing
};
</script>
</body>
</html>';
return '
<html>
<head>
<style>
body { margin: 0; padding: 0; width: 60mm; height: auto; font-size: 10pt; font-family: DejaVu Sans, sans-serif; }
.sticker-table { width: 60mm; height: 14mm; border-collapse: collapse; page-break-after: always; }
.qr-cell { width: 14mm; 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: 2mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; }
img.qr { width: 19mm; height: 19mm; 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>';
$mpdf = new Mpdf([
'mode' => 'utf-8',
'format' => [60, 14],
'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0,
// 'tempDir' => '/var/www/storage/mpdf-tmp',
]);
// $mpdf = new Mpdf([
// 'mode' => 'utf-8',
// 'format' => [60, 14],
// 'margin_left' => 0,
// 'margin_right' => 0,
// 'margin_top' => 0,
// 'margin_bottom' => 0,
// // 'tempDir' => '/var/www/storage/mpdf-tmp',
// ]);
$mpdf->WriteHTML($html);
$mpdf->Output('qr-label.pdf', 'I');
// $mpdf->WriteHTML($html);
// // Output PDF to browser for printing
// $mpdf->Output('qr-label.pdf', 'I');
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//

View File

@@ -458,6 +458,7 @@ class TestingPanelController extends Controller
}
$output = [
"mot_subassembly_code" => $motorTestingMaster->subassembly_code ?? "",
"mot_model_name" => $description,
"mot_non_isi_model" => $motorTestingMaster->isi_model ? "0" :"1",
"mot_phase" => $motorTestingMaster->phase ?? "",
@@ -488,7 +489,7 @@ class TestingPanelController extends Controller
"mot_noload_pow_ll" => $motorTestingMaster->noload_pow_ll ?? "",
"mot_noload_pow_ul" => $motorTestingMaster->noload_pow_ul ?? "",
"mot_noload_spd_ll" => $motorTestingMaster->noload_spd_ll ?? "",
"mot_noload_spd_ul" => $motorTestingMaster->noload_spd_ul ?? "",
"mot_noload_spd_ul" => $motorTestingMaster->noload_spd_ul ?? ""
];
return response()->json($output, 200);

View File

@@ -2,6 +2,7 @@
namespace App\Mail;
use DateTime;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
@@ -14,12 +15,14 @@ class ProductionMail extends Mailable
use Queueable, SerializesModels;
public $tableData;
public $scheduleType;
/**
* Create a new message instance.
*/
public function __construct($tableData = [])
public function __construct($scheduleType,$tableData = [])
{
$this->scheduleType = $scheduleType;
$this->tableData = $tableData ?? [];
}
@@ -36,19 +39,57 @@ class ProductionMail extends Mailable
/**
* Get the message content definition.
*/
// public function content(): Content
// {
// return new Content(
// view: 'mail.production_report',
// with: [
// 'company' => "CRI Digital Manufacturing Solutions",
// 'greeting' => "Dear Sir/Madam,<br><br>Kindly find the attached production report status details for the 'Target Quantity' and 'Production Quantity' count,",
// // 'greeting' => "Dear Sir/Madam,<br><br>Kindly find the attached production report status details for the 'Target Quantity' and 'Production Quantity' count,<br>" . $reportPeriod,
// 'tableData' => $this->tableData,
// 'wishes' => "Thanks & Regards,<br>CRI Digital Manufacturing Solutions"
// ],
// );
// }
public function content(): Content
{
return new Content(
$greeting = "Dear Sir/Madam,<br><br>Kindly find the attached production report status details for the 'Target Quantity' and 'Production Quantity' count,";
if ($this->scheduleType == 'Daily') {
$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.production_report',
with: [
'company' => "CRI Digital Manufacturing Solutions",
'greeting' => "Dear Sir/Madam,<br><br>Kindly find the attached production report status details for the 'Target Quantity' and 'Production Quantity' count,",
'greeting' => $greeting,
'tableData' => $this->tableData,
'wishes' => "Thanks & Regards,<br>CRI Digital Manufacturing Solutions"
],
);
}
/**
* Get the attachments for the message.
*

View File

@@ -2,6 +2,7 @@
namespace App\Mail;
use DateTime;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
@@ -16,16 +17,16 @@ class test extends Mailable
public $materialTableData;
public $bundleTableData;
public $schedule;
/**
* Create a new message instance.
*/
// public function __construct($tableData = [])
// {
// $this->tableData = $tableData ?? [];
// }
public function __construct($serialTableData, $materialTableData, $bundleTableData)
public function __construct($serialTableData, $materialTableData, $bundleTableData, $schedule)
{
$this->schedule = $schedule;
$this->serialTableData = $serialTableData;
$this->materialTableData = $materialTableData;
$this->bundleTableData = $bundleTableData;
@@ -44,18 +45,54 @@ class test extends Mailable
/**
* Get the message content definition.
*/
// public function content(): Content
// {
// return new Content(
// view: 'mail.test_mail',
// with: [
// 'company' => "CRI Digital Manufacturing Solutions",
// 'greeting' => "Dear Sir/Madam,<br><br>Kindly find the attached invoice status details for the 'Total Number of Invoices' and 'Scanned Number of Invoices' count,",
// //'tableData' => $this->tableData,
// 'serialTableData' => $this->serialTableData,
// 'materialTableData' => $this->materialTableData,
// 'bundleTableData' => $this->bundleTableData,
// 'wishes' => "Thanks & Regards,<br>CRI Digital Manufacturing Solutions"
// ],
// );
// }
public function content(): Content
{
$greeting = "Dear Sir/Madam,<br><br>Kindly find the attached invoice status details for the 'Total Number of Invoices' and 'Scanned Number of Invoices' count,";
if ($this->schedule == '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;
$greeting .= "<br><br>$reportPeriod";
}
if ($this->schedule == '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->schedule == '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.test_mail',
// with: [
// 'name' => "CRI Digital Manufacturing Solutions<br><br>Dear Sir/Madam,<br><br> Kindly find the attached invoice status details for the 'Total Number Of Invoices' and 'Scanned Number Of Invoices' count,",
// 'tableData' => $this->tableData,
// 'wishes' => "Thanks & Regards<br><br>CRI Digital Manufacturing Solutions"
// ],
with: [
with: [
'company' => "CRI Digital Manufacturing Solutions",
'greeting' => "Dear Sir/Madam,<br><br>Kindly find the attached invoice status details for the 'Total Number of Invoices' and 'Scanned Number of Invoices' count,",
'greeting' => $greeting,
//'greeting' => "Dear Sir/Madam,<br><br>Kindly find the attached invoice status details for the 'Total Number of Invoices' and 'Scanned Number of Invoices' count,",
//'tableData' => $this->tableData,
'serialTableData' => $this->serialTableData,
'materialTableData' => $this->materialTableData,

View File

@@ -13,6 +13,7 @@ class MotorTestingMaster extends Model
protected $fillable = [
'plant_id',
'item_id',
'subassembly_code',
'isi_model',
'phase',
'kw',

View File

@@ -22,6 +22,12 @@ class ProductionQuantity extends Model
"serial_number",
"production_order",
"operator_id",
// "success_status",
// "no_of_employee",
// "list_of_employee",
"created_at",
"updated_at"
];
public function plant(): BelongsTo

View File

@@ -35,6 +35,8 @@ class QualityValidation extends Model
'part_validation5',
'operator_id',
'uom',
'created_at',
'updated_at',
'serial_number',
'sap_msg_status',
'sap_msg_description',

View File

@@ -86,9 +86,4 @@ return [
'livewire_loading_delay' => 'default',
// 'assets' => [
// 'app.js', // or your filament.js file
// ],
];

View File

@@ -1,84 +0,0 @@
<?php
use Laravel\Sanctum\Sanctum;
return [
/*
|--------------------------------------------------------------------------
| Stateful Domains
|--------------------------------------------------------------------------
|
| Requests from the following domains / hosts will receive stateful API
| authentication cookies. Typically, these should include your local
| and production domains which access your API via a frontend SPA.
|
*/
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'%s%s',
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
Sanctum::currentApplicationUrlWithPort(),
// Sanctum::currentRequestHost(),
))),
/*
|--------------------------------------------------------------------------
| Sanctum Guards
|--------------------------------------------------------------------------
|
| This array contains the authentication guards that will be checked when
| Sanctum is trying to authenticate a request. If none of these guards
| are able to authenticate the request, Sanctum will use the bearer
| token that's present on an incoming request for authentication.
|
*/
'guard' => ['web'],
/*
|--------------------------------------------------------------------------
| Expiration Minutes
|--------------------------------------------------------------------------
|
| This value controls the number of minutes until an issued token will be
| considered expired. This will override any values set in the token's
| "expires_at" attribute, but first-party sessions are not affected.
|
*/
'expiration' => null,
/*
|--------------------------------------------------------------------------
| Token Prefix
|--------------------------------------------------------------------------
|
| Sanctum can prefix new tokens in order to take advantage of numerous
| security scanning initiatives maintained by open source platforms
| that notify developers if they commit tokens into repositories.
|
| See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning
|
*/
'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''),
/*
|--------------------------------------------------------------------------
| Sanctum Middleware
|--------------------------------------------------------------------------
|
| When authenticating your first-party SPA with Sanctum you may need to
| customize some of the middleware Sanctum uses while processing the
| request. You may change the middleware listed below as required.
|
*/
'middleware' => [
'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class,
'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class,
'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
],
];

View File

@@ -35,8 +35,4 @@ return [
],
],
'gemini' => [
'key' => env('GEMINI_API_KEY'),
],
];

View File

@@ -70,7 +70,6 @@ return new class extends Migration
DB::statement($sql);
}
/**
* Reverse the migrations.
*/

View File

@@ -15,6 +15,8 @@ return new class extends Migration
CREATE TABLE alert_mail_rules (
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
plant BIGINT NOT NULL DEFAULT(0),
module TEXT NOT NULL,
rule_name TEXT NOT NULL,
@@ -27,6 +29,7 @@ return new class extends Migration
created_by TEXT NOT NULL,
updated_by TEXT NOT NULL
);
SQL;

View File

@@ -1,40 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// Enable TimescaleDB extension
DB::statement('CREATE EXTENSION IF NOT EXISTS timescaledb;');
DB::statement('ALTER TABLE mfm_readings ADD PRIMARY KEY (id, created_at);');
// Create hypertable partitioned by created_at
DB::statement("
SELECT create_hypertable(
'mfm_readings',
'created_at',
chunk_time_interval => interval '1 day',
if_not_exists => TRUE
);
");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('mfm_readings', function (Blueprint $table) {
// //
// });
}
};

View File

@@ -13,8 +13,8 @@ return new class extends Migration
{
$sql1 = <<<'SQL'
ALTER TABLE alert_mail_rules
ADD plant BIGINT NOT NULL DEFAULT (0);
ALTER TABLE motor_testing_masters
ADD subassembly_code TEXT DEFAULT NULL;
SQL;
@@ -26,7 +26,7 @@ return new class extends Migration
*/
public function down(): void
{
// Schema::table('alert_mail_rules', function (Blueprint $table) {
// Schema::table('motor_testing_masters', function (Blueprint $table) {
// //
// });
}

View File

@@ -34,24 +34,57 @@ class PermissionSeeder extends Seeder
}
//Master and Transaction Pages
Permission::updateOrCreate(['name' => 'view import block']);
Permission::updateOrCreate(['name' => 'view export block']);
Permission::updateOrCreate(['name' => 'view import user']);
Permission::updateOrCreate(['name' => 'view export user']);
Permission::updateOrCreate(['name' => 'view import company']);
Permission::updateOrCreate(['name' => 'view export company']);
Permission::updateOrCreate(['name' => 'view import plant']);
Permission::updateOrCreate(['name' => 'view export plant']);
Permission::updateOrCreate(['name' => 'view import block']);
Permission::updateOrCreate(['name' => 'view export block']);
Permission::updateOrCreate(['name' => 'view import shift']);
Permission::updateOrCreate(['name' => 'view export shift']);
Permission::updateOrCreate(['name' => 'view import line']);
Permission::updateOrCreate(['name' => 'view export line']);
Permission::updateOrCreate(['name' => 'view import item']);
Permission::updateOrCreate(['name' => 'view export item']);
Permission::updateOrCreate(['name' => 'view import line stop']);
Permission::updateOrCreate(['name' => 'view export line stop']);
Permission::updateOrCreate(['name' => 'view import sticker master']);
Permission::updateOrCreate(['name' => 'view export sticker master']);
Permission::updateOrCreate(['name' => 'view import locator']);
Permission::updateOrCreate(['name' => 'view export locator']);
Permission::updateOrCreate(['name' => 'view import configuration']);
Permission::updateOrCreate(['name' => 'view export configuration']);
Permission::updateOrCreate(['name' => 'view import work group master']);
Permission::updateOrCreate(['name' => 'view export work group master']);
Permission::updateOrCreate(['name' => 'view import machine']);
Permission::updateOrCreate(['name' => 'view export machine']);
Permission::updateOrCreate(['name' => 'view import motor testing master']);
Permission::updateOrCreate(['name' => 'view export motor testing master']);
Permission::updateOrCreate(['name' => 'view import guard name']);
Permission::updateOrCreate(['name' => 'view export guard name']);
Permission::updateOrCreate(['name' => 'view import check point name']);
Permission::updateOrCreate(['name' => 'view export check point name']);
Permission::updateOrCreate(['name' => 'view import check point time']);
Permission::updateOrCreate(['name' => 'view export check point time']);
Permission::updateOrCreate(['name' => 'view import guard name']);
Permission::updateOrCreate(['name' => 'view export guard name']);
Permission::updateOrCreate(['name' => 'view import guard patrol entry']);
Permission::updateOrCreate(['name' => 'view export guard patrol entry']);
Permission::updateOrCreate(['name' => 'view import guard patrol entries']);
@@ -60,34 +93,13 @@ class PermissionSeeder extends Seeder
Permission::updateOrCreate(['name' => 'view import material invoice']);
Permission::updateOrCreate(['name' => 'view export invoice']);
Permission::updateOrCreate(['name' => 'view import item']);
Permission::updateOrCreate(['name' => 'view export item']);
Permission::updateOrCreate(['name' => 'view import line']);
Permission::updateOrCreate(['name' => 'view export line']);
Permission::updateOrCreate(['name' => 'view import line stop']);
Permission::updateOrCreate(['name' => 'view export line stop']);
Permission::updateOrCreate(['name' => 'view import locator invoice validation']);
Permission::updateOrCreate(['name' => 'view export locator invoice validation']);
Permission::updateOrCreate(['name' => 'view import dispatch serial invoice validation']);
Permission::updateOrCreate(['name' => 'view import locator']);
Permission::updateOrCreate(['name' => 'view export locator']);
Permission::updateOrCreate(['name' => 'view import machine']);
Permission::updateOrCreate(['name' => 'view export machine']);
Permission::updateOrCreate(['name' => 'view import motor testing master']);
Permission::updateOrCreate(['name' => 'view export motor testing master']);
Permission::updateOrCreate(['name' => 'view import pallet validation']);
Permission::updateOrCreate(['name' => 'view export pallet validation']);
Permission::updateOrCreate(['name' => 'view import plant']);
Permission::updateOrCreate(['name' => 'view export plant']);
Permission::updateOrCreate(['name' => 'view import production line stop']);
Permission::updateOrCreate(['name' => 'view export production line stop']);
@@ -100,12 +112,6 @@ class PermissionSeeder extends Seeder
Permission::updateOrCreate(['name' => 'view import quality validation']);
Permission::updateOrCreate(['name' => 'view export quality validation']);
Permission::updateOrCreate(['name' => 'view import shift']);
Permission::updateOrCreate(['name' => 'view export shift']);
Permission::updateOrCreate(['name' => 'view import sticker master']);
Permission::updateOrCreate(['name' => 'view export sticker master']);
Permission::updateOrCreate(['name' => 'view import testing panel reading']);
Permission::updateOrCreate(['name' => 'view export testing panel reading']);
@@ -144,7 +150,6 @@ class PermissionSeeder extends Seeder
Permission::updateOrCreate(['name' => 'view ems trend line analysis dashboard']);
Permission::updateOrCreate(['name' => 'view ems trend chart analysis dashboard']);
//Send To Sap Permissions
Permission::updateOrCreate(['name' => 'view quality data send to sap']);
Permission::updateOrCreate(['name' => 'view production data send to sap']);

View File

@@ -14,7 +14,7 @@ class UserSeeder extends Seeder
public function run(): void
{
$user1 = User::updateOrCreate(
['email' => 'dhanabalan@cripumps.com'],
['email' => 'dhanabalan.saravanan@cripumps.com'],
[
'name' => 'Dhanabalan S',
'password' => bcrypt('SdHaNa@123'),

View File

@@ -1,22 +0,0 @@
Markets & Economy:
* The Reserve Bank of India (RBI) has kept the repo rate unchanged at 5.5% and maintained its GDP growth forecast at 6.5%.
* The RBI has lowered its inflation forecast for the 2026 fiscal year to 3.1%.
* India's foreign exchange reserves have decreased by $9 billion to $689 billion.
* The rupee has seen a rise of 15 paise, reaching 87.73 against the U.S. dollar in early trading.
* In the U.K., the services sector has experienced its most significant drop in orders in nearly three years.
Corporate News:
* Intel is reportedly facing challenges with a crucial manufacturing process for its upcoming PC chip.
* Shareholders are suing Elon Musk, alleging that he made exaggerated claims about Tesla's Robotaxi.
* News Corp has issued a warning that Donald Trump's AI is using content from his book, "The Art of the Deal."
* Chinese automakers, including BYD, saw significant increases in their U.K. sales in July.
Global Trade:
* There are concerns about the potential impact of tariffs proposed by Donald Trump on the Indian economy.
Other News:
* Central GST officers in India have uncovered significant tax evasion amounting to approximately Rs 7.08 lakh crore over the past five fiscal years.

View File

@@ -1,6 +0,0 @@
SIZE 60 mm,40 mm
GAP 3 mm,0 mm
CLS
QRCODE 40,100,M,4,A,0,M2,"HelloWorld123"
TEXT 200,100,"3",0,1,1,"HelloWorld123"
PRINT 1

View File

@@ -1,44 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Chart.js Example</title>
</head>
<body>
<canvas id="myChart"></canvas>
<!-- Load Chart.js and plugins -->
<script src="js/chart.min.js"></script>
<script src="js/chartjs-plugin-datalabels.min.js"></script>
<script src="js/chartjs-plugin-annotation.min.js"></script>
<!-- Your chart initialization code -->
<script>
const ctx = document.getElementById('myChart').getContext('2d');
new Chart(ctx, {
type: 'bar',
data: {
labels: ['Red', 'Blue', 'Yellow'],
datasets: [{
label: '# of Votes',
data: [12, 19, 3]
}]
},
options: {
plugins: {
datalabels: {
// plugin options
},
annotation: {
// plugin options
}
},
scales: {
y: {
beginAtZero: true
}
}
}
});
</script>
</body>
</html>

View File

@@ -1,4 +0,0 @@
// import ChartDataLabels from 'chartjs-plugin-datalabels'
// window.filamentChartJsPlugins ??= []
// window.filamentChartJsPlugins.push(ChartDataLabels)

View File

@@ -1 +0,0 @@
@import '../../../../vendor/filament/filament/resources/css/theme.css';

View File

@@ -1,3 +1 @@
import './bootstrap';

View File

@@ -1,86 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Gemini Chat</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 40px;
}
#chat-box {
border: 1px solid #ccc;
padding: 15px;
height: 300px;
overflow-y: scroll;
margin-bottom: 10px;
}
.user, .bot {
margin-bottom: 10px;
}
.user {
text-align: right;
color: blue;
}
.bot {
text-align: left;
color: green;
}
</style>
</head>
<body>
<h2>Gemini Chat</h2>
<div id="chat-box"></div>
<textarea id="prompt" rows="3" cols="60" placeholder="Type your message here..."></textarea><br>
<button onclick="sendPrompt()">Send</button>
<script>
async function getGeminiResponse(prompt) {
try {
const res = await fetch('http://172.31.31.51:8000/api/chatbot/message', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ message: prompt })
});
if (!res.ok) {
const errorText = await res.text();
console.error(`Server returned ${res.status}:`, errorText);
throw new Error(`HTTP error! Status: ${res.status}`);
}
const data = await res.json();
return data.reply || "Sorry, no response.";
} catch (e) {
console.error('Fetch error:', e);
return "Error fetching response.";
}
}
async function sendPrompt() {
const promptInput = document.getElementById('prompt');
const prompt = promptInput.value.trim();
if (!prompt) return;
appendMessage('user', prompt);
promptInput.value = '';
const reply = await getGeminiResponse(prompt);
appendMessage('bot', reply);
}
function appendMessage(sender, text) {
const chatBox = document.getElementById('chat-box');
const message = document.createElement('div');
message.className = sender;
message.textContent = text;
chatBox.appendChild(message);
chatBox.scrollTop = chatBox.scrollHeight;
}
</script>
</body>
</html>

View File

@@ -1,8 +0,0 @@
<button
type="button"
wire:click="updateInvoice"
class="px-2 py-1 border border-primary-500 text-primary-600 rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
>
Update Invoice
</button>

View File

@@ -98,6 +98,8 @@
<th>Plant</th>
<th>Total Number of Invoice</th>
<th>Scanned Number of Invoice</th>
<th>Total Invoice Quantity</th>
<th>Scanned Invoice Quantity</th>
</tr>
</thead>
<tbody>
@@ -107,6 +109,8 @@
<td style="white-space: nowrap;">{{ $row['plant'] }}</td>
<td>{{ $row['totalInvoice'] }}</td>
<td>{{ $row['scannedInvoice'] }}</td>
<td>{{ $row['totalInvoiceQuan'] }}</td>
<td>{{ $row['scannedInvoiceQuan'] }}</td>
</tr>
@endforeach
</tbody>
@@ -123,6 +127,8 @@
<th>Plant</th>
<th>Total Number of Invoice</th>
<th>Scanned Number of Invoice</th>
<th>Total Invoice Quantity</th>
<th>Scanned Invoice Quantity</th>
</tr>
</thead>
<tbody>
@@ -132,6 +138,8 @@
<td style="white-space: nowrap;">{{ $row['plant'] }}</td>
<td>{{ $row['totalInvoice'] }}</td>
<td>{{ $row['scannedInvoice'] }}</td>
<td>{{ $row['totalInvoiceQuan'] }}</td>
<td>{{ $row['scannedInvoiceQuan'] }}</td>
</tr>
@endforeach
</tbody>
@@ -148,6 +156,8 @@
<th>Plant</th>
<th>Total Number of Invoice</th>
<th>Scanned Number of Invoice</th>
<th>Total Invoice Quantity</th>
<th>Scanned Invoice Quantity</th>
</tr>
</thead>
<tbody>
@@ -157,6 +167,8 @@
<td style="white-space: nowrap;">{{ $row['plant'] }}</td>
<td>{{ $row['totalInvoice'] }}</td>
<td>{{ $row['scannedInvoice'] }}</td>
<td>{{ $row['totalInvoiceQuan'] }}</td>
<td>{{ $row['scannedInvoiceQuan'] }}</td>
</tr>
@endforeach
</tbody>

View File

@@ -1,6 +1,5 @@
<?php
use App\Http\Controllers\ChatbotController;
use App\Http\Controllers\InvoiceValidationController;
use App\Http\Controllers\MachineController;
use App\Http\Controllers\MfmParameterController;
@@ -140,5 +139,3 @@ Route::post('serial-invoice/store-data', [InvoiceValidationController::class, 's
Route::post('material-invoice/store-data', [InvoiceValidationController::class, 'materialInvoice']);
Route::post('/chatbot/message', [ChatbotController::class, 'handleMessage']);

View File

@@ -9,17 +9,17 @@ Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');
// Schedule::command('send:invoice-report');
// Schedule::command('send:production-report');
// Schedule::command('send:invoice-report');
// Schedule::command('send:production-report');
app()->booted(function () {
$schedule = app(Schedule::class);
app()->booted(function () {
$schedule = app(Schedule::class);
//Production report scheduling
// Production report scheduling
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
->where('rule_name', 'ProductionMail')
//->select('plant', 'schedule_type')
->select('plant', 'schedule_type')
->select('plant', 'schedule_type')
->distinct()
->get();
@@ -31,7 +31,7 @@ Artisan::command('inspire', function () {
$command = $schedule->command('send:production-report', [$type, $plantId]);
switch ($type) {
case 'Live':
case 'Live':
$command->everyMinute();
break;
case 'Hourly':
@@ -65,8 +65,8 @@ Artisan::command('inspire', function () {
case 'Daily':
$command->dailyAt('07:59');
break;
}
}
}
});
});

View File

@@ -10,11 +10,6 @@ use Illuminate\Support\Facades\Route;
return redirect('/admin');
});
Route::get('/chatbot', function () {
return view('chatbot');
});
// Route::get('/scheduler', function() {
// Artisan::call('schedule:run');
// });