diff --git a/app/Http/Controllers/LelongController.php b/app/Http/Controllers/LelongController.php index a1d4d5b..f5b3e97 100644 --- a/app/Http/Controllers/LelongController.php +++ b/app/Http/Controllers/LelongController.php @@ -5,8 +5,11 @@ namespace App\Http\Controllers; use App\Lelong; use App\Cawangan; use App\Gadai; +use App\TuntutBaki; use Illuminate\Http\Request; + use Carbon\Carbon; + class LelongController extends Controller { @@ -138,4 +141,97 @@ class LelongController extends Controller return response()->json($lelong); } + + public function simpantuntutbaki($kodcaw,Request $request){ + + $current = Carbon::now(); + $current = new Carbon(); + + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); + + $tuntutbaki = TuntutBaki::on($cawangan['mysql'])->create([ + 'batchno' => $request->batchno, + 'jenis' => $request->jenis, + 'kodcaw' => $kodcaw, + 'norujukan' => $request->norujukan, + 'tarikh' => $current->toDateString(), + 'prkod' => "01", + 'teller' => $request->teller, + 'bakipjm' => $request->bakipjm, + 'bakiupah' => $request->bakiupah, + 'cajlain' => $request->cajlain, + 'cajlelong' => $request->cajlelong, + 'kodgl' => "1000/013", + 'glcode' => "1000/010", + 'terima' => "*", + 'f_lulus' => "L", + 'jumlah' => $request->jumlah, + 'nowakil' => $request->nowakil, + 'hargajual' => $request->hargajual + ]); + + return response()->json($tuntutbaki,200); + } + + public function updatetagtbaki($kodcaw,$norujukan){ + + $current = Carbon::now(); + $current = new Carbon(); + + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); + + $gadai=Gadai::on($cawangan['mysql']) + ->where('norujukan','=',$norujukan) + ->update( + array('tagtbaki'=> 0)); + + $lelong=Lelong::on($cawangan['mysql']) + ->where('norujukan','=',$norujukan) + ->update( + array('trkhtuntut'=> $current->toDateString(), + 't_update' => $current->toDateString())); + + + if($gadai == 1 && $lelong == 1) + { + return response('Berjaya', 200); + }else{ + return response('Gagal', 200); + } + + } + + public function showTuntutBaki($kodcaw){ + + $current = Carbon::now(); + $current = new Carbon(); + + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); + + $tuntutbaki = TuntutBaki::on($cawangan['mysql']) + ->where('tarikh','=', $current->toDateString()) + ->get(); + + return response()->json($tuntutbaki,200); + } + + public function resitLelong($kodcaw,$norujukan){ + + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); + + $lelong = Lelong::on($cawangan['mysql']) + ->select('tuntutbaki.batchno','tuntutbaki.tarikh','tuntutbaki.bakipjm','tuntutbaki.bakiupah','tuntutbaki.recno','lelong.t_lelong','tuntutbaki.norujukan','customer.nama','customer.kpbaru','tuntutbaki.hargajual','tuntutbaki.jumlah','tuntutbaki.cajlelong','lelong.pinjaman') + ->where('lelong.norujukan','=',$norujukan) + ->whereNotNull('lelong.trkhtuntut') + ->leftJoin('tuntutbaki', 'tuntutbaki.norujukan', '=', 'lelong.norujukan') + ->leftJoin('gadai', 'gadai.norujukan', '=', 'lelong.norujukan') + ->leftJoin('customer', 'customer.kpbaru', '=', 'gadai.nokp') + ->orderBy('tuntutbaki.tarikh') + ->first(); + + return response()->json($lelong,200); + + } + + } \ No newline at end of file diff --git a/app/Lelong.php b/app/Lelong.php index 7b7a110..a7a21a3 100644 --- a/app/Lelong.php +++ b/app/Lelong.php @@ -8,14 +8,99 @@ class Lelong extends Model { protected $table = 'lelong'; + public $timestamps = false; + /** * The attributes that are mass assignable. * * @var array */ - // protected $fillable = [ - - // ]; + protected $fillable = [ + 'batchno', + 'sirilel', + 'kodcaw', + 'norujukan', + 't_lelong', + 'hargaasas', + 'hargajual', + 'glcode', + 't_jual', + 'nopembeli', + 'jbg', + 'kadarupah', + 'upahsimpan', + 'ansuran', + 'nilaimarhun', + 'nilaimarhuns', + 'pinjaman', + 'bakipjmas', + 'bakipjm', + 'bakiupahas', + 'bakiupah', + 'cajlainas', + 'cajlain', + 'cajlelongas', + 'cajlelong', + 'baki', + 'terima', + 'cetak', + 'teller', + 'pelulus', + 'pelulust', + 'f_lulus', + 'type', + 'prkod', + 'tagsurat', + 'trkhtuntut', + 'tellertb', + 'pelulustb', + 'terimatb', + 't_hapuskira', + 'hapuskira', + 'hkpjm', + 'cancelid', + 'canceltime', + 'kodgl', + 't_update', + 'berat', + 'marhun', + 'lebihkurang', + 'tagaid', + 'gst_hj', + 'gst_cl', + 't_lelong_sim', + 'hargajual_sim', + 'cajlelong_sim', + 'gst_hj_sim', + 'gst_cl_sim', + 'bakiupah_sim', + 'hargaasas_sim', + 'mutu_terendah', + 'harga_baru', + 'turun', + 'percent', + 'baki_sim', + 'hargalama', + 'makan_pinj', + 'baki_upah6', + 'baki6', + 'tag_gst', + 'tagpelanggan', + 'fasa', + 'jbg_lelong', + 'berat_plastik', + 'lel1stop', + 'nopelanggan', + 'status_bida_online', + 'tag_tbaki', + 'pel_tbaki', + 'pmt', + 'tagpmt', + 'hargaasasasal', + 'beratasal', + ' loopsemak', + 'tagcall' + ]; /** * The attributes excluded from the model's JSON form. diff --git a/routes/web.php b/routes/web.php index c0f0c74..372a5c8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -267,6 +267,13 @@ $router->group(['prefix'=>'api'], function () use ($router){ $router->put('DenominasiUpdate/{kodcaw}',['uses'=>'DenominasiController@updatedenominasi']); $router->post('DenominasiCreate/{kodcaw}',['uses'=>'DenominasiController@createdenominasi']); + //Tuntut Baki + $router->get('TuntutBaki/{kodcaw}',['uses'=>'LelongController@showTuntutBaki']); + $router->get('TuntutBaki/resit/{kodcaw}/{norujukan}',['uses'=>'LelongController@resitLelong']); + $router->post('Tuntutbakisimpan/{kodcaw}',['uses'=>'LelongController@simpantuntutbaki']); + $router->put('tuntutbakiupdate/{kodcaw}/{norujukan}',['uses'=>'LelongController@updatetagtbaki']); + + //Komuditi Pukal $router->get('komuditi/check',['uses'=>'KomuditiController@checkKomuditi']); $router->post('komuditi/pembelian',['uses'=>'KomuditiController@beliKomuditi']);