Resolve merge conflicts
This commit is contained in:
Vendored
BIN
Binary file not shown.
@@ -8,49 +8,97 @@ use App\Cawangan;
|
||||
use App\LookupAlasan;
|
||||
use App\Palsu;
|
||||
use App\Gadai;
|
||||
use App\Pampasan;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class BarangkesController extends Controller
|
||||
{
|
||||
public function LaporanBarangKes(Request $request)
|
||||
{
|
||||
$status = $request->status;
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', $request->kodcaw)->first();
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', $request->kodcaw)->first();
|
||||
|
||||
if (!$cawangan) {
|
||||
return response()->json(['error' => 'Invalid kodcaw'], 403);
|
||||
if (!$cawangan) {
|
||||
return response()->json(['error' => 'Invalid kodcaw'], 403);
|
||||
}
|
||||
|
||||
$palsu_query = Palsu::on($cawangan['mysql'])
|
||||
->select([
|
||||
'tarikh',
|
||||
'norujukan',
|
||||
'nota',
|
||||
'pembiayaan',
|
||||
'nilaimarhun',
|
||||
'jbg',
|
||||
'untung',
|
||||
'untungonepercent',
|
||||
'untungcajlain'
|
||||
])
|
||||
->when($request->filled('tarikh_mula') && $request->filled('tarikh_akhir'), function ($query) use ($request) {
|
||||
return $query->whereBetween('tarikh', [$request->tarikh_mula, $request->tarikh_akhir]);
|
||||
})
|
||||
->with(['tebus:norujukan', 'gadai:norujukan,nokp']);
|
||||
|
||||
$palsu_array = $palsu_query->get()->toArray();
|
||||
$pampasan_array = Pampasan::on($cawangan['mysql'])->where('kodcaw', $request->kodcaw)->get()->toArray();
|
||||
|
||||
$indexedArray2 = collect($pampasan_array)->keyBy('norujukan');
|
||||
|
||||
$merged = collect($palsu_array)->map(function ($item) use ($indexedArray2) {
|
||||
$id = $item['norujukan'];
|
||||
$itemArray = $item; // Already an array from toArray()
|
||||
$additional = $indexedArray2->get($id, []);
|
||||
|
||||
// Add exists_in_tebus flag based on relationship
|
||||
$itemArray['gadaian_sudah_tebus'] = !is_null($item['tebus']);
|
||||
|
||||
// Add nokp customer from gadai relationship
|
||||
$itemArray['nokp'] = $item['gadai']['nokp'];
|
||||
|
||||
// Remove the tebus relationship data to keep response clean
|
||||
unset($itemArray['tebus']);
|
||||
unset($itemArray['gadai']);
|
||||
|
||||
|
||||
return array_merge($itemArray, $additional);
|
||||
})->values()->toArray();
|
||||
|
||||
$filteredResults = [];
|
||||
|
||||
if ($status == 'dituntut') {
|
||||
foreach ($merged as $pampasan) {
|
||||
if (isset($pampasan['status']) && $pampasan['status'] == 1) {
|
||||
$filteredResults[] = $pampasan;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($status == 'belum-tuntut') {
|
||||
foreach ($merged as $pampasan) {
|
||||
if (!isset($pampasan['status'])) {
|
||||
$filteredResults[] = $pampasan;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($status == 'all' || $status == null) {
|
||||
$filteredResults = $merged;
|
||||
}
|
||||
|
||||
return response()->json($filteredResults);
|
||||
}
|
||||
|
||||
$query = DB::connection($cawangan['mysql'])->table('palsu')
|
||||
->select([
|
||||
'tarikh',
|
||||
'norujukan',
|
||||
'nota',
|
||||
'pembiayaan',
|
||||
'nilaimarhun',
|
||||
'jbg',
|
||||
'untung',
|
||||
'untungonepercent',
|
||||
'untungcajlain'
|
||||
])
|
||||
->whereBetween('tarikh', [$request->tarikh_mula, $request->tarikh_akhir]);
|
||||
|
||||
$result = $query->get();
|
||||
|
||||
return response()->json($result);
|
||||
}
|
||||
|
||||
public function store(Request $request) //cara fifi ajar
|
||||
{
|
||||
|
||||
|
||||
$current = Carbon::now();
|
||||
$kodcaw = $request->kodcaw;
|
||||
$cawangan = Cawangan::on('mysql7')
|
||||
->where('kodcaw', $kodcaw)
|
||||
->where('kodcaw', $kodcaw)
|
||||
->first();
|
||||
|
||||
$insert = Palsu::on($cawangan['mysql'])->create([
|
||||
@@ -66,7 +114,7 @@ class BarangkesController extends Controller
|
||||
'untungonepercent' => $request->tunggakanonepercent,
|
||||
'untungcajlain' => $request->tunggakanujrah,
|
||||
]);
|
||||
|
||||
|
||||
// return $insert;
|
||||
|
||||
return response()->json([
|
||||
@@ -78,7 +126,7 @@ class BarangkesController extends Controller
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
|
||||
|
||||
$current = Carbon::now();
|
||||
$kodcaw = $request->kodcaw;
|
||||
Log::info($request->all());
|
||||
@@ -116,4 +164,77 @@ class BarangkesController extends Controller
|
||||
'message' => $palsu ? 'Rekod gadai berjaya dikemaskini' : 'Rekod tidak dijumpai',
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function store(Request $request) //cara fifi ajar
|
||||
{
|
||||
|
||||
$current = Carbon::now();
|
||||
$kodcaw = $request->kodcaw;
|
||||
$cawangan = Cawangan::on('mysql7')
|
||||
->where('kodcaw', $kodcaw)
|
||||
->first();
|
||||
|
||||
$insert = Palsu::on($cawangan['mysql'])->create([
|
||||
'kodcaw' => $request->kodcaw,
|
||||
'tarikh' => $current->toDateString(),
|
||||
'norujukan' => $request->norujukan,
|
||||
'teller' => $request->teller,
|
||||
'nota' => $request->nota ? $request->nota : '',
|
||||
'pembiayaan' => $request->pinjaman,
|
||||
'nilaimarhun' => $request->nilaimarhun,
|
||||
'jbg' => $request->jbg,
|
||||
'untung' => $request->tunggakan,
|
||||
'untungonepercent' => $request->tunggakanonepercent,
|
||||
'untungcajlain' => $request->tunggakanujrah,
|
||||
]);
|
||||
|
||||
// return $insert;
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Barang kes berjaya didaftar',
|
||||
'data' => $insert
|
||||
], 201);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
|
||||
$current = Carbon::now();
|
||||
$kodcaw = $request->kodcaw;
|
||||
Log::info($request->all());
|
||||
|
||||
// Cari connection cawangan
|
||||
$cawangan = Cawangan::on('mysql7')
|
||||
->where('kodcaw', $kodcaw)
|
||||
->first();
|
||||
|
||||
if (!$cawangan) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Cawangan tidak dijumpai',
|
||||
], 404);
|
||||
}
|
||||
|
||||
// Update direct (ikut norujukan)
|
||||
$palsu = palsu::on($cawangan['mysql'])
|
||||
->where('norujukan', $request->norujukan)
|
||||
->update([
|
||||
'kodcaw' => $request->kodcaw,
|
||||
'tarikh' => $request->tarikh,
|
||||
'teller' => $request->teller,
|
||||
'nota' => $request->nota ?? '',
|
||||
'pembiayaan' => $request->pinjaman,
|
||||
'nilaimarhun' => $request->nilaimarhun,
|
||||
'jbg' => $request->jbg,
|
||||
'untung' => $request->tunggakan,
|
||||
'untungonepercent' => $request->tunggakanonepercent,
|
||||
'untungcajlain' => $request->tunggakanujrah,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => $palsu ? true : false,
|
||||
'message' => $palsu ? 'Rekod gadai berjaya dikemaskini' : 'Rekod tidak dijumpai',
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ class KelulusanController extends Controller
|
||||
{
|
||||
$harini = Carbon::now();
|
||||
$harini = new Carbon;
|
||||
$kelulusan = null;
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$pengesahan = $request->pengesahan;
|
||||
@@ -193,7 +194,33 @@ class KelulusanController extends Controller
|
||||
|
||||
$audit = new Audit();
|
||||
$audit->users = (isset($request->namakhazanah) ? $request->namakhazanah : '');
|
||||
$audit->actions = "Pengesahan Kelulusan 75%";
|
||||
$audit->actions = $request->actions ?? "pengesahan kelulusan 75%";
|
||||
|
||||
// Only prepare detailed audit data for Pampasan approval
|
||||
if($request->actions == 'Pengesahan Pembayaran Pampasan') {
|
||||
// Prepare data for audit - ensure it's an array
|
||||
$auditData = [];
|
||||
|
||||
// If kelulusan is a scalar (update result), create array structure
|
||||
if (is_scalar($kelulusan) || is_null($kelulusan)) {
|
||||
$auditData = ['update_result' => $kelulusan];
|
||||
} else {
|
||||
$auditData = $kelulusan;
|
||||
}
|
||||
|
||||
// Add namapelulus and norujukanasal to the audit data
|
||||
if(isset($request->namaoperasi)) {
|
||||
$auditData['namapelulus'] = !empty($request->namaoperasi) ? $request->namaoperasi : null;
|
||||
}
|
||||
if(isset($request->norujukan)) {
|
||||
$auditData['norujukan'] = !empty($request->norujukan) ? $request->norujukan : null;
|
||||
}
|
||||
} else {
|
||||
// For other actions, use simple kelulusan data
|
||||
$auditData = $kelulusan;
|
||||
}
|
||||
|
||||
$audit->new_data = json_encode($auditData);
|
||||
$audit->kodcaw = $kodcaw;
|
||||
$audit->created_at = $harini;
|
||||
$audit->updated_at = $harini;
|
||||
@@ -229,9 +256,7 @@ public function create(REQUEST $request,$kodcaw,$norujukan,$roles)
|
||||
|
||||
if($roles == "khazanah")
|
||||
{
|
||||
$kelulusan=Mohon::on($cawangan['mysql'])
|
||||
->create([
|
||||
|
||||
$createData = [
|
||||
'tarikh'=> $harini->toDateString(),
|
||||
'norujukan'=> $norujukan,
|
||||
'siri' => $request->siri,
|
||||
@@ -245,10 +270,14 @@ public function create(REQUEST $request,$kodcaw,$norujukan,$roles)
|
||||
'jenistebus' => $request->jenistebus,
|
||||
'teller' => $request->teller,
|
||||
'pelulus' => ($request->pelulus) ? $request->pelulus : ''
|
||||
];
|
||||
|
||||
// Add peloperasi if status is Kelulusan Pengeluaran Pampasan
|
||||
if($request->status == 'Kelulusan Pengeluaran Pampasan' && isset($request->peloperasi)) {
|
||||
$createData['peloperasi'] = $request->peloperasi;
|
||||
}
|
||||
|
||||
|
||||
]);
|
||||
$kelulusan=Mohon::on($cawangan['mysql'])->create($createData);
|
||||
}
|
||||
else if($roles == "operasi")
|
||||
{
|
||||
@@ -275,7 +304,7 @@ public function create(REQUEST $request,$kodcaw,$norujukan,$roles)
|
||||
|
||||
$audit = new Audit();
|
||||
$audit->users = (isset($request->teller) ? $request->teller : '');
|
||||
$audit->actions = "Minta Pengesahan kelulusan 75%";
|
||||
$audit->actions = $request->actions ?? "Minta Pengesahan kelulusan 75%";
|
||||
$audit->new_data = json_encode($kelulusan);
|
||||
$audit->kodcaw = $kodcaw;
|
||||
$audit->created_at = $harini;
|
||||
|
||||
@@ -1244,7 +1244,7 @@ $date = new Carbon($request->tarikh);
|
||||
array_push($atarray,[
|
||||
'tarikh' => $tarikh,
|
||||
'masa' => $masa,
|
||||
'users' => $at['users'],
|
||||
'users' => isset($at['users']) && $at['users'] !== '' ? $at['users'] : '-',
|
||||
'pelulus' => isset($atnewdata['namapelulus']) ? $atnewdata['namapelulus'] : '-',
|
||||
'actions' => $at['actions'],
|
||||
'norujukan' => $at['norujukan'],
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Cawangan;
|
||||
use App\Palsu;
|
||||
use App\Pampasan;
|
||||
use App\Panjar;
|
||||
use App\Tebus;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Log\Logger;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class PampasanController extends Controller
|
||||
{
|
||||
|
||||
public function terimaPampasan(Request $request)
|
||||
{
|
||||
$validated = $this->validate($request, [
|
||||
'norujukan' => 'required|string',
|
||||
'kodcaw' => 'required|string',
|
||||
'jumlah_pampasan' => 'required|numeric',
|
||||
'denominasi' => 'required|array',
|
||||
'teller' => 'required|string',
|
||||
]);
|
||||
|
||||
try {
|
||||
$cawangan = $this->getCawangan($request->kodcaw);
|
||||
|
||||
if (!$cawangan) {
|
||||
return $this->errorResponse('Cawangan tidak dijumpai untuk kodcaw: ' . $request->kodcaw, 404);
|
||||
}
|
||||
|
||||
$pampasan = Pampasan::on($cawangan['mysql'])
|
||||
->where('norujukan', $validated['norujukan'])
|
||||
->first();
|
||||
|
||||
$pampasan->update([
|
||||
'jumlah_pampasan' => $validated['jumlah_pampasan'],
|
||||
'denominasi' => isset($validated['denominasi']) ? json_encode($validated['denominasi']) : null,
|
||||
'teller' => $validated['teller'],
|
||||
]);
|
||||
|
||||
return $this->successResponse('Pampasan berjaya dibayar.', $pampasan, 201);
|
||||
} catch (\Exception $e) {
|
||||
return $this->errorResponse('Database error: ' . $e->getMessage(), 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateStatusPampasan(Request $request)
|
||||
{
|
||||
$norujukan = $request->norujukan;
|
||||
|
||||
$cawangan = $this->getCawangan($request->kodcaw);
|
||||
|
||||
if (!$cawangan) {
|
||||
return $this->errorResponse('Cawangan tidak dijumpai untuk kodcaw: ' . $request->kodcaw, 404);
|
||||
}
|
||||
|
||||
$tebus = Tebus::on($cawangan['mysql'])->where('norujukan', $norujukan)->first();
|
||||
|
||||
$pampasan = Pampasan::on($cawangan['mysql'])->where("norujukan", $norujukan)->first();
|
||||
|
||||
$pampasan->status = 1;
|
||||
|
||||
$pampasan->save();
|
||||
|
||||
// Update corresponding palsu table record status to 1
|
||||
Palsu::on($cawangan['mysql'])
|
||||
->where('norujukan', $norujukan)
|
||||
->update(['status' => 1]);
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
// dd($pampasan);
|
||||
>>>>>>> 83d619ac (Continue dev on pampasan module)
|
||||
|
||||
return $this->successResponse('Status Pampasan berjaya dituntut.', $pampasan, 201);
|
||||
}
|
||||
|
||||
public function getPampasan(Request $request)
|
||||
{
|
||||
$cawangan_connection = Cawangan::where('kodcaw', $request->kodcaw)->first()->mysql;
|
||||
|
||||
$pampasan = Pampasan::on($cawangan_connection)
|
||||
->when($request->filled('norujukan'), function ($query) use ($request) {
|
||||
return $query->where('norujukan', $request->norujukan);
|
||||
})
|
||||
->get();
|
||||
|
||||
|
||||
return $this->successResponse('Senarai pampasan', $pampasan, 201);
|
||||
}
|
||||
|
||||
public function updateAgreementPrintedAt(Request $request)
|
||||
{
|
||||
$validated = $this->validate($request, [
|
||||
'norujukan' => 'required|string',
|
||||
'kodcaw' => 'required|string',
|
||||
]);
|
||||
|
||||
try {
|
||||
$cawangan = $this->getCawangan($validated['kodcaw']);
|
||||
|
||||
if (!$cawangan) {
|
||||
return $this->errorResponse('Cawangan tidak dijumpai untuk kodcaw: ' . $validated['kodcaw'], 404);
|
||||
}
|
||||
|
||||
$pampasan = Pampasan::on($cawangan['mysql'])->where('norujukan', $validated['norujukan'])->first();
|
||||
|
||||
if (!$pampasan) {
|
||||
return $this->errorResponse('Pampasan tidak dijumpai untuk norujukan: ' . $validated['norujukan'], 404);
|
||||
}
|
||||
|
||||
$pampasan->agreement_printed_at = Carbon::now();
|
||||
$pampasan->save();
|
||||
|
||||
return $this->successResponse('Agreement printed timestamp berjaya dikemaskini.', $pampasan, 200);
|
||||
} catch (\Exception $e) {
|
||||
return $this->errorResponse('Database error: ' . $e->getMessage(), 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function initiatePampasan(Request $request)
|
||||
{
|
||||
$validated = $this->validate($request, [
|
||||
'norujukan' => 'required|string',
|
||||
'kodcaw' => 'required|string',
|
||||
'teller' => 'required|string',
|
||||
'baucerno' => 'required|string',
|
||||
]);
|
||||
|
||||
try {
|
||||
$cawangan = $this->getCawangan($validated['kodcaw']);
|
||||
|
||||
if (!$cawangan) {
|
||||
return $this->errorResponse('Cawangan tidak dijumpai untuk kodcaw: ' . $validated['kodcaw'], 404);
|
||||
}
|
||||
|
||||
// Find the palsu record
|
||||
$palsu = Palsu::on($cawangan['mysql'])->where('norujukan', $validated['norujukan'])->first();
|
||||
|
||||
if (!$palsu) {
|
||||
return $this->errorResponse('Barang kes tidak dijumpai untuk norujukan: ' . $validated['norujukan'], 404);
|
||||
}
|
||||
|
||||
// Check if pampasan already exists for this norujukan
|
||||
$existingPampasan = Pampasan::on($cawangan['mysql'])->where('norujukan', $validated['norujukan'])->first();
|
||||
|
||||
if ($existingPampasan) {
|
||||
// If pampasan exists, just update the agreement_printed_at
|
||||
$existingPampasan->agreement_printed_at = Carbon::now();
|
||||
$existingPampasan->save();
|
||||
|
||||
return $this->successResponse('Agreement printed timestamp berjaya dikemaskini untuk pampasan sedia ada.', $existingPampasan, 200);
|
||||
}
|
||||
|
||||
// Create new pampasan record based on palsu data
|
||||
$pampasan = Pampasan::on($cawangan['mysql'])->create([
|
||||
'norujukan' => $palsu->norujukan,
|
||||
'baucerno' => $validated['baucerno'],
|
||||
'kodcaw' => $palsu->kodcaw,
|
||||
'jumlah_pampasan' => $palsu->nilaimarhun,
|
||||
'teller' => $validated['teller'],
|
||||
'status' => 0,
|
||||
'agreement_printed_at' => Carbon::now(),
|
||||
]);
|
||||
|
||||
return $this->successResponse('Pampasan berjaya daftar dari rekod barang kes.', $pampasan, 201);
|
||||
} catch (\Exception $e) {
|
||||
return $this->errorResponse('Database error: ' . $e->getMessage(), 500);
|
||||
}
|
||||
}
|
||||
|
||||
private function getCawangan($kodcaw)
|
||||
{
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', $kodcaw)->first();
|
||||
|
||||
if (!$cawangan) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $cawangan;
|
||||
}
|
||||
|
||||
private function errorResponse($message, $statusCode = 404)
|
||||
{
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => $message,
|
||||
], $statusCode);
|
||||
}
|
||||
|
||||
private function successResponse($message, $data = null, $statusCode = 200)
|
||||
{
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => $message,
|
||||
'data' => $data,
|
||||
], $statusCode);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use App\Audit;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
@@ -31,6 +32,11 @@ class Palsu extends Model
|
||||
'untungonepercent',
|
||||
'untungcajlain',
|
||||
'pembiayaan',
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
'jenis',
|
||||
>>>>>>> 83d619ac (Continue dev on pampasan module)
|
||||
'status',
|
||||
];
|
||||
|
||||
// public static function boot()
|
||||
@@ -88,4 +94,17 @@ class Palsu extends Model
|
||||
// {
|
||||
// return $this->belongsTo(Daerah::class, 'koddaerah', 'koddaerah');
|
||||
// }
|
||||
|
||||
public function tebus(): HasOne
|
||||
{
|
||||
return $this->hasOne(Tebus::class, 'norujukan', 'norujukan');
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
public function gadai(): HasOne
|
||||
{
|
||||
return $this->hasOne(Gadai::class, 'norujukan', 'norujukan');
|
||||
}
|
||||
=======
|
||||
>>>>>>> 83d619ac (Continue dev on pampasan module)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Pampasan extends Model
|
||||
{
|
||||
protected $table = 'pampasan';
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'norujukan',
|
||||
'baucerno',
|
||||
'kodcaw',
|
||||
'jumlah_pampasan',
|
||||
'denominasi',
|
||||
'teller',
|
||||
'nota',
|
||||
'agreement_printed_at',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
// protected $hidden = [];
|
||||
}
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Cawangan;
|
||||
use App\KadarUpah;
|
||||
use App\Pampasan;
|
||||
use App\Support\v1\GadaiV1 as Version1Gadai;
|
||||
|
||||
use App\Services\MasterServices;
|
||||
use App\Support\v1\Penebusan;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request as HttpRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ use App\KomuditiPurchase;
|
||||
use App\KomuditiTransaksi;
|
||||
use App\Marhun;
|
||||
use App\Moratorium;
|
||||
use App\Palsu;
|
||||
use App\Pampasan;
|
||||
use App\Support\OnePercent;
|
||||
use App\Support\Tawarruq;
|
||||
use App\Support\v1\Calculation as V1Calculation;
|
||||
@@ -479,6 +481,17 @@ class Penebusan
|
||||
$upah_rebet_sebenar = $harga_tebus - $gadai['bakipjm'];
|
||||
}
|
||||
|
||||
$isPampasan = Pampasan::on($cawangan['mysql'])->where('norujukan', $request->norujukan)->exists();
|
||||
|
||||
if($isPampasan){
|
||||
$barang_kes = Palsu::on($cawangan['mysql'])->where('norujukan', $norujukan)->first();
|
||||
|
||||
$harga_tebus = $barang_kes->untung + $barang_kes->pembiayaan;
|
||||
$upah_tebus = $barang_kes->untung;
|
||||
$upah_rebet = $this->kiraUpahRebetSebenar($kodcaw,$norujukan);
|
||||
$upah_rebet_sebenar = $barang_kes->untung;
|
||||
$rebet = $gadai['hargajualan'] - $harga_tebus;
|
||||
}
|
||||
|
||||
$create_tebus = Tebus::on($cawangan['mysql'])->create([
|
||||
'kodcaw'=> $kodcaw,
|
||||
|
||||
@@ -2,5 +2,7 @@
|
||||
|
||||
return [
|
||||
'url' => env('APP_URL', url('/')),
|
||||
'api_arrahnbid' => env('API_ARRAHNBID', 'http://lelong.test/api/')
|
||||
'api_arrahnbid' => env('API_ARRAHNBID', 'http://lelong.test/api/'),
|
||||
'api_v3' => env('API_V3', 'http://apiv3.localhost/api/')
|
||||
];
|
||||
|
||||
|
||||
+16
-16
@@ -69,10 +69,10 @@ class AddNmJbgUntungPembiayaanColumnsToPalsuTable extends Migration
|
||||
// Add index and foreign key constraint to existing norujukan column
|
||||
if (Schema::connection($dbase)->hasColumn('palsu', 'norujukan')) {
|
||||
// Add index to norujukan column for better performance
|
||||
$table->index('norujukan');
|
||||
// $table->index('norujukan');
|
||||
|
||||
// Add foreign key constraint named 'norujukan'
|
||||
$table->foreign('norujukan', 'norujukan')->references('norujukan')->on('gadai');
|
||||
// $table->foreign('norujukan', 'norujukan')->references('norujukan')->on('gadai');
|
||||
}
|
||||
|
||||
});
|
||||
@@ -87,21 +87,21 @@ class AddNmJbgUntungPembiayaanColumnsToPalsuTable extends Migration
|
||||
Schema::connection($dbase)->table('palsu', function (Blueprint $table) use ($dbase) {
|
||||
|
||||
// Drop foreign key constraint and index from norujukan column
|
||||
if (Schema::connection($dbase)->hasColumn('palsu', 'norujukan')) {
|
||||
try {
|
||||
$table->dropForeign('norujukan');
|
||||
echo "Dropped foreign key 'norujukan' on connection '{$dbase}'\n";
|
||||
} catch (\Exception $e) {
|
||||
echo "Warning: Could not drop foreign key 'norujukan' on connection '{$dbase}': " . $e->getMessage() . "\n";
|
||||
}
|
||||
// if (Schema::connection($dbase)->hasColumn('palsu', 'norujukan')) {
|
||||
// try {
|
||||
// $table->dropForeign('norujukan');
|
||||
// echo "Dropped foreign key 'norujukan' on connection '{$dbase}'\n";
|
||||
// } catch (\Exception $e) {
|
||||
// echo "Warning: Could not drop foreign key 'norujukan' on connection '{$dbase}': " . $e->getMessage() . "\n";
|
||||
// }
|
||||
|
||||
try {
|
||||
$table->dropIndex(['norujukan']);
|
||||
echo "Dropped index on 'norujukan' column on connection '{$dbase}'\n";
|
||||
} catch (\Exception $e) {
|
||||
echo "Warning: Could not drop index on 'norujukan' on connection '{$dbase}': " . $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
// try {
|
||||
// $table->dropIndex(['norujukan']);
|
||||
// echo "Dropped index on 'norujukan' column on connection '{$dbase}'\n";
|
||||
// } catch (\Exception $e) {
|
||||
// echo "Warning: Could not drop index on 'norujukan' on connection '{$dbase}': " . $e->getMessage() . "\n";
|
||||
// }
|
||||
// }
|
||||
|
||||
// Drop other columns if they exist
|
||||
$columnsToCheck = ['nilaimarhun', 'jbg', 'untung','untungonepercent','untungcajlain', 'pembiayaan'];
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreatePampasanTable extends Migration
|
||||
{
|
||||
private function getActiveDB(): array
|
||||
{
|
||||
$config_db = array_keys(config('database.connections'));
|
||||
$db_connection = array_filter($config_db, function ($connection) {
|
||||
try {
|
||||
if ($connection === 'mysql7') return false; // ikut pattern sedia ada
|
||||
DB::connection($connection)->select('SELECT 1');
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return $db_connection ? array_values($db_connection) : [];
|
||||
}
|
||||
|
||||
public function up()
|
||||
{
|
||||
foreach ($this->getActiveDB() as $dbase) {
|
||||
if (!Schema::connection($dbase)->hasTable('pampasan')) {
|
||||
Schema::connection($dbase)->create('pampasan', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('norujukan', 50)->unique()->index();
|
||||
$table->string('baucerno', 30)->index();
|
||||
$table->string('kodcaw', 20)->index();
|
||||
$table->decimal('jumlah_pampasan', 11, 2);
|
||||
|
||||
if (Schema::getConnection()->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION) >= '5.7') {
|
||||
$table->json('denominasi')->nullable();
|
||||
} else {
|
||||
$table->longText('denominasi')->nullable();
|
||||
}
|
||||
$table->string('teller', 100);
|
||||
$table->tinyInteger('status')
|
||||
->default(0)
|
||||
->comment('0 = belum dituntut, 1 = dituntut');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
foreach ($this->getActiveDB() as $dbase) {
|
||||
Schema::connection($dbase)->dropIfExists('pampasan');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AddJenisColumnToPalsuTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Get active database connections
|
||||
*/
|
||||
private function getActiveDB(): array
|
||||
{
|
||||
$config_db = array_keys(config("database.connections"));
|
||||
|
||||
$db_connection = array_filter($config_db, function($connection) {
|
||||
try {
|
||||
if ($connection == 'mysql7') {
|
||||
return false;
|
||||
}
|
||||
|
||||
DB::connection($connection)->select('SELECT 1');
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return $db_connection ? array_values($db_connection) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach ($db_connection as $dbase) {
|
||||
Schema::connection($dbase)->table('palsu', function (Blueprint $table) use ($dbase) {
|
||||
if (!Schema::connection($dbase)->hasColumn('palsu', 'jenis')) {
|
||||
$table->string('jenis', 50)->nullable()->comment('Jenis/Type classification');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach ($db_connection as $dbase) {
|
||||
Schema::connection($dbase)->table('palsu', function (Blueprint $table) use ($dbase) {
|
||||
if (Schema::connection($dbase)->hasColumn('palsu', 'jenis')) {
|
||||
$table->dropColumn('jenis');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateJenisToPampasanForSempornaRecords extends Migration
|
||||
{
|
||||
/**
|
||||
* Semporna norujukan records to update
|
||||
*/
|
||||
private function getSempornaRecords(): array
|
||||
{
|
||||
return [
|
||||
'011237240808-0003',
|
||||
'011237240719-0015',
|
||||
'011237240806-0011',
|
||||
'011237240828-0001',
|
||||
'011237240904-0007',
|
||||
'011237240904-0008',
|
||||
'011237240904-0009',
|
||||
'011237240719-0023',
|
||||
'011237240719-0024',
|
||||
'011237240719-0025',
|
||||
'011237240618-0026',
|
||||
'011237240719-0027',
|
||||
'011237240719-0028',
|
||||
'011237240618-0020',
|
||||
'011237240719-0030',
|
||||
'011237240618-0029',
|
||||
'011237240731-0026',
|
||||
'011237240912-0009'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$semporna_records = $this->getSempornaRecords();
|
||||
|
||||
// Update jenis to 'pampasan' for Semporna records in mysql34 (Semporna branch)
|
||||
try {
|
||||
$updated = DB::connection('mysql34')->table('palsu')
|
||||
->whereIn('norujukan', $semporna_records)
|
||||
->update(['jenis' => 'pampasan']);
|
||||
|
||||
echo "Updated {$updated} Semporna records with jenis = 'pampasan'\n";
|
||||
} catch (\Exception $e) {
|
||||
echo "Error updating Semporna records: " . $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$semporna_records = $this->getSempornaRecords();
|
||||
|
||||
// Revert jenis to null for Semporna records
|
||||
try {
|
||||
$reverted = DB::connection('mysql34')->table('palsu')
|
||||
->whereIn('norujukan', $semporna_records)
|
||||
->update(['jenis' => null]);
|
||||
|
||||
echo "Reverted {$reverted} Semporna records jenis to null\n";
|
||||
} catch (\Exception $e) {
|
||||
echo "Error reverting Semporna records: " . $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateNonSempornaRecordsJenisToHapuskira extends Migration
|
||||
{
|
||||
/**
|
||||
* Get active database connections
|
||||
*/
|
||||
private function getActiveDB(): array
|
||||
{
|
||||
$config_db = array_keys(config("database.connections"));
|
||||
|
||||
$db_connection = array_filter($config_db, function($connection) {
|
||||
try {
|
||||
if ($connection == 'mysql7') {
|
||||
return false;
|
||||
}
|
||||
|
||||
DB::connection($connection)->select('SELECT 1');
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return $db_connection ? array_values($db_connection) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Semporna norujukan records to exclude
|
||||
*/
|
||||
private function getSempornaRecords(): array
|
||||
{
|
||||
return [
|
||||
'011237240808-0003',
|
||||
'011237240719-0015',
|
||||
'011237240806-0011',
|
||||
'011237240828-0001',
|
||||
'011237240904-0007',
|
||||
'011237240904-0008',
|
||||
'011237240904-0009',
|
||||
'011237240719-0023',
|
||||
'011237240719-0024',
|
||||
'011237240719-0025',
|
||||
'011237240618-0026',
|
||||
'011237240719-0027',
|
||||
'011237240719-0028',
|
||||
'011237240618-0020',
|
||||
'011237240719-0030',
|
||||
'011237240618-0029',
|
||||
'011237240731-0026',
|
||||
'011237240912-0009'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
$semporna_records = $this->getSempornaRecords();
|
||||
|
||||
foreach ($db_connection as $dbase) {
|
||||
try {
|
||||
if ($dbase == 'mysql34') {
|
||||
// For Semporna (mysql34), update only non-Semporna records to 'hapuskira'
|
||||
$updated = DB::connection($dbase)->table('palsu')
|
||||
->whereNotIn('norujukan', $semporna_records)
|
||||
->update(['jenis' => 'hapuskira']);
|
||||
|
||||
if ($updated > 0) {
|
||||
echo "Updated {$updated} non-Semporna records in {$dbase} to jenis = 'hapuskira'\n";
|
||||
}
|
||||
} else {
|
||||
// For all other databases, update all records to 'hapuskira'
|
||||
$updated = DB::connection($dbase)->table('palsu')
|
||||
->update(['jenis' => 'hapuskira']);
|
||||
|
||||
if ($updated > 0) {
|
||||
echo "Updated {$updated} records in {$dbase} to jenis = 'hapuskira'\n";
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
echo "Error updating {$dbase}: " . $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach ($db_connection as $dbase) {
|
||||
try {
|
||||
// Revert all jenis values to null except Semporna records which should remain 'pampasan'
|
||||
if ($dbase == 'mysql34') {
|
||||
$semporna_records = $this->getSempornaRecords();
|
||||
$reverted = DB::connection($dbase)->table('palsu')
|
||||
->whereNotIn('norujukan', $semporna_records)
|
||||
->update(['jenis' => null]);
|
||||
|
||||
if ($reverted > 0) {
|
||||
echo "Reverted {$reverted} non-Semporna records in {$dbase} jenis to null\n";
|
||||
}
|
||||
} else {
|
||||
$reverted = DB::connection($dbase)->table('palsu')
|
||||
->update(['jenis' => null]);
|
||||
|
||||
if ($reverted > 0) {
|
||||
echo "Reverted {$reverted} records in {$dbase} jenis to null\n";
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
echo "Error reverting {$dbase}: " . $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AddStatusColumnToPalsuTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Get active database connections
|
||||
*/
|
||||
private function getActiveDB(): array
|
||||
{
|
||||
$config_db = array_keys(config("database.connections"));
|
||||
|
||||
$db_connection = array_filter($config_db, function($connection) {
|
||||
try {
|
||||
if ($connection == 'mysql7') {
|
||||
return false;
|
||||
}
|
||||
|
||||
DB::connection($connection)->select('SELECT 1');
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return $db_connection ? array_values($db_connection) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach ($db_connection as $dbase) {
|
||||
Schema::connection($dbase)->table('palsu', function (Blueprint $table) use ($dbase) {
|
||||
if (!Schema::connection($dbase)->hasColumn('palsu', 'status')) {
|
||||
$table->unsignedSmallInteger('status')->default(0)->comment('Status value');
|
||||
}
|
||||
});
|
||||
|
||||
// Update existing rows to have status = 0
|
||||
DB::connection($dbase)->table('palsu')
|
||||
->whereNull('status')
|
||||
->update(['status' => 0]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach ($db_connection as $dbase) {
|
||||
Schema::connection($dbase)->table('palsu', function (Blueprint $table) use ($dbase) {
|
||||
if (Schema::connection($dbase)->hasColumn('palsu', 'status')) {
|
||||
$table->dropColumn('status');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateAllPalsuStatusToOne extends Migration
|
||||
{
|
||||
/**
|
||||
* Get active database connections
|
||||
*/
|
||||
private function getActiveDB(): array
|
||||
{
|
||||
$config_db = array_keys(config("database.connections"));
|
||||
|
||||
$db_connection = array_filter($config_db, function($connection) {
|
||||
try {
|
||||
if ($connection == 'mysql7') {
|
||||
return false;
|
||||
}
|
||||
|
||||
DB::connection($connection)->select('SELECT 1');
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return $db_connection ? array_values($db_connection) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach ($db_connection as $dbase) {
|
||||
try {
|
||||
// Update all status values to 1 in palsu table
|
||||
$updated = DB::connection($dbase)->table('palsu')
|
||||
->update(['status' => 1]);
|
||||
|
||||
if ($updated > 0) {
|
||||
echo "Updated {$updated} records in {$dbase} palsu table to status = 1\n";
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
echo "Error updating {$dbase}: " . $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach ($db_connection as $dbase) {
|
||||
try {
|
||||
// Revert all status values back to 0 in palsu table
|
||||
$reverted = DB::connection($dbase)->table('palsu')
|
||||
->update(['status' => 0]);
|
||||
|
||||
if ($reverted > 0) {
|
||||
echo "Reverted {$reverted} records in {$dbase} palsu table to status = 0\n";
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
echo "Error reverting {$dbase}: " . $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateSempornaRecordsStatusToZero extends Migration
|
||||
{
|
||||
/**
|
||||
* Semporna norujukan records to update status to 0
|
||||
*/
|
||||
private function getSempornaRecords(): array
|
||||
{
|
||||
return [
|
||||
'011237240808-0003',
|
||||
'011237240719-0015',
|
||||
'011237240806-0011',
|
||||
'011237240828-0001',
|
||||
'011237240904-0007',
|
||||
'011237240904-0008',
|
||||
'011237240904-0009',
|
||||
'011237240719-0023',
|
||||
'011237240719-0024',
|
||||
'011237240719-0025',
|
||||
'011237240618-0026',
|
||||
'011237240719-0027',
|
||||
'011237240719-0028',
|
||||
'011237240618-0020',
|
||||
'011237240719-0030',
|
||||
'011237240618-0029',
|
||||
'011237240731-0026',
|
||||
'011237240912-0009'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$semporna_records = $this->getSempornaRecords();
|
||||
|
||||
// Update status to 0 for Semporna records in mysql34 (Semporna branch)
|
||||
try {
|
||||
$updated = DB::connection('mysql34')->table('palsu')
|
||||
->whereIn('norujukan', $semporna_records)
|
||||
->update(['status' => 0]);
|
||||
|
||||
echo "Updated {$updated} Semporna records with status = 0\n";
|
||||
} catch (\Exception $e) {
|
||||
echo "Error updating Semporna records status: " . $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$semporna_records = $this->getSempornaRecords();
|
||||
|
||||
// Revert status to 1 for Semporna records
|
||||
try {
|
||||
$reverted = DB::connection('mysql34')->table('palsu')
|
||||
->whereIn('norujukan', $semporna_records)
|
||||
->update(['status' => 1]);
|
||||
|
||||
echo "Reverted {$reverted} Semporna records status to 1\n";
|
||||
} catch (\Exception $e) {
|
||||
echo "Error reverting Semporna records status: " . $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AddAgreementPrintedAtToPampasanTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Get active database connections
|
||||
*/
|
||||
private function getActiveDB(): array
|
||||
{
|
||||
$config_db = array_keys(config("database.connections"));
|
||||
|
||||
$db_connection = array_filter($config_db, function($connection) {
|
||||
try {
|
||||
if ($connection === 'mysql7') return false; // ikut pattern sedia ada
|
||||
DB::connection($connection)->select('SELECT 1');
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return $db_connection ? array_values($db_connection) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
foreach ($this->getActiveDB() as $dbase) {
|
||||
Schema::connection($dbase)->table('pampasan', function (Blueprint $table) use ($dbase) {
|
||||
if (!Schema::connection($dbase)->hasColumn('pampasan', 'agreement_printed_at')) {
|
||||
$table->timestamp('agreement_printed_at')->nullable()->comment('Timestamp when agreement was printed');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
foreach ($this->getActiveDB() as $dbase) {
|
||||
Schema::connection($dbase)->table('pampasan', function (Blueprint $table) use ($dbase) {
|
||||
if (Schema::connection($dbase)->hasColumn('pampasan', 'agreement_printed_at')) {
|
||||
$table->dropColumn('agreement_printed_at');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -384,6 +384,12 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
||||
$router->post('CreatePanjar/{kodcaw}',['uses'=>'PanjarController@create']);
|
||||
$router->post('DeletePanjar/{kodcaw}',['uses'=>'PanjarController@delete']);
|
||||
|
||||
//API PAMPASAN GUNA PANJAR
|
||||
$router->post('pampasan/initiatePampasan',['uses'=>'PampasanController@initiatePampasan']);
|
||||
$router->post('pampasan/terimaPampasan',['uses'=>'PampasanController@terimaPampasan']);
|
||||
$router->put('pampasan/updateStatusPampasan', ['uses' => 'PampasanController@updateStatusPampasan']);
|
||||
$router->get('pampasan', ['uses' => 'PampasanController@getPampasan']);
|
||||
|
||||
|
||||
//API KELULUSAN
|
||||
$router->get('SenaraiKelulusan/{kodcaw}',['uses'=>'KelulusanController@list']);
|
||||
|
||||
Reference in New Issue
Block a user