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
KirinZero0 committed Feb 21, 2025
2 parents 1d217a0 + 4e15500 commit 07b489b
Show file tree
Hide file tree
Showing 11 changed files with 318 additions and 33 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
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
1 change: 1 addition & 0 deletions app/Actions/Traits/WithDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ protected function getIntervalPercentage($intervalData, string $prefix, $key, $t

public function getDateIntervalFilter($interval): string
{
// TODO: #1461
$intervals = [
'1y' => now()->subYear(),
'1q' => now()->subQuarter(),
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
15 changes: 10 additions & 5 deletions 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 Expand Up @@ -184,10 +185,14 @@ public function withBetweenDates(array $allowedColumns, ?string $prefix = null):

if (count($parts) === 2) {
[$start, $end] = $parts;

// Normalize the start and end dates
$start = trim($start) . ' 00:00:00';
$end = trim($end) . ' 23:59:59';
// TODO: #1461
if ($start == $end) {
$start = trim($start) . ' 00:00:00';
$end = trim($end) . ' ' . now()->format('H:i:s');
} else {
$start = trim($start) . ' ' . now()->format('H:i:s');
$end = trim($end) . ' ' . now()->format('H:i:s');
}

$this->whereBetween("$table.$column", [$start, $end]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,32 +135,60 @@ function NumberDashboard(shop: any) {
return route(shop?.name, shop?.parameters)
}
const setChartOptions = () => ({
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
display: false,
},
tooltip: {
callbacks: {
title: (tooltipItems) => {
const index = tooltipItems[0].dataIndex
return props.visual.label[index]
const setChartOptions = () => {
// Base chart options
const options: any = {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
display: false,
},
tooltip: {
callbacks: {
title: function (tooltipItems) {
if (
props.visual &&
props.visual.value.hover_labels &&
tooltipItems.length > 0
) {
return props.visual.value.hover_labels[tooltipItems[0].dataIndex]
}
return tooltipItems[0].label
},
label: (context) => {
const value = parseFloat(context.parsed.y ?? context.parsed) || 0
const currencyCode = props.widget.currency_code
if (currencyCode) {
return locale.currencyFormat(currencyCode, value)
}
return locale.number(value)
},
},
},
},
}
label: (context) => {
const index = context.dataIndex
const hoverLabels = props.visual.hoverLabels
if (hoverLabels && hoverLabels[index]) {
return hoverLabels[index]
}
return context.formattedValue
// Only apply y-axis currency formatting for bar charts
if (props.visual && props.visual.type === "bar") {
options.scales = {
y: {
ticks: {
callback: (value) => {
const numericValue = Number(value) || 0
const currencyCode = props.widget.currency_code
if (currencyCode) {
return locale.currencyFormat(currencyCode, numericValue)
}
return locale.number(numericValue)
},
},
},
},
},
})
}
}
return options
}
// const chartLabels = ["1", "2", "3", "4", "5", "6", "7", "8"]
// const chartData = [10, 20, 15, 25, 20, 18, 22, 10]
Expand Down
Loading

0 comments on commit 07b489b

Please sign in to comment.