Compare commits
33 Commits
0de49f14ce
...
actions/ge
| Author | SHA1 | Date | |
|---|---|---|---|
| 2bc8584e7a | |||
| d126e931c8 | |||
|
|
e525e3c526 | ||
| 62bf68ad2e | |||
|
|
caf2f3c1e7 | ||
| c6c63dcb35 | |||
|
|
2ceb76f008 | ||
| d1663ae58a | |||
|
|
988d109acc | ||
| deb46cdda2 | |||
|
|
bc8163a535 | ||
| 002bdc597d | |||
|
|
6834e37429 | ||
| a406d1b58a | |||
|
|
a9012ffc05 | ||
| 58d0b9f0ae | |||
|
|
c67bbc02b6 | ||
| c0d8ca7b1e | |||
|
|
d71837f314 | ||
| f31ab62ec0 | |||
|
|
36a50815f9 | ||
| 4285a31f94 | |||
|
|
11678dd846 | ||
| 0c9228bfec | |||
|
|
035e6cd560 | ||
| 58b45c849d | |||
|
|
91deb448ef | ||
| 61a2e7ffad | |||
|
|
c05b536253 | ||
| 3779cf3e3b | |||
|
|
10071413a1 | ||
| acf955dd94 | |||
|
|
624e18e18d |
4
.github/workflows/gemini-pr-review.yaml
vendored
4
.github/workflows/gemini-pr-review.yaml
vendored
@@ -36,8 +36,8 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-npm-global-
|
||||
|
||||
- name: Install Gemini CLI globally
|
||||
run: npm install -g --loglevel=http @google/gemini-cli
|
||||
# - name: Install Gemini CLI globally
|
||||
# run: npm install -g --loglevel=http @google/gemini-cli
|
||||
|
||||
- name: Generate git diff and review with Gemini
|
||||
id: review
|
||||
|
||||
@@ -267,9 +267,7 @@ class ItemResource extends Resource
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
return $plantId
|
||||
? Item::where('plant_id', $plantId)->pluck('code', 'id')
|
||||
: [];
|
||||
return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
|
||||
@@ -620,9 +620,7 @@ class StickerMasterResource extends Resource
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
return $plantId
|
||||
? Item::where('plant_id', $plantId)->pluck('code', 'id')
|
||||
: Item::pluck('code', 'id');
|
||||
return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
|
||||
@@ -9,6 +9,7 @@ use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||
use Filament\Facades\Filament;
|
||||
use App\Models\StickerPrinting;
|
||||
use Filament\Notifications\Notification;
|
||||
use Str;
|
||||
|
||||
|
||||
class CreateStickerPrinting extends CreateRecord
|
||||
@@ -77,7 +78,65 @@ class CreateStickerPrinting extends CreateRecord
|
||||
|
||||
$sNumber = $this->form->getState()['serial_number'] ?? null;
|
||||
|
||||
if(empty($this->plantId) || empty($ref) || empty($this->serial_number)) {
|
||||
$pattern1 = '/^(?<item_code>[^|]+)\|(?<serial_number>[^|]+)\|?$/i';
|
||||
|
||||
$pattern2 = '/^(?<item_code>[^|]+)\|(?<serial_number>[^|]+)\|(?<batch_number>.+)$/i';
|
||||
|
||||
$pattern3 = '/^(?<serial_number>[^|]+)$/i';
|
||||
|
||||
|
||||
if (preg_match($pattern1, $sNumber, $matches) || preg_match($pattern2, $sNumber, $matches) || preg_match($pattern3, $sNumber, $matches)) {
|
||||
|
||||
$serial = $matches['serial_number'];
|
||||
|
||||
if (Str::length($serial) < 9) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Number')
|
||||
->body("Serial number should conatin minimum 9 digits '$serial'.")
|
||||
->warning()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plant,
|
||||
'reference_number' => $ref,
|
||||
'serial_number' => '',
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if(!ctype_alnum($serial)) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Number')
|
||||
->body("Serial number should be alphanumeric '$serial'.")
|
||||
->warning()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plant,
|
||||
'reference_number' => $ref,
|
||||
'serial_number' => '',
|
||||
]);
|
||||
return;
|
||||
}
|
||||
$extractedSerialNumber = $matches['serial_number'];
|
||||
$sNumber = $extractedSerialNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title('Invalid Format')
|
||||
->body("Serial number must be in the format 'itemcode|serialnumber' or 'itemcode|serialnumber|batchnumber'. or just 'serialnumber'.")
|
||||
->warning()
|
||||
->send();
|
||||
|
||||
// Reset only serial number field
|
||||
$this->form->fill([
|
||||
'plant_id' => $plant,
|
||||
'reference_number' => $ref,
|
||||
'serial_number' => '',
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($plant == null || trim($plant) == '' || $ref == null || trim($ref) == '' || $sNumber == null || trim($sNumber) == '')
|
||||
{
|
||||
Notification::make()
|
||||
->title('Unknown: Incomplete Data!')
|
||||
->body("Please ensure Plant, Reference Number, and Serial Number are provided.")
|
||||
@@ -110,16 +169,16 @@ class CreateStickerPrinting extends CreateRecord
|
||||
}
|
||||
|
||||
StickerPrinting::create([
|
||||
'plant_id' => $this->plantId,
|
||||
'plant_id' => $plant,
|
||||
'reference_number' => $ref,
|
||||
'serial_number' => $this->serial_number,
|
||||
'serial_number' => $sNumber,
|
||||
'created_by' => Filament::auth()->user()->name,
|
||||
]);
|
||||
|
||||
$this->dispatch('addStickerToList', $this->plantId, $ref, $this->serial_number);
|
||||
$this->dispatch('addStickerToList', $plant, $ref, $sNumber);
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $this->plantId,
|
||||
'plant_id' => $plant,
|
||||
'reference_number' => $ref,
|
||||
'serial_number' => '',
|
||||
]);
|
||||
@@ -175,6 +234,7 @@ class CreateStickerPrinting extends CreateRecord
|
||||
// Send data to Pdf view
|
||||
$pdf = PDF::loadView('pdf.qrcode', [
|
||||
'qrCode' => $qrCode,
|
||||
'referenceNumber' => $refNumber,
|
||||
]);
|
||||
|
||||
return response()->streamDownload(function () use ($pdf) {
|
||||
|
||||
55
app/Livewire/StickerPrintData.php
Normal file
55
app/Livewire/StickerPrintData.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use App\Models\StickerPrinting;
|
||||
|
||||
class StickerPrintData extends Component
|
||||
{
|
||||
public $plantId;
|
||||
|
||||
public $refNumber;
|
||||
|
||||
public $serialNumber;
|
||||
|
||||
public bool $materialInvoice = false;
|
||||
|
||||
public $records = [];
|
||||
|
||||
protected $listeners = [
|
||||
'refreshEmptySticker' => 'loadStickerData',
|
||||
'addStickerToList' => 'loadSticker'
|
||||
];
|
||||
|
||||
public function loadStickerData($plantId, $refNumber)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->refNumber = $refNumber;
|
||||
$this->materialInvoice = true;
|
||||
|
||||
$this->records = StickerPrinting::where('plant_id', $plantId)
|
||||
->where('reference_number', $refNumber)
|
||||
->orderBy('created_at', 'asc')
|
||||
->get(['serial_number', 'created_by']);
|
||||
|
||||
}
|
||||
|
||||
public function loadSticker($plantId, $refNumber, $serialNumber)
|
||||
{
|
||||
|
||||
$this->plantId = $plantId;
|
||||
$this->refNumber = $refNumber;
|
||||
$this->materialInvoice = true;
|
||||
|
||||
$this->records = StickerPrinting::where('plant_id', $plantId)
|
||||
->where('reference_number', $refNumber)
|
||||
->orderBy('created_at', 'asc')
|
||||
->get(['serial_number', 'created_by']);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.sticker-print-data');
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,13 @@ use Illuminate\Auth\Access\Response;
|
||||
use App\Models\StickerPrinting;
|
||||
use App\Models\User;
|
||||
|
||||
|
||||
class StickerPrintingPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(App\Models\User $user): bool
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any StickerPrinting');
|
||||
}
|
||||
@@ -19,7 +20,7 @@ class StickerPrintingPolicy
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(App\Models\User $user, StickerPrinting $stickerprinting): bool
|
||||
public function view(User $user, StickerPrinting $stickerprinting): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view StickerPrinting');
|
||||
}
|
||||
@@ -27,7 +28,7 @@ class StickerPrintingPolicy
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(App\Models\User $user): bool
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create StickerPrinting');
|
||||
}
|
||||
@@ -35,7 +36,7 @@ class StickerPrintingPolicy
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(App\Models\User $user, StickerPrinting $stickerprinting): bool
|
||||
public function update(User $user, StickerPrinting $stickerprinting): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update StickerPrinting');
|
||||
}
|
||||
@@ -43,7 +44,7 @@ class StickerPrintingPolicy
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(App\Models\User $user, StickerPrinting $stickerprinting): bool
|
||||
public function delete(User $user, StickerPrinting $stickerprinting): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete StickerPrinting');
|
||||
}
|
||||
@@ -51,7 +52,7 @@ class StickerPrintingPolicy
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(App\Models\User $user): bool
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any StickerPrinting');
|
||||
}
|
||||
@@ -59,7 +60,7 @@ class StickerPrintingPolicy
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(App\Models\User $user, StickerPrinting $stickerprinting): bool
|
||||
public function restore(User $user, StickerPrinting $stickerprinting): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore StickerPrinting');
|
||||
}
|
||||
@@ -67,7 +68,7 @@ class StickerPrintingPolicy
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(App\Models\User $user): bool
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any StickerPrinting');
|
||||
}
|
||||
@@ -75,7 +76,7 @@ class StickerPrintingPolicy
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(App\Models\User $user, StickerPrinting $stickerprinting): bool
|
||||
public function replicate(User $user, StickerPrinting $stickerprinting): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate StickerPrinting');
|
||||
}
|
||||
@@ -83,7 +84,7 @@ class StickerPrintingPolicy
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(App\Models\User $user): bool
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder StickerPrinting');
|
||||
}
|
||||
@@ -91,7 +92,7 @@ class StickerPrintingPolicy
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(App\Models\User $user, StickerPrinting $stickerprinting): bool
|
||||
public function forceDelete(User $user, StickerPrinting $stickerprinting): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete StickerPrinting');
|
||||
}
|
||||
@@ -99,7 +100,7 @@ class StickerPrintingPolicy
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(App\Models\User $user): bool
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any StickerPrinting');
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ return [
|
||||
|
||||
'user_model' => \App\Models\User::class,
|
||||
|
||||
'user_model_class' => \App\Models\User::class,
|
||||
// 'user_model_class' => \App\Models\User::class,
|
||||
|
||||
'policies_namespace' => 'App\Policies',
|
||||
],
|
||||
|
||||
@@ -169,6 +169,7 @@ class PermissionSeeder extends Seeder
|
||||
Permission::updateOrCreate(['name' => 'view import process order']);
|
||||
Permission::updateOrCreate(['name' => 'view export process order']);
|
||||
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import sticker printing']);
|
||||
Permission::updateOrCreate(['name' => 'view export sticker printing']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<x-filament::page>
|
||||
<form wire:submit.prevent="create" class="space-y-6">
|
||||
{{-- Form Section --}}
|
||||
<div class="filament-form space-y-6">
|
||||
{{ $this->form }}
|
||||
</div>
|
||||
|
||||
{{-- <livewire:notification-sound /> --}}
|
||||
|
||||
{{-- Livewire Component (Invoice Table) --}}
|
||||
<div class="bg-white shadow rounded-xl p-4">
|
||||
<livewire:sticker-print-data :ref-data="$ref_number" />
|
||||
</div>
|
||||
|
||||
{{-- Actions --}}
|
||||
<div class="filament-actions mt-6">
|
||||
<x-filament::actions>
|
||||
@foreach ($this->getFormActions() as $action)
|
||||
{{ $action }}
|
||||
@endforeach
|
||||
</x-filament::actions>
|
||||
</div>
|
||||
</form>
|
||||
</x-filament::page>
|
||||
23
resources/views/forms/components/print-button.blade.php
Normal file
23
resources/views/forms/components/print-button.blade.php
Normal file
@@ -0,0 +1,23 @@
|
||||
{{-- <div class="flex flex-col items-start space-y-2">
|
||||
<button
|
||||
type="button"
|
||||
wire:click="printSticker"
|
||||
class="mt-15 px-2 py-1 border border-primary-500 text-primary-600 rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
|
||||
>
|
||||
Print
|
||||
</button>
|
||||
</div> --}}
|
||||
|
||||
|
||||
<div class="flex flex-col items-start space-y-2">
|
||||
<button
|
||||
type="button"
|
||||
wire:click="printSticker"
|
||||
class="px-2 py-1 border border-primary-500 text-primary-600 bg-white rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
|
||||
style="margin-top: 10mm;"
|
||||
>
|
||||
Print
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
81
resources/views/livewire/sticker-print-data.blade.php
Normal file
81
resources/views/livewire/sticker-print-data.blade.php
Normal file
@@ -0,0 +1,81 @@
|
||||
|
||||
{{-- <div class="overflow-x-auto overflow-y-visible" style="height: 385px;">
|
||||
<table class="table-auto w-full border-collapse border">
|
||||
<thead class="bg-gray-100">
|
||||
<tr>
|
||||
<th class="border p-2">No</th>
|
||||
<th class="border p-2">Reference No</th>
|
||||
<th class="border p-2">Serial Number</th>
|
||||
<th class="border p-2">Created By</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($records as $index => $record)
|
||||
<tr>
|
||||
<td class="border p-2 text-center">{{ $index + 1 }}</td>
|
||||
<td class="border p-2 text-center">{{ $refNumber }}</td>
|
||||
<td class="border p-2 text-center">{{ $record['serial_number'] }}</td>
|
||||
<td class="border p-2 text-center">{{ $record->created_by }}</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td class="border p-2 text-center" colspan="4">No serial numbers found.</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div> --}}
|
||||
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold mb-2">Sticker Printing Table</h3>
|
||||
|
||||
<div
|
||||
wire:loading.remove
|
||||
@if(!$materialInvoice) style="display:none" @endif
|
||||
class="overflow-x-auto overflow-y-visible"
|
||||
style="height: 385px;"
|
||||
>
|
||||
<table class="table-auto w-full border-collapse border">
|
||||
{{-- <thead class="bg-gray-100"> --}}
|
||||
<thead class="bg-gray-100 text-xs">
|
||||
<tr>
|
||||
<th class="border p-2">No</th>
|
||||
<th class="border p-2">Reference No</th>
|
||||
<th class="border p-2">Serial Number</th>
|
||||
<th class="border p-2">Created By</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{{-- <tbody> --}}
|
||||
<tbody class="text-xs">
|
||||
@forelse($records as $index => $record)
|
||||
<tr>
|
||||
<td class="border p-2 text-center">{{ $index + 1 }}</td>
|
||||
<td class="border p-2 text-center">{{ $refNumber }}</td>
|
||||
<td class="border p-2 text-center">{{ $record['serial_number'] }}</td>
|
||||
<td class="border p-2 text-center">{{ $record->created_by }}</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td class="border p-2 text-center" colspan="4">No serial numbers found.</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
window.addEventListener('focus-serial-number', () => {
|
||||
setTimeout(() => {
|
||||
const container = document.getElementById('serial_number_input');
|
||||
const input = container?.querySelector('input'); // gets the actual input inside
|
||||
|
||||
if (input) {
|
||||
input.focus();
|
||||
input.select();
|
||||
}
|
||||
}, 50);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
92
resources/views/pdf/qrcode.blade.php
Normal file
92
resources/views/pdf/qrcode.blade.php
Normal file
@@ -0,0 +1,92 @@
|
||||
{{-- <!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body { text-align: center; font-family: Arial, sans-serif; }
|
||||
.qr-container { margin-top: 30px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="qr-container">
|
||||
<img src="data:image/png;base64,{{ $qrCode }}" width="250" height="250">
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html> --}}
|
||||
|
||||
|
||||
{{-- <!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
@page {
|
||||
margin: 0;
|
||||
size: 100mm 100mm;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100mm;
|
||||
height: 100mm;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
img {
|
||||
width: 100mm;
|
||||
height: 100mm;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<img src="data:image/png;base64,{{ $qrCode }}" />
|
||||
|
||||
</body>
|
||||
</html> --}}
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
@page {
|
||||
margin: 0;
|
||||
size: 100mm 100mm;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100mm;
|
||||
height: 100mm;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
img {
|
||||
width: 90mm; /* QR CODE REDUCED TO FIT TEXT */
|
||||
height: 90mm;
|
||||
}
|
||||
.ref-text {
|
||||
margin-top: 3mm;
|
||||
font-size: 16px; /* Increased Font Size */
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="ref-text">
|
||||
{{ $referenceNumber }}
|
||||
</div>
|
||||
<img src="data:image/png;base64,{{ $qrCode }}" />
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user