Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/inikoo/aiku into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Ganes556 committed Feb 21, 2025
2 parents 6391890 + b003ee7 commit 78d6af2
Show file tree
Hide file tree
Showing 9 changed files with 301 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function handle(PalletReturnItem $palletReturnItem, array $modelData): Pa
return DB::transaction(function () use ($palletReturnItem, $modelData) {
$quantity = Arr::get($modelData, 'quantity_picked');
$palletStoredItemQuantity = $palletReturnItem->palletStoredItem->quantity;

$this->update($palletReturnItem, $modelData);

StoreStoredItemMovementFromPicking::run($palletReturnItem, [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* author Arya Permana - Kirin
* created on 21-02-2025-14h-59m
Expand All @@ -14,7 +15,6 @@
use App\InertiaTable\InertiaTable;
use App\Models\Fulfilment\FulfilmentCustomer;
use App\Models\Fulfilment\Pallet;
use App\Models\Fulfilment\StoredItem;
use App\Models\Fulfilment\StoredItemAudit;
use App\Models\Fulfilment\StoredItemAuditDelta;
use App\Services\QueryBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
use App\Actions\Traits\Authorisations\WithFulfilmentAuthorisation;
use App\Enums\Fulfilment\StoredItemAudit\StoredItemAuditStateEnum;
use App\Http\Resources\Fulfilment\FulfilmentCustomerResource;
use App\Http\Resources\Fulfilment\NewStoredItemDeltasInProcessForPalletResource;
use App\Http\Resources\Fulfilment\StoredItemAuditDeltasResource;
use App\Http\Resources\Fulfilment\StoredItemAuditResource;
use App\Http\Resources\Fulfilment\StoredItemDeltasInProcessForPalletResource;
use App\Models\Fulfilment\Fulfilment;
use App\Models\Fulfilment\FulfilmentCustomer;
use App\Models\Fulfilment\Pallet;
Expand Down Expand Up @@ -84,8 +82,46 @@ public function htmlResponse(StoredItemAudit $storedItemAudit, ActionRequest $re
'label' => __('Add SKU'),
]
];
$editDeltas = StoredItemDeltasInProcessForPalletResource::collection(IndexStoredItemDeltasInProcessForPallet::run($storedItemAudit, 'edit_stored_item_deltas'));
$editNewDeltas = NewStoredItemDeltasInProcessForPalletResource::collection(IndexNewStoredItemDeltasInProcessForPallet::run($storedItemAudit, 'new_stored_item_deltas'));
$editDeltas = $pallet->getEditStoredItemDeltasQuery($pallet->id, $storedItemAudit->id)
->where('pallet_stored_items.pallet_id', $this->id)
->get()->map(fn ($item) => [
'stored_item_audit_id' => $storedItemAudit->id,
'pallet_id' => $item->pallet_id,
'stored_item_id' => $item->stored_item_id,
'reference' => $item->stored_item_reference,
'quantity' => (int)$item->quantity,
'audited_quantity' => (int)$item->audited_quantity,
'audit_notes' => $item->audit_notes,
'stored_item_audit_delta_id' => $item->stored_item_audit_delta_id,
'audit_type' => $item->audit_type,
'update_routes' => [
'name' => 'grp.models.stored_item_audit_delta.update',
'parameters' => [
$item->stored_item_audit_delta_id
]
],
'type' => 'current_item',
]);
$editNewDeltas = $pallet->getEditNewStoredItemDeltasQuery($pallet->id)
->where('stored_item_audit_deltas.pallet_id', $pallet->id)
->where('stored_item_audit_deltas.stored_item_audit_id', $storedItemAudit->id)
->get()->map(fn ($item) => [
'stored_item_audit_id' => $storedItemAudit->id,
'stored_item_id' => $item->stored_item_id,
'reference' => $item->stored_item_reference,
'quantity' => 0,
'audited_quantity' => (int)$item->audited_quantity,
'stored_item_audit_delta_id' => $item->audit_id,
'audit_type' => $item->audit_type,
'update_routes' => [
'name' => 'grp.models.stored_item_audit_delta.update',
'parameters' => [
$item->audit_id
]
],
'audit_notes' => $item->audit_notes,
'type' => 'new_item'
]);
} else {
$deltas = StoredItemAuditDeltasResource::collection(IndexStoredItemAuditDeltas::run($storedItemAudit, 'stored_item_deltas'));
}
Expand Down Expand Up @@ -165,8 +201,8 @@ public function htmlResponse(StoredItemAudit $storedItemAudit, ActionRequest $re
],

'data' => StoredItemAuditResource::make($storedItemAudit),
'edit_stored_item_deltas' => $editDeltas,
'edit_new_stored_item_deltas' => $editNewDeltas,
'xstored_items' => $editDeltas,
'xnew_stored_items' => $editNewDeltas,
'stored_item_deltas' => $deltas,
'fulfilment_customer' => FulfilmentCustomerResource::make($storedItemAudit->fulfilmentCustomer)->getArray()
]
Expand Down
55 changes: 55 additions & 0 deletions app/Actions/HumanResources/Timesheet/Pdf/PdfTimesheet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/*
* Author: Raul Perusquia <raul@inikoo.com>
* Created: Thu, 25 Jul 2024 14:54:12 Malaysia Time, Kuala Lumpur, Malaysia
* Copyright (c) 2024, Raul A Perusquia Flores
*/

namespace App\Actions\HumanResources\Timesheet\Pdf;

use App\Actions\Traits\WithExportData;
use App\Models\SysAdmin\Organisation;
use Lorisleiva\Actions\ActionRequest;
use Lorisleiva\Actions\Concerns\AsAction;
use Lorisleiva\Actions\Concerns\WithAttributes;
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf as PDF;
use Symfony\Component\HttpFoundation\Response;

class PdfTimesheet
{
use AsAction;
use WithAttributes;
use WithExportData;

/**
* @throws \Mpdf\MpdfException
*/
public function handle(Organisation $organisation)
{
$filename = __('Timesheets - ') . $organisation->name . '.pdf';
$config = [
'title' => $filename,
'margin_left' => 8,
'margin_right' => 8,
'margin_top' => 2,
'margin_bottom' => 2,
'auto_page_break' => true,
'auto_page_break_margin' => 10
];

return PDF::chunkLoadView('<html-separator/>', 'hr.timesheets', [
'filename' => $filename,
'organisation' => $organisation,
'employees' => $organisation->employees()->limit(10)->get(),
], [], $config)->stream($filename);
}

/**
* @throws \Mpdf\MpdfException
*/
public function asController(Organisation $organisation, ActionRequest $request): Response
{
return $this->handle($organisation);
}
}
21 changes: 19 additions & 2 deletions app/Actions/HumanResources/Timesheet/UI/IndexTimesheets.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function handle(Group|Organisation|Employee|Guest $parent, ?string $prefi
$query->whereDate('timesheets.date', now()->format('Y-m-d'));
}

$query->withFilterPeriod('created_at');
$query->withFilterPeriod('date');
$query->select([
'timesheets.id',
'timesheets.date',
Expand Down Expand Up @@ -228,7 +228,24 @@ public function htmlResponse(LengthAwarePaginator $timesheets, ActionRequest $re
'afterTitle' => $afterTitle,
'iconRight' => $iconRight,
'subNavigation' => $subNavigation,
],
'actions' => [
[
'type' => 'button',
'style' => 'tertiary',
'label' => 'PDF',
'target' => '_blank',
'icon' => 'fal fa-file-pdf',
'key' => 'action',
'route' => [
'name' => 'grp.org.hr.timesheets.export',
'parameters' => [
'organisation' => $this->parent->slug,
...$request->query,
]
]
]
]
],

'tabs' => [
'current' => $this->tab,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* author Arya Permana - Kirin
* created on 21-02-2025-15h-04m
Expand Down
3 changes: 2 additions & 1 deletion app/Services/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,14 @@ public function whereRadioFilter(

public function withFilterPeriod($column, ?string $prefix = null): static
{
$table = $this->getModel()->getTable();
$periodType = array_key_first(request()->input(($prefix ? $prefix.'_' : '').'period') ?? []);

if ($periodType) {
$periodData = $this->validatePeriod($periodType, $prefix);

if ($periodData) {
$this->whereBetween($column, [$periodData['start'], $periodData['end']]);
$this->whereBetween($table.'.'.$column, [$periodData['start'], $periodData['end']]);
}
}

Expand Down
178 changes: 178 additions & 0 deletions resources/views/hr/timesheets.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
<html>
<head>
<title>{{ $filename }}</title>
<style>
@page {
size: 8.27in 11.69in; /* <length>{1,2} | auto | portrait | landscape */
/* 'em' 'ex' and % are not allowed; length values are width height */
margin-top: 15%; /* <any of the usual CSS values for margins> */
/*(% of page-box width for LR, of height for TB) */
margin-bottom: 13%;
margin-right: 8%;
margin-left: 8%;
margin-header: 1mm; /* <any of the usual CSS values for margins> */
margin-footer: 5mm; /* <any of the usual CSS values for margins> */
marks: 'cross'; /*crop | cross | none*/
header: myheader;
footer: myfooter;
/* background: ...
background-image: ...
background-position ...
background-repeat ...
background-color ...
background-gradient: ... */
}
body {
font-family: sans-serif;
font-size: 10pt;
}
p {
margin: 0pt;
}
h1 {
font-size: 14pt
}
td {
vertical-align: top;
}
.items td {
border-left: 0.1mm solid #000000;
border-right: 0.1mm solid #000000;
border-bottom: 0.1mm solid #cfcfcf;
padding-bottom: 4px;
padding-top: 5px;
}
.items tbody.out_of_stock td {
color: #777;
font-style: italic
}
.items tbody.totals td {
text-align: right;
border: 0.1mm solid #222;
}
.items tr.total_net td {
border-top: 0.3mm solid #000;
}
.items tr.total td {
border-top: 0.3mm solid #000;
border-bottom: 0.3mm solid #000;
}
.items tr.last td {
border-bottom: 0.1mm solid #000000;
}
table thead td, table tr.title td {
background-color: #EEEEEE;
text-align: center;
border: 0.1mm solid #000000;
}
.items td.blanktotal {
background-color: #FFFFFF;
border: 0mm none #000000;
border-top: 0.1mm solid #000000;
border-right: 0.1mm solid #000000;
}
div.inline {
float: left;
}
.clearBoth {
clear: both;
}
.hide {
display: none
}
</style>
</head>

<body>
<htmlpageheader name="myheader">
<br><br>
<table width="100%" style="font-size: 9pt;">
<tr>
<td style="width:250px;padding-left:10px;">
{{$organisation->name}}
<div style="font-size:7pt">
{{$organisation->name}}
</div>
<div style="font-size:7pt">
{{$organisation->address->address_line_1}}
</div>
<div style="font-size:7pt">
{{$organisation->address->address_line_2}}
</div>
<div style="font-size:7pt">
{{$organisation->address->locality}} {{$organisation->address->postal_code}}
</div>
<div style="font-size:7pt">
www.{{$organisation->email}}
</div>
</td>
</tr>
</table>
</htmlpageheader>

<sethtmlpageheader name="myheader" value="on" show-this-page="1"/>
<sethtmlpagefooter name="myfooter" value="on"/>

@foreach($employees as $employee)
<table width="100%" style="font-family: sans-serif; margin-top: 20px" cellpadding="0">
<tr>
<td width="50%" style="vertical-align:bottom;border: 0mm solid #888888;">
<div>
<div>
{{ __('Employee') }}</b>
({{ $employee->contact_name }})
</div>
</div>
</td>
</tr>
</table>
<br>
<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse;" cellpadding="8">
<thead>
<tr>
<td style="width:14%;text-align:left">{{ __('Date') }}</td>
<td style="text-align:left">{{ __('Start At') }}</td>
<td style="text-align:left">{{ __('End At') }}</td>
<td style="text-align:left;width:20% ">{{ __('Break Duration') }}</td>
</tr>
</thead>
<tbody>

@foreach($employee->timesheets as $timesheet)
<tr class="@if($loop->last) last @endif">
<td style="text-align:left">{{ $timesheet->date?->format('Y-m-d') }}</td>
<td style="text-align:left">{{ $timesheet->start_at?->format('Y-m-d H:i') }}</td>
<td style="text-align:right">{{ $timesheet->end_at?->format('Y-m-d H:i') }}</td>
<td style="text-align:right">{{ Carbon\CarbonInterval::seconds($timesheet->breaks_duration)->cascade()->forHumans() }}</td>
</tr>
@endforeach

</tbody>
</table>
<br>
@endforeach
<htmlpagefooter name="myfooter">
<div>

</div>
</htmlpagefooter>
</body>
</html>
Loading

0 comments on commit 78d6af2

Please sign in to comment.