4 Commits

Author SHA1 Message Date
ISMAIL MASSERAN 8970d8e1b8 DONE: request online modal from pc to operasi, operasi can edit amount; WIP: customer detail confirmation form, retest pembiayaan online, notification if required 2026-08-24 10:59:20 +08:00
ISMAIL MASSERAN d2ffdc5909 Merge remote-tracking branch 'origin/rebate-anggota' into explore/ismail
DONE: pull latest changes from rebate-anggota into explore/ismail
2026-08-09 10:37:59 +08:00
ISMAIL MASSERAN 14870557b0 DONE: ignore db-dump folder in gitignore 2026-08-09 10:16:22 +08:00
ISMAIL MASSERAN 9a65d109e7 DO NOT PR THIS BRANCHgit add .!; DONE: add docker config for development 2026-04-22 12:44:16 +08:00
24 changed files with 137 additions and 716 deletions
-5
View File
@@ -1,10 +1,6 @@
.git .git
.gitea
node_modules node_modules
vendor vendor
.env
.env.*
!.env.example
storage/logs storage/logs
storage/framework/cache storage/framework/cache
storage/framework/sessions storage/framework/sessions
@@ -13,4 +9,3 @@ storage/debugbar
npm-debug.log npm-debug.log
Dockerfile Dockerfile
docker-compose.yml docker-compose.yml
docker-compose.staging.yml
-84
View File
@@ -1,84 +0,0 @@
APP_NAME=Lumen
APP_ENV=staging
APP_KEY=WbPGkYNmXZ6ZQplGlvl0iZ7zyW1b09xa
APP_DEBUG=true
APP_URL=http://127.0.0.1:8090
APP_TIMEZONE=Asia/Kuala_Lumpur
# Unique host ports — change these if they collide with other containers on the server.
# Host nginx should proxy the staging domain to 127.0.0.1:${HTTP_PORT}
HTTP_PORT=8090
MYSQL_PUBLISH_PORT=3308
LOG_CHANNEL=stack
LOG_LEVEL=debug
LOG_SLACK_WEBHOOK_URL=
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=erahn_xtra
DB_USERNAME=root
DB_PASSWORD=root
DB_CONNECTION_7=mysql
DB_HOST_7=mysql
DB_PORT_7=3306
DB_DATABASE_7=master_erahn
DB_USERNAME_7=root
DB_PASSWORD_7=root
DB_CONNECTION_2=mysql
DB_HOST_2=mysql
DB_PORT_2=3306
DB_DATABASE_2=erahn_xtra
DB_USERNAME_2=root
DB_PASSWORD_2=root
DB_CONNECTION_3=mysql
DB_HOST_3=mysql
DB_PORT_3=3306
DB_DATABASE_3=erahn_baling
DB_USERNAME_3=root
DB_PASSWORD_3=root
DB_CONNECTION_4=mysql
DB_HOST_4=mysql
DB_PORT_4=3306
DB_DATABASE_4=arrahn_ld
DB_USERNAME_4=root
DB_PASSWORD_4=root
DB_CONNECTION_5=mysql
DB_HOST_5=mysql
DB_PORT_5=3306
DB_DATABASE_5=erahn_segamat
DB_USERNAME_5=root
DB_PASSWORD_5=root
DB_CONNECTION_7=mysql
DB_HOST_7=mysql
DB_PORT_7=3306
DB_DATABASE_7=master_erahn
DB_USERNAME_7=root
DB_PASSWORD_7=root
DB_CONNECTION_6=mysql
DB_HOST_6=mysql
DB_PORT_6=3306
DB_DATABASE_6=erahn_test
DB_USERNAME_6=root
DB_PASSWORD_6=root
# DB_CONNECTION_8=mysql
# DB_HOST_8=mysql
# DB_PORT_8=3306
# DB_DATABASE_8=arrahn_klanas
# DB_USERNAME_8=spider
# DB_PASSWORD_8=G0dz!ll42020
TENNANT_MASTER_DB=master_erahn
TENNANT_KAUNTER_DB=kaunter_erahn
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
-49
View File
@@ -1,49 +0,0 @@
name: Build Docker Image
on:
push:
branches:
- staging
tags:
- "v*"
workflow_dispatch:
jobs:
build-backend:
runs-on: docker
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to Docker registry
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | \
docker login git.koppkb.com \
-u "${{ secrets.REGISTRY_USERNAME }}" \
--password-stdin
- name: Build & push backend image
run: |
set -e
IMAGE="git.koppkb.com/kopkb/api_arrahn"
TAGS="-t ${IMAGE}:${{ gitea.sha }}"
if [ "${{ gitea.ref_type }}" = "tag" ] && echo "${{ gitea.ref_name }}" | grep -q '^v'; then
TAGS="${TAGS} -t ${IMAGE}:${{ gitea.ref_name }}"
fi
if [ "${{ gitea.ref_name }}" = "staging" ]; then
TAGS="${TAGS} -t ${IMAGE}:staging"
fi
echo "Building and pushing backend: ${TAGS}"
docker buildx build \
--target staging \
--platform linux/amd64 \
--cache-from type=registry,ref=${IMAGE}:buildcache,ignore-error=true \
--cache-to type=registry,ref=${IMAGE}:buildcache,mode=max \
-f docker/php/Dockerfile \
${TAGS} \
--push .
-122
View File
@@ -1,122 +0,0 @@
name: Deploy to Staging
on:
workflow_dispatch:
inputs:
image_tag:
description: "Docker image tag to deploy (commit SHA, staging, or v*)"
required: true
default: "staging"
type: string
env:
APP_IMAGE: git.koppkb.com/kopkb/api_arrahn
DEPLOY_DIR: /home/arrahn/Project/api_arrahn
jobs:
deploy:
runs-on: host
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.image_tag }}
- name: Login to Docker registry
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | \
docker login git.koppkb.com \
-u "${{ secrets.REGISTRY_USERNAME }}" \
--password-stdin
- name: Verify image exists in registry
run: |
set -e
IMAGE_TAG="${{ inputs.image_tag }}"
IMAGE="${APP_IMAGE}:${IMAGE_TAG}"
echo "Checking if image exists: ${IMAGE}"
if ! docker manifest inspect "${IMAGE}" > /dev/null 2>&1; then
echo "ERROR: Image ${IMAGE} does not exist in registry!"
echo "Run the Build Docker Image workflow first."
exit 1
fi
echo "✓ ${IMAGE} found"
- name: Pull Docker image
run: |
set -e
IMAGE_TAG="${{ inputs.image_tag }}"
docker pull "${APP_IMAGE}:${IMAGE_TAG}"
echo "✓ Image pulled successfully"
- name: Sync compose file and deploy
run: |
set -e
IMAGE_TAG="${{ inputs.image_tag }}"
mkdir -p "${DEPLOY_DIR}/docker/nginx" "${DEPLOY_DIR}/docker/mysql"
cp docker-compose.staging.yml "${DEPLOY_DIR}/docker-compose.yml"
cp docker/nginx/default.conf "${DEPLOY_DIR}/docker/nginx/default.conf"
cp -R docker/mysql/init "${DEPLOY_DIR}/docker/mysql/"
if [ ! -f "${DEPLOY_DIR}/.env.staging" ]; then
if [ -f .env.staging ]; then
cp .env.staging "${DEPLOY_DIR}/.env.staging"
echo "Copied .env.staging from repo (first deploy). Edit ${DEPLOY_DIR}/.env.staging on the server if needed."
else
echo "ERROR: ${DEPLOY_DIR}/.env.staging is missing on the server"
exit 1
fi
fi
cd "${DEPLOY_DIR}"
export APP_IMAGE
export IMAGE_TAG
docker compose --env-file .env.staging -f docker-compose.yml pull app
docker compose --env-file .env.staging -f docker-compose.yml up -d --no-build --force-recreate --remove-orphans app web
echo "✓ Deployed IMAGE_TAG=${IMAGE_TAG}"
- name: Verify deployment
run: |
set -e
cd "${DEPLOY_DIR}"
echo "Waiting for services to start..."
sleep 10
for SERVICE in app web mysql; do
STATUS=$(docker compose --env-file .env.staging -f docker-compose.yml ps --status running --format '{{.Name}}' "$SERVICE" 2>/dev/null || true)
if [ -z "$STATUS" ]; then
echo "ERROR: ${SERVICE} is not running"
docker compose --env-file .env.staging -f docker-compose.yml ps
docker compose --env-file .env.staging -f docker-compose.yml logs --tail=50 "$SERVICE" || true
exit 1
fi
echo "✓ ${SERVICE} is running (${STATUS})"
done
HTTP_PORT=$(grep -E '^HTTP_PORT=' .env.staging 2>/dev/null | cut -d= -f2- | tr -d '"' || true)
HTTP_PORT=${HTTP_PORT:-8090}
check_health() {
NAME=$1
URL=$2
for i in 1 2 3 4 5 6; do
if curl -sf "$URL" > /dev/null; then
echo "✓ ${NAME} health check passed (${URL})"
return 0
fi
echo "Waiting for ${NAME}... attempt ${i}/6"
sleep 5
done
echo "ERROR: ${NAME} health check failed (${URL})"
docker compose --env-file .env.staging -f docker-compose.yml logs --tail=50 app web || true
return 1
}
check_health "api" "http://127.0.0.1:${HTTP_PORT}/health"
-7
View File
@@ -15,10 +15,3 @@ FLUSH PRIVILEGES;
Gadai=Pembiayaan Gadai=Pembiayaan
Tebus=penyelesaian penuh/ansuran Tebus=penyelesaian penuh/ansuran
## Load db dump without using docker
```bash
docker exec -i api_arrahn_staging_mysql mysql -uroot -proot erahn_test < erahn_test.sql
```
## Disable the cawangan in arrahn_master_db
+1 -2
View File
@@ -62,8 +62,7 @@ class Customer extends Model
'telefon2', 'telefon2',
'nota_pekerjaan', 'nota_pekerjaan',
'tagpelanggan', 'tagpelanggan',
'tag_anggota', 'tag_anggota'
'gambar_mykad'
]; ];
/** /**
+3 -114
View File
@@ -5,7 +5,6 @@ namespace App\Http\Controllers;
use App\Audit; use App\Audit;
use App\Marhun; use App\Marhun;
use App\BankMaster; use App\BankMaster;
use App\ARFiles;
use App\Customer; use App\Customer;
use App\Gadai; use App\Gadai;
use App\Lelong; use App\Lelong;
@@ -65,7 +64,7 @@ class CustomerController extends Controller
->orWhere('kpbaru','=',$ic) ->orWhere('kpbaru','=',$ic)
->first(); ->first();
return response()->json($this->withMykadPhoto($customer)); return response()->json($customer);
} }
public function showOneCustomerByICAdmin(Request $request){ public function showOneCustomerByICAdmin(Request $request){
@@ -75,7 +74,7 @@ class CustomerController extends Controller
->orWhere('kpbaru','=',$request->ic) ->orWhere('kpbaru','=',$request->ic)
->first(); ->first();
return response()->json($this->withMykadPhoto($customer)); return response()->json($customer);
} }
public function showOneCustomerByICMobile($ic){ public function showOneCustomerByICMobile($ic){
@@ -369,8 +368,6 @@ class CustomerController extends Controller
'tujuangadai'=>$request->tujuangadai 'tujuangadai'=>$request->tujuangadai
]); ]);
$this->attachMykadPhoto($customer, $request);
$audit = new Audit(); $audit = new Audit();
$audit->users = $request->teller; $audit->users = $request->teller;
$audit->actions = "Daftar Pelanggan Baru"; $audit->actions = "Daftar Pelanggan Baru";
@@ -380,7 +377,7 @@ class CustomerController extends Controller
$audit->updated_at = $current; $audit->updated_at = $current;
$audit->save(); $audit->save();
return response()->json($this->withMykadPhoto($customer), 201); return response()->json($customer, 201);
} }
public function customerUpdate($nokp,Request $request){ public function customerUpdate($nokp,Request $request){
@@ -1127,114 +1124,6 @@ public function AdminsearchCustomerBySAG(Request $request)
return response()->json(['message' => 'Customer PDPA updated successfully.'], 200); return response()->json(['message' => 'Customer PDPA updated successfully.'], 200);
} }
/**
* Save MyKad photo into arrahn_files and link it on customer.gambar_mykad.
*/
protected function attachMykadPhoto($customer, Request $request)
{
if (!$customer) {
return;
}
$raw = $this->photoBase64FromRequest($request);
if ($raw === '') {
return;
}
try {
$fileId = $this->storeMykadPhoto($raw, $request->input('photo_mime', $request->json('photo_mime')), $customer);
if (!$fileId) {
return;
}
Customer::on('mysql7')
->where('kpbaru', $customer->kpbaru)
->where('kplama', $customer->kplama)
->update(['gambar_mykad' => $fileId]);
$customer->gambar_mykad = $fileId;
} catch (\Throwable $e) {
Log::error('Failed to attach MyKad photo: ' . $e->getMessage());
}
}
protected function photoBase64FromRequest(Request $request)
{
$raw = $request->input('photo_base64');
if ($raw === null || $raw === '') {
$raw = $request->json('photo_base64');
}
return is_string($raw) ? $raw : '';
}
protected function storeMykadPhoto($raw, $mime, $customer)
{
$commaPos = strpos($raw, ',');
if ($commaPos !== false) {
$raw = substr($raw, $commaPos + 1);
}
$raw = preg_replace('/\s+/', '', $raw);
if ($raw === '') {
return null;
}
$decoded = base64_decode($raw, true);
if ($decoded === false) {
$decoded = base64_decode($raw);
}
if ($decoded === false || $decoded === '') {
Log::warning('MyKad photo skipped: invalid base64');
return null;
}
if (strlen($raw) > 400000) {
Log::warning('MyKad photo skipped: payload too large');
return null;
}
$mime = strtolower((string) ($mime ?: 'image/jpeg'));
if (!in_array($mime, ['image/jpeg', 'image/jpg', 'image/png'], true)) {
$mime = 'image/jpeg';
}
$nric = preg_replace('/[^0-9A-Za-z]/', '', (string) ($customer->kpbaru ?: ''));
$ext = $mime === 'image/png' ? 'png' : 'jpg';
$file = new ARFiles();
$file->data = $raw;
$file->filename = ($nric !== '' ? $nric : 'mykad') . '.' . $ext;
$file->type = $mime;
$file->tarikhmasa = Carbon::now()->toDateTimeString();
$file->save();
return $file->id;
}
protected function withMykadPhoto($customer)
{
if (!$customer) {
return $customer;
}
$payload = $customer->toArray();
$payload['photo_base64'] = null;
$payload['photo_mime'] = null;
if (empty($customer->gambar_mykad)) {
return $payload;
}
$file = ARFiles::on('mysql7')->where('id', $customer->gambar_mykad)->first();
if ($file && $file->data) {
$payload['photo_base64'] = $file->data;
$payload['photo_mime'] = $file->type ?: 'image/jpeg';
}
return $payload;
}
// public function createNotaArcc($kodcaw, Request $request) // public function createNotaArcc($kodcaw, Request $request)
// { // {
// $current = Carbon::now(); // $current = Carbon::now();
+5 -4
View File
@@ -147,16 +147,17 @@ class KomuditiController extends Controller
$unit_current = $komuditi_current['unit_komuditi']; $unit_current = $komuditi_current['unit_komuditi'];
$update_unit = $unit_current - $request->unit_komuditi; $update_unit = $unit_current - $request->unit_komuditi;
$unit_current = round((float) $komuditi_current['unit_komuditi'], 2); // $unit_current = round((float) $komuditi_current['unit_komuditi'], 2);
$unit_komuditi = round((float) $request->unit_komuditi, 2); // $unit_komuditi = round((float) $request->unit_komuditi, 2);
$update_unit = round($unit_current - $unit_komuditi, 2); // $update_unit = round($unit_current - $unit_komuditi, 2);
$update_komuditi = KomuditiPurchase::on('mysql7')->where('id','=',$komuditi_current['id'])->update([ $update_komuditi = KomuditiPurchase::on('mysql7')->where('id','=',$komuditi_current['id'])->update([
'unit_komuditi' => $update_unit 'unit_komuditi' => $update_unit
]); ]);
$komuditi_transaksi = KomuditiTransaksi::on('mysql7')->create([ $komuditi_transaksi = KomuditiTransaksi::on('mysql7')->create([
'unit_komuditi' => $unit_komuditi, 'unit_komuditi' => $request->unit_komuditi,
// 'unit_komuditi' => $unit_komuditi,
'nosijil'=>$komuditi_current['no_sijil'], 'nosijil'=>$komuditi_current['no_sijil'],
'norujukan' => $request->norujukan, 'norujukan' => $request->norujukan,
'kodcaw' => $request->kodcaw , 'kodcaw' => $request->kodcaw ,
+39 -14
View File
@@ -804,7 +804,8 @@ $date = new Carbon($request->tarikh);
$tebus = Tebus::on($cawangan['mysql']) $tebus = Tebus::on($cawangan['mysql'])
->join('gadai as gad','gad.norujukan','=','tebus.norujukan') ->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
->where([['t_tebus','>=',$request->mula],['t_tebus','<=',$request->akhir],['tebus.jenistebus','=','T']]); ->where([['t_tebus','>=',$request->mula],['t_tebus','<=',$request->akhir]]);
->where([['t_tebus','>=',$request->mula],['t_tebus','<=',$request->akhir]]);
$ansuran = Transaction::on('mysql7')->whereDate('created_at','>=',$request->mula)->whereDate('created_at','<=',$request->akhir)->where([['trans_type','=','A'],['kodcaw','=',$request->kodcaw]]); $ansuran = Transaction::on('mysql7')->whereDate('created_at','>=',$request->mula)->whereDate('created_at','<=',$request->akhir)->where([['trans_type','=','A'],['kodcaw','=',$request->kodcaw]]);
$bayaranonlinequery = Transaction::on('mysql7')->whereDate('created_at','>=',$request->mula)->whereDate('created_at','<=',$request->akhir)->where('teller','=','Online')->where('kodcaw',$request->kodcaw); $bayaranonlinequery = Transaction::on('mysql7')->whereDate('created_at','>=',$request->mula)->whereDate('created_at','<=',$request->akhir)->where('teller','=','Online')->where('kodcaw',$request->kodcaw);
@@ -834,19 +835,27 @@ $date = new Carbon($request->tarikh);
->whereDate('trans.created_at','<=',$request->akhir) ->whereDate('trans.created_at','<=',$request->akhir)
->where('trans.trans_type','=','A') ->where('trans.trans_type','=','A')
->where('trans.kodcaw','=',$request->kodcaw) ->where('trans.kodcaw','=',$request->kodcaw)
// ->pluck('trans.norujukan');
// ->pluck('trans.norujukan');
// ->groupBy('trans.id') // ->groupBy('trans.id')
->sum('bayaran_keuntungan'); ->sum('bayaran_keuntungan');
// dd($total_keuntunganansuran);
// dd($total_keuntunganansuran);
// $total_ansuran = number_format($total_ansuran,2); // $total_ansuran = number_format($total_ansuran,2);
$total_keuntungan = floatval($total_upah) + floatval($total_keuntunganansuran) + floatval($total_keuntungantebus); $total_keuntungan = floatval($total_upah) + floatval($total_keuntunganansuran) + floatval($total_keuntungantebus);
//b //b
$bilangan_gadai = $gadai->count(); $bilangan_gadai = $gadai->count();
$bilangan_tebus = $tebus->count(); $bilangan_tebus = $tebus->count();
// $bilangan_ansuran = $ansuran->count(); // $bilangan_ansuran = $ansuran->count();
//$bilangan_customer_baru = Customer::on($cawangan['mysql'])->where([['tarikhdaftar','>=',$request->mula],['tarikhdaftar','<=',$request->akhir]])->count(); //$bilangan_customer_baru = Customer::on('mysql7')->where([['tarikhdaftar','=',$request->tarikh],['kodcaw',$request->kodcaw]])->count()
//$bilangan_customer_baru = Customer::on('mysql7')->where([['tarikhdaftar','>=',$request->mula],['tarikhdaftar','<=',$request->akhir]])->count();
$bilangan_customer_baru = Customer::on('mysql7')->whereBetween('tarikhdaftar', [$request->mula, $request->akhir])->where('kodcaw', $request->kodcaw)->count();
//$bilangan_customer_baru = Customer::on('mysql7')->where([['tarikhdaftar','=',$request->tarikh],['kodcaw',$request->kodcaw]])->count()
//$bilangan_customer_baru = Customer::on('mysql7')->where([['tarikhdaftar','>=',$request->mula],['tarikhdaftar','<=',$request->akhir]])->count();
$bilangan_customer_baru = Customer::on('mysql7')->whereBetween('tarikhdaftar', [$request->mula, $request->akhir])->where('kodcaw', $request->kodcaw)->count(); $bilangan_customer_baru = Customer::on('mysql7')->whereBetween('tarikhdaftar', [$request->mula, $request->akhir])->where('kodcaw', $request->kodcaw)->count();
//f //f
@@ -970,21 +979,36 @@ $date = new Carbon($request->tarikh);
->whereDate('trans.created_at','<=',$request->akhir) ->whereDate('trans.created_at','<=',$request->akhir)
->where('trans.teller','<>','Online') ->where('trans.teller','<>','Online')
->where('trans.trans_type','=','A') ->where('trans.trans_type','=','A')
->where('trans.kodcaw',$request->kodcaw) ->where('trans.kodcaw',$request->kodcaw);
->pluck('transaksi_keuntungan.norujukan'); // ->pluck('transaksi_keuntungan.norujukan');
$gadaiDataKaunter = Gadai::on($cawangan['mysql'])->whereIn('norujukan',$total_keuntunganansuran_data_kaunter)->whereNotNull('hargajualan')->pluck('norujukan'); ->where('trans.kodcaw',$request->kodcaw);
// ->pluck('transaksi_keuntungan.norujukan');
$keuntunganansuran_kaunter_query = TransaksiKeuntungan::on('mysql7')
->whereIn('norujukan',$gadaiDataKaunter)
->whereDate('tarikh_bayaran','>=',$request->mula)
->whereDate('tarikh_bayaran','<=',$request->akhir);
// $gadaiDataKaunter = Gadai::on($cawangan['mysql'])->whereIn('norujukan',$total_keuntunganansuran_data_kaunter)->whereNotNull('hargajualan')->pluck('norujukan');
// $gadaiDataKaunter = Gadai::on($cawangan['mysql'])->whereIn('norujukan',$total_keuntunganansuran_data_kaunter)->whereNotNull('hargajualan')->pluck('norujukan');
$total_keuntunganansuran_kaunter = $keuntunganansuran_kaunter_query->sum('bayaran_keuntungan'); // $keuntunganansuran_kaunter_query = TransaksiKeuntungan::on('mysql7')
$bil_keuntunganansuran_kaunter = $keuntunganansuran_kaunter_query->count(); // ->whereIn('norujukan',$gadaiDataKaunter)
// ->where('kodcaw',$request->kodcaw)
// ->whereDate('tarikh_bayaran','>=',$request->mula)
// ->whereDate('tarikh_bayaran','<=',$request->akhir);
//dd($keuntunganansuran_kaunter_query->get()->toArray());
// $keuntunganansuran_kaunter_query = TransaksiKeuntungan::on('mysql7')
// ->whereIn('norujukan',$gadaiDataKaunter)
// ->where('kodcaw',$request->kodcaw)
// ->whereDate('tarikh_bayaran','>=',$request->mula)
// ->whereDate('tarikh_bayaran','<=',$request->akhir);
//dd($keuntunganansuran_kaunter_query->get()->toArray());
$total_keuntunganansuran_kaunter = $total_keuntunganansuran_data_kaunter->sum('bayaran_keuntungan');
//dd($total_keuntunganansuran_kaunter);
$bil_keuntunganansuran_kaunter = $total_keuntunganansuran_data_kaunter->count();
$total_keuntunganansuran_kaunter = $total_keuntunganansuran_data_kaunter->sum('bayaran_keuntungan');
//dd($total_keuntunganansuran_kaunter);
$bil_keuntunganansuran_kaunter = $total_keuntunganansuran_data_kaunter->count();
$total_keuntunganansuran_data_online = TransaksiKeuntungan::on('mysql7') $total_keuntunganansuran_data_online = TransaksiKeuntungan::on('mysql7')
->leftJoin('transaction as trans', function($join) ->leftJoin('transaction as trans', function($join)
{ {
@@ -1245,7 +1269,8 @@ $date = new Carbon($request->tarikh);
array_push($atarray,[ array_push($atarray,[
'tarikh' => $tarikh, 'tarikh' => $tarikh,
'masa' => $masa, 'masa' => $masa,
'users' => $at['users'], 'users' => isset($at['users']) && $at['users'] !== '' ? $at['users'] : '-',
'users' => isset($at['users']) && $at['users'] !== '' ? $at['users'] : '-',
'pelulus' => isset($atnewdata['namapelulus']) ? $atnewdata['namapelulus'] : '-', 'pelulus' => isset($atnewdata['namapelulus']) ? $atnewdata['namapelulus'] : '-',
'actions' => $at['actions'], 'actions' => $at['actions'],
'norujukan' => $at['norujukan'], 'norujukan' => $at['norujukan'],
+1 -1
View File
@@ -605,7 +605,7 @@ class LelongController extends Controller
if($cawangan['tagarrahnbid'] == 1){ if($cawangan['tagarrahnbid'] == 1){
if(env('APP_ENV') != 'production'){ if(env('APP_ENV') != 'production'){
$link = 'https://adminbid-kopkb.erahn.com.my/api/portalApi'; $link = 'http://niklah.arrahn.com.my/api/portalApi';
}else{ }else{
$link = 'https://adminbid-kopkb.erahn.com.my/api/portalApi'; $link = 'https://adminbid-kopkb.erahn.com.my/api/portalApi';
} }
@@ -48,7 +48,7 @@ class GadaianController extends Controller
$summary_gadaian_data = array_map(function ($db_connection) use ($request) { $summary_gadaian_data = array_map(function ($db_connection) use ($request) {
$query = Gadai::on($db_connection); $query = Gadai::on($db_connection);
$query->select(DB::raw('count(norujukan) as total_gadaian, sum(berat) as sum_berat, sum(nilaimarhun) as sum_nilai_marhun, sum(pinjaman) as sum_pinjaman, sum(upah12) as sum_upah_12')); $query->select(DB::raw('count(norujukan) as total_gadaian, sum(berat) as sum_berat, sum(nilaimarhun) as sum_nilai_marhun, sum(pinjaman) as sum_pinjaman'));
$query->when($request->filled('startDate') and $request->filled('endDate'), function ($q) use ($request) { $query->when($request->filled('startDate') and $request->filled('endDate'), function ($q) use ($request) {
return $q->where('t_gadai', '>=', $request->startDate) return $q->where('t_gadai', '>=', $request->startDate)
@@ -593,14 +593,20 @@ class PembiayaanOnlineService
} }
} }
list($batch, $appended) = $this->findOrCreateSlotBatch( $batchNo = $this->nextBatchNo($mysql, $kodcaw, $tarikh, $slot);
$mysql, $jumlah = round((float) $lines->sum('pinjaman'), 2);
$kodcaw,
$tarikh, $batch = BatchPembiayaanOnline::on($mysql)->create([
$slot, 'batch_no' => $batchNo,
$pcBy, 'kodcaw' => $kodcaw,
$now 'tarikh' => $tarikh,
); 'slot' => $slot,
'bilangan' => $lines->count(),
'jumlah_keseluruhan' => $jumlah,
'status' => 'SUBMITTED',
'pc_submitted_by' => $pcBy,
'submitted_at' => $now,
]);
foreach ($lines as $line) { foreach ($lines as $line) {
PembiayaanOnline::on($mysql)->where('id', $line->id)->update([ PembiayaanOnline::on($mysql)->where('id', $line->id)->update([
@@ -613,14 +619,6 @@ class PembiayaanOnlineService
]); ]);
} }
if ($appended) {
BatchPembiayaanOnline::on($mysql)->where('id', $batch->id)->update([
'submitted_at' => $now,
]);
}
$batch = $this->refreshBatchStatus($mysql, $batch->id);
$freshLines = PembiayaanOnline::on($mysql) $freshLines = PembiayaanOnline::on($mysql)
->where('batch_id', $batch->id) ->where('batch_id', $batch->id)
->orderBy('id', 'asc') ->orderBy('id', 'asc')
@@ -628,12 +626,11 @@ class PembiayaanOnlineService
return [ return [
'ok' => true, 'ok' => true,
'status' => $appended ? 200 : 201, 'status' => 201,
'payload' => [ 'payload' => [
'batch' => $batch, 'batch' => $batch,
'lines' => $freshLines, 'lines' => $freshLines,
'slot_info' => $slotInfo, 'slot_info' => $slotInfo,
'appended' => $appended,
], ],
]; ];
}); });
@@ -1538,45 +1535,24 @@ class PembiayaanOnlineService
]; ];
} }
/** protected function nextBatchNo($mysql, $kodcaw, $tarikh, $slot)
* One batch per branch / day / slot (B1-001 or B2-001). Later submits append.
*
* @return array{0:\App\BatchPembiayaanOnline,1:bool} [batch, appended]
*/
protected function findOrCreateSlotBatch($mysql, $kodcaw, $tarikh, $slot, $pcBy, $now)
{
$batch = BatchPembiayaanOnline::on($mysql)
->where('kodcaw', $kodcaw)
->where('tarikh', $tarikh)
->where('slot', $slot)
->orderBy('id', 'asc')
->lockForUpdate()
->first();
if ($batch) {
return [$batch, true];
}
$batch = BatchPembiayaanOnline::on($mysql)->create([
'batch_no' => $this->slotBatchNo($kodcaw, $tarikh, $slot),
'kodcaw' => $kodcaw,
'tarikh' => $tarikh,
'slot' => $slot,
'bilangan' => 0,
'jumlah_keseluruhan' => 0,
'status' => 'SUBMITTED',
'pc_submitted_by' => $pcBy,
'submitted_at' => $now,
]);
return [$batch, false];
}
protected function slotBatchNo($kodcaw, $tarikh, $slot)
{ {
$slotTag = $slot === 'BATCH1' ? 'B1' : 'B2'; $slotTag = $slot === 'BATCH1' ? 'B1' : 'B2';
$ymd = Carbon::parse($tarikh)->format('Ymd'); $ymd = Carbon::parse($tarikh)->format('Ymd');
$prefix = strtoupper($kodcaw) . '-PO-' . $ymd . '-' . $slotTag . '-';
return strtoupper($kodcaw) . '-PO-' . $ymd . '-' . $slotTag . '-001'; $last = BatchPembiayaanOnline::on($mysql)
->where('kodcaw', $kodcaw)
->where('tarikh', $tarikh)
->where('slot', $slot)
->orderBy('id', 'desc')
->first();
$seq = 1;
if ($last && preg_match('/-(\d+)$/', $last->batch_no, $m)) {
$seq = ((int) $m[1]) + 1;
}
return $prefix . str_pad((string) $seq, 3, '0', STR_PAD_LEFT);
} }
} }
+1 -1
View File
@@ -398,7 +398,7 @@ class OnePercentService
$t_gadai = Carbon::parse($gadai->t_gadai); $t_gadai = Carbon::parse($gadai->t_gadai);
$t_bayaran = Carbon::parse($trans->tarikh_bayaran); $t_bayaran = Carbon::parse($trans->tarikh_bayaran);
if (($t_gadai->month == $t_bayaran->month) && ($t_gadai->year == $t_bayaran->year)) { if ($t_gadai->month === $t_bayaran->month && $t_gadai->year === $t_bayaran->year) {
return false; return false;
}else{ }else{
return true; return true;
+34 -36
View File
@@ -58,34 +58,31 @@ class GadaiV2
} }
} }
private function getKadarUpahAnggota($nokp, $total_nilai_marhun = 0, $groupid = 2): ?float private function getKadarUpahAnggota($nokp,$total_nilai_marhun = 0,$groupid = 2) : Float{
{ //Log::info('DEBUG NOKP:' . $nokp);
if (!$nokp) { if($nokp){
return null; // tiada nokp = tak boleh tentukan kadar $customer = Customer::on('mysql7')
->select('tag_anggota')
->where(function($q) use ($nokp) {
$q->where('kpbaru', $nokp)
->orWhere('kplama', $nokp);
})
->first();
$customer = $customer ? $customer->toArray() : [];
if(isset($customer) && $customer['tag_anggota'] == 1){
return 0.16;
}else{
return KadarUpah::where('min', '<=', $total_nilai_marhun)
->where('max', '>=', $total_nilai_marhun)
->where('group_id', $groupid)
->value('kadarujrah');
}
}
return 0.0;
} }
$customer = Customer::on('mysql7')
->select('tag_anggota')
->where(function ($q) use ($nokp) {
$q->where('kpbaru', $nokp)
->orWhere('kplama', $nokp);
})
->first();
$customer = $customer ? $customer->toArray() : [];
if (isset($customer['tag_anggota']) && $customer['tag_anggota'] == 1) {
return 0.00; // ahli — kadar 0.00 memang sah
}
$kadar = KadarUpah::where('min', '<=', $total_nilai_marhun)
->where('max', '>=', $total_nilai_marhun)
->where('group_id', $groupid)
->value('kadarujrah');
return is_null($kadar) ? null : (float) $kadar; // tak jumpa row = null (block)
}
public function createMarhun($norujukan,HttpRequest $request){ public function createMarhun($norujukan,HttpRequest $request){
$current = Carbon::now(); $current = Carbon::now();
$current = new Carbon(); $current = new Carbon();
@@ -111,18 +108,19 @@ class GadaiV2
$total_nilai_marhun = Marhun::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->sum('n_marhun'); $total_nilai_marhun = Marhun::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->sum('n_marhun');
$total_berat = Marhun::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->sum('berat'); $total_berat = Marhun::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->sum('berat');
$kadar_raw = $this->getKadarUpahAnggota($request->nokp, $total_nilai_marhun, $cawangan['group_id']); $kadar_raw = $this->getKadarUpahAnggota($request->nokp, $total_nilai_marhun, $cawangan['group_id']);
if (is_null($kadar_raw)) { if (empty($kadar_raw) || $kadar_raw == 0) {
Log::error('[BLOCKED] Kadar upah tidak dijumpai', [
'nokp' => $request->nokp, Log::error('[BLOCKED] Kadar upah kosong / 0', [
'total_nilai_marhun' => $total_nilai_marhun, 'nokp' => $request->nokp,
'group_id' => $cawangan['group_id'], 'total_nilai_marhun' => $total_nilai_marhun,
]); 'group_id' => $cawangan['group_id'],
throw new \Exception("Kadar upah tidak dijumpai, transaksi dibatalkan!"); ]);
}
throw new \Exception("Kadar upah kosong / 0, transaksi dibatalkan!");
}
// $kadar_raw = 0.00 (ahli) akan lepas ke sini dan diteruskan
// query kadar upah lama // query kadar upah lama
// $kadar_raw = KadarUpah::where('min','<=',$total_nilai_marhun)->where('max','>=',$total_nilai_marhun)->first(); // $kadar_raw = KadarUpah::where('min','<=',$total_nilai_marhun)->where('max','>=',$total_nilai_marhun)->first();
@@ -1,46 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddGambarMykadToCustomerTable extends Migration
{
/**
* Master DB (mysql7) — stores arrahn_files.id for the MyKad photo.
*
* @return void
*/
public function up()
{
if (
Schema::connection('mysql7')->hasTable('customer')
&& !Schema::connection('mysql7')->hasColumn('customer', 'gambar_mykad')
) {
Schema::connection('mysql7')->table('customer', function (Blueprint $table) {
if (Schema::connection('mysql7')->hasColumn('customer', 'tag_anggota')) {
$table->unsignedBigInteger('gambar_mykad')->nullable()->after('tag_anggota');
} else {
$table->unsignedBigInteger('gambar_mykad')->nullable();
}
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
if (
Schema::connection('mysql7')->hasTable('customer')
&& Schema::connection('mysql7')->hasColumn('customer', 'gambar_mykad')
) {
Schema::connection('mysql7')->table('customer', function (Blueprint $table) {
$table->dropColumn('gambar_mykad');
});
}
}
}
-77
View File
@@ -1,77 +0,0 @@
# Staging stack — isolated from local docker-compose.yml (8080 / 3306)
# and from other apps on the server (unique project name + host ports).
#
# Local:
# docker compose --env-file .env.staging -f docker-compose.staging.yml up -d --build
#
# CI (image already in registry):
# APP_IMAGE=git.koppkb.com/KoPKB/api_arrahn IMAGE_TAG=<sha> \
# docker compose --env-file .env.staging -f docker-compose.staging.yml up -d --no-build --force-recreate app web
#
# Host nginx reverse-proxies the public domain to 127.0.0.1:${HTTP_PORT}.
# See docker/nginx/host-proxy.example.conf
#
# If 8090 or 3308 is already taken, set HTTP_PORT / MYSQL_PUBLISH_PORT in .env.staging.
name: api_arrahn_staging
services:
app:
image: ${APP_IMAGE:-api_arrahn}:${IMAGE_TAG:-staging}
build:
context: .
dockerfile: docker/php/Dockerfile
target: staging
container_name: api_arrahn_staging_app
working_dir: /var/www/html
volumes:
- storage_staging:/var/www/html/storage
- ./.env.staging:/var/www/html/.env.staging:ro
env_file:
- .env.staging
environment:
APP_ENV: staging
USE_STAGING_ENV: "true"
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
mysql:
condition: service_healthy
restart: unless-stopped
web:
image: nginx:1.25-alpine
container_name: api_arrahn_staging_web
ports:
- "${HTTP_PORT:-8090}:80"
volumes:
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
- app
restart: unless-stopped
mysql:
image: mysql:8.0
container_name: api_arrahn_staging_mysql
command: --default-authentication-plugin=mysql_native_password
ports:
- "127.0.0.1:${MYSQL_PUBLISH_PORT:-3308}:3306"
environment:
MYSQL_DATABASE: erahn_xtra
MYSQL_USER: xtrauser
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: root
volumes:
- mysql_staging_data:/var/lib/mysql
- ./docker/mysql/init:/docker-entrypoint-initdb.d:ro
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uroot", "-proot"]
interval: 5s
timeout: 5s
retries: 30
start_period: 20s
restart: unless-stopped
volumes:
mysql_staging_data:
storage_staging:
-1
View File
@@ -3,7 +3,6 @@ services:
build: build:
context: . context: .
dockerfile: docker/php/Dockerfile dockerfile: docker/php/Dockerfile
target: development
working_dir: /var/www/html working_dir: /var/www/html
volumes: volumes:
- ./:/var/www/html:cached - ./:/var/www/html:cached
@@ -1,7 +0,0 @@
CREATE DATABASE IF NOT EXISTS master_erahn;
CREATE DATABASE IF NOT EXISTS kaunter_erahn;
GRANT ALL PRIVILEGES ON master_erahn.* TO 'xtrauser'@'%';
GRANT ALL PRIVILEGES ON kaunter_erahn.* TO 'xtrauser'@'%';
GRANT ALL PRIVILEGES ON erahn_xtra.* TO 'xtrauser'@'%';
FLUSH PRIVILEGES;
+2 -13
View File
@@ -6,20 +6,9 @@ server {
index index.php index.html; index index.php index.html;
charset utf-8; charset utf-8;
client_max_body_size 50M;
location / { location / {
rewrite ^/(.*)/$ /$1 last; try_files $uri $uri/ /index.php?$query_string;
try_files $uri @php;
}
location @php {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/html/public/index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass app:9000;
fastcgi_index index.php;
fastcgi_read_timeout 120s;
} }
location ~ \.php$ { location ~ \.php$ {
@@ -28,10 +17,10 @@ server {
fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass app:9000; fastcgi_pass app:9000;
fastcgi_index index.php; fastcgi_index index.php;
fastcgi_read_timeout 120s;
} }
location ~ /\.(?!well-known).* { location ~ /\.(?!well-known).* {
deny all; deny all;
} }
} }
+16 -37
View File
@@ -1,51 +1,30 @@
FROM php:7.4-fpm AS base FROM php:7.4-fpm
WORKDIR /var/www/html WORKDIR /var/www/html
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
git \ git \
pkg-config \ pkg-config \
unzip \ unzip \
libonig-dev \ libonig-dev \
libzip-dev \ libzip-dev \
libpng-dev \ libpng-dev \
libjpeg62-turbo-dev \ libjpeg62-turbo-dev \
libfreetype6-dev \ libfreetype6-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j"$(nproc)" \ && docker-php-ext-install -j"$(nproc)" \
pdo_mysql \ pdo_mysql \
mbstring \ mbstring \
bcmath \ bcmath \
zip \ zip \
exif \ exif \
gd \ gd \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
COPY docker/php/php.ini /usr/local/etc/php/conf.d/app.ini COPY docker/php/php.ini /usr/local/etc/php/conf.d/app.ini
COPY docker/php/zz-clear-env.conf /usr/local/etc/php-fpm.d/zz-clear-env.conf
COPY docker/php/entrypoint.sh /usr/local/bin/app-entrypoint.sh
RUN chmod +x /usr/local/bin/app-entrypoint.sh \ RUN usermod -u 1000 www-data && groupmod -g 1000 www-data
&& usermod -u 1000 www-data && groupmod -g 1000 www-data
ENTRYPOINT ["app-entrypoint.sh"]
CMD ["php-fpm"]
FROM base AS staging
COPY --chown=www-data:www-data . /var/www/html
RUN composer install --no-interaction --prefer-dist --no-dev --optimize-autoloader \
&& mkdir -p \
storage/logs \
storage/framework/cache/data \
storage/framework/views \
storage/framework/sessions \
storage/app/public \
bootstrap/cache \
&& chown -R www-data:www-data storage bootstrap/cache vendor
FROM base AS development
-30
View File
@@ -1,30 +0,0 @@
#!/bin/sh
set -e
cd /var/www/html
if [ "${USE_STAGING_ENV:-false}" = "true" ] && [ -f .env.staging ]; then
cp .env.staging .env
fi
if [ -f composer.json ]; then
if [ -f vendor/autoload.php ] && [ "${USE_STAGING_ENV:-false}" = "true" ]; then
: # vendor is baked into the staging image
elif [ "${USE_STAGING_ENV:-false}" = "true" ]; then
composer install --no-interaction --prefer-dist --no-dev --optimize-autoloader
else
composer install --no-interaction --prefer-dist
fi
fi
mkdir -p \
storage/logs \
storage/framework/cache/data \
storage/framework/views \
storage/framework/sessions \
storage/app/public \
bootstrap/cache
chown -R www-data:www-data storage bootstrap/cache
exec docker-php-entrypoint "$@"
-3
View File
@@ -1,3 +0,0 @@
[www]
; Pass container env vars (from compose env_file) through to PHP workers.
clear_env = no
-4
View File
@@ -21,10 +21,6 @@ use App\Http\Controllers\TransactionOnlineTrailController;
use App\Http\Controllers\Reports\RingkasanHarianController; use App\Http\Controllers\Reports\RingkasanHarianController;
use App\Transaction; use App\Transaction;
$router->get('/health', function () {
return response()->json(['status' => 'ok']);
});
$router->group(['namespace' => '\Rap2hpoutre\LaravelLogViewer'], function() use ($router) { $router->group(['namespace' => '\Rap2hpoutre\LaravelLogViewer'], function() use ($router) {
$router->get('logs', 'LogViewerController@index'); $router->get('logs', 'LogViewerController@index');
}); });