Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c070c9763e | ||
|
|
2116ea422e | ||
|
|
acc98ad876 | ||
|
|
45898b2fa2 | ||
|
|
390e013ccb |
@@ -30,11 +30,252 @@ 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');
|
||||
@@ -62,8 +303,7 @@ 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;
|
||||
|
||||
@@ -82,27 +322,11 @@ 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
|
||||
@@ -120,25 +344,11 @@ 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
|
||||
@@ -156,49 +366,29 @@ 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, [], [], $schedule));
|
||||
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, $schedule));
|
||||
Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,21 +396,19 @@ 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, $schedule));
|
||||
Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData));
|
||||
}
|
||||
}
|
||||
|
||||
// Show preview in console
|
||||
$this->info('--- Serial Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $serialTableData);
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $serialTableData);
|
||||
|
||||
$this->info('--- Material Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $materialTableData);
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $materialTableData);
|
||||
|
||||
$this->info('--- Bundle Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $bundleTableData);
|
||||
|
||||
$this->info($contentVars['wishes'] ?? '');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $bundleTableData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,77 @@ 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');
|
||||
@@ -75,6 +146,55 @@ 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)
|
||||
@@ -112,38 +232,20 @@ 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($scheduleType, $tableData));
|
||||
Mail::to($email)->send(new ProductionMail($tableData));
|
||||
}
|
||||
$this->info("Production report sent to " . count($emails) . " recipient(s).");
|
||||
} else {
|
||||
$this->warn('No recipients found for ProductionMailAlert.');
|
||||
$this->info('No recipients found for ProductionMailAlert.');
|
||||
}
|
||||
|
||||
$this->info("Production report sent to " . count($emails) . " recipient(s).");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class ConfigurationExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE'),
|
||||
|
||||
92
app/Filament/Exports/MfmReadingExporter.php
Normal file
92
app/Filament/Exports/MfmReadingExporter.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,6 @@ 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')
|
||||
@@ -71,9 +69,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')
|
||||
|
||||
51
app/Filament/Exports/TempLiveReadingExporter.php
Normal file
51
app/Filament/Exports/TempLiveReadingExporter.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
@@ -41,15 +41,15 @@ class ConfigurationImporter extends Importer
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Line')
|
||||
->exampleHeader('Plant')
|
||||
->example(['4 inch pump line'])
|
||||
->label('Line')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'code')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Plant')
|
||||
->example(['1000'])
|
||||
->example(['Ransar Industries-I'])
|
||||
->label('Plant')
|
||||
->rules(['required']),
|
||||
];
|
||||
|
||||
@@ -36,6 +36,7 @@ class DeviceMasterImporter extends Importer
|
||||
->requiredMapping()
|
||||
->exampleHeader('IP Address')
|
||||
->label('IP Address')
|
||||
->example('172.31.76.67')
|
||||
->rules(['required', 'ip']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
|
||||
@@ -35,7 +35,7 @@ class LineStopImporter extends Importer
|
||||
public function resolveRecord(): ?LineStop
|
||||
{
|
||||
$warnMsg = [];
|
||||
if (Str::length($this->data['code']) < 3 || !ctype_alnum($this->data['code'])) {
|
||||
if (Str::length($this->data['code']) < 6 || !ctype_alnum($this->data['code'])) {
|
||||
$warnMsg[] = "Invalid line stop code found";
|
||||
}
|
||||
if (Str::length($this->data['reason']) < 5) {
|
||||
|
||||
@@ -21,7 +21,7 @@ class MfmMeterImporter extends Importer
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('Device Name')
|
||||
ImportColumn::make('devicemaster')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Device Name')
|
||||
->example('REG001')
|
||||
|
||||
186
app/Filament/Imports/MfmReadingImporter.php
Normal file
186
app/Filament/Imports/MfmReadingImporter.php
Normal file
@@ -0,0 +1,186 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
@@ -22,14 +22,7 @@ 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'])
|
||||
@@ -151,8 +144,8 @@ class MotorTestingMasterImporter extends Importer
|
||||
->rules(['required']),
|
||||
ImportColumn::make('leak_cur_limit')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Leak Current Limit')
|
||||
->label('Leak Current Limit')
|
||||
->exampleHeader('Leakage Current Limit')
|
||||
->label('Leakage Current Limit')
|
||||
->example(['50','50','50'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('lock_cur_ll')
|
||||
|
||||
66
app/Filament/Imports/TempLiveReadingImporter.php
Normal file
66
app/Filament/Imports/TempLiveReadingImporter.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
@@ -12,15 +12,11 @@ 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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateBlock extends CreateRecord
|
||||
{
|
||||
protected static string $resource = BlockResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateCompany extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CompanyResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateConfiguration extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ConfigurationResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateDeviceMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = DeviceMasterResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateEbReading extends CreateRecord
|
||||
{
|
||||
protected static string $resource = EbReadingResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,11 +61,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
];
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
|
||||
public function processInvoice($invoiceNumber)
|
||||
{
|
||||
$invoiceNumber = trim($invoiceNumber);
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateItem extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ItemResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateLine extends CreateRecord
|
||||
{
|
||||
protected static string $resource = LineResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateLineStop extends CreateRecord
|
||||
{
|
||||
protected static string $resource = LineStopResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,7 @@ 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;
|
||||
@@ -31,13 +29,8 @@ 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()
|
||||
{
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateLocator extends CreateRecord
|
||||
{
|
||||
protected static string $resource = LocatorResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,9 @@ class MachineResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $get('plant_id'))->where('no_of_operation', '>', 0)->pluck('name', 'id')->toArray();
|
||||
return Line::where('plant_id', $get('plant_id'))
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(Machine::latest()->first())->line_id;
|
||||
@@ -85,13 +87,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);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateMachine extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MachineResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateMfmMeter extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MfmMeterResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateMfmParameter extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MfmParameterResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
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;
|
||||
@@ -12,6 +14,9 @@ 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
|
||||
{
|
||||
@@ -196,6 +201,18 @@ 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');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateMfmReading extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MfmReadingResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateModuleList extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ModuleListResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ class MotorTestingMasterResource extends Resource
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Testing Panel';
|
||||
protected static ?string $navigationGroup = 'Master Entries';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
protected static ?int $navigationSort = 12;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
@@ -61,11 +61,6 @@ 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')
|
||||
@@ -87,40 +82,11 @@ class MotorTestingMasterResource extends Resource
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
}),
|
||||
Forms\Components\TextInput::make('subassembly_code')
|
||||
->label('Subassembly Code')
|
||||
Forms\Components\TimePicker::make('routine_test_time')
|
||||
->label('Routine Test Time')
|
||||
->default('00:40:00')
|
||||
->required()
|
||||
->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'),
|
||||
|
||||
->reactive(),
|
||||
Forms\Components\Select::make('isi_model')
|
||||
->label('ISI Model')
|
||||
->options([
|
||||
@@ -330,11 +296,6 @@ 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()
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateMotorTestingMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MotorTestingMasterResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,33 +14,24 @@ 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 $listeners = [
|
||||
'updateSnoQuantity' => 'handleUpdateSnoQuantity',
|
||||
];
|
||||
|
||||
public ?array $data = null;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
|
||||
public function processPalletSNo()
|
||||
{
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreatePlant extends CreateRecord
|
||||
{
|
||||
protected static string $resource = PlantResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2093,52 +2093,10 @@ 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.");
|
||||
@@ -2183,7 +2141,6 @@ class QualityValidationResource extends Resource
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('production_order')
|
||||
@@ -2460,8 +2417,6 @@ class QualityValidationResource extends Resource
|
||||
$query->whereIn('sticker_master_id', $stickerMasterIds);
|
||||
}
|
||||
}
|
||||
|
||||
$query->orderBy('created_at');
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
@@ -2532,8 +2487,7 @@ class QualityValidationResource extends Resource
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
//,,
|
||||
// public static function mutateFormDataBeforeCreate(array $data): array
|
||||
// {
|
||||
// $user =Filament::auth()->user();
|
||||
|
||||
@@ -21,11 +21,6 @@ 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'];
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateShift extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ShiftResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,7 +18,6 @@ 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;
|
||||
@@ -99,6 +98,7 @@ class StickerMasterResource extends Resource
|
||||
// ->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');
|
||||
|
||||
@@ -153,53 +153,32 @@ class StickerMasterResource extends Resource
|
||||
->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('part_validation2')
|
||||
->label('Part Validation 2')
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation3')
|
||||
->label('Part Validation 3')
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation4')
|
||||
->label('Part Validation 4')
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation5')
|
||||
->label('Part Validation 5 (Capacitor QR)')
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('laser_part_validation1')
|
||||
->label('Laser Part Validation 1')
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('laser_part_validation2')
|
||||
->label('Laser Part Validation 2')
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('panel_box_code')
|
||||
@@ -210,11 +189,12 @@ class StickerMasterResource extends Resource
|
||||
Forms\Components\TextInput::make('load_rate')
|
||||
->label('Load Rate')
|
||||
->default(0)
|
||||
->required()
|
||||
->disabled(function ($get) {
|
||||
return $get('material_type');
|
||||
})
|
||||
->integer(),
|
||||
->integer()
|
||||
->nullable(),
|
||||
|
||||
|
||||
Forms\Components\Select::make('material_type')
|
||||
->label('Material Type')
|
||||
@@ -430,6 +410,7 @@ class StickerMasterResource extends Resource
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,4 @@ class CreateStickerMaster extends CreateRecord
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,4 @@ class CreateTempLiveReading extends CreateRecord
|
||||
{
|
||||
return 'Create Live Readings';
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,13 @@
|
||||
|
||||
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;
|
||||
@@ -85,7 +80,6 @@ class UserResource extends Resource
|
||||
// ->label('ID')
|
||||
// ->numeric()
|
||||
// ->sortable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
@@ -97,23 +91,18 @@ class UserResource extends Resource
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('User Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('email')
|
||||
->label('Email')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
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()
|
||||
@@ -145,18 +134,6 @@ 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');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateUser extends CreateRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
90
app/Http/Controllers/ChatbotController.php
Normal file
90
app/Http/Controllers/ChatbotController.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,18 @@ 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']) == '')
|
||||
@@ -58,7 +70,8 @@ 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!'
|
||||
|
||||
@@ -73,6 +73,68 @@ 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);
|
||||
@@ -92,15 +154,15 @@ class PalletController extends Controller
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
return '
|
||||
$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: -8mm; padding-top: 0mm; }
|
||||
.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: 19mm; height: 19mm; display: block; }
|
||||
img.qr { width: 16mm; height: 16mm; display: block; margin-left: -2mm;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -116,24 +178,19 @@ class PalletController extends Controller
|
||||
</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);
|
||||
// // Output PDF to browser for printing
|
||||
// $mpdf->Output('qr-label.pdf', 'I');
|
||||
$mpdf->WriteHTML($html);
|
||||
$mpdf->Output('qr-label.pdf', 'I');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
|
||||
@@ -458,7 +458,6 @@ 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 ?? "",
|
||||
@@ -489,7 +488,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);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use DateTime;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
@@ -15,14 +14,12 @@ class ProductionMail extends Mailable
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tableData;
|
||||
public $scheduleType;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($scheduleType,$tableData = [])
|
||||
public function __construct($tableData = [])
|
||||
{
|
||||
$this->scheduleType = $scheduleType;
|
||||
$this->tableData = $tableData ?? [];
|
||||
}
|
||||
|
||||
@@ -39,57 +36,19 @@ 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
|
||||
{
|
||||
$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' => $greeting,
|
||||
'greeting' => "Dear Sir/Madam,<br><br>Kindly find the attached production report status details for the 'Target Quantity' and 'Production Quantity' count,",
|
||||
'tableData' => $this->tableData,
|
||||
'wishes' => "Thanks & Regards,<br>CRI Digital Manufacturing Solutions"
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use DateTime;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
@@ -17,16 +16,16 @@ class test extends Mailable
|
||||
public $materialTableData;
|
||||
public $bundleTableData;
|
||||
|
||||
public $schedule;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
|
||||
public function __construct($serialTableData, $materialTableData, $bundleTableData, $schedule)
|
||||
// public function __construct($tableData = [])
|
||||
// {
|
||||
// $this->tableData = $tableData ?? [];
|
||||
// }
|
||||
public function __construct($serialTableData, $materialTableData, $bundleTableData)
|
||||
{
|
||||
$this->schedule = $schedule;
|
||||
$this->serialTableData = $serialTableData;
|
||||
$this->materialTableData = $materialTableData;
|
||||
$this->bundleTableData = $bundleTableData;
|
||||
@@ -45,54 +44,18 @@ 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: [
|
||||
'company' => "CRI Digital Manufacturing Solutions",
|
||||
'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,",
|
||||
'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,
|
||||
|
||||
@@ -13,7 +13,6 @@ class MotorTestingMaster extends Model
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'item_id',
|
||||
'subassembly_code',
|
||||
'isi_model',
|
||||
'phase',
|
||||
'kw',
|
||||
|
||||
@@ -22,12 +22,6 @@ 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
|
||||
|
||||
@@ -35,8 +35,6 @@ class QualityValidation extends Model
|
||||
'part_validation5',
|
||||
'operator_id',
|
||||
'uom',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'serial_number',
|
||||
'sap_msg_status',
|
||||
'sap_msg_description',
|
||||
|
||||
@@ -86,4 +86,9 @@ return [
|
||||
|
||||
'livewire_loading_delay' => 'default',
|
||||
|
||||
// 'assets' => [
|
||||
// 'app.js', // or your filament.js file
|
||||
// ],
|
||||
|
||||
|
||||
];
|
||||
|
||||
84
config/sanctum.php
Normal file
84
config/sanctum.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?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,
|
||||
],
|
||||
|
||||
];
|
||||
@@ -35,4 +35,8 @@ return [
|
||||
],
|
||||
],
|
||||
|
||||
'gemini' => [
|
||||
'key' => env('GEMINI_API_KEY'),
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -70,6 +70,7 @@ return new class extends Migration
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
@@ -15,8 +15,6 @@ 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,
|
||||
|
||||
@@ -29,7 +27,6 @@ return new class extends Migration
|
||||
|
||||
created_by TEXT NOT NULL,
|
||||
updated_by TEXT NOT NULL
|
||||
|
||||
);
|
||||
SQL;
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ return new class extends Migration
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
|
||||
ALTER TABLE motor_testing_masters
|
||||
ADD subassembly_code TEXT DEFAULT NULL;
|
||||
ALTER TABLE alert_mail_rules
|
||||
ADD plant BIGINT NOT NULL DEFAULT (0);
|
||||
|
||||
SQL;
|
||||
|
||||
@@ -26,7 +26,7 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('motor_testing_masters', function (Blueprint $table) {
|
||||
// Schema::table('alert_mail_rules', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -34,57 +34,24 @@ class PermissionSeeder extends Seeder
|
||||
}
|
||||
|
||||
//Master and Transaction Pages
|
||||
Permission::updateOrCreate(['name' => 'view import user']);
|
||||
Permission::updateOrCreate(['name' => 'view export user']);
|
||||
Permission::updateOrCreate(['name' => 'view import block']);
|
||||
Permission::updateOrCreate(['name' => 'view export block']);
|
||||
|
||||
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']);
|
||||
@@ -93,13 +60,34 @@ 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']);
|
||||
|
||||
@@ -112,6 +100,12 @@ 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']);
|
||||
|
||||
@@ -150,6 +144,7 @@ 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']);
|
||||
|
||||
@@ -14,7 +14,7 @@ class UserSeeder extends Seeder
|
||||
public function run(): void
|
||||
{
|
||||
$user1 = User::updateOrCreate(
|
||||
['email' => 'dhanabalan.saravanan@cripumps.com'],
|
||||
['email' => 'dhanabalan@cripumps.com'],
|
||||
[
|
||||
'name' => 'Dhanabalan S',
|
||||
'password' => bcrypt('SdHaNa@123'),
|
||||
|
||||
22
finance-news-today.txt
Normal file
22
finance-news-today.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
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.
|
||||
6
public/C:\Users\Admin\Downloads
Normal file
6
public/C:\Users\Admin\Downloads
Normal file
@@ -0,0 +1,6 @@
|
||||
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
|
||||
44
public/index.html
Normal file
44
public/index.html
Normal file
@@ -0,0 +1,44 @@
|
||||
<!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>
|
||||
4
public/js/filament-chart-js-plugins.js
Normal file
4
public/js/filament-chart-js-plugins.js
Normal file
@@ -0,0 +1,4 @@
|
||||
// import ChartDataLabels from 'chartjs-plugin-datalabels'
|
||||
|
||||
// window.filamentChartJsPlugins ??= []
|
||||
// window.filamentChartJsPlugins.push(ChartDataLabels)
|
||||
1
resources/css/filament/admin/theme.css
Normal file
1
resources/css/filament/admin/theme.css
Normal file
@@ -0,0 +1 @@
|
||||
@import '../../../../vendor/filament/filament/resources/css/theme.css';
|
||||
@@ -1 +1,3 @@
|
||||
import './bootstrap';
|
||||
|
||||
|
||||
|
||||
86
resources/views/chatbot.blade.php
Normal file
86
resources/views/chatbot.blade.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<!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>
|
||||
@@ -0,0 +1,8 @@
|
||||
<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>
|
||||
|
||||
@@ -98,8 +98,6 @@
|
||||
<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>
|
||||
@@ -109,8 +107,6 @@
|
||||
<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>
|
||||
@@ -127,8 +123,6 @@
|
||||
<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>
|
||||
@@ -138,8 +132,6 @@
|
||||
<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>
|
||||
@@ -156,8 +148,6 @@
|
||||
<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>
|
||||
@@ -167,8 +157,6 @@
|
||||
<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>
|
||||
|
||||
0
resources/views/vendor/filament/components/layouts/app.blade.php
vendored
Normal file
0
resources/views/vendor/filament/components/layouts/app.blade.php
vendored
Normal file
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\ChatbotController;
|
||||
use App\Http\Controllers\InvoiceValidationController;
|
||||
use App\Http\Controllers\MachineController;
|
||||
use App\Http\Controllers\MfmParameterController;
|
||||
@@ -139,3 +140,5 @@ 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']);
|
||||
|
||||
|
||||
@@ -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:invoice-report');
|
||||
// Schedule::command('send:production-report');
|
||||
|
||||
app()->booted(function () {
|
||||
$schedule = app(Schedule::class);
|
||||
|
||||
// Production report scheduling
|
||||
//Production report scheduling
|
||||
|
||||
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
||||
->where('rule_name', 'ProductionMail')
|
||||
->select('plant', 'schedule_type')
|
||||
//->select('plant', 'schedule_type')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
@@ -10,6 +10,11 @@ use Illuminate\Support\Facades\Route;
|
||||
return redirect('/admin');
|
||||
});
|
||||
|
||||
Route::get('/chatbot', function () {
|
||||
return view('chatbot');
|
||||
});
|
||||
|
||||
|
||||
// Route::get('/scheduler', function() {
|
||||
// Artisan::call('schedule:run');
|
||||
// });
|
||||
|
||||
Reference in New Issue
Block a user