setting potongan gaji done

dev
ajikamaludin 2 years ago
parent 3a30d72203
commit 4029cd099f
Signed by: ajikamaludin
GPG Key ID: 476C9A2B4B794EBB

@ -26,4 +26,9 @@ class GeneralController extends Controller
{
return Inertia::render('Absensi/Index');
}
public function settingPotongGaji()
{
return Inertia::render('SettingPotongGaji/Index');
}
}

@ -6,6 +6,7 @@
"license": "MIT",
"require": {
"php": "^8.0.2",
"doctrine/dbal": "^3.3",
"guzzlehttp/guzzle": "^7.2",
"inertiajs/inertia-laravel": "^0.5.4",
"laravel/framework": "^9.19",

392
composer.lock generated

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "d22617b9b9a496fbcc2adf245b092300",
"content-hash": "bebfb1e58c7b84a1ae43e8f920244de6",
"packages": [
{
"name": "brick/math",
@ -141,6 +141,347 @@
},
"time": "2021-08-13T13:06:58+00:00"
},
{
"name": "doctrine/cache",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/cache.git",
"reference": "1ca8f21980e770095a31456042471a57bc4c68fb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/1ca8f21980e770095a31456042471a57bc4c68fb",
"reference": "1ca8f21980e770095a31456042471a57bc4c68fb",
"shasum": ""
},
"require": {
"php": "~7.1 || ^8.0"
},
"conflict": {
"doctrine/common": ">2.2,<2.4"
},
"require-dev": {
"cache/integration-tests": "dev-master",
"doctrine/coding-standard": "^9",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"psr/cache": "^1.0 || ^2.0 || ^3.0",
"symfony/cache": "^4.4 || ^5.4 || ^6",
"symfony/var-exporter": "^4.4 || ^5.4 || ^6"
},
"type": "library",
"autoload": {
"psr-4": {
"Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.",
"homepage": "https://www.doctrine-project.org/projects/cache.html",
"keywords": [
"abstraction",
"apcu",
"cache",
"caching",
"couchdb",
"memcached",
"php",
"redis",
"xcache"
],
"support": {
"issues": "https://github.com/doctrine/cache/issues",
"source": "https://github.com/doctrine/cache/tree/2.2.0"
},
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "custom"
},
{
"url": "https://www.patreon.com/phpdoctrine",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcache",
"type": "tidelift"
}
],
"time": "2022-05-20T20:07:39+00:00"
},
{
"name": "doctrine/dbal",
"version": "3.3.7",
"source": {
"type": "git",
"url": "https://github.com/doctrine/dbal.git",
"reference": "9f79d4650430b582f4598fe0954ef4d52fbc0a8a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/9f79d4650430b582f4598fe0954ef4d52fbc0a8a",
"reference": "9f79d4650430b582f4598fe0954ef4d52fbc0a8a",
"shasum": ""
},
"require": {
"composer-runtime-api": "^2",
"doctrine/cache": "^1.11|^2.0",
"doctrine/deprecations": "^0.5.3|^1",
"doctrine/event-manager": "^1.0",
"php": "^7.3 || ^8.0",
"psr/cache": "^1|^2|^3",
"psr/log": "^1|^2|^3"
},
"require-dev": {
"doctrine/coding-standard": "9.0.0",
"jetbrains/phpstorm-stubs": "2022.1",
"phpstan/phpstan": "1.7.13",
"phpstan/phpstan-strict-rules": "^1.2",
"phpunit/phpunit": "9.5.20",
"psalm/plugin-phpunit": "0.16.1",
"squizlabs/php_codesniffer": "3.7.0",
"symfony/cache": "^5.2|^6.0",
"symfony/console": "^2.7|^3.0|^4.0|^5.0|^6.0",
"vimeo/psalm": "4.23.0"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
},
"bin": [
"bin/doctrine-dbal"
],
"type": "library",
"autoload": {
"psr-4": {
"Doctrine\\DBAL\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
}
],
"description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.",
"homepage": "https://www.doctrine-project.org/projects/dbal.html",
"keywords": [
"abstraction",
"database",
"db2",
"dbal",
"mariadb",
"mssql",
"mysql",
"oci8",
"oracle",
"pdo",
"pgsql",
"postgresql",
"queryobject",
"sasql",
"sql",
"sqlite",
"sqlserver",
"sqlsrv"
],
"support": {
"issues": "https://github.com/doctrine/dbal/issues",
"source": "https://github.com/doctrine/dbal/tree/3.3.7"
},
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "custom"
},
{
"url": "https://www.patreon.com/phpdoctrine",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal",
"type": "tidelift"
}
],
"time": "2022-06-13T21:43:03+00:00"
},
{
"name": "doctrine/deprecations",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/deprecations.git",
"reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de",
"reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de",
"shasum": ""
},
"require": {
"php": "^7.1|^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^9",
"phpunit/phpunit": "^7.5|^8.5|^9.5",
"psr/log": "^1|^2|^3"
},
"suggest": {
"psr/log": "Allows logging deprecations via PSR-3 logger implementation"
},
"type": "library",
"autoload": {
"psr-4": {
"Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.",
"homepage": "https://www.doctrine-project.org/",
"support": {
"issues": "https://github.com/doctrine/deprecations/issues",
"source": "https://github.com/doctrine/deprecations/tree/v1.0.0"
},
"time": "2022-05-02T15:47:09+00:00"
},
{
"name": "doctrine/event-manager",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/event-manager.git",
"reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/event-manager/zipball/41370af6a30faa9dc0368c4a6814d596e81aba7f",
"reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"conflict": {
"doctrine/common": "<2.9@dev"
},
"require-dev": {
"doctrine/coding-standard": "^6.0",
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Common\\": "lib/Doctrine/Common"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
},
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com"
}
],
"description": "The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.",
"homepage": "https://www.doctrine-project.org/projects/event-manager.html",
"keywords": [
"event",
"event dispatcher",
"event manager",
"event system",
"events"
],
"support": {
"issues": "https://github.com/doctrine/event-manager/issues",
"source": "https://github.com/doctrine/event-manager/tree/1.1.x"
},
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "custom"
},
{
"url": "https://www.patreon.com/phpdoctrine",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Fevent-manager",
"type": "tidelift"
}
],
"time": "2020-05-29T18:28:51+00:00"
},
{
"name": "doctrine/inflector",
"version": "2.0.4",
@ -2234,6 +2575,55 @@
],
"time": "2021-12-04T23:24:31+00:00"
},
{
"name": "psr/cache",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/cache.git",
"reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf",
"reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf",
"shasum": ""
},
"require": {
"php": ">=8.0.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Cache\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for caching libraries",
"keywords": [
"cache",
"psr",
"psr-6"
],
"support": {
"source": "https://github.com/php-fig/cache/tree/3.0.0"
},
"time": "2021-02-03T23:26:27+00:00"
},
{
"name": "psr/container",
"version": "2.0.2",

@ -105,48 +105,48 @@ export default function Authenticated({ auth, children }) {
</div>
</nav>
<div className='flex flex-row md:mt-5 mx-auto max-w-7xl'>
<div className='flex flex-row md:mt-5 mx-au max-w-7xl mx-auto'>
<div className='w-auto hidden md:block'>
<aside className="w-64" aria-label="Sidebar">
<div className="overflow-y-auto py-4 px-3 bg-white rounded dark:bg-gray-800">
<ul className="space-y-2">
<li>
<Link href={route('dashboard')} className="flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700">
<Link href={route('dashboard')} className={`flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white ${route().current('dashboard') ? 'bg-gray-100' : 'hover:bg-gray-100'} dark:hover:bg-gray-700`}>
<span className="ml-3">Dashboard</span>
</Link>
</li>
<li>
<Link href={route('jabatan')} className="flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700">
<Link href={route('jabatan')} className={`flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white ${route().current('jabatan') ? 'bg-gray-100' : 'hover:bg-gray-100'} dark:hover:bg-gray-700`}>
<span className="flex-1 ml-3 whitespace-nowrap">Jabatan</span>
</Link>
</li>
<li>
<Link href={route('karyawan')} className="flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700">
<Link href={route('karyawan')} className={`flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white ${route().current('karyawan') ? 'bg-gray-100' : 'hover:bg-gray-100'} dark:hover:bg-gray-700`}>
<span className="flex-1 ml-3 whitespace-nowrap">Karyawan</span>
</Link>
</li>
<li>
<Link href={route('absensi')} className="flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700">
<Link href={route('absensi')} className={`flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white ${route().current('absensi') ? 'bg-gray-100' : 'hover:bg-gray-100'} dark:hover:bg-gray-700`}>
<span className="flex-1 ml-3 whitespace-nowrap">Data Absensi</span>
</Link>
</li>
<li>
<Link href={route('dashboard')} className="flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700">
<Link href={route('setting.potongan.gaji')} className={`flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white ${route().current('setting.potongan.gaji') ? 'bg-gray-100' : 'hover:bg-gray-100'} dark:hover:bg-gray-700`}>
<span className="flex-1 ml-3 whitespace-nowrap">Setting Potongan Gaji</span>
</Link>
</li>
<li>
<Link href={route('dashboard')} className="flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700">
<span className="flex-1 ml-3 whitespace-nowrap">Cetak Slip Gaji</span>
<Link href={route('dashboard')} className={`flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white ${route().current('cetak.slip.gaji') ? 'bg-gray-100' : 'hover:bg-gray-100'} dark:hover:bg-gray-700`}>
<span className="flex-1 ml-3 whitespace-nowrap">Data Gaji</span>
</Link>
</li>
<li>
<Link href={route('dashboard')} className="flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700">
<Link href={route('dashboard')} className={`flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white ${route().current('cetak.laporan.gaji') ? 'bg-gray-100' : 'hover:bg-gray-100'} dark:hover:bg-gray-700`}>
<span className="flex-1 ml-3 whitespace-nowrap">Cetak Laporan Gaji</span>
</Link>
</li>
<li>
<Link href={route('dashboard')} className="flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700">
<Link href={route('dashboard')} className={`flex items-center p-2 text-base font-normal text-gray-900 rounded-lg dark:text-white ${route().current('cetak.laporan.presensi') ? 'bg-gray-100' : 'hover:bg-gray-100'} dark:hover:bg-gray-700`}>
<span className="flex-1 ml-3 whitespace-nowrap">Cetak Laporan Presensi</span>
</Link>
</li>

@ -7,7 +7,7 @@ import Input from '@/Components/Input'
import { getAll } from '@/Services/Karyawan'
import { create } from '@/Services/Absensi'
export default function FormModal({ modalState, periode, refresh }) {
export default function FormModal({ modalState, periode }) {
const [loading, setLoading] = useState(false)
const { data, setData, reset } = useForm({
users: []
@ -53,6 +53,7 @@ export default function FormModal({ modalState, periode, refresh }) {
.then(() => {
reset()
modalState.toggle()
toast.success("berhasil menambahkan absensi")
})
.finally(() => setLoading(false))
}

@ -53,6 +53,9 @@ export default function Karyawan(props) {
<div className="max-w-7xl sm:px-6">
<div className="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div className="p-6 bg-white border-b border-gray-200">
<div className='mb-5 text-3xl font-semibold'>
Absensi
</div>
<div className='flex flex-col md:flex-row space-y-1 md:space-y-0 justify-between'>
<div className='flex space-x-1 items-center'>
<p>Periode Data :</p>

@ -46,6 +46,9 @@ export default function Jabatan(props) {
<div className="max-w-7xl sm:px-6">
<div className="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div className="p-6 bg-white border-b border-gray-200">
<div className='mb-5 text-3xl font-semibold'>
Jabatan
</div>
<Button onClick={formModal.toggle}>Tambah</Button>
<div className="overflow-x-auto relative pt-5">
<table className="w-full text-sm text-left text-gray-500 dark:text-gray-400">

@ -45,6 +45,9 @@ export default function Karyawan(props) {
<div className="max-w-7xl sm:px-6">
<div className="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div className="p-6 bg-white border-b border-gray-200">
<div className='mb-5 text-3xl font-semibold'>
Karyawan
</div>
<Button onClick={formModal.toggle}>Tambah</Button>
<div className="overflow-x-auto relative pt-5">
<table className="w-full text-sm text-left text-gray-500 dark:text-gray-400">
@ -68,14 +71,14 @@ export default function Karyawan(props) {
<td className="py-4 px-6">
{item.data.jabatan.nama}
</td>
<th>
<td>
<div className='flex space-x-1'>
<Button onClick={() => handleEditClick(item)}>Edit</Button>
{item.data.jabatan.id != "1" && (
<Button onClick={() => hanldeDeleteClick(item)}>Hapus</Button>
)}
</div>
</th>
</td>
</tr>
))}
</tbody>

@ -0,0 +1,100 @@
import React, { useEffect, useState } from 'react'
import { toast } from 'react-toastify'
import { Modal } from '@/Components/Modal'
import { useForm } from '@inertiajs/inertia-react'
import Button from '@/Components/Button'
import Input from '@/Components/Input'
import { create, update } from '@/Services/SettingPotonganGaji'
export default function FormModal({ modalState, refresh }) {
const [loading, setLoading] = useState(false)
const { data, setData, reset } = useForm({
jenis: 'alfa',
potongan: 0
})
useEffect(() => {
if (modalState.isOpen === false) {
reset()
modalState.setData(null)
}
if (modalState.data !== null) {
setData(modalState.data.data)
}
}, [modalState])
const onHandleChange = (event) => {
setData(
event.target.name,
event.target.type === 'checkbox'
? event.target.checked
: event.target.value
)
}
const submit = (e) => {
e.preventDefault()
setLoading(true)
if (modalState.data !== null) {
update(data, modalState.data.id)
.finally(() => {
reset()
toast.success("berhasil update")
setLoading(false)
modalState.toggle()
refresh()
})
} else {
create(data)
.then((id) => console.log(id))
.finally(() => {
reset()
toast.success("berhasil simpan")
setLoading(false)
modalState.toggle()
refresh()
})
}
}
return (
<Modal isOpen={modalState.isOpen} toggleModal={modalState.toggle}>
<div className="text-lg font-bold">Setting Potongan Gaji</div>
<label className="block text-sm mt-4">
<span className="text-gray-700 dark:text-gray-400">
Jenis Potongan
</span>
<select
className="border mt-1 border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
value={data.jenis}
name="jenis"
onChange={onHandleChange}
>
{["alfa", "sakit"].map((val, index) => (
<option
key={`val-${index}`}
value={val}
>
{val}
</option>
))}
</select>
</label>
<label className="block text-sm mt-4">
<span className="text-gray-700 dark:text-gray-400">
Jumlah Potongan
</span>
<Input
placeholder="081XXX"
name="potongan"
value={data.potongan}
handleChange={onHandleChange}
type="number"
/>
</label>
<Button className={'mt-4'} onClick={submit} disabled={loading} processing={loading}>
Save
</Button>
</Modal>
)
}

@ -0,0 +1,95 @@
import React, { useEffect, useState } from 'react';
import Authenticated from '@/Layouts/Authenticated';
import { Head } from '@inertiajs/inertia-react';
import { useModalState } from '@/Hooks'
import Button from '@/Components/Button';
import FormModal from './FormModal';
import { getAll } from '@/Services/SettingPotonganGaji';
import { toast } from 'react-toastify';
import { formatIDR } from '@/Utils';
export default function Karyawan(props) {
const formModal = useModalState(false)
const [items, setItems] = useState([])
const hanldeDeleteClick = (item) => {
const con = confirm("delete item?")
if (con) {
deleteById(item.id)
.then(() => toast.success('berhasil hapus'))
.finally(() => fetchData())
}
}
const handleEditClick = (item) => {
formModal.setData(item)
formModal.toggle()
}
const fetchData = () => {
getAll()
.then(items => {
console.log(items)
setItems(items)
})
}
useEffect(() => {
fetchData()
}, [])
return (
<Authenticated
auth={props.auth}
errors={props.errors}
>
<Head title="Potongan Gaji" />
<div className="py-0">
<div className="max-w-7xl sm:px-6">
<div className="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div className="p-6 bg-white border-b border-gray-200">
<div className='mb-5 text-3xl font-semibold'>
Setting Potongan Gaji
</div>
<Button onClick={formModal.toggle}>Tambah</Button>
<table className="w-full text-sm text-left text-gray-500 dark:text-gray-400 mt-5">
<thead className="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
<tr>
<th scope="col" className="py-3 px-6">
Jenis Potongan
</th>
<th scope="col" className="py-3 px-6">
Jumlah Potongan
</th>
<th scope="col" className="py-3 px-6"></th>
</tr>
</thead>
<tbody>
{items.map(item => (
<tr key={item.id} className="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
<th scope="row" className="py-4 px-6 font-medium text-gray-900 whitespace-nowrap dark:text-white">
{item.data.jenis}
</th>
<td className="py-4 px-6">
Rp. {formatIDR(item.data.potongan)}
</td>
<td>
<div className='flex space-x-1'>
<Button onClick={() => handleEditClick(item)}>Edit</Button>
<Button onClick={() => hanldeDeleteClick(item)}>Hapus</Button>
</div>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
</div>
</div>
<FormModal modalState={formModal}refresh={fetchData}/>
</Authenticated>
);
}

@ -0,0 +1,33 @@
import { useState } from "react";
import db from "@/firebase";
import { collection, getDocs, doc, addDoc, deleteDoc, updateDoc, query, where } from "firebase/firestore";
import { getAll as getKaryawan } from './Karyawan'
import { getAll as getJabatan } from './Jabatan'
async function getDataGaji() {
const [lists, setLists] = useState([])
const [jabatans, setJabatan] = useState([])
Promise.all([
() => getJabatan().then(items => setJabatan(items)),
() => getKaryawan().then(items => {
const employees = items.map(employee => {
const jab = jabatans.find(item => item.id == employee.data.jabatan.id)
// TODO: fetch potongan
return {
...employee,
gajiPokok: jab.gajiPokok,
tunjangan: jab.tunjangan,
feePenjualan: jab.feePenjualan,
transport: jab.transport,
uangMakan: jab.uangMakan,
bonus: jab.bonus,
total: jab.total
}
})
setLists(employees)
}),
])
return lists
}

@ -15,6 +15,21 @@ async function getAll() {
return lists
}
async function getByNama(nama) {
const collect = query(collection(db, COLLECTION), where("nama", "==", nama))
const data = await getDocs(collect)
if (data.size <= 0) {
return []
}
const lists = data.docs.map(doc => {
return {
...doc.data(),
id: doc.id
}
})
return lists
}
async function create(payload) {
const docRef = await addDoc(collection(db, COLLECTION), payload)
return docRef.id

@ -0,0 +1,41 @@
import db from "@/firebase";
import { collection, getDocs, doc, addDoc, deleteDoc, updateDoc } from "firebase/firestore";
const COLLECTION = "setting.potongan.gaji"
async function getAll() {
const collect = collection(db, COLLECTION)
const data = await getDocs(collect)
const lists = data.docs.map(doc => {
return {
data: doc.data(),
id: doc.id
}
})
return lists
}
async function create(payload) {
const docRef = await addDoc(collection(db, COLLECTION), payload)
return docRef.id
}
async function update(payload, id){
const docRef = doc(db, COLLECTION, id)
const result = await updateDoc(docRef, payload);
return result
}
async function deleteById(id) {
console.log(id)
const docRef = doc(db, COLLECTION, id)
const result = await deleteDoc(docRef);
return result
}
export {
getAll,
create,
update,
deleteById
}

@ -32,5 +32,6 @@ Route::middleware([IsSessionAuth::class])->group(function () {
Route::get('/jabatan', [GeneralController::class, 'jabatan'])->name('jabatan');
Route::get('/karyawan', [GeneralController::class, 'karyawan'])->name('karyawan');
Route::get('/absensi', [GeneralController::class, 'absensi'])->name('absensi');
Route::get('/setting-potong-gaji', [GeneralController::class, 'settingPotongGaji'])->name('setting.potongan.gaji');
Route::post('/logout', [AuthController::class, 'destroy'])->name('logout');
});

Loading…
Cancel
Save