Compare commits
5 Commits
ranjith-de
...
qds
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c070c9763e | ||
|
|
2116ea422e | ||
|
|
acc98ad876 | ||
|
|
45898b2fa2 | ||
|
|
390e013ccb |
140
app/Filament/Exports/EbReadingExporter.php
Normal file
140
app/Filament/Exports/EbReadingExporter.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\EbReading;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class EbReadingExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = EbReading::class;
|
||||
static $rowNumber = 0;
|
||||
public static function getColumns(): array
|
||||
{
|
||||
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('lcd_segment_check')
|
||||
->label('LCD SEGMENT CHECK'),
|
||||
ExportColumn::make('meter_serial_no')
|
||||
->label('METER SERIAL NO'),
|
||||
ExportColumn::make('eb_date_time')
|
||||
->label('EB DATE TIME'),
|
||||
ExportColumn::make('ph_seq_of_volt')
|
||||
->label('PH SEQ OF VOLT'),
|
||||
ExportColumn::make('ph_assoc_conn_check')
|
||||
->label('PH ASSOC CONN CHECK'),
|
||||
ExportColumn::make('instantaneous_ph_volt')
|
||||
->label('INSTANTANEOUS PH VOLT'),
|
||||
ExportColumn::make('instantaneous_curr')
|
||||
->label('INSTANTANEOUS CURR'),
|
||||
ExportColumn::make('instantaneous_freq')
|
||||
->label('INSTANTANEOUS FREQ'),
|
||||
ExportColumn::make('instantaneous_kw_with_sign')
|
||||
->label('INSTANTANEOUS KW WITH SIGN'),
|
||||
ExportColumn::make('instantaneous_kva')
|
||||
->label('INSTANTANEOUS KVA'),
|
||||
ExportColumn::make('instantaneous_kv_ar')
|
||||
->label('INSTANTANEOUS KV AR'),
|
||||
ExportColumn::make('instantaneous_pf_with_sign')
|
||||
->label('INSTANTANEOUS PF WITH SIGN'),
|
||||
ExportColumn::make('rd_with_elapsed_time_kva')
|
||||
->label('RD WITH ELAPSED TIME KVA'),
|
||||
ExportColumn::make('cum_active_import_energy')
|
||||
->label('CUM ACTIVE IMPORT ENERGY'),
|
||||
ExportColumn::make('tod1_active_energy_6_9')
|
||||
->label('TOD1 ACTIVE ENERGY 6-9'),
|
||||
ExportColumn::make('tod2_active_energy_18_21')
|
||||
->label('TOD2 ACTIVE ENERGY 18-21'),
|
||||
ExportColumn::make('tod3_active_energy_21_22')
|
||||
->label('TOD3 ACTIVE ENERGY 21-22'),
|
||||
ExportColumn::make('tod4_active_energy_5_6_9_18')
|
||||
->label('TOD4 ACTIVE ENERGY 5-6-9-18'),
|
||||
ExportColumn::make('tod5_active_energy_22_5')
|
||||
->label('TOD5 ACTIVE ENERGY 22-5'),
|
||||
ExportColumn::make('cum_reac_lag_energy')
|
||||
->label('CUM REAC LAG ENERGY'),
|
||||
ExportColumn::make('cum_reac_lead_energy')
|
||||
->label('CUM REAC LEAD ENERGY'),
|
||||
ExportColumn::make('cum_appar_energy')
|
||||
->label('CUM APPAR ENERGY'),
|
||||
ExportColumn::make('tod1_appar_energy_6_9')
|
||||
->label('TOD1 APPAR ENERGY 6-9'),
|
||||
ExportColumn::make('tod2_appar_energy_18_21')
|
||||
->label('TOD2 APPAR ENERGY 18-21'),
|
||||
ExportColumn::make('tod3_appar_energy_21_22')
|
||||
->label('TOD3 APPAR ENERGY 21-22'),
|
||||
ExportColumn::make('tod4_appar_energy_5_6_9_18')
|
||||
->label('TOD4 APPAR ENERGY 5-6-9-18'),
|
||||
ExportColumn::make('tod5_appar_energy_22_5')
|
||||
->label('TOD5 APPAR ENERGY 22-5'),
|
||||
ExportColumn::make('avg_pow_factor')
|
||||
->label('AVG POW FACTOR'),
|
||||
ExportColumn::make('avg_freq_15min_last_ip')
|
||||
->label('AVG FREQ 15MIN LAST IP'),
|
||||
ExportColumn::make('net_kv_arh_high')
|
||||
->label('NET KV ARH HIGH'),
|
||||
ExportColumn::make('net_kv_arh_low')
|
||||
->label('NET KV ARH LOW'),
|
||||
ExportColumn::make('cum_md_kva')
|
||||
->label('CUM MD KVA'),
|
||||
ExportColumn::make('present_md_kva')
|
||||
->label('PRESENT MD KVA'),
|
||||
ExportColumn::make('present_md_kva_date_time')
|
||||
->label('PRESENT MD KVA DATE TIME'),
|
||||
ExportColumn::make('tod1_md_kva_6_9')
|
||||
->label('TOD1 MD KVA 6-9'),
|
||||
ExportColumn::make('tod2_md_kva_18_21')
|
||||
->label('TOD2 MD KVA 18-21'),
|
||||
ExportColumn::make('tod3_md_kva_21_22')
|
||||
->label('TOD3 MD KVA 21-22'),
|
||||
ExportColumn::make('tod4_md_kva_5_6_9_18')
|
||||
->label('TOD4 MD KVA 5-6-9-18'),
|
||||
ExportColumn::make('tod5_md_kva_22_5')
|
||||
->label('TOD5 MD KVA 22-5'),
|
||||
ExportColumn::make('total_pow_off_hours')
|
||||
->label('TOTAL POW OFF HOURS'),
|
||||
ExportColumn::make('programming_count')
|
||||
->label('PROGRAMMING COUNT'),
|
||||
ExportColumn::make('last_occ_res_event_type')
|
||||
->label('LAST OCC RES EVENT TYPE'),
|
||||
ExportColumn::make('last_occ_res_event_date_time')
|
||||
->label('LAST OCC RES EVENT DATE TIME'),
|
||||
ExportColumn::make('tamper_count')
|
||||
->label('TAMPER COUNT'),
|
||||
ExportColumn::make('reset_count')
|
||||
->label('RESET COUNT'),
|
||||
ExportColumn::make('last_md_reset_date_time')
|
||||
->label('LAST MD RESET DATE TIME'),
|
||||
ExportColumn::make('electrician_sign')
|
||||
->label('ELECTRICIAN SIGN'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your eb 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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
243
app/Filament/Imports/EbReadingImporter.php
Normal file
243
app/Filament/Imports/EbReadingImporter.php
Normal file
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\EbReading;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class EbReadingImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = EbReading::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('lcd_segment_check')
|
||||
->label('LCD Segment Check')
|
||||
->example('Ok')
|
||||
->exampleHeader('LCD Segment Check'),
|
||||
ImportColumn::make('meter_serial_no')
|
||||
->label('Meter Serial No')
|
||||
->example('572880')
|
||||
->exampleHeader('Meter Serial No'),
|
||||
ImportColumn::make('eb_date_time')
|
||||
->label('EB Date Time')
|
||||
->example('2025-08-05 08:32:58')
|
||||
->exampleHeader('EB Date Time')
|
||||
->requiredMapping()
|
||||
->rules(['required', 'datetime']),
|
||||
ImportColumn::make('ph_seq_of_volt')
|
||||
->label('Phase Sequence of Volt')
|
||||
->example('RYB')
|
||||
->exampleHeader('Phase Sequence of Volt'),
|
||||
ImportColumn::make('ph_assoc_conn_check')
|
||||
->example('GOOD')
|
||||
->exampleHeader('Phase Associated Connection Check')
|
||||
->label('Phase Associated Connection Check'),
|
||||
ImportColumn::make('instantaneous_ph_volt')
|
||||
->exampleHeader('Instantaneous Phase Volt')
|
||||
->example('64.35,64.91,64.93')
|
||||
->label('Instantaneous Phase Volt'),
|
||||
ImportColumn::make('instantaneous_curr')
|
||||
->exampleHeader('Instantaneous Current')
|
||||
->example('1.02,1.00,0.94')
|
||||
->label('Instantaneous Current'),
|
||||
ImportColumn::make('instantaneous_freq')
|
||||
->exampleHeader('Instantaneous Frequency')
|
||||
->example('50.07')
|
||||
->label('Instantaneous Frequency'),
|
||||
ImportColumn::make('instantaneous_kw_with_sign')
|
||||
->exampleHeader('Instantaneous KW with Sign')
|
||||
->example('0.176')
|
||||
->label('Instantaneous KW with Sign'),
|
||||
ImportColumn::make('instantaneous_kva')
|
||||
->exampleHeader('Instantaneous KVA')
|
||||
->example('0.176')
|
||||
->label('Instantaneous KVA'),
|
||||
ImportColumn::make('instantaneous_kv_ar')
|
||||
->exampleHeader('Instantaneous KV AR')
|
||||
->example('0.02')
|
||||
->label('Instantaneous KV AR'),
|
||||
ImportColumn::make('instantaneous_pf_with_sign')
|
||||
->exampleHeader('Instantaneous PF with Sign')
|
||||
->example('0.99')
|
||||
->label('Instantaneous PF with Sign'),
|
||||
ImportColumn::make('rd_with_elapsed_time_kva')
|
||||
->exampleHeader('RD with Elapsed Time KVA')
|
||||
->example('0.047')
|
||||
->label('RD with Elapsed Time KVA'),
|
||||
ImportColumn::make('cum_active_import_energy')
|
||||
->exampleHeader('Cumulative Active Import Energy')
|
||||
->example('13246.46')
|
||||
->label('Cumulative Active Import Energy'),
|
||||
ImportColumn::make('tod1_active_energy_6_9')
|
||||
->exampleHeader('TOD1 Active Energy 6-9')
|
||||
->example('1367.75')
|
||||
->label('TOD1 Active Energy 6-9'),
|
||||
ImportColumn::make('tod2_active_energy_18_21')
|
||||
->exampleHeader('TOD2 Active Energy 18-21')
|
||||
->example('1759.08')
|
||||
->label('TOD2 Active Energy 18-21'),
|
||||
ImportColumn::make('tod3_active_energy_21_22')
|
||||
->exampleHeader('TOD3 Active Energy 21-22')
|
||||
->example('457.67')
|
||||
->label('TOD3 Active Energy 21-22'),
|
||||
ImportColumn::make('tod4_active_energy_5_6_9_18')
|
||||
->exampleHeader('TOD4 Active Energy 5-6-9-18')
|
||||
->example('6253.85')
|
||||
->label('TOD4 Active Energy 5-6-9-18'),
|
||||
ImportColumn::make('tod5_active_energy_22_5')
|
||||
->exampleHeader('TOD5 Active Energy 22-5')
|
||||
->example('3408.11')
|
||||
->label('TOD5 Active Energy 22-5'),
|
||||
ImportColumn::make('cum_reac_lag_energy')
|
||||
->exampleHeader('Cumulative Reactive Lag Energy')
|
||||
->example('685.11')
|
||||
->label('Cumulative Reactive Lag Energy'),
|
||||
ImportColumn::make('cum_reac_lead_energy')
|
||||
->exampleHeader('Cumulative Reactive Lead Energy')
|
||||
->example('426.1')
|
||||
->label('Cumulative Reactive Lead Energy'),
|
||||
ImportColumn::make('cum_appar_energy')
|
||||
->exampleHeader('Cumulative Apparent Energy')
|
||||
->example('13306.57')
|
||||
->label('Cumulative Apparent Energy'),
|
||||
ImportColumn::make('tod1_appar_energy_6_9')
|
||||
->exampleHeader('TOD1 Apparent Energy 6-9')
|
||||
->example('1374.63')
|
||||
->label('TOD1 Apparent Energy 6-9'),
|
||||
ImportColumn::make('tod2_appar_energy_18_21')
|
||||
->exampleHeader('TOD2 Apparent Energy 18-21')
|
||||
->example('1766.61')
|
||||
->label('TOD2 Apparent Energy 18-21'),
|
||||
ImportColumn::make('tod3_appar_energy_21_22')
|
||||
->exampleHeader('TOD3 Apparent Energy 21-22')
|
||||
->example('459.47')
|
||||
->label('TOD3 Apparent Energy 21-22'),
|
||||
ImportColumn::make('tod4_appar_energy_5_6_9_18')
|
||||
->exampleHeader('TOD4 Apparent Energy 5-6-9-18')
|
||||
->example('6283.28')
|
||||
->label('TOD4 Apparent Energy 5-6-9-18'),
|
||||
ImportColumn::make('tod5_appar_energy_22_5')
|
||||
->exampleHeader('TOD5 Apparent Energy 22-5')
|
||||
->example('3422.56')
|
||||
->label('TOD5 Apparent Energy 22-5'),
|
||||
ImportColumn::make('avg_pow_factor')
|
||||
->exampleHeader('Average Power Factor')
|
||||
->example('0.98')
|
||||
->label('Average Power Factor'),
|
||||
ImportColumn::make('avg_freq_15min_last_ip')
|
||||
->exampleHeader('Average Frequency 15min Last IP')
|
||||
->example('50')
|
||||
->label('Average Frequency 15min Last IP'),
|
||||
ImportColumn::make('net_kv_arh_high')
|
||||
->exampleHeader('Net KV ARH High')
|
||||
->example('2.99')
|
||||
->label('Net KV ARH High'),
|
||||
ImportColumn::make('net_kv_arh_low')
|
||||
->exampleHeader('Net KV ARH Low')
|
||||
->example('143.14')
|
||||
->label('Net KV ARH Low'),
|
||||
ImportColumn::make('cum_md_kva')
|
||||
->exampleHeader('Cumulative MD KVA')
|
||||
->example('43.816')
|
||||
->label('Cumulative MD KVA'),
|
||||
ImportColumn::make('present_md_kva')
|
||||
->exampleHeader('Present MD KVA')
|
||||
->example('0.379')
|
||||
->label('Present MD KVA'),
|
||||
ImportColumn::make('present_md_kva_date_time')
|
||||
->label('Present MD KVA Date Time')
|
||||
->exampleHeader('Present MD KVA Date Time')
|
||||
->example('2025-08-05 08:32:58')
|
||||
->requiredMapping()
|
||||
->rules(['required', 'datetime']),
|
||||
ImportColumn::make('tod1_md_kva_6_9')
|
||||
->exampleHeader('TOD1 MD KVA 6-9')
|
||||
->example('0.282')
|
||||
->label('TOD1 MD KVA 6-9'),
|
||||
ImportColumn::make('tod2_md_kva_18_21')
|
||||
->exampleHeader('TOD2 MD KVA 18-21')
|
||||
->example('0.268')
|
||||
->label('TOD2 MD KVA 18-21'),
|
||||
ImportColumn::make('tod3_md_kva_21_22')
|
||||
->exampleHeader('TOD3 MD KVA 21-22')
|
||||
->example('0')
|
||||
->label('TOD3 MD KVA 21-22'),
|
||||
ImportColumn::make('tod4_md_kva_5_6_9_18')
|
||||
->exampleHeader('TOD4 MD KVA 5-6-9-18')
|
||||
->example('0.379')
|
||||
->label('TOD4 MD KVA 5-6-9-18'),
|
||||
ImportColumn::make('tod5_md_kva_22_5')
|
||||
->exampleHeader('TOD5 MD KVA 22-5')
|
||||
->example('0.379')
|
||||
->label('TOD5 MD KVA 22-5'),
|
||||
ImportColumn::make('total_pow_off_hours')
|
||||
->exampleHeader('Total Power Off Hours')
|
||||
->example('6480.56')
|
||||
->label('Total Power Off Hours'),
|
||||
ImportColumn::make('programming_count')
|
||||
->exampleHeader('Programming Count')
|
||||
->example('3')
|
||||
->label('Programming Count'),
|
||||
ImportColumn::make('last_occ_res_event_type')
|
||||
->exampleHeader('Last Occurrence/Reset Event Type')
|
||||
->example('-')
|
||||
->label('Last Occurrence/Reset Event Type'),
|
||||
ImportColumn::make('last_occ_res_event_date_time')
|
||||
->label('Last Occurrence/Reset Event Date Time')
|
||||
->example('2025-08-05 08:32:58')
|
||||
->exampleHeader('Last Occurrence/Reset Event Date Time')
|
||||
->requiredMapping()
|
||||
->rules(['required', 'datetime']),
|
||||
ImportColumn::make('tamper_count')
|
||||
->exampleHeader('Tamper Count')
|
||||
->example('24')
|
||||
->label('Tamper Count'),
|
||||
ImportColumn::make('reset_count')
|
||||
->exampleHeader('Reset Count')
|
||||
->example('108')
|
||||
->label('Reset Count'),
|
||||
ImportColumn::make('last_md_reset_date_time')
|
||||
->exampleHeader('Last MD Reset Date Time')
|
||||
->example('2025-08-05 08:32:58')
|
||||
->label('Last MD Reset Date Time')
|
||||
->requiredMapping()
|
||||
->rules(['required', 'datetime']),
|
||||
ImportColumn::make('electrician_sign')
|
||||
->exampleHeader('Electrician Sign')
|
||||
->example('Admin')
|
||||
->label('Electrician Sign'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?EbReading
|
||||
{
|
||||
// return EbReading::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new EbReading();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your eb 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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
443
app/Filament/Resources/EbReadingResource.php
Normal file
443
app/Filament/Resources/EbReadingResource.php
Normal file
@@ -0,0 +1,443 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\EbReadingExporter;
|
||||
use App\Filament\Imports\EbReadingImporter;
|
||||
use App\Filament\Resources\EbReadingResource\Pages;
|
||||
use App\Filament\Resources\EbReadingResource\RelationManagers;
|
||||
use App\Models\EbReading;
|
||||
use App\Models\Plant;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
|
||||
class EbReadingResource extends Resource
|
||||
{
|
||||
protected static ?string $model = EbReading::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Power House';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('lcd_segment_check')
|
||||
->label('LCD Segment Check'),
|
||||
Forms\Components\TextInput::make('meter_serial_no')
|
||||
->label('Meter Serial No'),
|
||||
Forms\Components\DateTimePicker::make('eb_date_time')
|
||||
->required()
|
||||
->label('EB Date Time'),
|
||||
Forms\Components\TextInput::make('ph_seq_of_volt')
|
||||
->label('PH Sequence of Volt'),
|
||||
Forms\Components\TextInput::make('ph_assoc_conn_check')
|
||||
->label('PH Association Connection Check'),
|
||||
Forms\Components\TextInput::make('instantaneous_ph_volt')
|
||||
->label('Instantaneous PH Volt'),
|
||||
Forms\Components\TextInput::make('instantaneous_curr')
|
||||
->label('Instantaneous Current'),
|
||||
Forms\Components\TextInput::make('instantaneous_freq')
|
||||
->label('Instantaneous Frequency'),
|
||||
Forms\Components\TextInput::make('instantaneous_kw_with_sign')
|
||||
->label('Instantaneous KW with Sign'),
|
||||
Forms\Components\TextInput::make('instantaneous_kva')
|
||||
->label('Instantaneous KVA'),
|
||||
Forms\Components\TextInput::make('instantaneous_kv_ar')
|
||||
->label('Instantaneous KV AR'),
|
||||
Forms\Components\TextInput::make('instantaneous_pf_with_sign')
|
||||
->label('Instantaneous PF with Sign'),
|
||||
Forms\Components\TextInput::make('rd_with_elapsed_time_kva')
|
||||
->label('RD with Elapsed Time KVA'),
|
||||
Forms\Components\TextInput::make('cum_active_import_energy')
|
||||
->label('Cumulative Active Import Energy'),
|
||||
Forms\Components\TextInput::make('tod1_active_energy_6_9')
|
||||
->label('TOD1 Active Energy 6-9'),
|
||||
Forms\Components\TextInput::make('tod2_active_energy_18_21')
|
||||
->label('TOD2 Active Energy 18-21'),
|
||||
Forms\Components\TextInput::make('tod3_active_energy_21_22')
|
||||
->label('TOD3 Active Energy 21-22'),
|
||||
Forms\Components\TextInput::make('tod4_active_energy_5_6_9_18')
|
||||
->label('TOD4 Active Energy 5-6-9-18'),
|
||||
Forms\Components\TextInput::make('tod5_active_energy_22_5')
|
||||
->label('TOD5 Active Energy 22-5'),
|
||||
Forms\Components\TextInput::make('cum_reac_lag_energy')
|
||||
->label('Cumulative Reactive Lag Energy'),
|
||||
Forms\Components\TextInput::make('cum_reac_lead_energy')
|
||||
->label('Cumulative Reactive Lead Energy'),
|
||||
Forms\Components\TextInput::make('cum_appar_energy')
|
||||
->label('Cumulative Apparent Energy'),
|
||||
Forms\Components\TextInput::make('tod1_appar_energy_6_9')
|
||||
->label('TOD1 Apparent Energy 6-9'),
|
||||
Forms\Components\TextInput::make('tod2_appar_energy_18_21')
|
||||
->label('TOD2 Apparent Energy 18-21'),
|
||||
Forms\Components\TextInput::make('tod3_appar_energy_21_22')
|
||||
->label('TOD3 Apparent Energy 21-22'),
|
||||
Forms\Components\TextInput::make('tod4_appar_energy_5_6_9_18')
|
||||
->label('TOD4 Apparent Energy 5-6-9-18'),
|
||||
Forms\Components\TextInput::make('tod5_appar_energy_22_5')
|
||||
->label('TOD5 Apparent Energy 22-5'),
|
||||
Forms\Components\TextInput::make('avg_pow_factor')
|
||||
->label('Average Power Factor'),
|
||||
Forms\Components\TextInput::make('avg_freq_15min_last_ip')
|
||||
->label('Average Frequency 15min Last IP'),
|
||||
Forms\Components\TextInput::make('net_kv_arh_high')
|
||||
->label('Net KV ARH High'),
|
||||
Forms\Components\TextInput::make('net_kv_arh_low')
|
||||
->label('Net KV ARH Low'),
|
||||
Forms\Components\TextInput::make('cum_md_kva')
|
||||
->label('Cumulative MD KVA'),
|
||||
Forms\Components\TextInput::make('present_md_kva')
|
||||
->label('Present MD KVA'),
|
||||
Forms\Components\DateTimePicker::make('present_md_kva_date_time')
|
||||
->label('Present MD KVA Date Time')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('tod1_md_kva_6_9')
|
||||
->label('TOD1 MD KVA 6-9'),
|
||||
Forms\Components\TextInput::make('tod2_md_kva_18_21')
|
||||
->label('TOD2 MD KVA 18-21'),
|
||||
Forms\Components\TextInput::make('tod3_md_kva_21_22')
|
||||
->label('TOD3 MD KVA 21-22'),
|
||||
Forms\Components\TextInput::make('tod4_md_kva_5_6_9_18')
|
||||
->label('TOD4 MD KVA 5-6-9-18'),
|
||||
Forms\Components\TextInput::make('tod5_md_kva_22_5')
|
||||
->label('TOD5 MD KVA 22-5'),
|
||||
Forms\Components\TextInput::make('total_pow_off_hours')
|
||||
->label('Total Power Off Hours'),
|
||||
Forms\Components\TextInput::make('programming_count')
|
||||
->label('Programming Count'),
|
||||
Forms\Components\TextInput::make('last_occ_res_event_type')
|
||||
->label('Last Occurrence/Reset Event Type'),
|
||||
Forms\Components\DateTimePicker::make('last_occ_res_event_date_time')
|
||||
->label('Last Occurrence/Reset Event Date Time')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('tamper_count')
|
||||
->label('Tamper Count'),
|
||||
Forms\Components\TextInput::make('reset_count')
|
||||
->label('Reset Count'),
|
||||
Forms\Components\DateTimePicker::make('last_md_reset_date_time')
|
||||
->label('Last MD Reset Date Time')
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('electrician_sign')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->alignCenter()
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('lcd_segment_check')
|
||||
->alignCenter()
|
||||
->label('LCD Segment Check'),
|
||||
Tables\Columns\TextColumn::make('meter_serial_no')
|
||||
->alignCenter()
|
||||
->label('Meter Serial No'),
|
||||
Tables\Columns\TextColumn::make('eb_date_time')
|
||||
->alignCenter()
|
||||
->label('EB Date Time'),
|
||||
Tables\Columns\TextColumn::make('ph_seq_of_volt')
|
||||
->alignCenter()
|
||||
->label('PH Sequence of Volt'),
|
||||
Tables\Columns\TextColumn::make('ph_assoc_conn_check')
|
||||
->alignCenter()
|
||||
->label('PH Association Connection Check'),
|
||||
Tables\Columns\TextColumn::make('instantaneous_ph_volt')
|
||||
->alignCenter()
|
||||
->label('Instantaneous PH Volt'),
|
||||
Tables\Columns\TextColumn::make('instantaneous_curr')
|
||||
->alignCenter()
|
||||
->label('Instantaneous Current'),
|
||||
Tables\Columns\TextColumn::make('instantaneous_freq')
|
||||
->alignCenter()
|
||||
->label('Instantaneous Frequency'),
|
||||
Tables\Columns\TextColumn::make('instantaneous_kw_with_sign')
|
||||
->alignCenter()
|
||||
->label('Instantaneous KW with Sign'),
|
||||
Tables\Columns\TextColumn::make('instantaneous_kva')
|
||||
->alignCenter()
|
||||
->label('Instantaneous KVA'),
|
||||
Tables\Columns\TextColumn::make('instantaneous_kv_ar')
|
||||
->alignCenter()
|
||||
->label('Instantaneous KV AR'),
|
||||
Tables\Columns\TextColumn::make('instantaneous_pf_with_sign')
|
||||
->alignCenter()
|
||||
->label('Instantaneous PF with Sign'),
|
||||
Tables\Columns\TextColumn::make('rd_with_elapsed_time_kva')
|
||||
->alignCenter()
|
||||
->label('RD with Elapsed Time KVA'),
|
||||
Tables\Columns\TextColumn::make('cum_active_import_energy')
|
||||
->alignCenter()
|
||||
->label('Cumulative Active Import Energy'),
|
||||
Tables\Columns\TextColumn::make('tod1_active_energy_6_9')
|
||||
->alignCenter()
|
||||
->label('TOD1 Active Energy 6-9'),
|
||||
Tables\Columns\TextColumn::make('tod2_active_energy_18_21')
|
||||
->alignCenter()
|
||||
->label('TOD2 Active Energy 18-21'),
|
||||
Tables\Columns\TextColumn::make('tod3_active_energy_21_22')
|
||||
->alignCenter()
|
||||
->label('TOD3 Active Energy 21-22'),
|
||||
Tables\Columns\TextColumn::make('tod4_active_energy_5_6_9_18')
|
||||
->alignCenter()
|
||||
->label('TOD4 Active Energy 5-6-9-18'),
|
||||
Tables\Columns\TextColumn::make('tod5_active_energy_22_5')
|
||||
->alignCenter()
|
||||
->label('TOD5 Active Energy 22-5'),
|
||||
Tables\Columns\TextColumn::make('cum_reac_lag_energy')
|
||||
->alignCenter()
|
||||
->label('Cumulative Reactive Lag Energy'),
|
||||
Tables\Columns\TextColumn::make('cum_reac_lead_energy')
|
||||
->alignCenter()
|
||||
->label('Cumulative Reactive Lead Energy'),
|
||||
Tables\Columns\TextColumn::make('cum_appar_energy')
|
||||
->alignCenter()
|
||||
->label('Cumulative Apparent Energy'),
|
||||
Tables\Columns\TextColumn::make('tod1_appar_energy_6_9')
|
||||
->alignCenter()
|
||||
->label('TOD1 Apparent Energy 6-9'),
|
||||
Tables\Columns\TextColumn::make('tod2_appar_energy_18_21')
|
||||
->alignCenter()
|
||||
->label('TOD2 Apparent Energy 18-21'),
|
||||
Tables\Columns\TextColumn::make('tod3_appar_energy_21_22')
|
||||
->alignCenter()
|
||||
->label('TOD3 Apparent Energy 21-22'),
|
||||
Tables\Columns\TextColumn::make('tod4_appar_energy_5_6_9_18')
|
||||
->alignCenter()
|
||||
->label('TOD4 Apparent Energy 5-6-9-18'),
|
||||
Tables\Columns\TextColumn::make('tod5_appar_energy_22_5')
|
||||
->alignCenter()
|
||||
->label('TOD5 Apparent Energy 22-5'),
|
||||
Tables\Columns\TextColumn::make('avg_pow_factor')
|
||||
->alignCenter()
|
||||
->label('Average Power Factor'),
|
||||
Tables\Columns\TextColumn::make('avg_freq_15min_last_ip')
|
||||
->alignCenter()
|
||||
->label('Average Frequency 15min Last IP'),
|
||||
Tables\Columns\TextColumn::make('net_kv_arh_high')
|
||||
->alignCenter()
|
||||
->label('Net KV ARH High'),
|
||||
Tables\Columns\TextColumn::make('net_kv_arh_low')
|
||||
->alignCenter()
|
||||
->label('Net KV ARH Low'),
|
||||
Tables\Columns\TextColumn::make('cum_md_kva')
|
||||
->alignCenter()
|
||||
->label('Cumulative MD KVA'),
|
||||
Tables\Columns\TextColumn::make('present_md_kva')
|
||||
->alignCenter()
|
||||
->label('Present MD KVA'),
|
||||
Tables\Columns\TextColumn::make('present_md_kva_date_time')
|
||||
->alignCenter()
|
||||
->label('Present MD KVA Date Time'),
|
||||
Tables\Columns\TextColumn::make('tod1_md_kva_6_9')
|
||||
->alignCenter()
|
||||
->label('TOD1 MD KVA 6-9'),
|
||||
Tables\Columns\TextColumn::make('tod2_md_kva_18_21')
|
||||
->alignCenter()
|
||||
->label('TOD2 MD KVA 18-21'),
|
||||
Tables\Columns\TextColumn::make('tod3_md_kva_21_22')
|
||||
->alignCenter()
|
||||
->label('TOD3 MD KVA 21-22'),
|
||||
Tables\Columns\TextColumn::make('tod4_md_kva_5_6_9_18')
|
||||
->alignCenter()
|
||||
->label('TOD4 MD KVA 5-6-9-18'),
|
||||
Tables\Columns\TextColumn::make('tod5_md_kva_22_5')
|
||||
->alignCenter()
|
||||
->label('TOD5 MD KVA 22-5'),
|
||||
Tables\Columns\TextColumn::make('total_pow_off_hours')
|
||||
->alignCenter()
|
||||
->label('Total Power Off Hours'),
|
||||
Tables\Columns\TextColumn::make('programming_count')
|
||||
->alignCenter()
|
||||
->label('Programming Count'),
|
||||
Tables\Columns\TextColumn::make('last_occ_res_event_type')
|
||||
->alignCenter()
|
||||
->label('Last Occurrence/Reset Event Type'),
|
||||
Tables\Columns\TextColumn::make('last_occ_res_event_date_time')
|
||||
->alignCenter()
|
||||
->label('Last Occurrence/Reset Event Date Time'),
|
||||
Tables\Columns\TextColumn::make('tamper_count')
|
||||
->alignCenter()
|
||||
->label('Tamper Count'),
|
||||
Tables\Columns\TextColumn::make('reset_count')
|
||||
->alignCenter()
|
||||
->label('Reset Count'),
|
||||
Tables\Columns\TextColumn::make('last_md_reset_date_time')
|
||||
->alignCenter()
|
||||
->label('Last MD Reset Date Time'),
|
||||
Tables\Columns\TextColumn::make('electrician_sign')
|
||||
->alignCenter()
|
||||
->label('Created By'),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->alignCenter()
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
// ->filters([
|
||||
// Tables\Filters\TrashedFilter::make(),
|
||||
// ])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->nullable()
|
||||
->options(function () {
|
||||
return Plant::pluck('name', 'id');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('electrician_sign', null);
|
||||
}),
|
||||
TextInput::make('electrician_sign')
|
||||
->label('Created By'),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['electrician_sign'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (!empty($data['Plant'])) {
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (!empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
|
||||
if (!empty($data['electrician_sign'])) {
|
||||
$query->where('electrician_sign', $data['electrician_sign']);
|
||||
}
|
||||
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (!empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
|
||||
}
|
||||
|
||||
if (!empty($data['electrician_sign'])) {
|
||||
$indicators[] = 'Created By: ' . $data['electrician_sign'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$indicators[] = 'From: ' . $data['created_from'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_to'])) {
|
||||
$indicators[] = 'To: ' . $data['created_to'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
})
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(EbReadingImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import eb reading');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(EbReadingExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export eb reading');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListEbReadings::route('/'),
|
||||
'create' => Pages\CreateEbReading::route('/create'),
|
||||
'view' => Pages\ViewEbReading::route('/{record}'),
|
||||
'edit' => Pages\EditEbReading::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\EbReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EbReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateEbReading extends CreateRecord
|
||||
{
|
||||
protected static string $resource = EbReadingResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\EbReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EbReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditEbReading extends EditRecord
|
||||
{
|
||||
protected static string $resource = EbReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\EbReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EbReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListEbReadings extends ListRecords
|
||||
{
|
||||
protected static string $resource = EbReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\EbReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EbReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewEbReading extends ViewRecord
|
||||
{
|
||||
protected static string $resource = EbReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -2487,8 +2487,7 @@ class QualityValidationResource extends Resource
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
//,,
|
||||
// public static function mutateFormDataBeforeCreate(array $data): array
|
||||
// {
|
||||
// $user =Filament::auth()->user();
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\TempLiveReadingExporter;
|
||||
use App\Filament\Imports\TempLiveReadingImporter;
|
||||
use App\Filament\Resources\TempLiveReadingResource\Pages;
|
||||
use App\Filament\Resources\TempLiveReadingResource\RelationManagers;
|
||||
use App\Models\MfmMeter;
|
||||
@@ -15,6 +17,9 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
|
||||
|
||||
class TempLiveReadingResource extends Resource
|
||||
{
|
||||
@@ -108,6 +113,18 @@ class TempLiveReadingResource extends Resource
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(TempLiveReadingImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import temp live reading');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(TempLiveReadingExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export temp live reading');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
//
|
||||
|
||||
69
app/Models/EbReading.php
Normal file
69
app/Models/EbReading.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class EbReading extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'lcd_segment_check',
|
||||
'meter_serial_no',
|
||||
'eb_date_time',
|
||||
'ph_seq_of_volt',
|
||||
'ph_assoc_conn_check',
|
||||
'instantaneous_ph_volt',
|
||||
'instantaneous_curr',
|
||||
'instantaneous_freq',
|
||||
'instantaneous_kw_with_sign',
|
||||
'instantaneous_kva',
|
||||
'instantaneous_kv_ar',
|
||||
'instantaneous_pf_with_sign',
|
||||
'rd_with_elapsed_time_kva',
|
||||
'cum_active_import_energy',
|
||||
'tod1_active_energy_6_9',
|
||||
'tod2_active_energy_18_21',
|
||||
'tod3_active_energy_21_22',
|
||||
'tod4_active_energy_5_6_9_18',
|
||||
'tod5_active_energy_22_5',
|
||||
'cum_reac_lag_energy',
|
||||
'cum_reac_lead_energy',
|
||||
'cum_appar_energy',
|
||||
'tod1_appar_energy_6_9',
|
||||
'tod2_appar_energy_18_21',
|
||||
'tod3_appar_energy_21_22',
|
||||
'tod4_appar_energy_5_6_9_18',
|
||||
'tod5_appar_energy_22_5',
|
||||
'avg_pow_factor',
|
||||
'avg_freq_15min_last_ip',
|
||||
'net_kv_arh_high',
|
||||
'net_kv_arh_low',
|
||||
'cum_md_kva',
|
||||
'present_md_kva',
|
||||
'present_md_kva_date_time',
|
||||
'tod1_md_kva_6_9',
|
||||
'tod2_md_kva_18_21',
|
||||
'tod3_md_kva_21_22',
|
||||
'tod4_md_kva_5_6_9_18',
|
||||
'tod5_md_kva_22_5',
|
||||
'total_pow_off_hours',
|
||||
'programming_count',
|
||||
'last_occ_res_event_type',
|
||||
'last_occ_res_event_date_time',
|
||||
'tamper_count',
|
||||
'reset_count',
|
||||
'last_md_reset_date_time',
|
||||
'electrician_sign',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
}
|
||||
106
app/Policies/EbReadingPolicy.php
Normal file
106
app/Policies/EbReadingPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\EbReading;
|
||||
use App\Models\User;
|
||||
|
||||
class EbReadingPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any EbReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, EbReading $ebreading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view EbReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create EbReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, EbReading $ebreading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update EbReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, EbReading $ebreading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete EbReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any EbReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, EbReading $ebreading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore EbReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any EbReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, EbReading $ebreading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate EbReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder EbReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, EbReading $ebreading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete EbReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any EbReading');
|
||||
}
|
||||
}
|
||||
@@ -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'),
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE eb_readings (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
plant_id BIGINT NOT NULL,
|
||||
|
||||
lcd_segment_check TEXT DEFAULT NULL,
|
||||
meter_serial_no TEXT DEFAULT NULL,
|
||||
eb_date_time TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
ph_seq_of_volt TEXT DEFAULT NULL,
|
||||
ph_assoc_conn_check TEXT DEFAULT NULL,
|
||||
instantaneous_ph_volt TEXT DEFAULT NULL,
|
||||
instantaneous_curr TEXT DEFAULT NULL,
|
||||
instantaneous_freq TEXT DEFAULT NULL,
|
||||
instantaneous_kw_with_sign TEXT DEFAULT NULL,
|
||||
instantaneous_kva TEXT DEFAULT NULL,
|
||||
instantaneous_kv_ar TEXT DEFAULT NULL,
|
||||
instantaneous_pf_with_sign TEXT DEFAULT NULL,
|
||||
rd_with_elapsed_time_kva TEXT DEFAULT NULL,
|
||||
cum_active_import_energy TEXT DEFAULT NULL,
|
||||
tod1_active_energy_6_9 TEXT DEFAULT NULL,
|
||||
tod2_active_energy_18_21 TEXT DEFAULT NULL,
|
||||
tod3_active_energy_21_22 TEXT DEFAULT NULL,
|
||||
tod4_active_energy_5_6_9_18 TEXT DEFAULT NULL,
|
||||
tod5_active_energy_22_5 TEXT DEFAULT NULL,
|
||||
cum_reac_lag_energy TEXT DEFAULT NULL,
|
||||
cum_reac_lead_energy TEXT DEFAULT NULL,
|
||||
cum_appar_energy TEXT DEFAULT NULL,
|
||||
tod1_appar_energy_6_9 TEXT DEFAULT NULL,
|
||||
tod2_appar_energy_18_21 TEXT DEFAULT NULL,
|
||||
tod3_appar_energy_21_22 TEXT DEFAULT NULL,
|
||||
tod4_appar_energy_5_6_9_18 TEXT DEFAULT NULL,
|
||||
tod5_appar_energy_22_5 TEXT DEFAULT NULL,
|
||||
avg_pow_factor TEXT DEFAULT NULL,
|
||||
avg_freq_15min_last_ip TEXT DEFAULT NULL,
|
||||
net_kv_arh_high TEXT DEFAULT NULL,
|
||||
net_kv_arh_low TEXT DEFAULT NULL,
|
||||
cum_md_kva TEXT DEFAULT NULL,
|
||||
present_md_kva TEXT DEFAULT NULL,
|
||||
present_md_kva_date_time TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
tod1_md_kva_6_9 TEXT DEFAULT NULL,
|
||||
tod2_md_kva_18_21 TEXT DEFAULT NULL,
|
||||
tod3_md_kva_21_22 TEXT DEFAULT NULL,
|
||||
tod4_md_kva_5_6_9_18 TEXT DEFAULT NULL,
|
||||
tod5_md_kva_22_5 TEXT DEFAULT NULL,
|
||||
total_pow_off_hours TEXT DEFAULT NULL,
|
||||
programming_count TEXT DEFAULT NULL,
|
||||
last_occ_res_event_type TEXT DEFAULT NULL,
|
||||
last_occ_res_event_date_time TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
tamper_count TEXT DEFAULT NULL,
|
||||
reset_count TEXT DEFAULT NULL,
|
||||
last_md_reset_date_time TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
electrician_sign TEXT DEFAULT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
deleted_at TIMESTAMP,
|
||||
updated_by TEXT NULL,
|
||||
|
||||
FOREIGN KEY (plant_id) REFERENCES plants (id)
|
||||
|
||||
);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('eb_readings');
|
||||
}
|
||||
};
|
||||
@@ -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) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
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>
|
||||
|
||||
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']);
|
||||
|
||||
|
||||
@@ -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