Compare commits
26 Commits
c267d312b2
...
ranjith-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f93f2bd92 | ||
|
|
d19b8120e2 | ||
|
|
8fb42203c3 | ||
|
|
bb2f5082b1 | ||
|
|
3215cd39ad | ||
|
|
7755d15741 | ||
|
|
4586fc0d60 | ||
|
|
65fc5202a4 | ||
|
|
770f0c9af3 | ||
|
|
47a0cf31d2 | ||
|
|
e5f23303d9 | ||
|
|
b9e164725e | ||
|
|
4699de9a77 | ||
|
|
196117f07f | ||
|
|
84b617f8fb | ||
|
|
9f6959784f | ||
|
|
bbdd9fb75c | ||
|
|
cc788ea6d4 | ||
|
|
8c0af96b94 | ||
|
|
b02954d0a2 | ||
|
|
9b098864bc | ||
|
|
50f542c3d1 | ||
|
|
dfb48055ea | ||
|
|
881e2fa6d9 | ||
|
|
3a7104513c | ||
|
|
25cfaa6479 |
@@ -34,6 +34,8 @@ class SendInvoiceReport extends Command
|
||||
// $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');
|
||||
|
||||
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
@@ -91,6 +93,7 @@ class SendInvoiceReport extends Command
|
||||
|
||||
$serialTableData[] = [
|
||||
'no' => $no,
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantName,
|
||||
'totalInvoice' => $totalSerialCount,
|
||||
'scannedInvoice' => $scannedSerialCount,
|
||||
@@ -127,6 +130,7 @@ class SendInvoiceReport extends Command
|
||||
|
||||
$materialTableData[] = [
|
||||
'no' => $no,
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantName,
|
||||
'totalInvoice' => $totalMatCount,
|
||||
'scannedInvoice' => $scannedMatCount,
|
||||
@@ -163,6 +167,7 @@ class SendInvoiceReport extends Command
|
||||
|
||||
$bundleTableData[] = [
|
||||
'no' => $no,
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantName,
|
||||
'totalInvoice' => $totalBundleCount,
|
||||
'scannedInvoice' => $scannedBundleCount,
|
||||
@@ -206,7 +211,26 @@ class SendInvoiceReport extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, [], [], $schedule));
|
||||
if ($rule->plant == 0) {
|
||||
$filteredSerialData = $serialTableData;
|
||||
|
||||
} else {
|
||||
$filteredSerialData = collect($serialTableData)
|
||||
->where('plant_id', $rule->plant)
|
||||
->values()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)
|
||||
->cc($ccEmails)
|
||||
->send(new test(
|
||||
$filteredSerialData,
|
||||
[],
|
||||
[],
|
||||
$schedule
|
||||
));
|
||||
|
||||
// \Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, [], [], $schedule));
|
||||
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||
}
|
||||
@@ -240,7 +264,35 @@ class SendInvoiceReport extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
||||
// FILTER DATA
|
||||
if ($rule->plant == 0) {
|
||||
|
||||
$filteredMaterialData = $materialTableData;
|
||||
$filteredBundleData = $bundleTableData;
|
||||
|
||||
} else {
|
||||
|
||||
$filteredMaterialData = collect($materialTableData)
|
||||
->where('plant_id', $rule->plant)
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$filteredBundleData = collect($bundleTableData)
|
||||
->where('plant_id', $rule->plant)
|
||||
->values()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)
|
||||
->cc($ccEmails)
|
||||
->send(new test(
|
||||
[],
|
||||
$filteredMaterialData,
|
||||
$filteredBundleData,
|
||||
$schedule
|
||||
));
|
||||
|
||||
// \Mail::to($toEmails)->cc($ccEmails)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
||||
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||
}
|
||||
@@ -275,7 +327,41 @@ class SendInvoiceReport extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
||||
// FILTER DATA
|
||||
if ($rule->plant == 0) {
|
||||
|
||||
$filteredSerialData = $serialTableData;
|
||||
$filteredMaterialData = $materialTableData;
|
||||
$filteredBundleData = $bundleTableData;
|
||||
|
||||
} else {
|
||||
|
||||
$filteredSerialData = collect($serialTableData)
|
||||
->where('plant_id', $rule->plant)
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$filteredMaterialData = collect($materialTableData)
|
||||
->where('plant_id', $rule->plant)
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$filteredBundleData = collect($bundleTableData)
|
||||
->where('plant_id', $rule->plant)
|
||||
->values()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)
|
||||
->cc($ccEmails)
|
||||
->send(new test(
|
||||
$filteredSerialData,
|
||||
$filteredMaterialData,
|
||||
$filteredBundleData,
|
||||
$schedule
|
||||
));
|
||||
|
||||
// \Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
||||
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ class ProcessOrderExporter extends Exporter
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ class InvoiceValidationImporter extends Importer
|
||||
ImportColumn::make('operator_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('OPERATOR ID')
|
||||
->example('USER1')
|
||||
->example('USER00001')
|
||||
->label('OPERATOR ID')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_at')
|
||||
@@ -122,19 +122,19 @@ class InvoiceValidationImporter extends Importer
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CREATED BY')
|
||||
->example('USER1')
|
||||
->example('USER00001')
|
||||
->label('CREATED BY')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('UPDATED AT')
|
||||
->example('USER1')
|
||||
->example('')
|
||||
->label('UPDATED AT')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('UPDATED BY')
|
||||
->example('')
|
||||
->example('USER00001')
|
||||
->label('UPDATED BY')
|
||||
->rules(['required']),
|
||||
];
|
||||
|
||||
@@ -102,7 +102,6 @@ class ProductCharacteristicsMasterImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?ProductCharacteristicsMaster
|
||||
{
|
||||
|
||||
$warnMsg = [];
|
||||
$plantCod = trim($this->data['plant']) ?? null;
|
||||
$itemCod = trim($this->data['item']) ?? null;
|
||||
|
||||
@@ -2,10 +2,17 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionCharacteristic;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class ProductionCharacteristicImporter extends Importer
|
||||
{
|
||||
@@ -16,40 +23,170 @@ class ProductionCharacteristicImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('1200')
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
->exampleHeader('LINE NAME')
|
||||
->example('Poly Wrapped Wire SFG')
|
||||
->label('LINE NAME')
|
||||
->relationship(resolveUsing: 'name'),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example('123456')
|
||||
->label('ITEM CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
ImportColumn::make('machine_name')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->exampleHeader('MACHINE NAME')
|
||||
->example('RMI001234')
|
||||
->label('MACHINE NAME')
|
||||
// ->relationship(resolveUsing: 'work_center')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('production_order'),
|
||||
ImportColumn::make('serial_number'),
|
||||
ImportColumn::make('characteristic_name'),
|
||||
ImportColumn::make('observed_value'),
|
||||
ImportColumn::make('status'),
|
||||
ImportColumn::make('inspection_status'),
|
||||
ImportColumn::make('remark'),
|
||||
ImportColumn::make('created_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
ImportColumn::make('production_order')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PRODUCTION ORDER')
|
||||
->example('1880231')
|
||||
->label('PRODUCTION ORDER')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('SERIAL NUMBER')
|
||||
->example('20001202121')
|
||||
->label('SERIAL NUMBER')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('characteristic_name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CHARACTERISTIC NAME')
|
||||
->example('Voltage')
|
||||
->label('CHARACTERISTIC NAME'),
|
||||
ImportColumn::make('observed_value')
|
||||
->exampleHeader('OBSERVED VALUE')
|
||||
->example('0')
|
||||
->label('OBSERVED VALUE'),
|
||||
ImportColumn::make('status')
|
||||
->exampleHeader('STATUS')
|
||||
->example('Ok')
|
||||
->label('STATUS'),
|
||||
ImportColumn::make('remark')
|
||||
->exampleHeader('REMARK')
|
||||
->example('Issue')
|
||||
->label('REMARK'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ProductionCharacteristic
|
||||
{
|
||||
// return ProductionCharacteristic::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new ProductionCharacteristic();
|
||||
$warnMsg = [];
|
||||
$plant = null;
|
||||
$plantCod = trim($this->data['plant']) ?? '';
|
||||
$plantId = null;
|
||||
$iCode = trim($this->data['item']) ?? '';
|
||||
$itemId = null;
|
||||
$lineNam = trim($this->data['line']) ?? '';
|
||||
$lineId = null;
|
||||
$machineName = trim($this->data['machine_name'] ?? '');
|
||||
$pOrder = trim($this->data['production_order'] ?? '');
|
||||
$sNo = trim($this->data['serial_number'] ?? '');
|
||||
$charName = trim($this->data['characteristic_name'] ?? '');
|
||||
$obsValue = trim($this->data['observed_value'] ?? '');
|
||||
$status = trim($this->data['status'] ?? '');
|
||||
$remark = trim($this->data['remark'] ?? '');
|
||||
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
}
|
||||
if ($iCode == null || $iCode == '') {
|
||||
$warnMsg[] = "Item code can't be empty!";
|
||||
} elseif (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
$warnMsg[] = 'Invalid item code found!';
|
||||
}
|
||||
if ($machineName != null && $machineName != '' && Str::length($machineName) > 18) {
|
||||
$warnMsg[] = 'Invalid machine name found!';
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
|
||||
$itemCode = Item::where('code', $iCode)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found!';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found for the given plant!';
|
||||
} else {
|
||||
$itemId = $itemCode->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$lineExists = Line::where('name', $lineNam)->first();
|
||||
if (! $lineExists) {
|
||||
$warnMsg[] = 'Line name not found!';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$lineAgainstPlant = Line::where('name', $lineNam)->where('plant_id', $plantId)->first();
|
||||
if (! $lineAgainstPlant) {
|
||||
$warnMsg[] = 'Line name not found for the given plant!';
|
||||
} else {
|
||||
$lineId = $lineAgainstPlant->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$machineExists = Machine::where('work_center', $machineName)->first();
|
||||
if (! $machineExists) {
|
||||
$warnMsg[] = 'Machine not found!';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$machineAgainstPlant = Machine::where('work_center', $machineName)->where('plant_id', $plantId)->first();
|
||||
if (! $machineAgainstPlant) {
|
||||
$warnMsg[] = 'Machine not found for the given plant!';
|
||||
} else {
|
||||
$machineId = $machineAgainstPlant->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
ProductionCharacteristic::Create(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => $itemId,
|
||||
'machine_id' => $machineId,
|
||||
'production_order' => $pOrder,
|
||||
'serial_number' => $sNo,
|
||||
'characteristic_name' => $charName,
|
||||
'observed_value' => $obsValue,
|
||||
'status' => $status,
|
||||
'remark' => $remark,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
'created_by' => Filament::auth()->user()->name,
|
||||
'updated_by' => Filament::auth()->user()->name,
|
||||
]
|
||||
);
|
||||
|
||||
return null;
|
||||
|
||||
// return new ProductionCharacteristic();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -11,6 +11,7 @@ use Filament\Forms\Form;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
|
||||
class InvoiceDashboard extends Page
|
||||
{
|
||||
@@ -27,9 +28,13 @@ class InvoiceDashboard extends Page
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selec_plant', 'select_invoice']);
|
||||
session()->forget(['from_date']);
|
||||
session()->forget(['to_date']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null,
|
||||
'invoice' => null,
|
||||
'from_date' => null,
|
||||
'to_date' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -62,9 +67,23 @@ class InvoiceDashboard extends Page
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['select_invoice' => $state]);
|
||||
$this->dispatch('invoiceChart');
|
||||
})
|
||||
}),
|
||||
DatePicker::make('created_from')
|
||||
->label('Created From')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state,callable $set) {
|
||||
session(['from_date' => $state]);
|
||||
$this->dispatch('invoiceChart');
|
||||
}),
|
||||
DatePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state,callable $set) {
|
||||
session(['to_date' => $state]);
|
||||
$this->dispatch('invoiceChart');
|
||||
}),
|
||||
])
|
||||
->columns(2);
|
||||
->columns(4);
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
|
||||
@@ -291,7 +291,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
$machineId = $get('machine_id');
|
||||
|
||||
$this->mNam = $machineId;
|
||||
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
// 'class' => $get('pqLineError') ? 'border-red-500' : '',
|
||||
|
||||
@@ -22,6 +22,7 @@ use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
// use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
class ImportTransitResource extends Resource
|
||||
{
|
||||
@@ -446,6 +447,20 @@ class ImportTransitResource extends Resource
|
||||
|
||||
}
|
||||
|
||||
// $spreadsheet = IOFactory::load($fullPath);
|
||||
|
||||
// foreach ($spreadsheet->getAllSheets() as $sheet) {
|
||||
// $state = $sheet->getSheetState();
|
||||
// if ($state == \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::SHEETSTATE_HIDDEN ||
|
||||
// $state == \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::SHEETSTATE_VERYHIDDEN) {
|
||||
// Notification::make()
|
||||
// ->title('Import Failed')
|
||||
// ->body("Hidden sheet found: \"{$sheet->getTitle()}\". Please remove all hidden sheets and try again.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
try
|
||||
{
|
||||
@@ -459,6 +474,13 @@ class ImportTransitResource extends Resource
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
$formattedDate = null;
|
||||
$formattedShipperDate = null;
|
||||
$etaDate = null;
|
||||
$etdDate = null;
|
||||
$formattedBlRcvdDate = null;
|
||||
|
||||
$criRfqNo = trim($row[1] ?? '');
|
||||
$mailRcvdDate = trim($row[2] ?? '');
|
||||
$pricolRefNo = trim($row[3] ?? '');
|
||||
|
||||
@@ -339,8 +339,9 @@ class ProductionCharacteristicResource extends Resource
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
$set('Line', null);
|
||||
$set('Item', null);
|
||||
$set('Machine', null);
|
||||
}),
|
||||
Select::make('Line')
|
||||
->label('Search by Line Name')
|
||||
@@ -361,7 +362,7 @@ class ProductionCharacteristicResource extends Resource
|
||||
})->pluck('name', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('process_order', null);
|
||||
$set('Machine', null);
|
||||
}),
|
||||
Select::make('Item')
|
||||
->label('Search by Item Code')
|
||||
|
||||
@@ -203,7 +203,6 @@ class ProductionOrderResource extends Resource
|
||||
->label('Production Order')
|
||||
->readOnly()
|
||||
->visible(fn ($get) => $get('quantity') > 0),
|
||||
// ->visible(fn ($get) => $get('show_extra_fields')),
|
||||
Forms\Components\TextInput::make('from_serial_number')
|
||||
->label('From Serial Number')
|
||||
->readOnly()
|
||||
|
||||
@@ -245,7 +245,6 @@ class CreateProductionOrder extends CreateRecord
|
||||
} else {
|
||||
return redirect()->route('production-orders.printpanel', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function getFormActions(): array
|
||||
|
||||
@@ -94,7 +94,7 @@ class QualityValidationResource extends Resource
|
||||
Forms\Components\Hidden::make('plant')
|
||||
->default(fn () => session('last_selected_plant_id'))
|
||||
->afterStateHydrated(function ($state, $set) {
|
||||
if (!$state && request()->has('plant_id')) {
|
||||
if (! $state && request()->has('plant_id')) {
|
||||
$set('plant_id', request()->get('plant_id'));
|
||||
}
|
||||
}),
|
||||
@@ -136,7 +136,7 @@ class QualityValidationResource extends Resource
|
||||
Forms\Components\Hidden::make('line')
|
||||
->default(fn () => session('last_selected_line'))
|
||||
->afterStateHydrated(function ($state, $set) {
|
||||
if (!$state && request()->has('line_id')) {
|
||||
if (! $state && request()->has('line_id')) {
|
||||
$set('line_id', request()->get('line_id'));
|
||||
}
|
||||
}),
|
||||
@@ -178,7 +178,7 @@ class QualityValidationResource extends Resource
|
||||
Forms\Components\Hidden::make('production')
|
||||
->default(fn () => session('last_selected_production'))
|
||||
->afterStateHydrated(function ($state, $set) {
|
||||
if (!$state && request()->has('production_order')) {
|
||||
if (! $state && request()->has('production_order')) {
|
||||
$set('production_order', request()->get('production_order'));
|
||||
}
|
||||
}),
|
||||
@@ -2423,7 +2423,6 @@ class QualityValidationResource extends Resource
|
||||
$emails = $mailData['emails'];
|
||||
$mUserName = Filament::auth()->user()->name;
|
||||
|
||||
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
@@ -2519,7 +2518,6 @@ class QualityValidationResource extends Resource
|
||||
$emails = $mailData['emails'];
|
||||
$mUserName = Filament::auth()->user()->name;
|
||||
|
||||
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
@@ -2711,7 +2709,6 @@ class QualityValidationResource extends Resource
|
||||
$emails = $mailData['emails'];
|
||||
$mUserName = Filament::auth()->user()->name;
|
||||
|
||||
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
@@ -2864,16 +2861,6 @@ class QualityValidationResource extends Resource
|
||||
'showChecklist' => $livewire->showChecklist,
|
||||
]),
|
||||
|
||||
// Forms\Components\View::make('components.production-checklist-wrapper')
|
||||
// ->statePath('checklist')
|
||||
// ->key('checklist-view')
|
||||
// ->viewData(fn ($livewire) => [
|
||||
// 'existingRecords' => is_array($livewire->existingRecords)
|
||||
// ? $livewire->existingRecords
|
||||
// : $livewire->existingRecords->toArray(),
|
||||
// 'showChecklist' => $livewire->showChecklist,
|
||||
// ]),
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -3066,7 +3053,6 @@ class QualityValidationResource extends Resource
|
||||
])
|
||||
|
||||
->filters([
|
||||
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
|
||||
@@ -630,7 +630,7 @@ class TestingPanelReadingResource extends Resource
|
||||
->options(function () {
|
||||
// return Plant::pluck('name', 'id');
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
|
||||
@@ -37,6 +37,9 @@ class VehicleEntryResource extends Resource
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('uuid')
|
||||
->label('Uuid')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('vehicle_number')
|
||||
->label('Vehicle Number')
|
||||
->required(),
|
||||
@@ -102,6 +105,11 @@ class VehicleEntryResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('uuid')
|
||||
->label('UUID')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('vehicle_number')
|
||||
->label('Vehicle Number')
|
||||
->alignCenter()
|
||||
|
||||
@@ -22,6 +22,10 @@ class InvoiceChart extends ChartWidget
|
||||
{
|
||||
$selectedPlant = session('selec_plant');
|
||||
$selectedInvoice = session('select_invoice');
|
||||
|
||||
$fromDt = session('from_date');
|
||||
$toDt = session('to_date');
|
||||
|
||||
$activeFilter = $this->filter; // Assuming filter is passed and activeFilter can be 'yesterday', 'this_week', 'this_month'
|
||||
|
||||
if (!$selectedPlant || !$selectedInvoice) {
|
||||
@@ -31,23 +35,33 @@ class InvoiceChart extends ChartWidget
|
||||
];
|
||||
}
|
||||
|
||||
// Define the date range based on the active filter
|
||||
if ($activeFilter == 'yesterday') {
|
||||
$startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
$endDate = now()->setTime(8, 0, 0);
|
||||
$groupBy = 'none'; // No grouping by hour
|
||||
} elseif ($activeFilter == 'this_week') {
|
||||
$startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||
$endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||
$groupBy = 'day_of_week';
|
||||
} elseif ($activeFilter == 'this_month') {
|
||||
$startDate = now()->startOfMonth()->setTime(8, 0, 0);
|
||||
$endDate = now()->endOfMonth()->setTime(8, 0, 0);
|
||||
$groupBy = 'week_of_month';
|
||||
} else {
|
||||
$startDate = now()->setTime(8, 0, 0);
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
$groupBy = 'none'; // No grouping by hour
|
||||
$isCustomDate = !empty($fromDt) && !empty($toDt);
|
||||
|
||||
if (!empty($fromDt) && !empty($toDt)) {
|
||||
$startDate = \Carbon\Carbon::parse($fromDt)->setTime(8, 0, 0);
|
||||
$endDate = \Carbon\Carbon::parse($toDt)->addDay()->setTime(8, 0, 0);
|
||||
$groupBy = 'none';
|
||||
}
|
||||
else{
|
||||
|
||||
// Define the date range based on the active filter
|
||||
if ($activeFilter == 'yesterday') {
|
||||
$startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
$endDate = now()->setTime(8, 0, 0);
|
||||
$groupBy = 'none'; // No grouping by hour
|
||||
} elseif ($activeFilter == 'this_week') {
|
||||
$startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||
$endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||
$groupBy = 'day_of_week';
|
||||
} elseif ($activeFilter == 'this_month') {
|
||||
$startDate = now()->startOfMonth()->setTime(8, 0, 0);
|
||||
$endDate = now()->endOfMonth()->setTime(8, 0, 0);
|
||||
$groupBy = 'week_of_month';
|
||||
} else {
|
||||
$startDate = now()->setTime(8, 0, 0);
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
$groupBy = 'none'; // No grouping by hour
|
||||
}
|
||||
}
|
||||
|
||||
// Get the counts for Imported Invoices (unique invoice numbers) and Completed Invoices
|
||||
@@ -111,7 +125,11 @@ class InvoiceChart extends ChartWidget
|
||||
$labels = []; // Labels for each bar
|
||||
$datasets = []; // Datasets for the chart
|
||||
|
||||
if (in_array($activeFilter, ['yesterday'])) {
|
||||
if (!empty($fromDt) && !empty($toDt)) {
|
||||
$activeFilter = null;
|
||||
}
|
||||
|
||||
if ($isCustomDate || in_array($activeFilter, ['yesterday'])) {
|
||||
$labels = ['Imported Invoice', 'Completed Invoice'];
|
||||
$datasets = [[
|
||||
'label' => 'Invoices',
|
||||
@@ -120,8 +138,7 @@ class InvoiceChart extends ChartWidget
|
||||
'fill' => false,
|
||||
]];
|
||||
}
|
||||
|
||||
elseif ($activeFilter == 'this_week')
|
||||
elseif ($isCustomDate || $activeFilter == 'this_week')
|
||||
{
|
||||
$daysOfWeek = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
||||
$importedInvoicesPerDay = array_fill(0, 7, 0);
|
||||
@@ -191,7 +208,7 @@ class InvoiceChart extends ChartWidget
|
||||
],
|
||||
];
|
||||
}
|
||||
elseif ($activeFilter == 'this_month') {
|
||||
elseif ($isCustomDate || $activeFilter == 'this_month') {
|
||||
$startOfMonth = now()->startOfMonth()->setTime(8, 0, 0);
|
||||
$endOfMonth = now()->endOfMonth()->addDay()->setTime(23, 59, 59); // include full last day
|
||||
$monthName = $startOfMonth->format('M');
|
||||
@@ -279,7 +296,7 @@ class InvoiceChart extends ChartWidget
|
||||
],
|
||||
];
|
||||
}
|
||||
else
|
||||
elseif (!$isCustomDate)
|
||||
{
|
||||
$labels = ['Imported Invoice', 'Completed Invoice'];
|
||||
$datasets = [[
|
||||
@@ -354,7 +371,7 @@ class InvoiceChart extends ChartWidget
|
||||
|
||||
public static function canView(): bool
|
||||
{
|
||||
// dd('Checking route:', request()->route()->getName());
|
||||
// dd('Checking route:', request()->route()->getName());
|
||||
// to avoid showing the widget in other pages
|
||||
return request()->routeIs('filament.admin.pages.invoice-dashboard');
|
||||
}
|
||||
|
||||
@@ -3780,7 +3780,7 @@ class CharacteristicsController extends Controller
|
||||
if (! $cField) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Master characteristic field value '{$charField}'' not found in approver master!",
|
||||
'status_description' => "Master characteristic field value '{$charField}' not found in approver master!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
@@ -3856,6 +3856,21 @@ class CharacteristicsController extends Controller
|
||||
$query->where('approver_type', 'Characteristic');
|
||||
})->where('machine_id', $machineId)->where('plant_id', $plantId)->get();
|
||||
|
||||
$requestQual = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
|
||||
->whereHas('approver', function ($query) {
|
||||
$query->where('approver_type', 'Quality');
|
||||
})->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get();
|
||||
|
||||
foreach ($requestQual as $row) {
|
||||
$workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1';
|
||||
|
||||
TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId)
|
||||
->update([
|
||||
'has_work_flow_id' => $workFlowStatus,
|
||||
'updated_by' => $userName,
|
||||
]);
|
||||
}
|
||||
|
||||
$tempClassChars = TempClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->get();
|
||||
|
||||
if (! $requestChars->isEmpty()) {
|
||||
@@ -3966,6 +3981,21 @@ class CharacteristicsController extends Controller
|
||||
$query->where('approver_type', 'Characteristic');
|
||||
})->where('machine_id', $machineId)->where('plant_id', $plantId)->get();
|
||||
|
||||
$requestQual = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
|
||||
->whereHas('approver', function ($query) {
|
||||
$query->where('approver_type', 'Quality');
|
||||
})->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get();
|
||||
|
||||
foreach ($requestQual as $row) {
|
||||
$workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1';
|
||||
|
||||
TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId)
|
||||
->update([
|
||||
'has_work_flow_id' => $workFlowStatus,
|
||||
'updated_by' => $userName,
|
||||
]);
|
||||
}
|
||||
|
||||
if (! $requestChars->isEmpty()) {
|
||||
$hasCharPending = false;
|
||||
|
||||
@@ -4980,6 +5010,21 @@ class CharacteristicsController extends Controller
|
||||
$query->where('approver_type', 'Characteristic');
|
||||
})->where('machine_id', $machineId)->where('plant_id', $plantId)->get();
|
||||
|
||||
$requestQual = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
|
||||
->whereHas('approver', function ($query) {
|
||||
$query->where('approver_type', 'Quality');
|
||||
})->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get();
|
||||
|
||||
foreach ($requestQual as $row) {
|
||||
$workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1';
|
||||
|
||||
TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId)
|
||||
->update([
|
||||
'has_work_flow_id' => $workFlowStatus,
|
||||
'updated_by' => $userName,
|
||||
]);
|
||||
}
|
||||
|
||||
$tempClassChars = TempClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->get();
|
||||
|
||||
if (! $requestChars->isEmpty()) {
|
||||
@@ -5084,6 +5129,21 @@ class CharacteristicsController extends Controller
|
||||
$query->where('approver_type', 'Characteristic');
|
||||
})->where('machine_id', $machineId)->where('plant_id', $plantId)->get();
|
||||
|
||||
$requestQual = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
|
||||
->whereHas('approver', function ($query) {
|
||||
$query->where('approver_type', 'Quality');
|
||||
})->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get();
|
||||
|
||||
foreach ($requestQual as $row) {
|
||||
$workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1';
|
||||
|
||||
TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId)
|
||||
->update([
|
||||
'has_work_flow_id' => $workFlowStatus,
|
||||
'updated_by' => $userName,
|
||||
]);
|
||||
}
|
||||
|
||||
if (! $requestChars->isEmpty()) {
|
||||
$hasCharPending = false;
|
||||
|
||||
@@ -5160,12 +5220,20 @@ class CharacteristicsController extends Controller
|
||||
'approver_status_3' => $row->approver_status3 ?? '',
|
||||
'approver_remark_3' => $row->approver_remark3 ?? '',
|
||||
'approved_at_3' => $row->approved3_at ?? '', // ? $row->approved3_at->format('d-m-Y H:i:s') : '',
|
||||
'mail_status' => ($row->mail_status == 'Sent') ? 'Sent-M1' : (($row->mail_status == 'Sent-Mail2') ? 'Sent-M2' : (($row->mail_status == 'Sent-Mail3') ? 'Sent-M3' : '-')),
|
||||
'triggered_at' => $row->trigger_at ?? '',
|
||||
'requested_by' => ($row->created_by == 'Admin') ? 'jothi' : $row->created_by ?? '',
|
||||
'requested_at' => $row->created_at ? $row->created_at->format('Y-m-d H:i:s') : '',
|
||||
];
|
||||
} else {
|
||||
$workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1';
|
||||
|
||||
// / TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId)
|
||||
// / ->update([
|
||||
// / 'has_work_flow_id' => $workFlowStatus,
|
||||
// / 'updated_by' => $userName,
|
||||
// / ]);
|
||||
|
||||
if ($workFlowStatus == '1') {
|
||||
$workFlowStatus = ($row->approver_status1 == 'Rejected' || $row->approver_status2 == 'Rejected' || $row->approver_status3 == 'Rejected') ? '2' : '1';
|
||||
}
|
||||
@@ -5191,6 +5259,8 @@ class CharacteristicsController extends Controller
|
||||
'approver_status_3' => $row->approver_status3 ?? '',
|
||||
'approver_remark_3' => $row->approver_remark3 ?? '',
|
||||
'approved_at_3' => $row->approved3_at ?? '', // ? $row->approved3_at->format('d-m-Y H:i:s') : '',
|
||||
'mail_status' => ($row->mail_status == 'Sent') ? 'Sent-M1' : (($row->mail_status == 'Sent-Mail2') ? 'Sent-M2' : (($row->mail_status == 'Sent-Mail3') ? 'Sent-M3' : '-')),
|
||||
'triggered_at' => $row->trigger_at ?? '',
|
||||
'requested_by' => ($row->created_by == 'Admin') ? 'jothi' : $row->created_by ?? '',
|
||||
'requested_at' => $row->created_at ? $row->created_at->format('Y-m-d H:i:s') : '',
|
||||
];
|
||||
|
||||
@@ -107,7 +107,7 @@ class PalletPrintController extends Controller
|
||||
|
||||
$index = $completedPallets->search($pallet);
|
||||
|
||||
$currentPalletNo = ($index != false) ? $index + 1 : 0;
|
||||
$currentPalletNo = ($index !== false) ? $index + 1 : 0;
|
||||
|
||||
$boxLabel = $currentPalletNo.'/'.$totalBoxes;
|
||||
|
||||
|
||||
@@ -41,12 +41,11 @@ class VehicleController extends Controller
|
||||
|
||||
if (!ctype_digit((string) $plantCode)) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "plant code must be $plantCode a numeric value",
|
||||
], 404);
|
||||
}
|
||||
|
||||
|
||||
$plantCod = Plant::where('code', $plantCode)->first();
|
||||
|
||||
if(!$plantCod){
|
||||
@@ -58,100 +57,167 @@ class VehicleController extends Controller
|
||||
|
||||
$plantId = $plantCod->id;
|
||||
|
||||
$data = $request->all();
|
||||
// $data = $request->all();
|
||||
|
||||
$vehicleNo = $data['vehicle_number'] ?? '';
|
||||
$entryTimeRaw = $data['entry_time'] ?? '';
|
||||
$exitTimeRaw = $data['exit_time'] ?? '';
|
||||
$duration = $data['duration'] ?? '';
|
||||
$type = $data['type'] ?? '';
|
||||
$data = $request->json()->all();
|
||||
|
||||
if(!$vehicleNo)
|
||||
$results = [];
|
||||
|
||||
foreach ($data as $item) {
|
||||
|
||||
$uuid = $item['uuid'] ?? '';
|
||||
$vehicleNo = trim($item['vehicle_number'] ?? '');
|
||||
$entryTimeRaw = $item['entry_time'] ?? '';
|
||||
$exitTimeRaw = $item['exit_time'] ?? '';
|
||||
$duration = $item['duration'] ?? '';
|
||||
$type = $item['type'] ?? '';
|
||||
|
||||
if (!$vehicleNo) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Vehicle number can't be empty!"
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
elseif (strlen($vehicleNo) < 8) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Vehicle number '$vehicleNo' must be at least 8 characters long"
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
elseif (!$entryTimeRaw) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Entry time can't be empty!"
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
elseif (!$type) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Type can't be empty!"
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
elseif ($entryTimeRaw && !Carbon::hasFormat($entryTimeRaw, 'd/m/Y h:i:s A')) {
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid Entry time format $entryTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM"
|
||||
];
|
||||
continue;
|
||||
}
|
||||
else if ($exitTimeRaw && !Carbon::hasFormat($exitTimeRaw, 'd/m/Y h:i:s A')) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid Exit time format $exitTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM"
|
||||
];
|
||||
continue;
|
||||
}
|
||||
elseif ($duration && !preg_match('/^\d{2}:\d{2}:\d{2}$/', $duration)) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid duration format $duration"
|
||||
];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($results)){
|
||||
return response()->json($results, 404);
|
||||
}
|
||||
|
||||
foreach ($data as $item) {
|
||||
|
||||
$uuid = $item['uuid'] ?? '';
|
||||
$vehicleNo = trim($item['vehicle_number'] ?? '');
|
||||
$entryTimeRaw = $item['entry_time'] ?? '';
|
||||
$exitTimeRaw = $item['exit_time'] ?? '';
|
||||
$duration = $item['duration'] ?? '';
|
||||
$type = $item['type'] ?? '';
|
||||
|
||||
if(!empty($entryTimeRaw)){
|
||||
$entryTime = $entryTimeRaw
|
||||
? Carbon::createFromFormat('d/m/Y h:i:s A', $entryTimeRaw)
|
||||
: null;
|
||||
}
|
||||
|
||||
$exitTime = null;
|
||||
|
||||
if(!empty($exitTimeRaw)){
|
||||
|
||||
$exitTime = $exitTimeRaw
|
||||
? Carbon::createFromFormat('d/m/Y h:i:s A', $exitTimeRaw)
|
||||
: null;
|
||||
}
|
||||
|
||||
if (
|
||||
empty($duration) &&
|
||||
!empty($entryTime) &&
|
||||
!empty($exitTime)
|
||||
) {
|
||||
|
||||
$totalSeconds = $entryTime->diffInSeconds($exitTime);
|
||||
|
||||
$hours = floor($totalSeconds / 3600);
|
||||
$minutes = floor(($totalSeconds % 3600) / 60);
|
||||
$seconds = $totalSeconds % 60;
|
||||
|
||||
$duration = sprintf(
|
||||
'%02d:%02d:%02d',
|
||||
$hours,
|
||||
$minutes,
|
||||
$seconds
|
||||
);
|
||||
}
|
||||
|
||||
$record = VehicleEntry::updateOrInsert(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
'uuid' => $uuid
|
||||
],
|
||||
[
|
||||
'vehicle_number' => $vehicleNo,
|
||||
'entry_time' => $entryTime,
|
||||
'exit_time' => $exitTime ?? null,
|
||||
'duration' => $duration ?: null,
|
||||
'type' => $type,
|
||||
'updated_at' => now(),
|
||||
'created_at' => now(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if($record){
|
||||
return response()->json([
|
||||
'status' => 'SUCCESS',
|
||||
'status_description' => 'Vehicle entry inserted successfully'
|
||||
], 200);
|
||||
}
|
||||
else
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Vehicle number cant't be empty!",
|
||||
'status_description' => 'Failed to insert record in the table vehicle entry'
|
||||
], 404);
|
||||
}
|
||||
else if (strlen($vehicleNo) < 8) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "vehicle number '$vehicleNo' must be at least 8 characters long",
|
||||
], 404);
|
||||
}
|
||||
else if(!$entryTimeRaw)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Entry time cant't be empty!",
|
||||
], 404);
|
||||
}
|
||||
else if(!$exitTimeRaw)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Exit time cant't be empty!",
|
||||
], 404);
|
||||
}
|
||||
else if(!$duration)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Duration cant't be empty!",
|
||||
], 404);
|
||||
}
|
||||
else if(!$type)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "type cant't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
|
||||
if ($entryTimeRaw && !Carbon::hasFormat($entryTimeRaw, 'd/m/Y h:i:s A')) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Invalid Entry time format $entryTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM",
|
||||
], 404);
|
||||
}
|
||||
else if ($exitTimeRaw && !Carbon::hasFormat($exitTimeRaw, 'd/m/Y h:i:s A')) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Invalid Exit time format $exitTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM",
|
||||
], 404);
|
||||
}
|
||||
else if ($duration && !preg_match('/^\d{2}:\d{2}:\d{2}$/', $duration)) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'status_description' => "Invalid duration format $duration. Expected HH:MM:SS",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$entryTime = $entryTimeRaw
|
||||
? Carbon::createFromFormat('d/m/Y h:i:s A', $entryTimeRaw)
|
||||
: null;
|
||||
|
||||
$exitTime = $exitTimeRaw
|
||||
? Carbon::createFromFormat('d/m/Y h:i:s A', $exitTimeRaw)
|
||||
: null;
|
||||
|
||||
VehicleEntry::insert([
|
||||
'plant_id' => $plantId,
|
||||
'vehicle_number' => $vehicleNo,
|
||||
'entry_time' => $entryTime,
|
||||
'exit_time' => $exitTime,
|
||||
'duration' => $duration,
|
||||
'type' => $type,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'status_description' => 'Vehicle entry inserted successfully'
|
||||
], 200);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,28 +4,42 @@ namespace App\Mail;
|
||||
|
||||
use DateTime;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
// use App\Exports\ProductionExport;
|
||||
// use Illuminate\Mail\Mailables\Attachment;
|
||||
// use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class ProductionMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tableData;
|
||||
|
||||
public $scheduleType;
|
||||
// public $excelData;
|
||||
// public $dates;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($scheduleType,$tableData = [])
|
||||
public function __construct($scheduleType, $tableData = [])
|
||||
{
|
||||
$this->scheduleType = $scheduleType;
|
||||
$this->tableData = $tableData ?? [];
|
||||
$this->scheduleType = $scheduleType;
|
||||
$this->tableData = $tableData ?? [];
|
||||
}
|
||||
|
||||
// public function __construct($scheduleType,$tableData = [],$excelData = [],$dates = [])
|
||||
// {
|
||||
// $this->scheduleType = $scheduleType;
|
||||
// $this->tableData = $tableData;
|
||||
// $this->excelData = $excelData;
|
||||
// $this->dates = $dates;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
@@ -52,13 +66,14 @@ class ProductionMail extends Mailable
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
|
||||
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';
|
||||
$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;
|
||||
}
|
||||
@@ -74,22 +89,21 @@ class ProductionMail extends Mailable
|
||||
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');
|
||||
$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",
|
||||
'company' => 'CRI Digital Manufacturing Solutions',
|
||||
'greeting' => $greeting,
|
||||
'tableData' => $this->tableData,
|
||||
'wishes' => "Thanks & Regards,<br>CRI Digital Manufacturing Solutions"
|
||||
'wishes' => 'Thanks & Regards,<br>CRI Digital Manufacturing Solutions',
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
@@ -98,5 +112,19 @@ class ProductionMail extends Mailable
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
// return [
|
||||
// Attachment::fromData(
|
||||
// fn () => Excel::raw(
|
||||
// new ProductionExport(
|
||||
// $this->excelData,
|
||||
// $this->dates
|
||||
// ),
|
||||
// \Maatwebsite\Excel\Excel::XLSX
|
||||
// ),
|
||||
// 'production_plan_data.xlsx'
|
||||
// )->withMime(
|
||||
// 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
// ),
|
||||
// ];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class RequestCharacteristic extends Model
|
||||
'mail_status',
|
||||
'trigger_at',
|
||||
'work_flow_id',
|
||||
|
||||
'model_type',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
|
||||
@@ -17,6 +17,7 @@ class VehicleEntry extends Model
|
||||
'exit_time',
|
||||
'duration',
|
||||
'type',
|
||||
'uuid',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_at',
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE request_characteristics
|
||||
ADD COLUMN model_type TEXT DEFAULT NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('request_characteristics', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE vehicle_entries
|
||||
ADD COLUMN uuid TEXT DEFAULT NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('vehicle_entries', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -210,7 +210,20 @@ class PermissionSeeder extends Seeder
|
||||
Permission::updateOrCreate(['name' => 'view import temp class characteristic']);
|
||||
Permission::updateOrCreate(['name' => 'view export temp class characteristic']);
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import production temp']);
|
||||
Permission::updateOrCreate(['name' => 'view export production temp']);
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import production orders']);
|
||||
Permission::updateOrCreate(['name' => 'view export production orders']);
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import transit']);
|
||||
Permission::updateOrCreate(['name' => 'view export import transit']);
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view reprint production order']);
|
||||
Permission::updateOrCreate(['name' => 'create osp production sticker reprint page']);
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view print production order button']);
|
||||
Permission::updateOrCreate(['name' => 'view save production order button']);
|
||||
Permission::updateOrCreate(['name' => 'view print panel production order button']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -948,84 +948,80 @@ function cameraCapture() {
|
||||
|
||||
|
||||
async verifyPhoto() {
|
||||
if (!this.capturedPhoto) {
|
||||
alert("Please capture a photo first!");
|
||||
return;
|
||||
}
|
||||
if (!this.capturedPhoto) {
|
||||
alert("Please capture a photo first!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.isWorkerReady) {
|
||||
alert("OCR worker not ready yet!");
|
||||
return;
|
||||
}
|
||||
if (!this.isWorkerReady) {
|
||||
alert("OCR worker not ready yet!");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const img = new Image();
|
||||
img.src = this.capturedPhoto;
|
||||
try {
|
||||
const img = new Image();
|
||||
img.src = this.capturedPhoto;
|
||||
|
||||
img.onload = async () => {
|
||||
img.onload = async () => {
|
||||
|
||||
// Reuse the same temp canvas (no memory leak)
|
||||
this.tempCanvas.width = img.width;
|
||||
this.tempCanvas.height = img.height;
|
||||
this.tempCtx.drawImage(img, 0, 0);
|
||||
// Reuse the same temp canvas (no memory leak)
|
||||
this.tempCanvas.width = img.width;
|
||||
this.tempCanvas.height = img.height;
|
||||
this.tempCtx.drawImage(img, 0, 0);
|
||||
|
||||
// Worker OCR — much faster
|
||||
const result = await this.ocrWorker.recognize(this.tempCanvas);
|
||||
// Worker OCR — much faster
|
||||
const result = await this.ocrWorker.recognize(this.tempCanvas);
|
||||
|
||||
const detectedText = result.data.text.trim();
|
||||
console.log("Detected Text:", detectedText);
|
||||
const detectedText = result.data.text.trim();
|
||||
console.log("Detected Text:", detectedText);
|
||||
|
||||
// -------------------------------------------------------
|
||||
// SERIAL EXTRACTION LOGIC — SAME AS YOUR ORIGINAL
|
||||
// -------------------------------------------------------
|
||||
const serialWithLabelRegex = /Serial\s*No[:\-]?\s*([A-Za-z0-9]+)/i;
|
||||
const match = detectedText.match(serialWithLabelRegex);
|
||||
const serialWithLabelRegex = /Serial\s*No[:\-]?\s*([A-Za-z0-9]+)/i;
|
||||
const match = detectedText.match(serialWithLabelRegex);
|
||||
|
||||
if (match && match[1]) {
|
||||
// "Serial No: XXXXX"
|
||||
this.serialNumbers = [match[1].trim()];
|
||||
console.log("Serial with Label:", this.serialNumbers[0]);
|
||||
} else {
|
||||
// Extract first 4 alphanumeric sequences of 4+ chars
|
||||
const generalNums = detectedText.match(/[A-Za-z0-9]{4,}/g) || [];
|
||||
this.serialNumbers = generalNums.slice(0, 4);
|
||||
if (match && match[1]) {
|
||||
this.serialNumbers = [match[1].trim()];
|
||||
console.log("Serial with Label:", this.serialNumbers[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
const generalNums = detectedText.match(/[A-Za-z0-9]{4,}/g) || [];
|
||||
this.serialNumbers = generalNums.slice(0, 4);
|
||||
|
||||
if (this.serialNumbers.length === 0) {
|
||||
alert("No serial numbers detected!");
|
||||
return;
|
||||
if (this.serialNumbers.length == 0) {
|
||||
alert("No serial numbers detected!");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Serial Numbers List:", this.serialNumbers);
|
||||
}
|
||||
|
||||
console.log("Serial Numbers List:", this.serialNumbers);
|
||||
// Save into hidden input (your original logic)
|
||||
this.$refs.hiddenInputSerials.value = JSON.stringify(this.serialNumbers);
|
||||
|
||||
alert("Serial numbers:\n" + this.$refs.hiddenInputSerials.value);
|
||||
|
||||
fetch('/save-serials-to-session', {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
serial_numbers: this.serialNumbers,
|
||||
}),
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log("Session Updated:", data);
|
||||
alert("✅ Serial numbers saved to session!");
|
||||
});
|
||||
};
|
||||
} catch (err) {
|
||||
console.error("OCR verify error:", err);
|
||||
alert("OCR verify failed:\n" + (err.message || err));
|
||||
}
|
||||
|
||||
// Save into hidden input (your original logic)
|
||||
this.$refs.hiddenInputSerials.value = JSON.stringify(this.serialNumbers);
|
||||
|
||||
alert("Serial numbers:\n" + this.$refs.hiddenInputSerials.value);
|
||||
|
||||
fetch('/save-serials-to-session', {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
serial_numbers: this.serialNumbers,
|
||||
}),
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log("Session Updated:", data);
|
||||
alert("✅ Serial numbers saved to session!");
|
||||
});
|
||||
};
|
||||
|
||||
} catch (err) {
|
||||
console.error("OCR verify error:", err);
|
||||
alert("OCR verify failed:\n" + (err.message || err));
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
startDetection() {
|
||||
if (this.textDetectionInterval) {
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
if (!scanInput) return;
|
||||
|
||||
scanInput.addEventListener('keydown', function (event) {
|
||||
if (event.key === 'Enter') {
|
||||
if (event.key == 'Enter') {
|
||||
event.preventDefault();
|
||||
|
||||
const value = scanInput.value.trim();
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
<div class="bg-white max-h-[80vh] overflow-hidden p-6 rounded-lg shadow-lg pointer-events-auto"
|
||||
style="width:30vw !important; max-width:none !important;">
|
||||
|
||||
@if($records && $records->count())
|
||||
{{-- @if($records && $records->count()) --}}
|
||||
@if(!empty($records) && count($records))
|
||||
<div style="max-height:250px; overflow-y:auto; border:1px solid #ccc;">
|
||||
|
||||
{{-- <table class="min-w-full border"> --}}
|
||||
|
||||
@@ -106,7 +106,6 @@
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
|
||||
{{-- <td>{{ $row['lr_bl_aw_date'] }}</td> --}}
|
||||
<td>{{ $row['transit_days'] }}</td>
|
||||
<td>{{ $row['status'] }}</td>
|
||||
|
||||
Reference in New Issue
Block a user