deposit sort
parent
d42065944b
commit
5cf19db71d
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class CustomerHistoryController extends Controller
|
||||
{
|
||||
public function deposit()
|
||||
{
|
||||
}
|
||||
|
||||
public function sale()
|
||||
{
|
||||
}
|
||||
|
||||
public function paylater()
|
||||
{
|
||||
}
|
||||
|
||||
public function paylater_limit()
|
||||
{
|
||||
}
|
||||
|
||||
public function paylater_deadline()
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,176 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { Link, router } from '@inertiajs/react'
|
||||
import { usePrevious } from 'react-use'
|
||||
import { Head } from '@inertiajs/react'
|
||||
import { HiEye } from 'react-icons/hi2'
|
||||
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
|
||||
import Pagination from '@/Components/Pagination'
|
||||
import FormModal from './FormModal'
|
||||
import SearchInput from '@/Components/SearchInput'
|
||||
import { hasPermission } from '@/utils'
|
||||
import { useModalState } from '@/hooks'
|
||||
|
||||
export default function Index(props) {
|
||||
const {
|
||||
query: { links, data },
|
||||
auth,
|
||||
} = props
|
||||
|
||||
const [search, setSearch] = useState('')
|
||||
const preValue = usePrevious(search)
|
||||
|
||||
const formModal = useModalState()
|
||||
|
||||
const toggleFormModal = (deposit = null) => {
|
||||
formModal.setData(deposit)
|
||||
formModal.toggle()
|
||||
}
|
||||
|
||||
const params = { q: search }
|
||||
useEffect(() => {
|
||||
if (preValue) {
|
||||
router.get(
|
||||
route(route().current()),
|
||||
{ q: search },
|
||||
{
|
||||
replace: true,
|
||||
preserveState: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
}, [search])
|
||||
|
||||
const canUpdate = hasPermission(auth, 'update-deposit')
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout page={'Deposit'} action={''}>
|
||||
<Head title="Deposit" />
|
||||
|
||||
<div>
|
||||
<div className="mx-auto sm:px-6 lg:px-8 ">
|
||||
<div className="p-6 overflow-hidden shadow-sm sm:rounded-lg bg-gray-200 dark:bg-gray-800 space-y-4">
|
||||
<div className="flex justify-between">
|
||||
<div className="flex items-center">
|
||||
<SearchInput
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
value={search}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="overflow-auto">
|
||||
<div>
|
||||
<table className="w-full text-sm text-left text-gray-500 dark:text-gray-400 mb-4">
|
||||
<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"
|
||||
>
|
||||
#
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
>
|
||||
Customer
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
>
|
||||
Deposit
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
>
|
||||
Tanggal
|
||||
</th>
|
||||
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
>
|
||||
Status
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
>
|
||||
Approver
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
/>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{data.map((deposit) => (
|
||||
<tr
|
||||
className="bg-white border-b dark:bg-gray-800 dark:border-gray-700"
|
||||
key={deposit.id}
|
||||
>
|
||||
<td
|
||||
scope="row"
|
||||
className="py-4 px-6 font-medium text-gray-900 whitespace-nowrap dark:text-white"
|
||||
>
|
||||
{deposit.description}
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
<Link
|
||||
className="hover:underline"
|
||||
href={route(
|
||||
'customer.edit',
|
||||
deposit.customer.id
|
||||
)}
|
||||
>
|
||||
{deposit.customer.name}
|
||||
</Link>
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
{deposit.amount}
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
{deposit.format_created_at}
|
||||
</td>
|
||||
<td
|
||||
className={`py-4 px-6 ${deposit.status.text_color}`}
|
||||
>
|
||||
{deposit.status.text}
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
{deposit.editor?.name}
|
||||
</td>
|
||||
<td className="py-4 px-6 flex justify-center">
|
||||
{canUpdate && (
|
||||
<div
|
||||
className="flex space-x-1 items-center hover:underline"
|
||||
onClick={() =>
|
||||
toggleFormModal(
|
||||
deposit
|
||||
)
|
||||
}
|
||||
>
|
||||
<HiEye />
|
||||
<div>Lihat</div>
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="w-full flex items-center justify-center">
|
||||
<Pagination links={links} params={params} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<FormModal modalState={formModal} />
|
||||
</AuthenticatedLayout>
|
||||
)
|
||||
}
|
@ -0,0 +1,212 @@
|
||||
import React, { useEffect } from 'react'
|
||||
import { Head, Link, useForm } from '@inertiajs/react'
|
||||
import { isEmpty } from 'lodash'
|
||||
|
||||
import { STATUS_APPROVE, STATUS_REJECT } from '@/constant'
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
|
||||
import FormInput from '@/Components/FormInput'
|
||||
import Button from '@/Components/Button'
|
||||
import FormInputNumeric from '@/Components/FormInputNumeric'
|
||||
|
||||
export default function Form(props) {
|
||||
const { deposit } = props
|
||||
|
||||
const { data, setData, post, processing, errors } = useForm({
|
||||
debit: 0,
|
||||
is_valid: 0,
|
||||
reject_reason: '',
|
||||
})
|
||||
|
||||
const handleOnChange = (event) => {
|
||||
setData(
|
||||
event.target.name,
|
||||
event.target.type === 'checkbox'
|
||||
? event.target.checked
|
||||
? 1
|
||||
: 0
|
||||
: event.target.value
|
||||
)
|
||||
}
|
||||
|
||||
const showForm =
|
||||
+deposit.is_valid !== STATUS_APPROVE &&
|
||||
+deposit.is_valid !== STATUS_REJECT
|
||||
|
||||
const handleSubmit = () => {
|
||||
post(route('deposit.update', deposit))
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (isEmpty(deposit) === false) {
|
||||
setData({
|
||||
debit: deposit.debit,
|
||||
is_valid: deposit.is_valid,
|
||||
reject_reason: deposit.reject_reason,
|
||||
})
|
||||
return
|
||||
}
|
||||
}, [deposit])
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout
|
||||
page={'Deposit'}
|
||||
action={'Form'}
|
||||
parent={route('deposit.index')}
|
||||
>
|
||||
<Head title="Deposit" />
|
||||
|
||||
<div>
|
||||
<div className="mx-auto sm:px-6 lg:px-8">
|
||||
<div className="overflow-hidden p-4 shadow-sm sm:rounded-lg bg-white dark:bg-gray-800 flex flex-col ">
|
||||
<div className="text-xl font-bold mb-4">Deposit</div>
|
||||
<table className="relative w-full overflow-x-auto p-2 rounded">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td className="font-bold">Customer</td>
|
||||
<td>:</td>
|
||||
<td>
|
||||
<Link
|
||||
href={route('customer.edit', {
|
||||
customer: deposit.customer,
|
||||
})}
|
||||
className="hover:underline"
|
||||
>
|
||||
{deposit.customer.name}
|
||||
</Link>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="font-bold">Deskripsi</td>
|
||||
<td>:</td>
|
||||
<td>{deposit.description}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="font-bold">
|
||||
Metode Pembayaran
|
||||
</td>
|
||||
<td>:</td>
|
||||
<td>{deposit.payment_channel}</td>
|
||||
</tr>
|
||||
{deposit.account !== null && (
|
||||
<tr>
|
||||
<td className="font-bold">Bank Akun</td>
|
||||
<td>:</td>
|
||||
<td>
|
||||
{deposit.account.name} (
|
||||
{deposit.account.bank_name})
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
{deposit.deposit_location !== null && (
|
||||
<tr>
|
||||
<td className="font-bold">
|
||||
Lokasi Cash / Setor Tunai
|
||||
</td>
|
||||
<td>:</td>
|
||||
<td>{deposit.deposit_location.name}</td>
|
||||
</tr>
|
||||
)}
|
||||
<tr>
|
||||
<td className="font-bold">Jumlah</td>
|
||||
<td>:</td>
|
||||
<td>{deposit.amount}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="font-bold">Status</td>
|
||||
<td>:</td>
|
||||
<td className={deposit.status.text_color}>
|
||||
{deposit.status.text}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="font-bold">
|
||||
Alasan Penolakan
|
||||
</td>
|
||||
<td>:</td>
|
||||
<td>{deposit.reject_reason}</td>
|
||||
</tr>
|
||||
{isEmpty(deposit.editor) === false && (
|
||||
<tr>
|
||||
<td className="font-bold">Approver</td>
|
||||
<td>:</td>
|
||||
<td>{deposit.editor.name}</td>
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{isEmpty(deposit.image_prove_url) === false && (
|
||||
<div>
|
||||
<a
|
||||
href={deposit.image_prove_url}
|
||||
target="_blank"
|
||||
>
|
||||
<img
|
||||
src={deposit.image_prove_url}
|
||||
className="w-full object-fill h-96"
|
||||
loading="lazy"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
{showForm && (
|
||||
<>
|
||||
<div className="my-4">
|
||||
<FormInputNumeric
|
||||
type="number"
|
||||
label="Jumlah Deposit"
|
||||
name="debit"
|
||||
onChange={handleOnChange}
|
||||
value={data.debit}
|
||||
error={errors.debit}
|
||||
/>
|
||||
<div className="mb-1 text-sm">Status</div>
|
||||
<select
|
||||
className="bg-gray-50 border 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"
|
||||
onChange={handleOnChange}
|
||||
value={+data.is_valid}
|
||||
name="is_valid"
|
||||
>
|
||||
<option value="">
|
||||
{' '}
|
||||
-- pilih status --{' '}
|
||||
</option>
|
||||
<option value={STATUS_APPROVE}>
|
||||
Approve
|
||||
</option>
|
||||
<option value={STATUS_REJECT}>
|
||||
Reject
|
||||
</option>
|
||||
</select>
|
||||
{errors.status && (
|
||||
<div className="text-sm text-red-500">
|
||||
{errors.status}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{+data.is_valid === STATUS_REJECT && (
|
||||
<FormInput
|
||||
label="Alasan penolakan"
|
||||
name="reject_reason"
|
||||
value={data.reject_reason}
|
||||
onChange={handleOnChange}
|
||||
error={errors.reject_reason}
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className="mt-8">
|
||||
<Button
|
||||
onClick={handleSubmit}
|
||||
processing={processing}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
)
|
||||
}
|
@ -1,208 +0,0 @@
|
||||
import React, { useEffect } from 'react'
|
||||
import { Link, useForm } from '@inertiajs/react'
|
||||
import { isEmpty } from 'lodash'
|
||||
|
||||
import { STATUS_APPROVE, STATUS_REJECT } from '@/constant'
|
||||
import Modal from '@/Components/Modal'
|
||||
import Button from '@/Components/Button'
|
||||
import FormInput from '@/Components/FormInput'
|
||||
|
||||
export default function FormModal(props) {
|
||||
const { modalState } = props
|
||||
const { data, setData, post, processing, errors, reset, clearErrors } =
|
||||
useForm({
|
||||
amount: '',
|
||||
image_prove_url: '',
|
||||
status: '',
|
||||
account: {
|
||||
name: '',
|
||||
bank_name: '',
|
||||
holder_name: '',
|
||||
account_number: '',
|
||||
},
|
||||
deposit_location: null,
|
||||
payment_channel: '',
|
||||
is_valid: 0,
|
||||
status_text: '',
|
||||
text_color: '',
|
||||
customer: '',
|
||||
description: '',
|
||||
reject_reason: '',
|
||||
})
|
||||
|
||||
const handleOnChange = (event) => {
|
||||
setData(
|
||||
event.target.name,
|
||||
event.target.type === 'checkbox'
|
||||
? event.target.checked
|
||||
? 1
|
||||
: 0
|
||||
: event.target.value
|
||||
)
|
||||
}
|
||||
|
||||
const handleReset = () => {
|
||||
modalState.setData(null)
|
||||
reset()
|
||||
clearErrors()
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
handleReset()
|
||||
modalState.toggle()
|
||||
}
|
||||
|
||||
const handleSubmit = () => {
|
||||
const deposit = modalState.data
|
||||
post(route('deposit.update', deposit), {
|
||||
onSuccess: () => handleClose(),
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const deposit = modalState.data
|
||||
if (isEmpty(deposit) === false) {
|
||||
setData({
|
||||
amount: deposit.amount,
|
||||
account: deposit.account,
|
||||
image_prove_url: deposit.image_prove_url,
|
||||
payment_channel: deposit.payment_channel,
|
||||
is_valid: deposit.is_valid,
|
||||
status_text: deposit.status.text,
|
||||
text_color: deposit.status.text_color,
|
||||
customer: deposit.customer,
|
||||
description: deposit.description,
|
||||
reject_reason: deposit.note,
|
||||
deposit_location: deposit.deposit_location,
|
||||
})
|
||||
return
|
||||
}
|
||||
}, [modalState])
|
||||
|
||||
return (
|
||||
<Modal
|
||||
isOpen={modalState.isOpen}
|
||||
toggle={handleClose}
|
||||
title={'Deposit'}
|
||||
>
|
||||
<table className="relative w-full overflow-x-auto p-2 rounded">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td className="font-bold">Customer</td>
|
||||
<td>:</td>
|
||||
<td>
|
||||
<Link
|
||||
href={route('customer.edit', {
|
||||
customer: data.customer,
|
||||
})}
|
||||
className="hover:underline"
|
||||
>
|
||||
{data.customer.name}
|
||||
</Link>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="font-bold">Deskripsi</td>
|
||||
<td>:</td>
|
||||
<td>{data.description}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="font-bold">Metode Pembayaran</td>
|
||||
<td>:</td>
|
||||
<td>{data.payment_channel}</td>
|
||||
</tr>
|
||||
{data.account !== null && (
|
||||
<tr>
|
||||
<td className="font-bold">Bank Akun</td>
|
||||
<td>:</td>
|
||||
<td>
|
||||
{data.account.name} ({data.account.bank_name})
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
{data.deposit_location !== null && (
|
||||
<tr>
|
||||
<td className="font-bold">
|
||||
Lokasi Cash / Setor Tunai
|
||||
</td>
|
||||
<td>:</td>
|
||||
<td>{data.deposit_location.name}</td>
|
||||
</tr>
|
||||
)}
|
||||
<tr>
|
||||
<td className="font-bold">Jumlah</td>
|
||||
<td>:</td>
|
||||
<td>{data.amount}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="font-bold">Status</td>
|
||||
<td>:</td>
|
||||
<td className={data.text_color}>{data.status_text}</td>
|
||||
</tr>
|
||||
{+data.is_valid === STATUS_REJECT && (
|
||||
<tr>
|
||||
<td className="font-bold">Alasan Penolakan</td>
|
||||
<td>:</td>
|
||||
<td>{data.reject_reason}</td>
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{isEmpty(data.image_prove_url) === false && (
|
||||
<div>
|
||||
<a href={data.image_prove_url} target="_blank">
|
||||
<img
|
||||
src={data.image_prove_url}
|
||||
className="w-full object-fill h-96"
|
||||
loading="lazy"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
{+data.is_valid !== STATUS_APPROVE &&
|
||||
+data.is_valid !== STATUS_REJECT && (
|
||||
<>
|
||||
<div className="my-4">
|
||||
<div className="mb-1 text-sm">Status </div>
|
||||
<select
|
||||
className="bg-gray-50 border 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"
|
||||
onChange={handleOnChange}
|
||||
value={+data.status}
|
||||
name="status"
|
||||
>
|
||||
<option value=""> -- pilih status -- </option>
|
||||
<option value={STATUS_APPROVE}>Approve</option>
|
||||
<option value={STATUS_REJECT}>Reject</option>
|
||||
</select>
|
||||
{errors.status && (
|
||||
<div className="text-sm text-red-500">
|
||||
{errors.status}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{+data.status === STATUS_REJECT && (
|
||||
<FormInput
|
||||
label="Alasan penolakan"
|
||||
name="reject_reason"
|
||||
value={data.reject_reason}
|
||||
onChange={handleOnChange}
|
||||
error={errors.reject_reason}
|
||||
/>
|
||||
)}
|
||||
<div className="flex items-center">
|
||||
<Button
|
||||
onClick={handleSubmit}
|
||||
processing={processing}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
<Button onClick={handleClose} type="secondary">
|
||||
Batal
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</Modal>
|
||||
)
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
npm run build
|
||||
|
||||
rsync -arP -e 'ssh -p 225' --exclude=node_modules --exclude=database/database.sqlite --exclude=.git --exclude=.env --exclude=public/hot . arm@ajikamaludin.id:/home/arm/projects/www/voucher
|
||||
rsync -arP -e 'ssh -p 225' --exclude=node_modules --exclude=public/uploads --exclude=database/database.sqlite --exclude=.git --exclude=.env --exclude=public/hot . arm@ajikamaludin.id:/home/arm/projects/www/voucher
|
||||
|
||||
ssh -p 225 arm@ajikamaludin.id -C docker exec php82 php /var/www/voucher/artisan migrate:refresh --seed
|
||||
|
Loading…
Reference in New Issue