From fa89519762f6db81fb502e5a53b3f27050066cf9 Mon Sep 17 00:00:00 2001 From: Amir Date: Wed, 16 Nov 2022 06:55:06 +0800 Subject: [PATCH 1/4] Add export data lelong --- app/BatchLel.php | 11 ++-- app/Http/Controllers/LelongController.php | 64 +++++++++++++++++++++++ app/LelMarhun.php | 9 ++++ routes/web.php | 1 + 4 files changed, 82 insertions(+), 3 deletions(-) diff --git a/app/BatchLel.php b/app/BatchLel.php index 49f2c65..ec59c42 100644 --- a/app/BatchLel.php +++ b/app/BatchLel.php @@ -7,15 +7,20 @@ use Illuminate\Database\Eloquent\Model; class BatchLel extends Model { protected $table = 'batchlel'; + public $timestamps = false; + /** * The attributes that are mass assignable. * * @var array */ - // protected $fillable = [ - - // ]; + protected $fillable = [ + 'tarikh', + 'tarikh2', + 'batchno', + 'kodcaw' + ]; /** * The attributes excluded from the model's JSON form. diff --git a/app/Http/Controllers/LelongController.php b/app/Http/Controllers/LelongController.php index 14b8e10..75e0bb3 100644 --- a/app/Http/Controllers/LelongController.php +++ b/app/Http/Controllers/LelongController.php @@ -22,7 +22,9 @@ use App\Tebus; use App\Advansur; use App\LelTebus; use App\LelMarhun; +use App\Tunai; use App\Audit; +use App\GlDetail; use Illuminate\Http\Request; use DB; @@ -963,4 +965,66 @@ class LelongController extends Controller return response()->json($arraylelong); } + public function exportLelong(Request $request) + { + $cawangan = Cawangan::on('mysql7')->where('kodcaw', $request->kodcaw)->first(); + + $batchlel = BatchLel::on($cawangan['mysql']) + ->select('batchno') + ->orderBy('batchno', 'desc') + ->first(); + + $newBatchNo = $batchlel->batchno + 1; + + $newBatchLel = BatchLel::on($cawangan['mysql'])->create([ + 'kodcaw' => $request->kodcaw, + 'batchno' => $newBatchNo, + 'tarikh' => $request->tarikh, + 'tarikh2' => $request->tarikh, + ]); + + 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->norujukan = $index['norujukan']; + + $lelong_arr[] = $lelong_to_be_inserted->attributesToArray(); + } + + Lelong::on($cawangan['mysql'])->insert($lelong_arr); + + foreach ($request->lelongbidmarhun as $data) { + $lelmarhun_to_be_inserted = new LelMarhun(); + $lelmarhun_to_be_inserted->kodcaw = $request['kodcaw']; + $lelmarhun_to_be_inserted->norujukan = $data['norujukan']; + $lelmarhun_to_be_inserted->t_gadai = $data['t_gadai']; + $lelmarhun_to_be_inserted->nota = $data['nota']; + $lelmarhun_to_be_inserted->batch_no = $newBatchNo; + + $lelmarhun_arr[] = $lelmarhun_to_be_inserted->attributesToArray(); + } + + LelMarhun::on($cawangan['mysql'])->insert($lelmarhun_arr); + + $tunai = Tunai::on($cawangan['mysql'])->create([ + 'tarikh' => $request->tarikh, + 'kodlaluan' => "LELONG", + 'masuk' => $request->tunai, + ]); + + $gldetail = GlDetail::on($cawangan['mysql'])->create([ + 'tarikh' => $request->tarikh, + 'dtacct' => "1000/010", + 'ktacct' => "1000/020", + 'teller' => "LELONG ONLINE", + 'descpt' => "SERAHAN LELONG ONLINE", + 'amaun' => $request->gldetail + ]); + + + return response()->json("success"); + } + } diff --git a/app/LelMarhun.php b/app/LelMarhun.php index 61cfaa9..72466b5 100644 --- a/app/LelMarhun.php +++ b/app/LelMarhun.php @@ -15,6 +15,15 @@ class LelMarhun extends Model * @var array */ + protected $fillable = [ + 'kodcaw', + 'norujukan', + 't_gadai', + 'marhun', + 'nota', + 'batch_no', + ]; + /** * The attributes excluded from the model's JSON form. * diff --git a/routes/web.php b/routes/web.php index eda1719..7968682 100644 --- a/routes/web.php +++ b/routes/web.php @@ -740,6 +740,7 @@ $router->group(['prefix'=>'admin'], function () use ($router){ $router->group(['prefix'=>'lelong'], function () use ($router){ $router->post('taglel/update',['uses'=>'GadaiController@updateTagLelong']); $router->post('taglel/revert',['uses'=>'GadaiController@revertTagLelong']); + $router->post('exportLelong',['uses'=>'LelongController@exportLelong']); }); $router->group(['prefix'=>'kelantanpay'], function () use ($router){ From 501c46d8398921bb13cc20e38298d32c87cbb9a1 Mon Sep 17 00:00:00 2001 From: Amir Date: Wed, 16 Nov 2022 10:09:25 +0800 Subject: [PATCH 2/4] Fix export data lelong --- app/Http/Controllers/LelongController.php | 34 ++++++++++++----------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/LelongController.php b/app/Http/Controllers/LelongController.php index 75e0bb3..0e11365 100644 --- a/app/Http/Controllers/LelongController.php +++ b/app/Http/Controllers/LelongController.php @@ -997,9 +997,8 @@ class LelongController extends Controller foreach ($request->lelongbidmarhun as $data) { $lelmarhun_to_be_inserted = new LelMarhun(); - $lelmarhun_to_be_inserted->kodcaw = $request['kodcaw']; + $lelmarhun_to_be_inserted->kodcaw = $request->kodcaw; $lelmarhun_to_be_inserted->norujukan = $data['norujukan']; - $lelmarhun_to_be_inserted->t_gadai = $data['t_gadai']; $lelmarhun_to_be_inserted->nota = $data['nota']; $lelmarhun_to_be_inserted->batch_no = $newBatchNo; @@ -1008,21 +1007,24 @@ class LelongController extends Controller LelMarhun::on($cawangan['mysql'])->insert($lelmarhun_arr); - $tunai = Tunai::on($cawangan['mysql'])->create([ - 'tarikh' => $request->tarikh, - 'kodlaluan' => "LELONG", - 'masuk' => $request->tunai, - ]); - - $gldetail = GlDetail::on($cawangan['mysql'])->create([ - 'tarikh' => $request->tarikh, - 'dtacct' => "1000/010", - 'ktacct' => "1000/020", - 'teller' => "LELONG ONLINE", - 'descpt' => "SERAHAN LELONG ONLINE", - 'amaun' => $request->gldetail - ]); + if ($request->tunai != null) { + $tunai = Tunai::on($cawangan['mysql'])->create([ + 'tarikh' => $request->tarikh, + 'kodlaluan' => "LELONG", + 'masuk' => $request->tunai, + ]); + } + if ($request->gldetail != null) { + $gldetail = GlDetail::on($cawangan['mysql'])->create([ + 'tarikh' => $request->tarikh, + 'dtacct' => "1000/010", + 'ktacct' => "1000/020", + 'teller' => "LELONG ONLINE", + 'descpt' => "SERAHAN LELONG ONLINE", + 'amaun' => $request->gldetail + ]); + } return response()->json("success"); } From a6dae2eeb6965e82e177ea8c44b17cb0deff8877 Mon Sep 17 00:00:00 2001 From: Amir Date: Thu, 24 Nov 2022 10:27:10 +0800 Subject: [PATCH 3/4] 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', ]; /** From fc4fd51281087a6aa1ea5f14d588be33aa073533 Mon Sep 17 00:00:00 2001 From: Amir Date: Thu, 1 Dec 2022 10:20:23 +0800 Subject: [PATCH 4/4] Fix export lelong --- app/Http/Controllers/LelongController.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/LelongController.php b/app/Http/Controllers/LelongController.php index a4d2b8c..2de93d7 100644 --- a/app/Http/Controllers/LelongController.php +++ b/app/Http/Controllers/LelongController.php @@ -995,6 +995,11 @@ class LelongController extends Controller ->first(); foreach ($request->lelongbid as $index) { + + $update_gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$index['norujukan'])->update(array( + 'sttebus' => "L" + )); + $lelong_to_be_inserted = new Lelong(); $lelong_to_be_inserted->batchno = $newBatchNo; $lelong_to_be_inserted->sirilel = $lelong->sirilel + 1; @@ -1045,8 +1050,6 @@ class LelongController extends Controller $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);