Compare commits
37 Commits
f068b1b79a
...
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 |
@@ -4,8 +4,10 @@ namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\ImportTransitMail;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\EmployeeMaster;
|
||||
use App\Models\ImportTransit;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Console\Command;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\ImportTransitReportExport;
|
||||
@@ -81,11 +83,22 @@ class SendImportTransit extends Command
|
||||
'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(
|
||||
$scheduleType,
|
||||
$tableData,
|
||||
$mailSubject,
|
||||
$fileName
|
||||
$fileName,
|
||||
$employeeName,
|
||||
$mobileNumber,
|
||||
);
|
||||
|
||||
$toEmails = collect(explode(',', $rule->email))
|
||||
@@ -111,11 +124,9 @@ class SendImportTransit extends Command
|
||||
->cc($ccEmails)
|
||||
->send($mail);
|
||||
|
||||
$this->info(
|
||||
"Mail sent → Rule {$rule->id} | To: " . implode(', ', $toEmails)
|
||||
);
|
||||
}
|
||||
$this->info("Mail sent → Rule {$rule->id} | To: " . implode(', ', $toEmails));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,6 @@ class ProductionCharacteristicExporter extends Exporter
|
||||
->label('OBSERVED VALUE'),
|
||||
ExportColumn::make('status')
|
||||
->label('STATUS'),
|
||||
ExportColumn::make('inspection_status')
|
||||
->label('INSPECTION STATUS'),
|
||||
ExportColumn::make('remark')
|
||||
->label('REMARK'),
|
||||
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}'.";
|
||||
}
|
||||
|
||||
$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();
|
||||
// if (! $user) {
|
||||
// $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\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class WireMasterPrint extends Page
|
||||
{
|
||||
@@ -77,41 +78,69 @@ class WireMasterPrint extends Page
|
||||
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(),
|
||||
select::make('scan_pallet_no')
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('scan_pallet_no', null);
|
||||
}),
|
||||
Select::make('scan_pallet_no')
|
||||
->label('Scan Pallet No')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function ($get) {
|
||||
|
||||
$plantId = $get('plant_id');
|
||||
$customerPoId = $get('customer_po_master_id');
|
||||
// $plantId = $get('plant_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 [];
|
||||
}
|
||||
|
||||
$poIds = CustomerPoMaster::where('plant_id', $plantId)->where('customer_po', $customerPo)->pluck('id');
|
||||
$palletNumbers = WireMasterPacking::query()
|
||||
->select('wire_packing_number')
|
||||
->where('plant_id', $plantId)
|
||||
->where('customer_po_master_id', $customerPoId)
|
||||
->whereIn('customer_po_master_id', $poIds)
|
||||
->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')
|
||||
->orderBy('wire_packing_number')
|
||||
->pluck('wire_packing_number')
|
||||
->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) {
|
||||
$palletNo = $state;
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
|
||||
$this->dispatch('loadData', $palletNo, $plantId);
|
||||
})
|
||||
->extraAttributes([
|
||||
|
||||
@@ -6,25 +6,24 @@ use App\Filament\Exports\CharacteristicApproverMasterExporter;
|
||||
use App\Filament\Imports\CharacteristicApproverMasterImporter;
|
||||
use App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\Item;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
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
|
||||
{
|
||||
@@ -34,6 +33,8 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Laser Marking';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
@@ -224,7 +225,8 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
Forms\Components\TextInput::make('duration2')
|
||||
->label('Duration (HH.MM)')
|
||||
->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])$/')
|
||||
->validationMessages([
|
||||
'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')
|
||||
->label('Duration (HH.MM)')
|
||||
->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])$/')
|
||||
->validationMessages([
|
||||
'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) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('requestCharacteristics', function ($query) {
|
||||
return Plant::whereHas('characteristicApproverMaster', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
@@ -434,7 +437,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::whereHas('requestCharacteristics', function ($query) use ($plantId) {
|
||||
return Machine::whereHas('characteristicApproverMaster', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
|
||||
@@ -82,6 +82,13 @@ class CustomerPoMasterResource extends Resource
|
||||
|
||||
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')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
@@ -110,10 +117,18 @@ class CustomerPoMasterResource extends Resource
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
|
||||
@@ -12,6 +12,7 @@ use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
@@ -39,18 +40,32 @@ class EquipmentMasterResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$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();
|
||||
})
|
||||
->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')
|
||||
// ->relationship('machine', 'name')
|
||||
->label('Work Center')
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
@@ -60,15 +75,30 @@ class EquipmentMasterResource extends Resource
|
||||
|
||||
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')
|
||||
->label('Name'),
|
||||
->label('Name')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
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')
|
||||
->label('Make'),
|
||||
->label('Make')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
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')
|
||||
->label('Equipment Number')
|
||||
->reactive()
|
||||
@@ -82,6 +112,8 @@ class EquipmentMasterResource extends Resource
|
||||
];
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
|
||||
if (! $state) {
|
||||
return;
|
||||
}
|
||||
@@ -108,7 +140,10 @@ class EquipmentMasterResource extends Resource
|
||||
// }
|
||||
// }),
|
||||
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')
|
||||
// ->label('Calibrated On')
|
||||
// ->required(),
|
||||
@@ -128,6 +163,7 @@ class EquipmentMasterResource extends Resource
|
||||
$frequency = $get('frequency') ?? '1';
|
||||
$nextDate = self::calculateNextCalibrationDate($state, $frequency);
|
||||
$set('next_calibration_date', $nextDate);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
|
||||
// $frequency = (int) $get('frequency');
|
||||
@@ -152,6 +188,7 @@ class EquipmentMasterResource extends Resource
|
||||
$calibratedOn = $get('calibrated_on');
|
||||
$nextDate = self::calculateNextCalibrationDate($calibratedOn, $state);
|
||||
$set('next_calibration_date', $nextDate);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
|
||||
// $calibratedOn = $get('calibrated_on');
|
||||
@@ -171,12 +208,21 @@ class EquipmentMasterResource extends Resource
|
||||
Forms\Components\DateTimePicker::make('next_calibration_date')
|
||||
->label('Next Calibration Date')
|
||||
->readOnly()
|
||||
->required(),
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
|
||||
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')
|
||||
->label('Calibration Certificate'),
|
||||
->label('Calibration Certificate')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
|
||||
Forms\Components\FileUpload::make('attachment')
|
||||
->label('PDF Upload')
|
||||
@@ -185,7 +231,10 @@ class EquipmentMasterResource extends Resource
|
||||
->disk('local')
|
||||
->directory('uploads/temp')
|
||||
->preserveFilenames()
|
||||
->reactive(),
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
|
||||
// Forms\Components\Actions::make([
|
||||
// Action::make('uploadNow')
|
||||
@@ -341,7 +390,11 @@ class EquipmentMasterResource extends Resource
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
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;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->label('Plant Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
@@ -413,24 +466,30 @@ class EquipmentMasterResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created Bys')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
->toggleable(isToggledHiddenByDefault: false),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: false),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
|
||||
@@ -27,6 +27,8 @@ class PanelBoxValidationResource extends Resource
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Panel Box';
|
||||
|
||||
public $isSubmitted = false;
|
||||
|
||||
public $data = [];
|
||||
@@ -176,6 +178,8 @@ class PanelBoxValidationResource extends Resource
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
|
||||
$pId = $get('line_id');
|
||||
$plantId = $get('plant_id');
|
||||
$plaCode = Plant::find($plantId)?->code;
|
||||
$set('part_validation_type', null);
|
||||
$set('show_validation_image', false);
|
||||
$set('validation1_image_url', null);
|
||||
@@ -382,7 +386,17 @@ class PanelBoxValidationResource extends Resource
|
||||
$set('item_id', null);
|
||||
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()
|
||||
->title('Invalid QR Format')
|
||||
@@ -476,6 +490,7 @@ class PanelBoxValidationResource extends Resource
|
||||
// $set('serial_number', null);
|
||||
// $set('serial_number', $serialNumber);
|
||||
}
|
||||
|
||||
// Check if user input matches the database values
|
||||
foreach ($partValidationColumns as $field) {
|
||||
if ($get("{$field}_visible")) {
|
||||
|
||||
@@ -65,8 +65,13 @@ class CreatePanelBoxValidation extends CreateRecord {
|
||||
$this->showChecklist = true;
|
||||
$this->halt();
|
||||
}
|
||||
|
||||
return $data;
|
||||
else{
|
||||
\Filament\Notifications\Notification::make()
|
||||
->title('Characteristics not found for the scanned item.')
|
||||
->danger()
|
||||
->send();
|
||||
$this->halt();
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkIfHasCharacteristics(array $data)
|
||||
|
||||
@@ -23,6 +23,10 @@ use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
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
|
||||
{
|
||||
@@ -61,9 +65,14 @@ class WireMasterPackingResource extends Resource
|
||||
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')
|
||||
->label('Scan Wire Packing No')
|
||||
->reactive()
|
||||
@@ -160,13 +169,19 @@ class WireMasterPackingResource extends Resource
|
||||
->options(function ($get) {
|
||||
|
||||
$plantId = $get('plant_id');
|
||||
$customerPo = $get('customer_po_master_id');
|
||||
|
||||
if (! $plantId) {
|
||||
if (!$plantId || !$customerPo) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$customerPoIds = CustomerPoMaster::where('plant_id', $plantId)
|
||||
->where('customer_po', $customerPo)
|
||||
->pluck('id');
|
||||
|
||||
return WireMasterPacking::query()
|
||||
->where('plant_id', $plantId)
|
||||
->whereIn('customer_po_master_id', $customerPoIds)
|
||||
->where(function ($query) {
|
||||
$query->whereNull('wire_packing_status')
|
||||
->orWhere('wire_packing_status', '');
|
||||
@@ -468,6 +483,22 @@ class WireMasterPackingResource extends Resource
|
||||
Tables\Actions\ForceDeleteBulkAction::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;
|
||||
}
|
||||
|
||||
$itemId = Item::where('code', $materialCode)
|
||||
->where('plant_id', $plantId)
|
||||
->value('id');
|
||||
|
||||
$icodeAgaCPoPlant = CustomerPoMaster::where('item_id', $itemId)->where('plant_id', $plantId)->first();
|
||||
|
||||
if(!$icodeAgaCPoPlant)
|
||||
@@ -214,23 +210,24 @@ class CreateWireMasterPacking extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
$customerPoRecord = CustomerPoMaster::where('id', $customerPo)
|
||||
$customerPoRecord = CustomerPoMaster::where('customer_po', $customerPo)
|
||||
->where('plant_id', $plantId)
|
||||
->where('item_id', $itemId)
|
||||
->first();
|
||||
|
||||
$customerPoName = $customerPoRecord->customer_po;
|
||||
// $customerPoName = $customerPoRecord->customer_po;
|
||||
|
||||
if ($customerPoRecord) {
|
||||
$customerPoName = $customerPoRecord->customer_po;
|
||||
} else {
|
||||
$customerPoName = null;
|
||||
}
|
||||
// if ($customerPoRecord) {
|
||||
// $customerPoName = $customerPoRecord->customer_po;
|
||||
// } else {
|
||||
// $customerPoName = null;
|
||||
// }
|
||||
|
||||
if(!$customerPoRecord)
|
||||
{
|
||||
Notification::make()
|
||||
->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()
|
||||
->duration(5000)
|
||||
->send();
|
||||
@@ -247,7 +244,7 @@ class CreateWireMasterPacking extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
$alreadyScannedQty = WireMasterPacking::where('customer_po_master_id', $customerPo)
|
||||
$alreadyScannedQty = WireMasterPacking::where('customer_po_master_id', $customerPoRecord->id)
|
||||
->where('plant_id', $plantId)
|
||||
->where('item_id', $itemId)
|
||||
->selectRaw('SUM(CAST(weight AS NUMERIC)) as total_weight')
|
||||
@@ -259,7 +256,7 @@ class CreateWireMasterPacking extends CreateRecord
|
||||
{
|
||||
Notification::make()
|
||||
->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()
|
||||
->duration(5000)
|
||||
->send();
|
||||
@@ -268,6 +265,7 @@ class CreateWireMasterPacking extends CreateRecord
|
||||
'process_order' => null,
|
||||
'plant_id' => $plantId,
|
||||
'customer_po_master_id' => $customerPo,
|
||||
'item_id' => $itemId,
|
||||
'wire_packing_number' => $wirePackNo,
|
||||
'Sno_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
@@ -294,7 +292,7 @@ class CreateWireMasterPacking extends CreateRecord
|
||||
'item_id' => $itemId,
|
||||
'wire_packing_number' => $wirePackNo,
|
||||
'process_order' => $processOrderId . '-' . $coilNo,
|
||||
'customer_po_master_id' => $customerPo,
|
||||
'customer_po_master_id' => $customerPoRecord->id,
|
||||
'weight' => $weight,
|
||||
'created_by' => $createdBy,
|
||||
'scanned_by' => $operatorName,
|
||||
@@ -314,6 +312,7 @@ class CreateWireMasterPacking extends CreateRecord
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'customer_po_master_id' => $customerPo,
|
||||
'item_id' => $itemId,
|
||||
'wire_packing_number' => $wirePackNo,
|
||||
'process_order' => null,
|
||||
// 'pending_pallet_list' => $pendingPallet,
|
||||
@@ -334,6 +333,7 @@ class CreateWireMasterPacking extends CreateRecord
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'customer_po_master_id' => $customerPo,
|
||||
'item_id' => $itemId,
|
||||
'wire_packing_number' => $wirePackNo,
|
||||
'process_order' => null,
|
||||
// 'pending_pallet_list' => $pendingPallet,
|
||||
|
||||
@@ -19,182 +19,23 @@ 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)
|
||||
// {
|
||||
|
||||
// $customerId = $request->query('customer');
|
||||
|
||||
// $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,
|
||||
// ];
|
||||
// });
|
||||
// ->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)
|
||||
@@ -205,6 +46,29 @@ class PalletPrintController extends Controller
|
||||
// $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')
|
||||
@@ -226,7 +90,7 @@ class PalletPrintController extends Controller
|
||||
|
||||
// $currentPalletNo = ($index !== false) ? $index + 1 : 0;
|
||||
|
||||
// $boxLabel = $currentPalletNo . '/' . $totalBoxes;
|
||||
// $boxLabel = $currentPalletNo.'/'.$totalBoxes;
|
||||
|
||||
// // $completedPallets = WireMasterPacking::where('plant_id', $plant)
|
||||
// // ->select('wire_packing_number')
|
||||
@@ -243,50 +107,180 @@ class PalletPrintController extends Controller
|
||||
// // $boxLabel = $currentPalletNo . '/' . $totalBoxes;
|
||||
|
||||
// $grossWeight = $items->sum('weight');
|
||||
// $widthPt = 85 * 2.83465; // 85mm → points
|
||||
// $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');
|
||||
|
||||
// $qrBase64 = $this->generateQrDataUri($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',
|
||||
// 'plantName' => $plantName,
|
||||
// $pdf = Pdf::loadView('pdf.wire-pallet', [
|
||||
// 'product' => 'Submersible Winding Wire',
|
||||
// 'plantName' => $plantName,
|
||||
// 'plantAddress' => $plantAddress,
|
||||
// 'monthYear' => now()->format('M-y'),
|
||||
// 'monthYear' => now()->format('M-y'),
|
||||
// 'branch' => '',
|
||||
// 'customerCode' => $customerCode,
|
||||
// 'customerName' => $customerName,
|
||||
// 'masterBox' => $pallet,
|
||||
// 'items' => $items,
|
||||
// 'grossWeight' => $grossWeight,
|
||||
// 'netWeight' => $grossWeight - 3.05,
|
||||
// 'pallet' => $pallet,
|
||||
// 'qrBase64' => $qrBase64,
|
||||
// ])->render();
|
||||
// 'masterBox' => $boxLabel,
|
||||
// 'items' => $items,
|
||||
// 'grossWeight' => $grossWeight + 3.050,
|
||||
// 'netWeight' => $grossWeight,
|
||||
// // 'grossWeight' => $grossWeight,
|
||||
// // 'netWeight' => $grossWeight - 3.05,
|
||||
// 'pallet' => $pallet,
|
||||
// ])->setPaper([0, 0, $widthPt, $heightPt], 'portrait');
|
||||
|
||||
// $mpdf->WriteHTML($html);
|
||||
// return $mpdf->Output("Pallet-{$pallet}.pdf", 'I'); // 'I' = inline view in browser
|
||||
// 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);
|
||||
// // }
|
||||
// }
|
||||
|
||||
// private function generateQrDataUri(string $data): string
|
||||
// {
|
||||
// $qr = new \Mpdf\QrCode\QrCode($data, 'H');
|
||||
// $output = new \Mpdf\QrCode\Output\Png();
|
||||
// $pngData = $output->output($qr, 80, [255, 255, 255], [0, 0, 0]);
|
||||
// return 'data:image/png;base64,' . base64_encode($pngData);
|
||||
// }
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
|
||||
public function print(Request $request, $pallet, $plant)
|
||||
{
|
||||
|
||||
$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)
|
||||
{
|
||||
|
||||
@@ -151,12 +151,27 @@ public $records = [];
|
||||
|
||||
$characteristic = ProductCharacteristicsMaster::find($characteristicId);
|
||||
|
||||
if (($characteristic?->inspection_type ?? null) === 'Value') {
|
||||
if (
|
||||
$characteristic &&
|
||||
is_numeric($value) &&
|
||||
$value >= $characteristic->lower &&
|
||||
$value <= $characteristic->upper
|
||||
$itemCharacteristic = ProductCharacteristicsMaster::where('plant_id', $this->data['plant_id'])
|
||||
->where('line_id', $this->data['line_id'])
|
||||
->where('name', $characteristic->name)
|
||||
->where('item_id', $itemId)
|
||||
->first();
|
||||
|
||||
// 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';
|
||||
} else {
|
||||
@@ -167,7 +182,7 @@ public $records = [];
|
||||
$status = $value;
|
||||
}
|
||||
|
||||
ProductionCharacteristic::create([
|
||||
$prod = ProductionCharacteristic::create([
|
||||
'plant_id' => $this->data['plant_id'] ?? null,
|
||||
'item_id' => $itemId ?? 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->dispatch('checklist-saved');
|
||||
@@ -201,7 +225,7 @@ public $records = [];
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@@ -218,11 +242,24 @@ public $records = [];
|
||||
|
||||
$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)) {
|
||||
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 $name;
|
||||
|
||||
public $mobileNo;
|
||||
|
||||
/**
|
||||
* 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->tableData = $tableData ?? [];
|
||||
$this->mailSubject = $mailSubject ?? 'Import Transit';
|
||||
$this->excelPath = $excelPath;
|
||||
$this->name = $name;
|
||||
$this->mobileNo = $mobileNo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +87,7 @@ class ImportTransitMail extends Mailable
|
||||
'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<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');
|
||||
}
|
||||
|
||||
public function characteristicApproverMaster()
|
||||
{
|
||||
return $this->hasMany(CharacteristicApproverMaster::class, 'machine_id', 'id');
|
||||
}
|
||||
|
||||
public function productionCharacteristics()
|
||||
{
|
||||
return $this->hasMany(ProductionCharacteristic::class, 'machine_id', 'id');
|
||||
|
||||
@@ -193,4 +193,9 @@ class Plant extends Model
|
||||
// {
|
||||
// return $this->hasMany(LocatorValidation::class, 'plant_id', 'id');
|
||||
// }
|
||||
|
||||
public function characteristicApproverMaster()
|
||||
{
|
||||
return $this->hasMany(CharacteristicApproverMaster::class, 'plant_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,15 @@
|
||||
</td>
|
||||
</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>
|
||||
<td style="border:1px solid #d1d5db;font-weight:bold;">
|
||||
Visit Time
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
$grossWeightHeight = 5;
|
||||
$netWeightHeight = 5;
|
||||
$licenseHeight = 5;
|
||||
$companyInfoHeight = 6.9;
|
||||
$companyInfoHeight = 6.9; //6.9
|
||||
$logoHeight = $titleHeight * 0.8;
|
||||
$logoMaxWidth = 20;
|
||||
$isilogoHeight = $titleHeight * 0.9;
|
||||
@@ -240,8 +240,13 @@
|
||||
/* Column widths */
|
||||
.col-1 { width: 22%; }
|
||||
.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-4 { width: 25%; }
|
||||
.col-4 { width: 17%; } */
|
||||
|
||||
/* Force exact heights for rows - ALL FIXED EXCEPT ITEM ROWS */
|
||||
.title-row {
|
||||
|
||||
Reference in New Issue
Block a user