Compare commits
38 Commits
6bf54a89ae
...
ranjith-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ce7995105 | ||
|
|
d5cd1437fe | ||
|
|
d4d101c5c9 | ||
|
|
b8cb0aa237 | ||
|
|
eef42d9736 | ||
|
|
3316c11036 | ||
|
|
bf22ef5af0 | ||
|
|
52868742c0 | ||
|
|
30175a71d3 | ||
|
|
5fe8eeaeee | ||
|
|
fa10ea14fe | ||
|
|
f0af6853ee | ||
|
|
d213049fdd | ||
|
|
42e926f9c2 | ||
|
|
140249e824 | ||
|
|
5a77cdfdc2 | ||
|
|
015976dcb5 | ||
|
|
7627aa07fd | ||
|
|
aad961260a | ||
|
|
305d28617b | ||
|
|
851e753b74 | ||
|
|
c94688a794 | ||
|
|
9db6227566 | ||
|
|
d24b4f35f4 | ||
|
|
56656264c0 | ||
|
|
abf33605f5 | ||
|
|
60eb3c05a5 | ||
|
|
ccd06a4b6e | ||
|
|
0d6ced5f63 | ||
|
|
faa355ad79 | ||
|
|
cc75016575 | ||
|
|
6180cdda52 | ||
|
|
776d1664ce | ||
|
|
65b4ce50d3 | ||
|
|
c338751a48 | ||
|
|
075591459f | ||
|
|
fc0a132c73 | ||
|
|
a7e07affa0 |
@@ -4,8 +4,10 @@ namespace App\Console\Commands;
|
|||||||
|
|
||||||
use App\Mail\ImportTransitMail;
|
use App\Mail\ImportTransitMail;
|
||||||
use App\Models\AlertMailRule;
|
use App\Models\AlertMailRule;
|
||||||
|
use App\Models\EmployeeMaster;
|
||||||
use App\Models\ImportTransit;
|
use App\Models\ImportTransit;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
use App\Exports\ImportTransitReportExport;
|
use App\Exports\ImportTransitReportExport;
|
||||||
@@ -81,11 +83,22 @@ class SendImportTransit extends Command
|
|||||||
'local'
|
'local'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$updatedBy = $tableData->last()?->updated_by;
|
||||||
|
|
||||||
|
$employee = EmployeeMaster::where('code', $updatedBy)
|
||||||
|
->select('name', 'mobile_number')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$employeeName = $employee?->name;
|
||||||
|
$mobileNumber = $employee?->mobile_number;
|
||||||
|
|
||||||
$mail = new ImportTransitMail(
|
$mail = new ImportTransitMail(
|
||||||
$scheduleType,
|
$scheduleType,
|
||||||
$tableData,
|
$tableData,
|
||||||
$mailSubject,
|
$mailSubject,
|
||||||
$fileName
|
$fileName,
|
||||||
|
$employeeName,
|
||||||
|
$mobileNumber,
|
||||||
);
|
);
|
||||||
|
|
||||||
$toEmails = collect(explode(',', $rule->email))
|
$toEmails = collect(explode(',', $rule->email))
|
||||||
@@ -111,11 +124,9 @@ class SendImportTransit extends Command
|
|||||||
->cc($ccEmails)
|
->cc($ccEmails)
|
||||||
->send($mail);
|
->send($mail);
|
||||||
|
|
||||||
$this->info(
|
$this->info("Mail sent → Rule {$rule->id} | To: " . implode(', ', $toEmails));
|
||||||
"Mail sent → Rule {$rule->id} | To: " . implode(', ', $toEmails)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -39,8 +39,6 @@ class ProductionCharacteristicExporter extends Exporter
|
|||||||
->label('OBSERVED VALUE'),
|
->label('OBSERVED VALUE'),
|
||||||
ExportColumn::make('status')
|
ExportColumn::make('status')
|
||||||
->label('STATUS'),
|
->label('STATUS'),
|
||||||
ExportColumn::make('inspection_status')
|
|
||||||
->label('INSPECTION STATUS'),
|
|
||||||
ExportColumn::make('remark')
|
ExportColumn::make('remark')
|
||||||
->label('REMARK'),
|
->label('REMARK'),
|
||||||
ExportColumn::make('created_at')
|
ExportColumn::make('created_at')
|
||||||
|
|||||||
68
app/Filament/Exports/WireMasterPackingExporter.php
Normal file
68
app/Filament/Exports/WireMasterPackingExporter.php
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Exports;
|
||||||
|
|
||||||
|
use App\Models\WireMasterPacking;
|
||||||
|
use Filament\Actions\Exports\ExportColumn;
|
||||||
|
use Filament\Actions\Exports\Exporter;
|
||||||
|
use Filament\Actions\Exports\Models\Export;
|
||||||
|
|
||||||
|
class WireMasterPackingExporter extends Exporter
|
||||||
|
{
|
||||||
|
protected static ?string $model = WireMasterPacking::class;
|
||||||
|
|
||||||
|
public static function getColumns(): array
|
||||||
|
{
|
||||||
|
static $rowNumber = 0;
|
||||||
|
return [
|
||||||
|
ExportColumn::make('no')
|
||||||
|
->label('NO')
|
||||||
|
->state(function ($record) use (&$rowNumber) {
|
||||||
|
// Increment and return the row number
|
||||||
|
return ++$rowNumber;
|
||||||
|
}),
|
||||||
|
ExportColumn::make('plant.code')
|
||||||
|
->label('PLANT CODE'),
|
||||||
|
ExportColumn::make('item.code')
|
||||||
|
->label('ITEM CODE'),
|
||||||
|
ExportColumn::make('customerPo.customer_po')
|
||||||
|
->label('CUSTOMER PO NUMBER'),
|
||||||
|
ExportColumn::make('wire_packing_number')
|
||||||
|
->label('WIRE PACKING NUMBER'),
|
||||||
|
ExportColumn::make('process_order')
|
||||||
|
->label('PROCESS ORDER'),
|
||||||
|
ExportColumn::make('batch_number')
|
||||||
|
->label('BATCH NUMBER'),
|
||||||
|
ExportColumn::make('weight')
|
||||||
|
->label('WEIGHT'),
|
||||||
|
ExportColumn::make('wire_packing_status')
|
||||||
|
->label('WIRE PACKING STATUS'),
|
||||||
|
ExportColumn::make('created_at')
|
||||||
|
->label('CREATED AT'),
|
||||||
|
ExportColumn::make('updated_at')
|
||||||
|
->label('UPDATED AT'),
|
||||||
|
ExportColumn::make('scanned_at')
|
||||||
|
->label('SCANNED AT'),
|
||||||
|
ExportColumn::make('created_by')
|
||||||
|
->label('CREATED BY'),
|
||||||
|
ExportColumn::make('updated_by')
|
||||||
|
->label('UPDATED BY'),
|
||||||
|
ExportColumn::make('scanned_by')
|
||||||
|
->label('SCANNED BY'),
|
||||||
|
ExportColumn::make('deleted_at')
|
||||||
|
->label('DELETED AT')
|
||||||
|
->enabledByDefault(false),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCompletedNotificationBody(Export $export): string
|
||||||
|
{
|
||||||
|
$body = 'Your wire master packing export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||||
|
|
||||||
|
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||||
|
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -111,6 +111,13 @@ class CustomerPoMasterImporter extends Importer
|
|||||||
$warnMsg[] = "Customer PO '{$this->data['customer_po']}' is already mapped to customer '{$existingPo->customer_name}'.";
|
$warnMsg[] = "Customer PO '{$this->data['customer_po']}' is already mapped to customer '{$existingPo->customer_name}'.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$existingPoItem = CustomerPoMaster::where('plant_id', $plant->id)->where('item_id', $item->id)->where('customer_po', $this->data['customer_po'])->where('customer_name', $this->data['customer_name'])->first();
|
||||||
|
|
||||||
|
if ($existingPoItem)
|
||||||
|
{
|
||||||
|
$warnMsg[] = "Customer PO '{$this->data['customer_po']}' is already exist with item code '{$this->data['item']}' and customer name '{$this->data['customer_name']}'.";
|
||||||
|
}
|
||||||
|
|
||||||
// $user = User::where('name', $this->data['created_by'])->first();
|
// $user = User::where('name', $this->data['created_by'])->first();
|
||||||
// if (! $user) {
|
// if (! $user) {
|
||||||
// $warnMsg[] = 'User not found';
|
// $warnMsg[] = 'User not found';
|
||||||
|
|||||||
96
app/Filament/Imports/WireMasterPackingImporter.php
Normal file
96
app/Filament/Imports/WireMasterPackingImporter.php
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Imports;
|
||||||
|
|
||||||
|
use App\Models\WireMasterPacking;
|
||||||
|
use Filament\Actions\Imports\ImportColumn;
|
||||||
|
use Filament\Actions\Imports\Importer;
|
||||||
|
use Filament\Actions\Imports\Models\Import;
|
||||||
|
|
||||||
|
class WireMasterPackingImporter extends Importer
|
||||||
|
{
|
||||||
|
protected static ?string $model = WireMasterPacking::class;
|
||||||
|
|
||||||
|
public static function getColumns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ImportColumn::make('plant')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('PLANT CODE')
|
||||||
|
->example('1000')
|
||||||
|
->label('PLANT CODE')
|
||||||
|
->relationship(resolveUsing: 'code')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('item')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('ITEM CODE')
|
||||||
|
->example('630214')
|
||||||
|
->label('ITEM CODE')
|
||||||
|
->relationship(resolveUsing: 'code')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('customer_po_master_id')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('CUSTOMER PO NUMBER')
|
||||||
|
->example('PO12345')
|
||||||
|
->label('CUSTOMER PO NUMBER')
|
||||||
|
->numeric()
|
||||||
|
->rules(['required', 'integer']),
|
||||||
|
ImportColumn::make('wire_packing_number')
|
||||||
|
->exampleHeader('WIRE PACKING NUMBER')
|
||||||
|
->example('WP001')
|
||||||
|
->label('WIRE PACKING NUMBER'),
|
||||||
|
ImportColumn::make('process_order')
|
||||||
|
->exampleHeader('PROCESS ORDER')
|
||||||
|
->example('PO001')
|
||||||
|
->label('PROCESS ORDER'),
|
||||||
|
ImportColumn::make('batch_number')
|
||||||
|
->exampleHeader('BATCH NUMBER')
|
||||||
|
->example('BN001')
|
||||||
|
->label('BATCH NUMBER'),
|
||||||
|
ImportColumn::make('weight')
|
||||||
|
->exampleHeader('WEIGHT')
|
||||||
|
->example('100.5')
|
||||||
|
->label('WEIGHT'),
|
||||||
|
ImportColumn::make('wire_packing_status')
|
||||||
|
->exampleHeader('WIRE PACKING STATUS')
|
||||||
|
->example('Active')
|
||||||
|
->label('WIRE PACKING STATUS'),
|
||||||
|
ImportColumn::make('scanned_at')
|
||||||
|
->requiredMapping()
|
||||||
|
->rules(['required', 'datetime']),
|
||||||
|
ImportColumn::make('created_by')
|
||||||
|
->exampleHeader('CREATED BY')
|
||||||
|
->example('John Doe')
|
||||||
|
->label('CREATED BY'),
|
||||||
|
ImportColumn::make('updated_by')
|
||||||
|
->exampleHeader('UPDATED BY')
|
||||||
|
->example('Jane Smith')
|
||||||
|
->label('UPDATED BY'),
|
||||||
|
ImportColumn::make('scanned_by')
|
||||||
|
->exampleHeader('SCANNED BY')
|
||||||
|
->example('John Doe')
|
||||||
|
->label('SCANNED BY'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolveRecord(): ?WireMasterPacking
|
||||||
|
{
|
||||||
|
// return WireMasterPacking::firstOrNew([
|
||||||
|
// // Update existing records, matching them by `$this->data['column_name']`
|
||||||
|
// 'email' => $this->data['email'],
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
return new WireMasterPacking();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
|
{
|
||||||
|
$body = 'Your wire master packing import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||||
|
|
||||||
|
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||||
|
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ use Filament\Forms\Components\Section;
|
|||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class WireMasterPrint extends Page
|
class WireMasterPrint extends Page
|
||||||
{
|
{
|
||||||
@@ -77,41 +78,69 @@ class WireMasterPrint extends Page
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return CustomerPoMaster::where('plant_id', $plantId)->pluck('customer_po', 'id');
|
return CustomerPoMaster::where('plant_id', $plantId)->distinct()->pluck('customer_po', 'customer_po'); //->pluck('customer_po', 'id'); ->distinct()
|
||||||
})
|
})
|
||||||
->required(),
|
->required()
|
||||||
select::make('scan_pallet_no')
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('scan_pallet_no', null);
|
||||||
|
}),
|
||||||
|
Select::make('scan_pallet_no')
|
||||||
->label('Scan Pallet No')
|
->label('Scan Pallet No')
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->searchable()
|
||||||
->options(function ($get) {
|
->options(function ($get) {
|
||||||
|
|
||||||
$plantId = $get('plant_id');
|
// $plantId = $get('plant_id');
|
||||||
$customerPoId = $get('customer_po_master_id');
|
// $customerPoId = $get('customer_po_master_id');
|
||||||
|
|
||||||
if (! $plantId || ! $customerPoId) {
|
// if (! $plantId || ! $customerPoId) {
|
||||||
|
// return [];
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $palletNumbers = WireMasterPacking::query()
|
||||||
|
// ->select('wire_packing_number')
|
||||||
|
// ->where('plant_id', $plantId)
|
||||||
|
// ->where('customer_po_master_id', $customerPoId)
|
||||||
|
// ->whereNotNull('wire_packing_number')
|
||||||
|
// ->groupBy('wire_packing_number')
|
||||||
|
// ->havingRaw('COUNT(*) = COUNT(wire_packing_status)')
|
||||||
|
// ->havingRaw("SUM(CASE WHEN TRIM(wire_packing_status) = '' THEN 1 ELSE 0 END) = 0")
|
||||||
|
// ->orderBy('wire_packing_number', 'asc')
|
||||||
|
// ->pluck('wire_packing_number')
|
||||||
|
// ->toArray();
|
||||||
|
|
||||||
|
// return collect($palletNumbers)
|
||||||
|
// ->mapWithKeys(fn ($number) => [$number => $number])
|
||||||
|
// ->toArray();
|
||||||
|
|
||||||
|
//..New Logic
|
||||||
|
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
$customerPo = $get('customer_po_master_id');
|
||||||
|
|
||||||
|
if (! $plantId || ! $customerPo)
|
||||||
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$poIds = CustomerPoMaster::where('plant_id', $plantId)->where('customer_po', $customerPo)->pluck('id');
|
||||||
$palletNumbers = WireMasterPacking::query()
|
$palletNumbers = WireMasterPacking::query()
|
||||||
->select('wire_packing_number')
|
|
||||||
->where('plant_id', $plantId)
|
->where('plant_id', $plantId)
|
||||||
->where('customer_po_master_id', $customerPoId)
|
->whereIn('customer_po_master_id', $poIds)
|
||||||
->whereNotNull('wire_packing_number')
|
->whereNotNull('wire_packing_number')
|
||||||
->groupBy('wire_packing_number')
|
->groupBy('wire_packing_number')
|
||||||
->havingRaw('COUNT(*) = COUNT(wire_packing_status)')
|
->havingRaw('COUNT(*) = COUNT(wire_packing_status)')
|
||||||
->havingRaw("SUM(CASE WHEN TRIM(wire_packing_status) = '' THEN 1 ELSE 0 END) = 0")
|
->havingRaw("SUM(CASE WHEN TRIM(wire_packing_status) = '' THEN 1 ELSE 0 END) = 0")
|
||||||
->orderBy('wire_packing_number', 'asc')
|
->orderBy('wire_packing_number')
|
||||||
->pluck('wire_packing_number')
|
->pluck('wire_packing_number')
|
||||||
->toArray();
|
->toArray();
|
||||||
|
return collect($palletNumbers) ->mapWithKeys(fn ($number) => [$number => $number]) ->toArray();
|
||||||
return collect($palletNumbers)
|
|
||||||
->mapWithKeys(fn ($number) => [$number => $number])
|
|
||||||
->toArray();
|
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, $get) {
|
->afterStateUpdated(function ($state, callable $set, $get) {
|
||||||
$palletNo = $state;
|
$palletNo = $state;
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
|
|
||||||
|
|
||||||
$this->dispatch('loadData', $palletNo, $plantId);
|
$this->dispatch('loadData', $palletNo, $plantId);
|
||||||
})
|
})
|
||||||
->extraAttributes([
|
->extraAttributes([
|
||||||
|
|||||||
@@ -6,25 +6,24 @@ use App\Filament\Exports\CharacteristicApproverMasterExporter;
|
|||||||
use App\Filament\Imports\CharacteristicApproverMasterImporter;
|
use App\Filament\Imports\CharacteristicApproverMasterImporter;
|
||||||
use App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
use App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
||||||
use App\Models\CharacteristicApproverMaster;
|
use App\Models\CharacteristicApproverMaster;
|
||||||
use App\Models\Item;
|
|
||||||
use App\Models\Machine;
|
use App\Models\Machine;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
use Filament\Forms\Components\Section;
|
use Filament\Forms\Components\Section;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\ExportAction;
|
use Filament\Tables\Actions\ExportAction;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
|
use Filament\Tables\Filters\Filter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Filament\Forms\Components\DateTimePicker;
|
|
||||||
use Filament\Forms\Components\Select;
|
|
||||||
use Filament\Forms\Components\TextInput;
|
|
||||||
use Filament\Tables\Filters\Filter;
|
|
||||||
|
|
||||||
class CharacteristicApproverMasterResource extends Resource
|
class CharacteristicApproverMasterResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -34,6 +33,8 @@ class CharacteristicApproverMasterResource extends Resource
|
|||||||
|
|
||||||
protected static ?string $navigationGroup = 'Laser Marking';
|
protected static ?string $navigationGroup = 'Laser Marking';
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 2;
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
@@ -224,7 +225,8 @@ class CharacteristicApproverMasterResource extends Resource
|
|||||||
Forms\Components\TextInput::make('duration2')
|
Forms\Components\TextInput::make('duration2')
|
||||||
->label('Duration (HH.MM)')
|
->label('Duration (HH.MM)')
|
||||||
->reactive()
|
->reactive()
|
||||||
->length(4)
|
->minLength(4)
|
||||||
|
->maxLength(5)
|
||||||
->regex('/^([0-9]|0[0-9]|1[0-9]|2[0-3])\.(0[0-9]|[1-5][0-9])$/')
|
->regex('/^([0-9]|0[0-9]|1[0-9]|2[0-3])\.(0[0-9]|[1-5][0-9])$/')
|
||||||
->validationMessages([
|
->validationMessages([
|
||||||
'regex' => 'Duration must be HH.MM format (example: 00.00 - 23.59)',
|
'regex' => 'Duration must be HH.MM format (example: 00.00 - 23.59)',
|
||||||
@@ -256,7 +258,8 @@ class CharacteristicApproverMasterResource extends Resource
|
|||||||
Forms\Components\TextInput::make('duration3')
|
Forms\Components\TextInput::make('duration3')
|
||||||
->label('Duration (HH.MM)')
|
->label('Duration (HH.MM)')
|
||||||
->reactive()
|
->reactive()
|
||||||
->length(4)
|
->minLength(4)
|
||||||
|
->maxLength(5)
|
||||||
->regex('/^([0-9]|0[0-9]|1[0-9]|2[0-3])\.(0[0-9]|[1-5][0-9])$/')
|
->regex('/^([0-9]|0[0-9]|1[0-9]|2[0-3])\.(0[0-9]|[1-5][0-9])$/')
|
||||||
->validationMessages([
|
->validationMessages([
|
||||||
'regex' => 'Duration must be HH.MM format (example: 00.00 - 23.59)',
|
'regex' => 'Duration must be HH.MM format (example: 00.00 - 23.59)',
|
||||||
@@ -411,7 +414,7 @@ class CharacteristicApproverMasterResource extends Resource
|
|||||||
if ($userHas && strlen($userHas) > 0) {
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||||
} else {
|
} else {
|
||||||
return Plant::whereHas('requestCharacteristics', function ($query) {
|
return Plant::whereHas('characteristicApproverMaster', function ($query) {
|
||||||
$query->whereNotNull('id');
|
$query->whereNotNull('id');
|
||||||
})->orderBy('code')->pluck('name', 'id');
|
})->orderBy('code')->pluck('name', 'id');
|
||||||
}
|
}
|
||||||
@@ -434,7 +437,7 @@ class CharacteristicApproverMasterResource extends Resource
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Machine::whereHas('requestCharacteristics', function ($query) use ($plantId) {
|
return Machine::whereHas('characteristicApproverMaster', function ($query) use ($plantId) {
|
||||||
if ($plantId) {
|
if ($plantId) {
|
||||||
$query->where('plant_id', $plantId);
|
$query->where('plant_id', $plantId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,13 @@ class CustomerPoMasterResource extends Resource
|
|||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
|
Tables\Columns\TextColumn::make('id')
|
||||||
|
->label('ID')
|
||||||
|
->numeric()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->searchable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
->label('Plant')
|
->label('Plant')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
@@ -110,10 +117,18 @@ class CustomerPoMasterResource extends Resource
|
|||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('created_by')
|
||||||
|
->label('Created By')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
Tables\Columns\TextColumn::make('updated_at')
|
Tables\Columns\TextColumn::make('updated_at')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('updated_by')
|
||||||
|
->label('Updated By')
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
Tables\Columns\TextColumn::make('deleted_at')
|
Tables\Columns\TextColumn::make('deleted_at')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use Filament\Facades\Filament;
|
|||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Components\Actions\Action;
|
use Filament\Forms\Components\Actions\Action;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
@@ -39,18 +40,32 @@ class EquipmentMasterResource extends Resource
|
|||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
->label('Plant')
|
->label('Plant Name')
|
||||||
->reactive()
|
|
||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
|
->required()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->required(),
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('machine_id', null);
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
})
|
||||||
|
->default(function () {
|
||||||
|
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(EquipmentMaster::latest()->first())->plant_id;
|
||||||
|
}),
|
||||||
Forms\Components\Select::make('machine_id')
|
Forms\Components\Select::make('machine_id')
|
||||||
// ->relationship('machine', 'name')
|
// ->relationship('machine', 'name')
|
||||||
->label('Work Center')
|
->label('Work Center')
|
||||||
|
->required()
|
||||||
|
->searchable()
|
||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
@@ -60,15 +75,30 @@ class EquipmentMasterResource extends Resource
|
|||||||
|
|
||||||
return \App\Models\Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
return \App\Models\Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||||
})
|
})
|
||||||
->required(),
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('name')
|
Forms\Components\TextInput::make('name')
|
||||||
->label('Name'),
|
->label('Name')
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('description')
|
Forms\Components\TextInput::make('description')
|
||||||
->label('Description'),
|
->label('Description')
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('make')
|
Forms\Components\TextInput::make('make')
|
||||||
->label('Make'),
|
->label('Make')
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('model')
|
Forms\Components\TextInput::make('model')
|
||||||
->label('Model'),
|
->label('Model')
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('equipment_number')
|
Forms\Components\TextInput::make('equipment_number')
|
||||||
->label('Equipment Number')
|
->label('Equipment Number')
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -82,6 +112,8 @@ class EquipmentMasterResource extends Resource
|
|||||||
];
|
];
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set) {
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
|
||||||
if (! $state) {
|
if (! $state) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -108,7 +140,10 @@ class EquipmentMasterResource extends Resource
|
|||||||
// }
|
// }
|
||||||
// }),
|
// }),
|
||||||
Forms\Components\TextInput::make('instrument_serial_number')
|
Forms\Components\TextInput::make('instrument_serial_number')
|
||||||
->label('Instrument Serial Number'),
|
->label('Instrument Serial Number')
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
// Forms\Components\DateTimePicker::make('calibrated_on')
|
// Forms\Components\DateTimePicker::make('calibrated_on')
|
||||||
// ->label('Calibrated On')
|
// ->label('Calibrated On')
|
||||||
// ->required(),
|
// ->required(),
|
||||||
@@ -128,6 +163,7 @@ class EquipmentMasterResource extends Resource
|
|||||||
$frequency = $get('frequency') ?? '1';
|
$frequency = $get('frequency') ?? '1';
|
||||||
$nextDate = self::calculateNextCalibrationDate($state, $frequency);
|
$nextDate = self::calculateNextCalibrationDate($state, $frequency);
|
||||||
$set('next_calibration_date', $nextDate);
|
$set('next_calibration_date', $nextDate);
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
}),
|
}),
|
||||||
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
|
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
|
||||||
// $frequency = (int) $get('frequency');
|
// $frequency = (int) $get('frequency');
|
||||||
@@ -152,6 +188,7 @@ class EquipmentMasterResource extends Resource
|
|||||||
$calibratedOn = $get('calibrated_on');
|
$calibratedOn = $get('calibrated_on');
|
||||||
$nextDate = self::calculateNextCalibrationDate($calibratedOn, $state);
|
$nextDate = self::calculateNextCalibrationDate($calibratedOn, $state);
|
||||||
$set('next_calibration_date', $nextDate);
|
$set('next_calibration_date', $nextDate);
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
}),
|
}),
|
||||||
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
|
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
|
||||||
// $calibratedOn = $get('calibrated_on');
|
// $calibratedOn = $get('calibrated_on');
|
||||||
@@ -171,12 +208,21 @@ class EquipmentMasterResource extends Resource
|
|||||||
Forms\Components\DateTimePicker::make('next_calibration_date')
|
Forms\Components\DateTimePicker::make('next_calibration_date')
|
||||||
->label('Next Calibration Date')
|
->label('Next Calibration Date')
|
||||||
->readOnly()
|
->readOnly()
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('calibrated_by')
|
Forms\Components\TextInput::make('calibrated_by')
|
||||||
->label('Calibrated By'),
|
->label('Calibrated By')
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
Forms\Components\Textarea::make('calibration_certificate')
|
Forms\Components\Textarea::make('calibration_certificate')
|
||||||
->label('Calibration Certificate'),
|
->label('Calibration Certificate')
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
|
||||||
Forms\Components\FileUpload::make('attachment')
|
Forms\Components\FileUpload::make('attachment')
|
||||||
->label('PDF Upload')
|
->label('PDF Upload')
|
||||||
@@ -185,7 +231,10 @@ class EquipmentMasterResource extends Resource
|
|||||||
->disk('local')
|
->disk('local')
|
||||||
->directory('uploads/temp')
|
->directory('uploads/temp')
|
||||||
->preserveFilenames()
|
->preserveFilenames()
|
||||||
->reactive(),
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
|
||||||
// Forms\Components\Actions::make([
|
// Forms\Components\Actions::make([
|
||||||
// Action::make('uploadNow')
|
// Action::make('uploadNow')
|
||||||
@@ -341,7 +390,11 @@ class EquipmentMasterResource extends Resource
|
|||||||
->label('Created By')
|
->label('Created By')
|
||||||
->default(Filament::auth()->user()?->name),
|
->default(Filament::auth()->user()?->name),
|
||||||
Forms\Components\Hidden::make('updated_by')
|
Forms\Components\Hidden::make('updated_by')
|
||||||
->label('Updated By'),
|
->label('Updated By')
|
||||||
|
->default(Filament::auth()->user()?->name),
|
||||||
|
Forms\Components\TextInput::make('id')
|
||||||
|
->hidden()
|
||||||
|
->readOnly(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,7 +412,7 @@ class EquipmentMasterResource extends Resource
|
|||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
->label('Plant')
|
->label('Plant Name')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('machine.work_center')
|
Tables\Columns\TextColumn::make('machine.work_center')
|
||||||
@@ -413,24 +466,30 @@ class EquipmentMasterResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('created_by')
|
Tables\Columns\TextColumn::make('created_by')
|
||||||
->label('Created Bys')
|
->label('Created By')
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('updated_by')
|
|
||||||
->label('Updated By')
|
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
->label('Created At')
|
->label('Created At')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('updated_by')
|
||||||
|
->label('Updated By')
|
||||||
|
->alignCenter()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: false),
|
||||||
Tables\Columns\TextColumn::make('updated_at')
|
Tables\Columns\TextColumn::make('updated_at')
|
||||||
->label('Updated At')
|
->label('Updated At')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable()
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: false),
|
||||||
|
Tables\Columns\TextColumn::make('deleted_at')
|
||||||
|
->label('Deleted At')
|
||||||
|
->dateTime()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
|
|||||||
@@ -11,23 +11,22 @@ use App\Models\Plant;
|
|||||||
use App\Models\WorkGroupMaster;
|
use App\Models\WorkGroupMaster;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
use Filament\Forms\Components\Section;
|
use Filament\Forms\Components\Section;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Forms\Get;
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\ExportAction;
|
use Filament\Tables\Actions\ExportAction;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
|
use Filament\Tables\Filters\Filter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Str;
|
use Str;
|
||||||
use Filament\Forms\Components\DateTimePicker;
|
|
||||||
use Filament\Forms\Components\FileUpload;
|
|
||||||
use Filament\Forms\Components\Select;
|
|
||||||
use Filament\Forms\Components\TextInput;
|
|
||||||
use Filament\Tables\Filters\Filter;
|
|
||||||
|
|
||||||
class MachineResource extends Resource
|
class MachineResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -71,6 +70,8 @@ class MachineResource extends Resource
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
$set('mPlantError', null);
|
$set('mPlantError', null);
|
||||||
|
$set('line_id', null);
|
||||||
|
$set('work_group_master_id', null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->extraAttributes(fn ($get) => [
|
->extraAttributes(fn ($get) => [
|
||||||
@@ -112,6 +113,7 @@ class MachineResource extends Resource
|
|||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
$set('mLineError', null);
|
$set('mLineError', null);
|
||||||
|
$set('work_group_master_id', null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->extraAttributes(fn ($get) => [
|
->extraAttributes(fn ($get) => [
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ class PanelBoxValidationResource extends Resource
|
|||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'Panel Box';
|
||||||
|
|
||||||
public $isSubmitted = false;
|
public $isSubmitted = false;
|
||||||
|
|
||||||
public $data = [];
|
public $data = [];
|
||||||
@@ -176,6 +178,8 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
|
|
||||||
$pId = $get('line_id');
|
$pId = $get('line_id');
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
$plaCode = Plant::find($plantId)?->code;
|
||||||
$set('part_validation_type', null);
|
$set('part_validation_type', null);
|
||||||
$set('show_validation_image', false);
|
$set('show_validation_image', false);
|
||||||
$set('validation1_image_url', null);
|
$set('validation1_image_url', null);
|
||||||
@@ -382,7 +386,17 @@ class PanelBoxValidationResource extends Resource
|
|||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
else if($plantCode != $plaCode){
|
||||||
|
Notification::make()
|
||||||
|
->title('Invalid Plant Code')
|
||||||
|
->body("Scanned plant code doesn't match the selected plant.")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$set('item_id', null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid QR Format')
|
->title('Invalid QR Format')
|
||||||
@@ -476,6 +490,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
// $set('serial_number', null);
|
// $set('serial_number', null);
|
||||||
// $set('serial_number', $serialNumber);
|
// $set('serial_number', $serialNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if user input matches the database values
|
// Check if user input matches the database values
|
||||||
foreach ($partValidationColumns as $field) {
|
foreach ($partValidationColumns as $field) {
|
||||||
if ($get("{$field}_visible")) {
|
if ($get("{$field}_visible")) {
|
||||||
|
|||||||
@@ -65,8 +65,13 @@ class CreatePanelBoxValidation extends CreateRecord {
|
|||||||
$this->showChecklist = true;
|
$this->showChecklist = true;
|
||||||
$this->halt();
|
$this->halt();
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
return $data;
|
\Filament\Notifications\Notification::make()
|
||||||
|
->title('Characteristics not found for the scanned item.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->halt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function checkIfHasCharacteristics(array $data)
|
protected function checkIfHasCharacteristics(array $data)
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ use Filament\Tables\Filters\Filter;
|
|||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\DateTimePicker;
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
use Str;
|
use Str;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
|
use App\Filament\Exports\WireMasterPackingExporter;
|
||||||
|
use App\Filament\Imports\WireMasterPackingImporter;
|
||||||
|
|
||||||
class WireMasterPackingResource extends Resource
|
class WireMasterPackingResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -61,9 +65,14 @@ class WireMasterPackingResource extends Resource
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return CustomerPoMaster::where('plant_id', $plantId)->pluck('customer_po', 'id');
|
// return CustomerPoMaster::where('plant_id', $plantId)->pluck('customer_po', 'id');
|
||||||
|
return CustomerPoMaster::where('plant_id', $plantId)->distinct()->pluck('customer_po', 'customer_po');
|
||||||
|
|
||||||
})
|
})
|
||||||
->required(),
|
->required()
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('wire_packing_number', null);
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('wire_packing_number')
|
Forms\Components\TextInput::make('wire_packing_number')
|
||||||
->label('Scan Wire Packing No')
|
->label('Scan Wire Packing No')
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -160,13 +169,19 @@ class WireMasterPackingResource extends Resource
|
|||||||
->options(function ($get) {
|
->options(function ($get) {
|
||||||
|
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
|
$customerPo = $get('customer_po_master_id');
|
||||||
|
|
||||||
if (! $plantId) {
|
if (!$plantId || !$customerPo) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$customerPoIds = CustomerPoMaster::where('plant_id', $plantId)
|
||||||
|
->where('customer_po', $customerPo)
|
||||||
|
->pluck('id');
|
||||||
|
|
||||||
return WireMasterPacking::query()
|
return WireMasterPacking::query()
|
||||||
->where('plant_id', $plantId)
|
->where('plant_id', $plantId)
|
||||||
|
->whereIn('customer_po_master_id', $customerPoIds)
|
||||||
->where(function ($query) {
|
->where(function ($query) {
|
||||||
$query->whereNull('wire_packing_status')
|
$query->whereNull('wire_packing_status')
|
||||||
->orWhere('wire_packing_status', '');
|
->orWhere('wire_packing_status', '');
|
||||||
@@ -468,6 +483,22 @@ class WireMasterPackingResource extends Resource
|
|||||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
Tables\Actions\RestoreBulkAction::make(),
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
]),
|
]),
|
||||||
|
])
|
||||||
|
->headerActions([
|
||||||
|
ImportAction::make()
|
||||||
|
->label('Import Wire Packing Master')
|
||||||
|
->color('warning')
|
||||||
|
->importer(WireMasterPackingImporter::class)
|
||||||
|
->visible(function () {
|
||||||
|
return Filament::auth()->user()->can('view import wire packing master');
|
||||||
|
}),
|
||||||
|
ExportAction::make()
|
||||||
|
->label('Export Wire Packing Master')
|
||||||
|
->color('warning')
|
||||||
|
->exporter(WireMasterPackingExporter::class)
|
||||||
|
->visible(function () {
|
||||||
|
return Filament::auth()->user()->can('view export wire packing master');
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,10 +164,6 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$itemId = Item::where('code', $materialCode)
|
|
||||||
->where('plant_id', $plantId)
|
|
||||||
->value('id');
|
|
||||||
|
|
||||||
$icodeAgaCPoPlant = CustomerPoMaster::where('item_id', $itemId)->where('plant_id', $plantId)->first();
|
$icodeAgaCPoPlant = CustomerPoMaster::where('item_id', $itemId)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
if(!$icodeAgaCPoPlant)
|
if(!$icodeAgaCPoPlant)
|
||||||
@@ -214,23 +210,24 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$customerPoRecord = CustomerPoMaster::where('id', $customerPo)
|
$customerPoRecord = CustomerPoMaster::where('customer_po', $customerPo)
|
||||||
->where('plant_id', $plantId)
|
->where('plant_id', $plantId)
|
||||||
|
->where('item_id', $itemId)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
$customerPoName = $customerPoRecord->customer_po;
|
// $customerPoName = $customerPoRecord->customer_po;
|
||||||
|
|
||||||
if ($customerPoRecord) {
|
// if ($customerPoRecord) {
|
||||||
$customerPoName = $customerPoRecord->customer_po;
|
// $customerPoName = $customerPoRecord->customer_po;
|
||||||
} else {
|
// } else {
|
||||||
$customerPoName = null;
|
// $customerPoName = null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if(!$customerPoRecord)
|
if(!$customerPoRecord)
|
||||||
{
|
{
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("PO Not Found")
|
->title("PO Not Found")
|
||||||
->body("Customer PO '$customerPoName' for Item '$materialCode' not found against Plant '$plantcode'")
|
->body("Customer PO '$customerPoRecord->customer_po' for Item '$materialCode' not found against Plant '$plantcode'")
|
||||||
->danger()
|
->danger()
|
||||||
->duration(5000)
|
->duration(5000)
|
||||||
->send();
|
->send();
|
||||||
@@ -247,7 +244,7 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$alreadyScannedQty = WireMasterPacking::where('customer_po_master_id', $customerPo)
|
$alreadyScannedQty = WireMasterPacking::where('customer_po_master_id', $customerPoRecord->id)
|
||||||
->where('plant_id', $plantId)
|
->where('plant_id', $plantId)
|
||||||
->where('item_id', $itemId)
|
->where('item_id', $itemId)
|
||||||
->selectRaw('SUM(CAST(weight AS NUMERIC)) as total_weight')
|
->selectRaw('SUM(CAST(weight AS NUMERIC)) as total_weight')
|
||||||
@@ -259,7 +256,7 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
{
|
{
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("Scanned Weight Exceeds PO Quantity")
|
->title("Scanned Weight Exceeds PO Quantity")
|
||||||
->body("Scanned weight '$weight' and already scanned weight '$alreadyScannedQty' exceeds allowed quantity '{$customerPoRecord->quantity}' for PO '$customerPoName' and Item '$materialCode'")
|
->body("Scanned weight '$weight' and already scanned weight '$alreadyScannedQty' exceeds allowed quantity '{$customerPoRecord->quantity}' for PO '$customerPoRecord->customer_po' and Item '$materialCode'")
|
||||||
->danger()
|
->danger()
|
||||||
->duration(5000)
|
->duration(5000)
|
||||||
->send();
|
->send();
|
||||||
@@ -268,6 +265,7 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
'process_order' => null,
|
'process_order' => null,
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'customer_po_master_id' => $customerPo,
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'item_id' => $itemId,
|
||||||
'wire_packing_number' => $wirePackNo,
|
'wire_packing_number' => $wirePackNo,
|
||||||
'Sno_quantity' => 0,
|
'Sno_quantity' => 0,
|
||||||
'created_by' => $operatorName,
|
'created_by' => $operatorName,
|
||||||
@@ -294,7 +292,7 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
'item_id' => $itemId,
|
'item_id' => $itemId,
|
||||||
'wire_packing_number' => $wirePackNo,
|
'wire_packing_number' => $wirePackNo,
|
||||||
'process_order' => $processOrderId . '-' . $coilNo,
|
'process_order' => $processOrderId . '-' . $coilNo,
|
||||||
'customer_po_master_id' => $customerPo,
|
'customer_po_master_id' => $customerPoRecord->id,
|
||||||
'weight' => $weight,
|
'weight' => $weight,
|
||||||
'created_by' => $createdBy,
|
'created_by' => $createdBy,
|
||||||
'scanned_by' => $operatorName,
|
'scanned_by' => $operatorName,
|
||||||
@@ -314,6 +312,7 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'customer_po_master_id' => $customerPo,
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'item_id' => $itemId,
|
||||||
'wire_packing_number' => $wirePackNo,
|
'wire_packing_number' => $wirePackNo,
|
||||||
'process_order' => null,
|
'process_order' => null,
|
||||||
// 'pending_pallet_list' => $pendingPallet,
|
// 'pending_pallet_list' => $pendingPallet,
|
||||||
@@ -334,6 +333,7 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'customer_po_master_id' => $customerPo,
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'item_id' => $itemId,
|
||||||
'wire_packing_number' => $wirePackNo,
|
'wire_packing_number' => $wirePackNo,
|
||||||
'process_order' => null,
|
'process_order' => null,
|
||||||
// 'pending_pallet_list' => $pendingPallet,
|
// 'pending_pallet_list' => $pendingPallet,
|
||||||
|
|||||||
@@ -19,168 +19,9 @@ class PalletPrintController extends Controller
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
public function print(Request $request, $pallet, $plant)
|
|
||||||
{
|
|
||||||
|
|
||||||
$customerId = $request->query('customer');
|
|
||||||
|
|
||||||
// $customerName = $request->query('customer_name');
|
|
||||||
|
|
||||||
// $items = WireMasterPacking::with('item')
|
|
||||||
// ->where('plant_id', $plant)
|
|
||||||
// ->where('wire_packing_number', $pallet)
|
|
||||||
// ->get()
|
|
||||||
// ->groupBy('item_id')
|
|
||||||
// ->map(function ($rows) {
|
|
||||||
// $first = $rows->first();
|
|
||||||
|
|
||||||
// return (object) [
|
|
||||||
// 'code' => $first->item->code,
|
|
||||||
// 'description' => $first->item->description,
|
|
||||||
// 'box_count' => $rows->count(),
|
|
||||||
// 'weight' => $rows->sum('weight'),
|
|
||||||
// ];
|
|
||||||
// })
|
|
||||||
// ->values();
|
|
||||||
|
|
||||||
$items = WireMasterPacking::with('item')
|
|
||||||
->where('plant_id', $plant)
|
|
||||||
->where('wire_packing_number', $pallet)
|
|
||||||
->get()
|
|
||||||
->map(function ($row) {
|
|
||||||
return (object) [
|
|
||||||
'code' => $row->item->code,
|
|
||||||
'description' => $row->item->description,
|
|
||||||
'box_count' => 1, // each row = one box
|
|
||||||
'weight' => $row->weight,
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
$masterBox = WireMasterPacking::where('plant_id', $plant)
|
|
||||||
->where('wire_packing_number', $pallet)
|
|
||||||
->value('customer_po_master_id');
|
|
||||||
|
|
||||||
$customer = CustomerPoMaster::find($masterBox);
|
|
||||||
|
|
||||||
$customerCode = $customer->customer_po ?? '';
|
|
||||||
$customerName = $customer->customer_name ?? '';
|
|
||||||
|
|
||||||
// $masterBox = WireMasterPacking::where('plant_id', $plant)
|
|
||||||
// ->where('wire_packing_number', $pallet)
|
|
||||||
// ->distinct('customer_po')
|
|
||||||
// ->count('customer_po');
|
|
||||||
|
|
||||||
// $pallets = WireMasterPacking::where('plant_id', $plant)
|
|
||||||
// ->select('wire_packing_number', 'updated_at')
|
|
||||||
// ->distinct('wire_packing_number')
|
|
||||||
// ->orderBy('wire_packing_number')
|
|
||||||
// ->orderBy('updated_at', 'asc')
|
|
||||||
// ->get()
|
|
||||||
// ->pluck('wire_packing_number')
|
|
||||||
// ->values();
|
|
||||||
|
|
||||||
// $currentPalletNo = $pallets->search($pallet) + 1;
|
|
||||||
|
|
||||||
// $totalBoxes = WireMasterPacking::where('plant_id', $plant)
|
|
||||||
// // ->where('wire_packing_number', $pallet)
|
|
||||||
// ->distinct()
|
|
||||||
// ->count('customer_po');
|
|
||||||
|
|
||||||
// $boxLabel = $currentPalletNo . '/' . $totalBoxes;
|
|
||||||
|
|
||||||
$totalBoxes = WireMasterPacking::where('plant_id', $plant)
|
|
||||||
->where('customer_po_master_id', $customerId)
|
|
||||||
->distinct('wire_packing_number')
|
|
||||||
->count('wire_packing_number');
|
|
||||||
|
|
||||||
$completedPallets = WireMasterPacking::where('plant_id', $plant)
|
|
||||||
->where('customer_po_master_id', $customerId)
|
|
||||||
->select('wire_packing_number')
|
|
||||||
->groupBy('wire_packing_number')
|
|
||||||
->havingRaw(
|
|
||||||
'COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)',
|
|
||||||
['Completed']
|
|
||||||
)
|
|
||||||
->orderBy('wire_packing_number')
|
|
||||||
->pluck('wire_packing_number')
|
|
||||||
->values();
|
|
||||||
|
|
||||||
$index = $completedPallets->search($pallet);
|
|
||||||
|
|
||||||
$currentPalletNo = ($index !== false) ? $index + 1 : 0;
|
|
||||||
|
|
||||||
$boxLabel = $currentPalletNo.'/'.$totalBoxes;
|
|
||||||
|
|
||||||
// $completedPallets = WireMasterPacking::where('plant_id', $plant)
|
|
||||||
// ->select('wire_packing_number')
|
|
||||||
// ->groupBy('wire_packing_number')
|
|
||||||
// ->havingRaw('COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)', ['Completed'])
|
|
||||||
// ->orderBy('wire_packing_number')
|
|
||||||
// ->pluck('wire_packing_number')
|
|
||||||
// ->values();
|
|
||||||
|
|
||||||
// $currentPalletNo = $completedPallets->search($pallet) != false
|
|
||||||
// ? $completedPallets->search($pallet) + 1
|
|
||||||
// : 0;
|
|
||||||
|
|
||||||
// $boxLabel = $currentPalletNo . '/' . $totalBoxes;
|
|
||||||
|
|
||||||
$grossWeight = $items->sum('weight');
|
|
||||||
$widthPt = 85 * 2.83465; // 85mm → points
|
|
||||||
$heightPt = 100 * 2.83465; // 100mm → points
|
|
||||||
|
|
||||||
$plantName = Plant::where('id', $plant)->value('name');
|
|
||||||
|
|
||||||
$plantAddress = Plant::where('id', $plant)->value('address');
|
|
||||||
|
|
||||||
$pdf = Pdf::loadView('pdf.wire-pallet', [
|
|
||||||
'product' => 'Submersible Winding Wire',
|
|
||||||
'plantName' => $plantName,
|
|
||||||
'plantAddress' => $plantAddress,
|
|
||||||
'monthYear' => now()->format('M-y'),
|
|
||||||
'branch' => '',
|
|
||||||
'customerCode' => $customerCode,
|
|
||||||
'customerName' => $customerName,
|
|
||||||
'masterBox' => $boxLabel,
|
|
||||||
'items' => $items,
|
|
||||||
'grossWeight' => $grossWeight + 3.050,
|
|
||||||
'netWeight' => $grossWeight,
|
|
||||||
// 'grossWeight' => $grossWeight,
|
|
||||||
// 'netWeight' => $grossWeight - 3.05,
|
|
||||||
'pallet' => $pallet,
|
|
||||||
])->setPaper([0, 0, $widthPt, $heightPt], 'portrait');
|
|
||||||
|
|
||||||
return $pdf->stream("Pallet-{$pallet}.pdf");
|
|
||||||
// $pdfPath = storage_path("app/public/Pallet-{$pallet}.pdf");
|
|
||||||
// $pdf->save($pdfPath);
|
|
||||||
|
|
||||||
// $printerName = 'Tsc';
|
|
||||||
// $output = [];
|
|
||||||
// $returnVar = 0;
|
|
||||||
|
|
||||||
// exec("lp -d {$printerName} " . escapeshellarg($pdfPath), $output, $returnVar);
|
|
||||||
|
|
||||||
// if ($returnVar == 0) {
|
|
||||||
// return response()->json([
|
|
||||||
// 'status' => 'success',
|
|
||||||
// 'message' => "PDF sent to printer $printerName successfully."
|
|
||||||
// ]);
|
|
||||||
// } else {
|
|
||||||
// return response()->json([
|
|
||||||
// 'status' => 'error',
|
|
||||||
// 'message' => "Failed to send PDF to printer $printerName.",
|
|
||||||
// 'output' => $output,
|
|
||||||
// 'code' => $returnVar
|
|
||||||
// ], 500);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a newly created resource in storage.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// public function print(Request $request, $pallet, $plant)
|
// public function print(Request $request, $pallet, $plant)
|
||||||
// {
|
// {
|
||||||
|
|
||||||
// $customerId = $request->query('customer');
|
// $customerId = $request->query('customer');
|
||||||
|
|
||||||
// $items = WireMasterPacking::with('item')
|
// $items = WireMasterPacking::with('item')
|
||||||
@@ -205,6 +46,29 @@ class PalletPrintController extends Controller
|
|||||||
// $customerCode = $customer->customer_po ?? '';
|
// $customerCode = $customer->customer_po ?? '';
|
||||||
// $customerName = $customer->customer_name ?? '';
|
// $customerName = $customer->customer_name ?? '';
|
||||||
|
|
||||||
|
// // $masterBox = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
// // ->where('wire_packing_number', $pallet)
|
||||||
|
// // ->distinct('customer_po')
|
||||||
|
// // ->count('customer_po');
|
||||||
|
|
||||||
|
// // $pallets = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
// // ->select('wire_packing_number', 'updated_at')
|
||||||
|
// // ->distinct('wire_packing_number')
|
||||||
|
// // ->orderBy('wire_packing_number')
|
||||||
|
// // ->orderBy('updated_at', 'asc')
|
||||||
|
// // ->get()
|
||||||
|
// // ->pluck('wire_packing_number')
|
||||||
|
// // ->values();
|
||||||
|
|
||||||
|
// // $currentPalletNo = $pallets->search($pallet) + 1;
|
||||||
|
|
||||||
|
// // $totalBoxes = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
// // // ->where('wire_packing_number', $pallet)
|
||||||
|
// // ->distinct()
|
||||||
|
// // ->count('customer_po');
|
||||||
|
|
||||||
|
// // $boxLabel = $currentPalletNo . '/' . $totalBoxes;
|
||||||
|
|
||||||
// $totalBoxes = WireMasterPacking::where('plant_id', $plant)
|
// $totalBoxes = WireMasterPacking::where('plant_id', $plant)
|
||||||
// ->where('customer_po_master_id', $customerId)
|
// ->where('customer_po_master_id', $customerId)
|
||||||
// ->distinct('wire_packing_number')
|
// ->distinct('wire_packing_number')
|
||||||
@@ -250,43 +114,173 @@ class PalletPrintController extends Controller
|
|||||||
|
|
||||||
// $plantAddress = Plant::where('id', $plant)->value('address');
|
// $plantAddress = Plant::where('id', $plant)->value('address');
|
||||||
|
|
||||||
// $qrBase64 = $this->generateQrDataUri($pallet);
|
// $pdf = Pdf::loadView('pdf.wire-pallet', [
|
||||||
|
|
||||||
// $mpdf = new Mpdf([
|
|
||||||
// 'format' => [85, 100],
|
|
||||||
// 'margin_left' => 0,
|
|
||||||
// 'margin_right' => 0,
|
|
||||||
// 'margin_top' => 0,
|
|
||||||
// 'margin_bottom' => 0,
|
|
||||||
// 'tempDir' => '/var/www/tmp/mpdf'
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
// $html = view('pdf.wire-pallet', [
|
|
||||||
// 'product' => 'Submersible Winding Wire',
|
// 'product' => 'Submersible Winding Wire',
|
||||||
// 'plantName' => $plantName,
|
// 'plantName' => $plantName,
|
||||||
// 'plantAddress' => $plantAddress,
|
// 'plantAddress' => $plantAddress,
|
||||||
// 'monthYear' => now()->format('M-y'),
|
// 'monthYear' => now()->format('M-y'),
|
||||||
|
// 'branch' => '',
|
||||||
// 'customerCode' => $customerCode,
|
// 'customerCode' => $customerCode,
|
||||||
// 'customerName' => $customerName,
|
// 'customerName' => $customerName,
|
||||||
// 'masterBox' => $pallet,
|
// 'masterBox' => $boxLabel,
|
||||||
// 'items' => $items,
|
// 'items' => $items,
|
||||||
// 'grossWeight' => $grossWeight,
|
// 'grossWeight' => $grossWeight + 3.050,
|
||||||
// 'netWeight' => $grossWeight - 3.05,
|
// 'netWeight' => $grossWeight,
|
||||||
|
// // 'grossWeight' => $grossWeight,
|
||||||
|
// // 'netWeight' => $grossWeight - 3.05,
|
||||||
// 'pallet' => $pallet,
|
// 'pallet' => $pallet,
|
||||||
// 'qrBase64' => $qrBase64,
|
// ])->setPaper([0, 0, $widthPt, $heightPt], 'portrait');
|
||||||
// ])->render();
|
|
||||||
|
|
||||||
// $mpdf->WriteHTML($html);
|
// return $pdf->stream("Pallet-{$pallet}.pdf");
|
||||||
// return $mpdf->Output("Pallet-{$pallet}.pdf", 'I'); // 'I' = inline view in browser
|
// // $pdfPath = storage_path("app/public/Pallet-{$pallet}.pdf");
|
||||||
|
// // $pdf->save($pdfPath);
|
||||||
|
|
||||||
|
// // $printerName = 'Tsc';
|
||||||
|
// // $output = [];
|
||||||
|
// // $returnVar = 0;
|
||||||
|
|
||||||
|
// // exec("lp -d {$printerName} " . escapeshellarg($pdfPath), $output, $returnVar);
|
||||||
|
|
||||||
|
// // if ($returnVar == 0) {
|
||||||
|
// // return response()->json([
|
||||||
|
// // 'status' => 'success',
|
||||||
|
// // 'message' => "PDF sent to printer $printerName successfully."
|
||||||
|
// // ]);
|
||||||
|
// // } else {
|
||||||
|
// // return response()->json([
|
||||||
|
// // 'status' => 'error',
|
||||||
|
// // 'message' => "Failed to send PDF to printer $printerName.",
|
||||||
|
// // 'output' => $output,
|
||||||
|
// // 'code' => $returnVar
|
||||||
|
// // ], 500);
|
||||||
|
// // }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// private function generateQrDataUri(string $data): string
|
/**
|
||||||
// {
|
* Store a newly created resource in storage.
|
||||||
// $qr = new \Mpdf\QrCode\QrCode($data, 'H');
|
*/
|
||||||
// $output = new \Mpdf\QrCode\Output\Png();
|
|
||||||
// $pngData = $output->output($qr, 80, [255, 255, 255], [0, 0, 0]);
|
public function print(Request $request, $pallet, $plant)
|
||||||
// return 'data:image/png;base64,' . base64_encode($pngData);
|
{
|
||||||
// }
|
|
||||||
|
$customerPoMasterId = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
->where('wire_packing_number', $pallet)
|
||||||
|
->value('customer_po_master_id');
|
||||||
|
|
||||||
|
$masterIds = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
->where('wire_packing_number', $pallet)
|
||||||
|
->pluck('customer_po_master_id');
|
||||||
|
|
||||||
|
$customerPo = CustomerPoMaster::whereIn('id', $masterIds)
|
||||||
|
->value('customer_po');
|
||||||
|
|
||||||
|
$customerPoMasterIds = CustomerPoMaster::where('customer_po', $customerPo)
|
||||||
|
->pluck('id');
|
||||||
|
|
||||||
|
$items = WireMasterPacking::with('item')
|
||||||
|
->where('plant_id', $plant)
|
||||||
|
->where('wire_packing_number', $pallet)
|
||||||
|
->get()
|
||||||
|
->map(function ($row) {
|
||||||
|
return (object) [
|
||||||
|
'code' => $row->item->code,
|
||||||
|
'description' => $row->item->description,
|
||||||
|
'box_count' => 1, // each row = one box
|
||||||
|
'weight' => $row->weight,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
$customer = CustomerPoMaster::find($customerPoMasterId);
|
||||||
|
|
||||||
|
$customerCode = $customer->customer_po ?? '';
|
||||||
|
$customerName = $customer->customer_name ?? '';
|
||||||
|
|
||||||
|
// $totalBoxes = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
// ->where('customer_po_master_id', $customerPoMasterId)
|
||||||
|
// ->select('wire_packing_number')
|
||||||
|
// ->groupBy('wire_packing_number')
|
||||||
|
// ->havingRaw(
|
||||||
|
// 'COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)',
|
||||||
|
// ['Completed']
|
||||||
|
// )
|
||||||
|
// ->count();
|
||||||
|
|
||||||
|
$totalBoxes = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
->whereIn('customer_po_master_id', $customerPoMasterIds)
|
||||||
|
->select('wire_packing_number')
|
||||||
|
->groupBy('wire_packing_number')
|
||||||
|
->havingRaw(
|
||||||
|
'COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)',
|
||||||
|
['Completed']
|
||||||
|
)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
// $completedPallets = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
// ->where('customer_po_master_id', $customerPoMasterId)
|
||||||
|
// ->select('wire_packing_number')
|
||||||
|
// ->groupBy('wire_packing_number')
|
||||||
|
// ->havingRaw(
|
||||||
|
// 'COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)',
|
||||||
|
// ['Completed']
|
||||||
|
// )
|
||||||
|
// ->orderBy('wire_packing_number')
|
||||||
|
// ->pluck('wire_packing_number')
|
||||||
|
// ->values();
|
||||||
|
|
||||||
|
$completedPallets = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
->whereIn('customer_po_master_id', $customerPoMasterIds)
|
||||||
|
->select('wire_packing_number')
|
||||||
|
->groupBy('wire_packing_number')
|
||||||
|
->havingRaw(
|
||||||
|
'COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)',
|
||||||
|
['Completed']
|
||||||
|
)
|
||||||
|
->orderBy('wire_packing_number')
|
||||||
|
->pluck('wire_packing_number')
|
||||||
|
->values();
|
||||||
|
|
||||||
|
$index = $completedPallets->search($pallet);
|
||||||
|
|
||||||
|
$currentPalletNo = ($index !== false) ? $index + 1 : 0;
|
||||||
|
|
||||||
|
$boxLabel = $currentPalletNo.'/'.$totalBoxes;
|
||||||
|
|
||||||
|
$grossWeight = $items->sum('weight');
|
||||||
|
$widthPt = 85 * 2.83465; // 85mm → points
|
||||||
|
$heightPt = 100 * 2.83465; // 100mm → points
|
||||||
|
|
||||||
|
$plantName = Plant::where('id', $plant)->value('name');
|
||||||
|
|
||||||
|
$plantAddress = Plant::where('id', $plant)->value('address');
|
||||||
|
|
||||||
|
$scannedAt = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
->where('wire_packing_number', $pallet)
|
||||||
|
->value('scanned_at');
|
||||||
|
|
||||||
|
$pdf = Pdf::loadView('pdf.wire-pallet', [
|
||||||
|
'product' => 'Submersible Winding Wire',
|
||||||
|
'plantName' => $plantName,
|
||||||
|
'plantAddress' => $plantAddress,
|
||||||
|
// 'monthYear' => now()->format('M-y'),
|
||||||
|
'monthYear' => $scannedAt
|
||||||
|
? \Carbon\Carbon::parse($scannedAt)->format('M-y')
|
||||||
|
: '',
|
||||||
|
'branch' => '',
|
||||||
|
'customerCode' => $customerCode,
|
||||||
|
'customerName' => $customerName,
|
||||||
|
'masterBox' => $boxLabel,
|
||||||
|
'items' => $items,
|
||||||
|
'grossWeight' => $grossWeight + 3.050,
|
||||||
|
'netWeight' => $grossWeight,
|
||||||
|
'pallet' => $pallet,
|
||||||
|
])->setPaper([0, 0, $widthPt, $heightPt], 'portrait');
|
||||||
|
|
||||||
|
return $pdf->stream("Pallet-{$pallet}.pdf");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -151,12 +151,27 @@ public $records = [];
|
|||||||
|
|
||||||
$characteristic = ProductCharacteristicsMaster::find($characteristicId);
|
$characteristic = ProductCharacteristicsMaster::find($characteristicId);
|
||||||
|
|
||||||
if (($characteristic?->inspection_type ?? null) === 'Value') {
|
$itemCharacteristic = ProductCharacteristicsMaster::where('plant_id', $this->data['plant_id'])
|
||||||
if (
|
->where('line_id', $this->data['line_id'])
|
||||||
$characteristic &&
|
->where('name', $characteristic->name)
|
||||||
is_numeric($value) &&
|
->where('item_id', $itemId)
|
||||||
$value >= $characteristic->lower &&
|
->first();
|
||||||
$value <= $characteristic->upper
|
|
||||||
|
// if (($characteristic?->inspection_type ?? null) === 'Value') {
|
||||||
|
// if ($characteristic && is_numeric($value) && (($value >= $characteristic->lower && $value <= $characteristic->upper) || $value == $characteristic->lower || $value == $characteristic->upper)
|
||||||
|
// ) {
|
||||||
|
// $status = 'Ok';
|
||||||
|
// } else {
|
||||||
|
// $status = 'NotOk';
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// $status = $value;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (($itemCharacteristic?->inspection_type ?? null) === 'Value') {
|
||||||
|
|
||||||
|
if ($itemCharacteristic && is_numeric($value) && $value >= $itemCharacteristic->lower && $value <= $itemCharacteristic->upper
|
||||||
) {
|
) {
|
||||||
$status = 'Ok';
|
$status = 'Ok';
|
||||||
} else {
|
} else {
|
||||||
@@ -167,7 +182,7 @@ public $records = [];
|
|||||||
$status = $value;
|
$status = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProductionCharacteristic::create([
|
$prod = ProductionCharacteristic::create([
|
||||||
'plant_id' => $this->data['plant_id'] ?? null,
|
'plant_id' => $this->data['plant_id'] ?? null,
|
||||||
'item_id' => $itemId ?? null,
|
'item_id' => $itemId ?? null,
|
||||||
'line_id' => $this->data['line_id'] ?? null,
|
'line_id' => $this->data['line_id'] ?? null,
|
||||||
@@ -182,6 +197,15 @@ public $records = [];
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $prod) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Failed to save Panel Box Validation')
|
||||||
|
->body('Something went wrong while inserting data.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->showChecklist = false;
|
$this->showChecklist = false;
|
||||||
|
|
||||||
$this->dispatch('checklist-saved');
|
$this->dispatch('checklist-saved');
|
||||||
@@ -201,7 +225,7 @@ public $records = [];
|
|||||||
|
|
||||||
$characteristic = ProductCharacteristicsMaster::find($characteristicId);
|
$characteristic = ProductCharacteristicsMaster::find($characteristicId);
|
||||||
|
|
||||||
if (! $characteristic || ! is_numeric($value) || $value <= $characteristic->lower || $value >= $characteristic->upper){
|
if (! $characteristic || ! is_numeric($value) || ($value < $characteristic->lower || $value > $characteristic->upper)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -218,11 +242,24 @@ public $records = [];
|
|||||||
|
|
||||||
$characteristic = ProductCharacteristicsMaster::find($characteristicId);
|
$characteristic = ProductCharacteristicsMaster::find($characteristicId);
|
||||||
|
|
||||||
|
$itemCode = $this->data['item_id'];
|
||||||
|
|
||||||
|
$itemId = Item::where('plant_id', $characteristic->plant_id)->where('code', $itemCode)->value('id');
|
||||||
|
|
||||||
|
$characteristic = ProductCharacteristicsMaster::find($characteristicId);
|
||||||
|
|
||||||
|
$limit = ProductCharacteristicsMaster::where('plant_id', $characteristic->plant_id)
|
||||||
|
->where('line_id', $characteristic->line_id)
|
||||||
|
->where('name', $characteristic->name)
|
||||||
|
->where('item_id', $itemId)
|
||||||
|
->first();
|
||||||
|
|
||||||
if (! $characteristic || ! is_numeric($value)) {
|
if (! $characteristic || ! is_numeric($value)) {
|
||||||
return 'Not Ok';
|
return 'Not Ok';
|
||||||
}
|
}
|
||||||
|
// return ($value >= $characteristic->lower && $value <= $characteristic->upper) ? 'Ok' : 'Not Ok';
|
||||||
|
|
||||||
return ($value > $characteristic->lower && $value < $characteristic->upper) ? 'Ok' : 'Not Ok';
|
return ($value >= $limit->lower && $value <= $limit->upper) ? 'Ok' : 'Not Ok';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,15 +23,21 @@ class ImportTransitMail extends Mailable
|
|||||||
|
|
||||||
public $excelPath;
|
public $excelPath;
|
||||||
|
|
||||||
|
public $name;
|
||||||
|
|
||||||
|
public $mobileNo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new message instance.
|
* Create a new message instance.
|
||||||
*/
|
*/
|
||||||
public function __construct($scheduleType, $tableData, $mailSubject, $excelPath)
|
public function __construct($scheduleType, $tableData, $mailSubject, $excelPath, $name, $mobileNo)
|
||||||
{
|
{
|
||||||
$this->scheduleType = $scheduleType;
|
$this->scheduleType = $scheduleType;
|
||||||
$this->tableData = $tableData ?? [];
|
$this->tableData = $tableData ?? [];
|
||||||
$this->mailSubject = $mailSubject ?? 'Import Transit';
|
$this->mailSubject = $mailSubject ?? 'Import Transit';
|
||||||
$this->excelPath = $excelPath;
|
$this->excelPath = $excelPath;
|
||||||
|
$this->name = $name;
|
||||||
|
$this->mobileNo = $mobileNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,7 +87,7 @@ class ImportTransitMail extends Mailable
|
|||||||
'company' => 'CRI Digital Manufacturing Solutions',
|
'company' => 'CRI Digital Manufacturing Solutions',
|
||||||
'greeting' => $greeting,
|
'greeting' => $greeting,
|
||||||
'tableData' => $this->tableData,
|
'tableData' => $this->tableData,
|
||||||
'wishes' => 'Thanks & Regards,<br>CRI Digital Manufacturing Solutions',
|
'wishes' => "Thanks & Regards,<br>CRI Digital Manufacturing Solutions<br><b>Updated By</b> - $this->name<br>For any queries, please contact the number below<br>+91 $this->mobileNo",
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ class Machine extends Model
|
|||||||
return $this->hasMany(RequestCharacteristic::class, 'machine_id', 'id');
|
return $this->hasMany(RequestCharacteristic::class, 'machine_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function characteristicApproverMaster()
|
||||||
|
{
|
||||||
|
return $this->hasMany(CharacteristicApproverMaster::class, 'machine_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
public function productionCharacteristics()
|
public function productionCharacteristics()
|
||||||
{
|
{
|
||||||
return $this->hasMany(ProductionCharacteristic::class, 'machine_id', 'id');
|
return $this->hasMany(ProductionCharacteristic::class, 'machine_id', 'id');
|
||||||
|
|||||||
@@ -193,4 +193,9 @@ class Plant extends Model
|
|||||||
// {
|
// {
|
||||||
// return $this->hasMany(LocatorValidation::class, 'plant_id', 'id');
|
// return $this->hasMany(LocatorValidation::class, 'plant_id', 'id');
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
public function characteristicApproverMaster()
|
||||||
|
{
|
||||||
|
return $this->hasMany(CharacteristicApproverMaster::class, 'plant_id', 'id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,15 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="border:1px solid #d1d5db;font-weight:bold;">
|
||||||
|
No of Person
|
||||||
|
</td>
|
||||||
|
<td style="border:1px solid #d1d5db;">
|
||||||
|
{{ $visitor->number_of_person }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td style="border:1px solid #d1d5db;font-weight:bold;">
|
<td style="border:1px solid #d1d5db;font-weight:bold;">
|
||||||
Visit Time
|
Visit Time
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
$grossWeightHeight = 5;
|
$grossWeightHeight = 5;
|
||||||
$netWeightHeight = 5;
|
$netWeightHeight = 5;
|
||||||
$licenseHeight = 5;
|
$licenseHeight = 5;
|
||||||
$companyInfoHeight = 6.9;
|
$companyInfoHeight = 6.9; //6.9
|
||||||
$logoHeight = $titleHeight * 0.8;
|
$logoHeight = $titleHeight * 0.8;
|
||||||
$logoMaxWidth = 20;
|
$logoMaxWidth = 20;
|
||||||
$isilogoHeight = $titleHeight * 0.9;
|
$isilogoHeight = $titleHeight * 0.9;
|
||||||
@@ -240,8 +240,13 @@
|
|||||||
/* Column widths */
|
/* Column widths */
|
||||||
.col-1 { width: 22%; }
|
.col-1 { width: 22%; }
|
||||||
.col-2 { width: 45%; }
|
.col-2 { width: 45%; }
|
||||||
|
.col-3 { width: 11%; }
|
||||||
|
.col-4 { width: 29%; }
|
||||||
|
|
||||||
|
/* .col-1 { width: 20%; }
|
||||||
|
.col-2 { width: 48%; }
|
||||||
.col-3 { width: 15%; }
|
.col-3 { width: 15%; }
|
||||||
.col-4 { width: 25%; }
|
.col-4 { width: 17%; } */
|
||||||
|
|
||||||
/* Force exact heights for rows - ALL FIXED EXCEPT ITEM ROWS */
|
/* Force exact heights for rows - ALL FIXED EXCEPT ITEM ROWS */
|
||||||
.title-row {
|
.title-row {
|
||||||
|
|||||||
Reference in New Issue
Block a user