From 5960e2265ce8b1851117496807c74dabd524f942 Mon Sep 17 00:00:00 2001 From: Nur Izzati Zulkifli Date: Wed, 31 May 2023 15:50:39 +0800 Subject: [PATCH] update blast wabot tuntut baki dan parameter setting --- app/Http/Controllers/NotisController.php | 86 ++++++++- app/Jobs/WhatsappNotisTuntutBaki.php | 165 ++++++++++++++++++ ...21_12_13_053311_create_cawangans_table.php | 5 +- ...2021_12_14_041557_create_lelongs_table.php | 4 + database/seeders/RolesSeeder.php | 6 + resources/views/includes/sidebar.blade.php | 57 ++---- .../views/jananotis/notistuntutbaki.blade.php | 7 +- .../kemaskininotistuntutbaki.blade.php | 118 +++++++++++++ .../views/pdf/pdfnotistuntutbaki.blade.php | 6 +- routes/web.php | 10 +- 10 files changed, 411 insertions(+), 53 deletions(-) create mode 100644 app/Jobs/WhatsappNotisTuntutBaki.php create mode 100644 resources/views/parameter/kemaskininotistuntutbaki.blade.php diff --git a/app/Http/Controllers/NotisController.php b/app/Http/Controllers/NotisController.php index 93277795..023dc575 100644 --- a/app/Http/Controllers/NotisController.php +++ b/app/Http/Controllers/NotisController.php @@ -28,6 +28,7 @@ use App\Models\LelongTebus; use App\Models\LogUser; use Illuminate\Support\Facades\Log; use App\Jobs\WhatsappNotisPeringatanKedua; +use App\Jobs\WhatsappNotisTuntutBaki; use App\Models\FailedJob; use Carbon\Carbon; use PDF; @@ -1741,10 +1742,10 @@ Sekian, terima kasih.'; $lelongid[$index1]['bilangan'] = sizeof($listsag); // dd(sizeof($listsag)); - + $caw_id = $bil['caw_id']; } - return view('jananotis.notistuntutbaki',compact('lelongid')); + return view('jananotis.notistuntutbaki',compact('lelongid','caw_id','caw')); } public function senaraituntutbaki($lelongid, $cawid) @@ -1906,6 +1907,87 @@ Sekian, terima kasih.'; return $pdf->download('Penjanaan Notis Tuntut Baki ' . $lelong_id . '.pdf'); } + + public function blastnotistuntutbaki($lelong_id,$caw_id) + { + $user = Auth::user(); + $caw = Cawangan::where('id', '=', $caw_id)->first(); + $bilblast = 0; + $currentdate = Carbon::now(); + + $lel = Lelong::find($lelong_id); + WhatsappNotisTuntutBaki::dispatch($user->id, $user->kodcaw, $lelong_id, $caw_id); + + $updatestatus = CawanganLelong::where('lelong_id', '=', $lelong_id)->where('caw_id', '=', $caw_id)->first(); + $bilblast = $updatestatus->bilblast; + $bilblast++; + $updatestatus->bilblast = $bilblast; //blastwabot + $updatestatus->save(); + + return redirect()->route('jananotis.notistuntutbaki') + ->with('success','Blast Whatsapp Dalam Proses'); + } + + Public function kemaskininotistuntutbaki(Request $request){ + + + $tetapan = Tetapan::where('id','=',1)->get(); + + + return view('parameter.kemaskininotistuntutbaki',compact('tetapan')); + + } + public function storeparabaki(Request $request) { + + + // dd($request->all()); + $tetapan = Tetapan::find(1); + + $tetapan->parabaki = $request->parabaki; + $tetapan->update(); + + $cawangan = Cawangan::all(); + + foreach($cawangan as $updatecaw){ + + $update = Cawangan::where('id', $updatecaw['id']) + ->update(['parabaki'=>$request->parabaki]); + // $update->para2 = $request->para2; + // $update->update(); + + } + + return redirect()->route('parameter.kemaskininotistuntutbaki') + ->with('success','Kemaskini Berjaya'); + + + } + + public function storeparabaki2(Request $request) { + + + // dd($request->all()); + $tetapan = Tetapan::find(1); + + $tetapan->parabaki2 = $request->parabaki2; + $tetapan->update(); + + $cawangan = Cawangan::all(); + + foreach($cawangan as $updatecaw){ + + $update = Cawangan::where('id', $updatecaw['id']) + ->update(['parabaki2'=>$request->parabaki2]); + // $update->para2 = $request->para2; + // $update->update(); + + } + + return redirect()->route('parameter.kemaskininotistuntutbaki') + ->with('success','Kemaskini Berjaya'); + + + } diff --git a/app/Jobs/WhatsappNotisTuntutBaki.php b/app/Jobs/WhatsappNotisTuntutBaki.php new file mode 100644 index 00000000..4e038b87 --- /dev/null +++ b/app/Jobs/WhatsappNotisTuntutBaki.php @@ -0,0 +1,165 @@ +user_id = $user_id; + $this->user_kodcaw = $user_kodcaw; + $this->lelong_id = $lelong_id; + $this->caw_id = $caw_id; + } + + /** + * Execute the job. + * + * @return void + */ + public function handle() + { + // $user = Auth::user(); + $caw = Cawangan::where('id', '=', $this->caw_id)->first(); + + $currentdate = Carbon::now(); + + $lel = Lelong::with('cawangan')->find($this->lelong_id); + + $cawanganDetail = $lel->cawangan->find($this->caw_id); + $lelong_id = $this->lelong_id; + $cawangan = Cawangan::with(["lelongBid" => function($q) use ($lelong_id){ + $q->where('lelong_id', '=', $lelong_id)->select('id','caw_id','kodcaw','norujukan','pinjaman','bakiupah','hargaasas','nilaimarhun','cajlelong','baki'); + }]) + ->where('caw_code','=',$cawanganDetail->caw_code)->first(); + $lelongbid_data_pluck_norujukan = $cawangan->lelongBid->pluck('norujukan')->toArray(); + $gadai_all = LelongCawangan::on($cawanganDetail->caw_code)->whereIn('lelong.norujukan', $lelongbid_data_pluck_norujukan) + ->join('gadai','gadai.norujukan','=','lelong.norujukan') + ->where('trkhtuntut','=',null) + ->where('baki','>', '0.00') + ->select('nokp', 'lelong.norujukan','lelong.t_lelong AS tarikhlelong','lelong.hargajual','lelong.gst_hj','gadai.bakipjm','lelong.bakiupah','lelong.cajlelong','lelong.gst_cl','lelong.cajlain','lelong.baki') + ->orderBy('nokp', 'asc') + ->orderBy('lelong.norujukan','ASC') + ->get(); + + $customers_list = $gadai_all->pluck('nokp')->unique(); + $customers = Customer::whereIn('kpbaru', $customers_list) + ->orWhereIn('kplama', $customers_list) + ->select('id','kpbaru','kplama' ,'nama', 'telefon') + ->get()->keyBy('id'); + + $customers_keyBy_noKp = $customers->keyBy(function ($item) { + if ($item->kpbaru != '') { + return $item->kpbaru; + } else if ($item->kplama != '') { + return $item->kplama; + } + }); + + $customers_pluck_notel = $customers_keyBy_noKp->pluck('telefon'); + // dd($customers_pluck_notel); + foreach($customers_pluck_notel as $index1 =>$custphone) { + // dd($custphone); + $special = preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $custphone); + // dump($special); + if($special == 0){ + if($custphone == ''){ + $newtel = ''; + }elseif($custphone <> ''){ + $newtel = '6'.$custphone; + } + } + elseif($special == 1){ + if($custphone == ''){ + $newtel = ''; + }elseif($custphone <> ''){ + $newtel = '6'.str_replace( array( '-' ), '', $custphone); + } + } + // dump($newtel); + + } + $lelong_bid_all_groupby_norujukan = $gadai_all->groupBy('norujukan'); + $lelong_all_keyBy_norujukan = $gadai_all->keyBy('norujukan'); + foreach($lelong_bid_all_groupby_norujukan as $index7=>$lelongbid){ + // dd($notis_all_keyBy_norujukan); + if($lelong_all_keyBy_norujukan[$index7]){ + + $gadai_true = $lelong_all_keyBy_norujukan[$index7]; + $gadai_true['data_lelongbid'] = $lelongbid; + } + + } + // dd($gadai_all); + foreach ($gadai_all as $index => $suratnotis) { + $datanotisbid = $suratnotis['data_lelongbid'][0]->fasa; + // dd($suratnotis); + if($customers_keyBy_noKp[$suratnotis->nokp]) + { + $mobile_no = '60178916936'; + // $mobile_no = $newtel; + $user_true = $customers_keyBy_noKp[$suratnotis->nokp]; + $nama = $user_true->nama; + $baki = number_format($suratnotis->baki, 2, '.', ','); + $t_jual = Carbon::parse($suratnotis->t_jual); + $t_jualf1 = $t_jual->format('d-m-Y'); + $cawname = $caw->caw_name; + $parabaki2 = $caw->parabaki2; + // dd($t_matang1); + $message = '*NOTIS MAKLUMAN LEBIHAN WANG LELONGAN BARANGAN* + +Nama: *'.$nama.'* +No.KP: *'.$suratnotis->nokp.'*'.' +No.Rujukan: *'.$suratnotis->norujukan.'* +Tarikh Lelong: *'.$t_jualf1.'* +Wang Lebihan: *RM'.$baki.'*'.' + +'.$parabaki2. ' *'.$cawname.'*. + +Terima Kasih'; + + $response = Http::get(env('WABOT_API'), [ + 'number' => $mobile_no, + 'type' => 'text', + 'message' => $message, + 'instance_id' => env('WABOT_INSTANCES_ID'), + 'access_token' => env('WABOT_TOKEN_KEYS') + ]); + + Log::info("WABOT - Notis Tuntutan Baki Lelong" . $response); + } + sleep(2); + } + } +} diff --git a/database/migrations/2021_12_13_053311_create_cawangans_table.php b/database/migrations/2021_12_13_053311_create_cawangans_table.php index f181a278..c8313dc8 100644 --- a/database/migrations/2021_12_13_053311_create_cawangans_table.php +++ b/database/migrations/2021_12_13_053311_create_cawangans_table.php @@ -30,7 +30,10 @@ class CreateCawangansTable extends Migration $table->string('nofaks')->nullable(); $table->string('lokasi')->nullable(); $table->string('pkb_jmc')->nullable(); - // $table->string('para2')->nullable(); + $table->longText('para2')->nullable(); + $table->longText('para3')->nullable(); + $table->longText('parabaki')->nullable(); + $table->longText('parabaki2')->nullable(); $table->timestamps(); }); diff --git a/database/migrations/2021_12_14_041557_create_lelongs_table.php b/database/migrations/2021_12_14_041557_create_lelongs_table.php index 1dc55c27..54da9fa1 100644 --- a/database/migrations/2021_12_14_041557_create_lelongs_table.php +++ b/database/migrations/2021_12_14_041557_create_lelongs_table.php @@ -65,6 +65,7 @@ class CreateLelongsTable extends Migration $table->string('lokasi')->nullable(); $table->integer('fasa')->default(0); $table->integer('kali')->nullable(); + $table->integer('bilblast')->nullable(); $table->timestamps(); $table->foreign('caw_id') @@ -199,6 +200,8 @@ class CreateLelongsTable extends Migration $table->timestamps(); $table->longText('para2')->nullable(); $table->longText('para3')->nullable(); + $table->longText('parabaki')->nullable(); + $table->longText('parabaki2')->nullable(); // $table->foreign('norujukan') @@ -220,5 +223,6 @@ class CreateLelongsTable extends Migration Schema::dropIfExists('lelongbidmarhun'); Schema::dropIfExists('lelkarat'); Schema::dropIfExists('lelkarat_temp'); + Schema::dropIfExists('tetapan'); } } diff --git a/database/seeders/RolesSeeder.php b/database/seeders/RolesSeeder.php index 85a13ae9..ca46d56e 100644 --- a/database/seeders/RolesSeeder.php +++ b/database/seeders/RolesSeeder.php @@ -145,6 +145,11 @@ class RolesSeeder extends Seeder 'description' => 'Report By Cawangan(operasi)' ]); + Permission::create([ + 'name' => 'parameter', + 'description' => 'Parameter' + ]); + //account Permission::create([ 'name' => 'pengesahanbayaran', @@ -232,6 +237,7 @@ class RolesSeeder extends Seeder $role6->givePermissionTo('reportkali'); $role6->givePermissionTo('pengurusangambar'); $role6->givePermissionTo('reportbycaw'); + $role6->givePermissionTo('parameter'); diff --git a/resources/views/includes/sidebar.blade.php b/resources/views/includes/sidebar.blade.php index 2c4b59aa..fcc9288a 100644 --- a/resources/views/includes/sidebar.blade.php +++ b/resources/views/includes/sidebar.blade.php @@ -584,16 +584,7 @@
  • Tangguh Lelong
  • -
  • - - - - Notis Lelong - - -
  • +
  • @@ -762,49 +753,29 @@
  • - {{--
  • -
  • -