From a6dae2eeb6965e82e177ea8c44b17cb0deff8877 Mon Sep 17 00:00:00 2001 From: Amir Date: Thu, 24 Nov 2022 10:27:10 +0800 Subject: [PATCH] Export lelong, add insert field lelong, lelmarhun --- app/BatchLel.php | 5 +- app/Http/Controllers/LelongController.php | 58 +++++++++++++++++++++-- app/LelMarhun.php | 8 +++- 3 files changed, 65 insertions(+), 6 deletions(-) diff --git a/app/BatchLel.php b/app/BatchLel.php index ec59c42..21f6464 100644 --- a/app/BatchLel.php +++ b/app/BatchLel.php @@ -19,7 +19,10 @@ class BatchLel extends Model 'tarikh', 'tarikh2', 'batchno', - 'kodcaw' + 'kodcaw', + 't_daftar', + 'masadari', + 'masahingga' ]; /** diff --git a/app/Http/Controllers/LelongController.php b/app/Http/Controllers/LelongController.php index 0e11365..a4d2b8c 100644 --- a/app/Http/Controllers/LelongController.php +++ b/app/Http/Controllers/LelongController.php @@ -967,6 +967,9 @@ class LelongController extends Controller public function exportLelong(Request $request) { + $currentDate = Carbon::now(); + $currentDate = $currentDate->toDateString(); + $cawangan = Cawangan::on('mysql7')->where('kodcaw', $request->kodcaw)->first(); $batchlel = BatchLel::on($cawangan['mysql']) @@ -981,14 +984,44 @@ class LelongController extends Controller 'batchno' => $newBatchNo, 'tarikh' => $request->tarikh, 'tarikh2' => $request->tarikh, + 't_daftar' => $currentDate, + 'masadari' => $request->masadari, + 'masahingga' => $request->masahingga ]); + $lelong = Lelong::on($cawangan['mysql']) + ->select('sirilel') + ->orderBy('batchno', 'desc') + ->first(); + foreach ($request->lelongbid as $index) { $lelong_to_be_inserted = new Lelong(); - $lelong_to_be_inserted->kodcaw = $index['kodcaw']; $lelong_to_be_inserted->batchno = $newBatchNo; - $lelong_to_be_inserted->t_lelong = $request->tarikh; + $lelong_to_be_inserted->sirilel = $lelong->sirilel + 1; + $lelong_to_be_inserted->kodcaw = $index['kodcaw']; $lelong_to_be_inserted->norujukan = $index['norujukan']; + $lelong_to_be_inserted->t_lelong = $request->tarikh; + $lelong_to_be_inserted->hargaasas = $index['hargaasas']; + $lelong_to_be_inserted->hargajual = $index['hargajual']; + $lelong_to_be_inserted->glcode = "1000/010"; + $lelong_to_be_inserted->t_jual = $index['t_lelong']; + // $lelong_to_be_inserted->nopembeli = $; + $lelong_to_be_inserted->jbg = $index['jbg']; + $lelong_to_be_inserted->kadarupah = $index['kadarupah']; + $lelong_to_be_inserted->upahsimpan = $index['upahsimpan']; + $lelong_to_be_inserted->ansuran = $index['ansuran']; + $lelong_to_be_inserted->nilaimarhun = $index['nilaimarhun']; + $lelong_to_be_inserted->nilaimarhuns = $index['nmarhuns']; + $lelong_to_be_inserted->pinjaman = $index['pinjaman']; + $lelong_to_be_inserted->bakiupah = $index['bakiupah']; + $lelong_to_be_inserted->cajlelong = $index['cajlelong']; + $lelong_to_be_inserted->baki = $index['baki']; + $lelong_to_be_inserted->teller = $index['teller']; + $lelong_to_be_inserted->prkod = "01"; + $lelong_to_be_inserted->kodgl = "1000/013"; + $lelong_to_be_inserted->berat = $index['berat']; + $lelong_to_be_inserted->marhun = $index['marhun']; + $lelong_to_be_inserted->fasa = $index['fasa']; $lelong_arr[] = $lelong_to_be_inserted->attributesToArray(); } @@ -999,10 +1032,21 @@ class LelongController extends Controller $lelmarhun_to_be_inserted = new LelMarhun(); $lelmarhun_to_be_inserted->kodcaw = $request->kodcaw; $lelmarhun_to_be_inserted->norujukan = $data['norujukan']; + $lelmarhun_to_be_inserted->bil = $data['bil']; + $lelmarhun_to_be_inserted->marhun = $data['marhun']; $lelmarhun_to_be_inserted->nota = $data['nota']; + $lelmarhun_to_be_inserted->karat = $data['karat']; + $lelmarhun_to_be_inserted->berat = $data['berat']; + $lelmarhun_to_be_inserted->harga = $data['harga']; + $lelmarhun_to_be_inserted->n_marhun = $data['n_marhun']; + $lelmarhun_to_be_inserted->hargaasas = $data['hargaasas']; $lelmarhun_to_be_inserted->batch_no = $newBatchNo; + // $lelmarhun_to_be_inserted->beratasal = $; $lelmarhun_arr[] = $lelmarhun_to_be_inserted->attributesToArray(); + + $gadai = Gadai::on($cawangan['mysql'])->where('norujukan', $data['norujukan'])->get(); + dd($gadai); } LelMarhun::on($cawangan['mysql'])->insert($lelmarhun_arr); @@ -1010,22 +1054,28 @@ class LelongController extends Controller if ($request->tunai != null) { $tunai = Tunai::on($cawangan['mysql'])->create([ 'tarikh' => $request->tarikh, + 'kodcaw' => $request->kodcaw, 'kodlaluan' => "LELONG", 'masuk' => $request->tunai, + 'baki' => $request->tunai, ]); } if ($request->gldetail != null) { $gldetail = GlDetail::on($cawangan['mysql'])->create([ + 'kodcaw' => $request->kodcaw, 'tarikh' => $request->tarikh, 'dtacct' => "1000/010", 'ktacct' => "1000/020", + 'descpt' => "SERAHAN LELONG ONLINE, " . $request->tarikh, + 'amaun' => $request->gldetail, 'teller' => "LELONG ONLINE", - 'descpt' => "SERAHAN LELONG ONLINE", - 'amaun' => $request->gldetail + 'serahan' => $request->gldetail, ]); } + //update table gadai + return response()->json("success"); } diff --git a/app/LelMarhun.php b/app/LelMarhun.php index 72466b5..fed99e8 100644 --- a/app/LelMarhun.php +++ b/app/LelMarhun.php @@ -18,10 +18,16 @@ class LelMarhun extends Model protected $fillable = [ 'kodcaw', 'norujukan', - 't_gadai', + 'bil', 'marhun', 'nota', + 'karat', + 'berat', + 'harga', + 'n_marhun', + 'hargaasas', 'batch_no', + 'beratasal', ]; /**