Merge branch 'ujrah_master' into new-onepercent
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BlastSMS extends Model
|
||||
{
|
||||
protected $table = 'log_blast_sms';
|
||||
protected $connection = 'mysql7';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'kodcaw',
|
||||
'nokp',
|
||||
'notelefon',
|
||||
'status',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BlastWasap extends Model
|
||||
{
|
||||
protected $table = 'log_blast_wasap';
|
||||
protected $connection = 'mysql7';
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'kodcaw',
|
||||
'nokp',
|
||||
'notelefon',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
@@ -754,8 +754,7 @@ class GadaiController extends Controller
|
||||
|
||||
public function getLaporanGadai($kodcaw,$tarikh){
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
|
||||
$gadai_data = Gadai::on($cawangan['mysql'])->select('t_gadai','norujukan','nokp','semakbarcode','masa','berat','nilaimarhun','pinjaman','upah12','percentpinj','teller','nokp')
|
||||
$gadai_data = Gadai::on($cawangan['mysql'])->select('t_gadai','norujukan','nokp','semakbarcode','masa','berat','nilaimarhun','pinjaman','upah12','percentpinj','teller','nokp','ujrah','onepercent')
|
||||
->where('t_gadai','=',$tarikh)
|
||||
->orderBy('teller')
|
||||
->orderBy('sirig')
|
||||
@@ -779,7 +778,9 @@ class GadaiController extends Controller
|
||||
"upah12"=> $gadaiData['upah12'],
|
||||
"percentpinj"=> $gadaiData['percentpinj'],
|
||||
"alamat1"=> $customer_info['alamat1'],
|
||||
"teller"=> $gadaiData['teller']
|
||||
"teller"=> $gadaiData['teller'],
|
||||
"onepercent"=> $gadaiData['onepercent'],
|
||||
"ujrah"=> $gadaiData['ujrah']
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -806,7 +807,7 @@ class GadaiController extends Controller
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
|
||||
$gadai_data = Gadai::on($cawangan['mysql'])->select('t_gadai','norujukan','nokp','semakbarcode','masa','berat','nilaimarhun','pinjaman','upah12','percentpinj','teller','nokp')
|
||||
$gadai_data = Gadai::on($cawangan['mysql'])->select('t_gadai','norujukan','nokp','semakbarcode','masa','berat','nilaimarhun','pinjaman','upah12','percentpinj','teller','nokp','ujrah','onepercent')
|
||||
->where('t_gadai','>=',$request->mula)
|
||||
->where('t_gadai','<=',$request->akhir)
|
||||
->orderBy('t_gadai')
|
||||
@@ -832,7 +833,9 @@ class GadaiController extends Controller
|
||||
"upah12"=> $gadaiData['upah12'],
|
||||
"percentpinj"=> $gadaiData['percentpinj'],
|
||||
"alamat1"=> $customer_info['alamat1'],
|
||||
"teller"=> $gadaiData['teller']
|
||||
"teller"=> $gadaiData['teller'],
|
||||
"ujrah"=> $gadaiData['ujrah'],
|
||||
"onepercent"=> $gadaiData['onepercent']
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1154,7 +1157,17 @@ class GadaiController extends Controller
|
||||
$dateans = new Carbon($request->tarikh);
|
||||
|
||||
$ansuran_data = Transaction::on('mysql7')
|
||||
->select('transaction.norujukan','trans.tarikh_bayaran','transaction.nokp','transaction.kodcaw','transaction.trans_type','cust.nama','trans.bayaran_pembiayaan','transaction.duit_masuk','trans.bayaran_keuntungan','transaction.teller')
|
||||
->select('transaction.norujukan',
|
||||
'trans.tarikh_bayaran',
|
||||
'transaction.nokp',
|
||||
'transaction.kodcaw',
|
||||
'transaction.trans_type',
|
||||
'cust.nama','trans.bayaran_pembiayaan',
|
||||
'transaction.duit_masuk',
|
||||
'trans.bayaran_keuntungan',
|
||||
'transaction.teller',
|
||||
'trans.ujrah',
|
||||
'trans.onepercent')
|
||||
->leftJoin('transaksi_keuntungan as trans', function($join)
|
||||
{
|
||||
$join->on('transaction.norujukan', '=', 'trans.norujukan');
|
||||
@@ -1189,7 +1202,72 @@ class GadaiController extends Controller
|
||||
"bayaran_pembiayaan" => $ansuranData['bayaran_pembiayaan'],
|
||||
"duit_masuk" => $ansuranData['duit_masuk'],
|
||||
"bayaran_keuntungan" => $ansuranData['bayaran_keuntungan'],
|
||||
"teller" => $ansuranData['teller']
|
||||
"teller" => $ansuranData['teller'],
|
||||
"ansuranujrah" => $ansuranData['ujrah'],
|
||||
"ansuranonepercent" => $ansuranData['onepercent'],
|
||||
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json($ansuran);
|
||||
}
|
||||
|
||||
public function getLaporanAnsuranUjrah($kodcaw,Request $request){
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
|
||||
$ansuran_data = Transaction::on('mysql7')
|
||||
->select('transaction.norujukan',
|
||||
'trans.tarikh_bayaran',
|
||||
'transaction.nokp',
|
||||
'transaction.kodcaw',
|
||||
'transaction.trans_type',
|
||||
'cust.nama','trans.bayaran_pembiayaan',
|
||||
'transaction.duit_masuk',
|
||||
'trans.bayaran_keuntungan',
|
||||
'transaction.teller',
|
||||
'trans.ujrah',
|
||||
'trans.onepercent')
|
||||
->leftJoin('transaksi_keuntungan as trans', function($join)
|
||||
{
|
||||
$join->on('transaction.norujukan', '=', 'trans.norujukan');
|
||||
$join->on('transaction.created_at', '=', 'trans.tarikh_bayaran');
|
||||
})
|
||||
->leftJoin('customer as cust', function($join)
|
||||
{
|
||||
$join->on('transaction.nokp', '=', 'cust.kpbaru');
|
||||
$join->orOn('transaction.nokp', '=', 'cust.kplama');
|
||||
})
|
||||
->where('transaction.kodcaw','=',$kodcaw)
|
||||
->where('transaction.trans_type','=','A')
|
||||
->where('transaction.created_at','>=',$request->mula)
|
||||
->where('transaction.created_at','<=',$request->akhir)
|
||||
->orderBy('trans.tarikh_bayaran')
|
||||
->orderBy('transaction.teller')
|
||||
->get();
|
||||
|
||||
$ansuran = [];
|
||||
|
||||
if($ansuran_data){
|
||||
foreach($ansuran_data as $index=>$ansuranData){
|
||||
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan',$ansuranData['norujukan'])->first();
|
||||
|
||||
array_push($ansuran,[
|
||||
"norujukan" => $ansuranData['norujukan'],
|
||||
"tarikh_bayaran" => $ansuranData['tarikh_bayaran'],
|
||||
"nokp" => $ansuranData['nokp'],
|
||||
"kodcaw" => $ansuranData['kodcaw'],
|
||||
"trans_type" => $ansuranData['trans_type'],
|
||||
"nama" => $ansuranData['nama'],
|
||||
"tempoh" => $gadai['tempoh'],
|
||||
"bakipjm" => $gadai['bakipjm'],
|
||||
"bayaran_pembiayaan" => $ansuranData['bayaran_pembiayaan'],
|
||||
"duit_masuk" => $ansuranData['duit_masuk'],
|
||||
"bayaran_keuntungan" => $ansuranData['bayaran_keuntungan'],
|
||||
"teller" => $ansuranData['teller'],
|
||||
"ansuranujrah" => $ansuranData['ujrah'],
|
||||
"ansuranonepercent" => $ansuranData['onepercent'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1227,12 +1305,83 @@ class GadaiController extends Controller
|
||||
$keuntungankaunter = $ansuranskaunter->sum('trans.bayaran_keuntungan');
|
||||
$pendahuluankaunter = $ansuranskaunter->sum('trans.bayaran_pembiayaan');
|
||||
$bilangankaunter = $ansuranskaunter->count();
|
||||
$ujrahkaunter = $ansuranskaunter->sum('trans.ujrah');
|
||||
$onepercentkaunter = $ansuranskaunter->sum('trans.onepercent');
|
||||
|
||||
$keuntunganonline = $ansuransonline->sum('trans.bayaran_keuntungan');
|
||||
$pendahuluanonline = $ansuransonline->sum('trans.bayaran_pembiayaan');
|
||||
$bilanganonline = $ansuransonline->count();
|
||||
|
||||
$arrayansuran = ['totalpendahuluankaunter' => $pendahuluankaunter, 'totalkeuntungankaunter' => $keuntungankaunter, 'bilangankaunter' => $bilangankaunter,'totalpendahuluanonline' => $pendahuluanonline, 'totalkeuntunganonline' => $keuntunganonline, 'bilanganonline' => $bilanganonline];
|
||||
$arrayansuran = [
|
||||
'totalpendahuluankaunter' => $pendahuluankaunter,
|
||||
'totalkeuntungankaunter' => $keuntungankaunter,
|
||||
'bilangankaunter' => $bilangankaunter,
|
||||
'totalujrahkaunter' => $ujrahkaunter,
|
||||
'totalonepercentkaunter' => $onepercentkaunter,
|
||||
|
||||
'totalpendahuluanonline' => $pendahuluanonline,
|
||||
'totalkeuntunganonline' => $keuntunganonline,
|
||||
'bilanganonline' => $bilanganonline
|
||||
];
|
||||
|
||||
return response()->json($arrayansuran,200);
|
||||
}
|
||||
|
||||
public function getAnsuranSummaryRange($kodcaw,Request $request){
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$dateans = new Carbon($request->mula);
|
||||
$dateans2 = new Carbon($request->akhir);
|
||||
|
||||
$ansuranskaunter = Transaction::on('mysql7')
|
||||
->leftJoin('transaksi_keuntungan as trans', function($join)
|
||||
{
|
||||
$join->on('transaction.norujukan', '=', 'trans.norujukan');
|
||||
$join->on('transaction.created_at', '=', 'trans.tarikh_bayaran');
|
||||
})
|
||||
->where('transaction.kodcaw','=',$kodcaw)
|
||||
->where('transaction.trans_type','=','A')
|
||||
->where('transaction.teller','<>','Online')
|
||||
->whereDate('transaction.created_at','>=',$dateans)
|
||||
->whereDate('transaction.created_at','<=',$dateans2);
|
||||
|
||||
$ansuransonline = Transaction::on('mysql7')
|
||||
->leftJoin('transaksi_keuntungan as trans', function($join)
|
||||
{
|
||||
$join->on('transaction.norujukan', '=', 'trans.norujukan');
|
||||
$join->on('transaction.created_at', '=', 'trans.tarikh_bayaran');
|
||||
})
|
||||
->where('transaction.kodcaw','=',$kodcaw)
|
||||
->where('transaction.trans_type','=','A')
|
||||
->where('transaction.teller','=','Online')
|
||||
->whereDate('transaction.created_at','>=',$dateans)
|
||||
->whereDate('transaction.created_at','<=',$dateans2);
|
||||
|
||||
$keuntungankaunter = $ansuranskaunter->sum('trans.bayaran_keuntungan');
|
||||
$pendahuluankaunter = $ansuranskaunter->sum('trans.bayaran_pembiayaan');
|
||||
$bilangankaunter = $ansuranskaunter->count();
|
||||
$ujrahkaunter = $ansuranskaunter->sum('trans.ujrah');
|
||||
$onepercentkaunter = $ansuranskaunter->sum('trans.onepercent');
|
||||
|
||||
|
||||
$keuntunganonline = $ansuransonline->sum('trans.bayaran_keuntungan');
|
||||
$pendahuluanonline = $ansuransonline->sum('trans.bayaran_pembiayaan');
|
||||
$bilanganonline = $ansuransonline->count();
|
||||
$ujrahonline = $ansuransonline->sum('trans.ujrah');
|
||||
$onepercentonline = $ansuransonline->sum('trans.onepercent');
|
||||
|
||||
$arrayansuran = [
|
||||
'totalpendahuluankaunter' => $pendahuluankaunter,
|
||||
'totalkeuntungankaunter' => $keuntungankaunter,
|
||||
'bilangankaunter' => $bilangankaunter,
|
||||
'totalujrahkaunter' => $ujrahkaunter,
|
||||
'totalonepercentkaunter' => $onepercentkaunter,
|
||||
|
||||
'totalpendahuluanonline' => $pendahuluanonline,
|
||||
'totalkeuntunganonline' => $keuntunganonline,
|
||||
'bilanganonline' => $bilanganonline,
|
||||
'totalujrahonline' => $ujrahonline,
|
||||
'totalonepercentonline' => $onepercentonline,
|
||||
];
|
||||
|
||||
return response()->json($arrayansuran,200);
|
||||
}
|
||||
|
||||
@@ -3,14 +3,12 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Cawangan;
|
||||
use App\CawanganDetail;
|
||||
use App\Customer;
|
||||
use App\Gadai;
|
||||
use App\Marhun;
|
||||
use DateTime;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Services\Reports\GadaianService as ReportGadaianService;
|
||||
use App\Helper;
|
||||
|
||||
|
||||
class ReportGadaiController extends Controller
|
||||
{
|
||||
@@ -27,7 +25,7 @@ class ReportGadaiController extends Controller
|
||||
$startDate = $request->startDate;
|
||||
$endDate = $request->endDate;
|
||||
|
||||
$active_cawangan_db_connection = getActiveCawanganDbConnection();
|
||||
$active_cawangan_db_connection = Helper::getActiveCawanganDbConnection();
|
||||
|
||||
$active_cawangan_db_name = array_map(function ($db_connection) {
|
||||
return config('database.connections' . '.' . $db_connection . '.' . 'database');
|
||||
|
||||
@@ -0,0 +1,312 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Gadai;
|
||||
use App\Marhun;
|
||||
use App\Cawangan;
|
||||
use App\Transaction;
|
||||
use App\TransaksiKeuntungan;
|
||||
use App\TransactionOnline;
|
||||
use App\batalGadai;
|
||||
use App\TuntutBaki;
|
||||
use App\AnsRugi;
|
||||
use App\Lelong;
|
||||
use App\WTD;
|
||||
use App\HapusKira;
|
||||
use App\Tebus;
|
||||
use App\Vault;
|
||||
use App\Tunai;
|
||||
use App\Komuditi;
|
||||
use App\KawalanStokLama;
|
||||
use App\KawalanStok;
|
||||
use App\KadarUpah;
|
||||
use App\Moratorium;
|
||||
use App\Audit;
|
||||
use App\Customer;
|
||||
use App\KomuditiPurchase;
|
||||
use App\KomuditiTransaksi;
|
||||
use App\Advansur;
|
||||
use App\BlastWasap;
|
||||
use App\HistoryEmasSandaran;
|
||||
use App\InOutMar;
|
||||
use App\Jobs\WhatsappPelangganSAGLAMA;
|
||||
use App\Jobs\SMSPelangganSAGLAMA;
|
||||
use Illuminate\Http\Request;
|
||||
use App\CawanganDetail;
|
||||
use App\BlastSMS;
|
||||
|
||||
use App\Services\OnePercentServices;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class StokAuditController extends Controller
|
||||
{
|
||||
public function LaporanAuditKhasAktif($kodcaw,Request $request)
|
||||
{
|
||||
// dd($request->kodcaw);
|
||||
$daritempoh = $request->daritempoh;
|
||||
$hinggatempoh = $request->hinggatempoh;
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||
|
||||
$audit = Gadai::on($cawangan['mysql'])
|
||||
->where([['tagpalsu','=',0],['tempoh','>=',$daritempoh],['tempoh','<=',$hinggatempoh],['sttebus','=',''],['taglel','=',0]])
|
||||
->orderBy('t_gadai', 'ASC')
|
||||
->orderBy('sirig', 'ASC');
|
||||
// ->get();
|
||||
// dd($audit);
|
||||
$arraynorujukan = $audit->pluck('norujukan')->toArray();
|
||||
$rekodaudit = $audit->get();
|
||||
$gadainokp = Gadai::on($cawangan['mysql'])->whereIn('norujukan', $arraynorujukan)
|
||||
->select('nokp')
|
||||
->groupBy('nokp')
|
||||
->get();
|
||||
|
||||
// dd($gadainokp);
|
||||
|
||||
foreach($gadainokp as $index1=>$cal){
|
||||
$customer = Customer::on('mysql7')->where('kpbaru','=',$cal['nokp'])
|
||||
->orWhere('kplama','=',$cal['nokp'])
|
||||
->first();
|
||||
|
||||
$listsag = Gadai::on($cawangan['mysql'])->whereIn('norujukan', $arraynorujukan)
|
||||
// ->where('nokp','=',$cal['nokp'])
|
||||
->where('nokp', 'like', '%'.$cal['nokp'].'%')
|
||||
->get();
|
||||
|
||||
foreach($listsag as $index2=>$cal2){
|
||||
|
||||
if($cal2){
|
||||
$checkingnokp = BlastWasap::on('mysql7')
|
||||
->where('nokp','=',$cal['nokp'])
|
||||
->where('norujukan','=',$cal2['norujukan'])
|
||||
->where('kodcaw','=',$kodcaw)
|
||||
->first();
|
||||
|
||||
// $gadainokp[$index1]['blasted'] = $checkingnokp;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$gadainokp[$index1]['info'] = $customer;
|
||||
$gadainokp[$index1]['listsag'] = $listsag;
|
||||
$gadainokp[$index1]['blasted'] = $checkingnokp;
|
||||
}
|
||||
|
||||
$totalrekod = $audit->sum('pinjaman');
|
||||
$totalberat = $audit->sum('berat');
|
||||
$totalnilaimarhun = $audit->sum('nilaimarhun');
|
||||
$totalpinjaman = $audit->sum('pinjaman');
|
||||
$totalbakipjm = $audit->sum('bakipjm');
|
||||
$totaltunggakan = $audit->sum('tunggakan');
|
||||
|
||||
$arrayrekod = ['rekod' => $gadainokp, 'total' => $totalrekod,'totalberat' => $totalberat,'totalnilaimarhun' => $totalnilaimarhun,'totalpinjaman'=>$totalpinjaman,'totalbakipjm'=>$totalbakipjm,'totaltunggakan'=>$totaltunggakan];
|
||||
// dd($arrayrekod);
|
||||
return response()->json($arrayrekod,200);
|
||||
}
|
||||
|
||||
|
||||
public function blastwasap($kodcaw,Request $request)
|
||||
{
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$daritempoh = $request->daritempoh;
|
||||
$hinggatempoh = $request->hinggatempoh;
|
||||
$namapengguna = $request->namapengguna;
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||
$cawangan_detail = CawanganDetail::on($cawangan['mysql'])->first();
|
||||
$caw_name = $cawangan->details_caw;
|
||||
$nofoncaw = $cawangan_detail->notel;
|
||||
// dd($cawangan_detail->notel);
|
||||
|
||||
$audit = Gadai::on($cawangan['mysql'])
|
||||
->where([['tagpalsu','=',0],['tempoh','>=',$daritempoh],['tempoh','<=',$hinggatempoh],['sttebus','=',''],['taglel','=',0]])
|
||||
->orderBy('t_gadai', 'ASC')
|
||||
->orderBy('sirig', 'ASC');
|
||||
// ->get();
|
||||
// dd($audit);
|
||||
$rekodaudit = $audit->get();
|
||||
$arraynorujukan = $audit->pluck('norujukan')->toArray();
|
||||
$keybynorujukan = $rekodaudit->keyBy('norujukan');
|
||||
|
||||
$gadainokp = Gadai::on($cawangan['mysql'])->whereIn('norujukan', $arraynorujukan)
|
||||
->select('nokp')
|
||||
->groupBy('nokp')
|
||||
->get();
|
||||
$gadai_all_groupby_nokp = $rekodaudit->groupBy('nokp');
|
||||
// dd($gadai_all_groupby_nokp);
|
||||
|
||||
// dd($gadainokp);
|
||||
|
||||
foreach($gadainokp as $index1=>$cal){
|
||||
// dd($cal->nokp);
|
||||
if($gadai_all_groupby_nokp[$cal->nokp]){
|
||||
$gadainokp[$index1]['gadai'] = $gadai_all_groupby_nokp[$cal->nokp];
|
||||
}
|
||||
// dd($gadainokp[$index1]['gadai'][$index1]['norujukan']);
|
||||
|
||||
|
||||
$customer = Customer::on('mysql7')->where('kpbaru','=',$cal['nokp'])
|
||||
->orWhere('kplama','=',$cal['nokp'])
|
||||
->first();
|
||||
$nokp=$cal['nokp'];
|
||||
|
||||
foreach($gadainokp[$index1]['gadai'] as $index1=>$cal3){
|
||||
|
||||
$checkingnokp = BlastWasap::on('mysql7')
|
||||
->where('nokp','=',$cal['nokp'])
|
||||
->where('norujukan','=',$cal3->norujukan)
|
||||
->where('kodcaw','=',$kodcaw)
|
||||
->first();
|
||||
|
||||
if(!$checkingnokp){
|
||||
|
||||
if($customer->telefon != 'null'){
|
||||
$telefon=$customer->telefon;
|
||||
// //insert log blast wasap
|
||||
// $logblastwasap = new BlastWasap();
|
||||
// $logblastwasap->kodcaw = $kodcaw;
|
||||
// $logblastwasap->nokp = $nokp;
|
||||
// $logblastwasap->notelefon = $customer->telefon;
|
||||
// $logblastwasap->norujukan = $cal3->norujukan;
|
||||
// $logblastwasap->tempoh = $cal3->tempoh;
|
||||
// $logblastwasap->created_at = $current;
|
||||
// $logblastwasap->updated_at = $current;
|
||||
// $logblastwasap->save();
|
||||
|
||||
//log auditrail
|
||||
$audit = new Audit();
|
||||
$audit->users = $namapengguna;
|
||||
$audit->actions = 'Blast Whatsapp & SMS';
|
||||
$audit->norujukan = $cal3->norujukan;
|
||||
$audit->new_data = $customer->telefon;
|
||||
$audit->old_data = $nokp;
|
||||
$audit->kodcaw = $kodcaw;
|
||||
$audit->created_at = $current;
|
||||
$audit->updated_at = $current;
|
||||
$audit->save();
|
||||
|
||||
dispatch(new WhatsappPelangganSAGLAMA($nokp,$customer->telefon,$caw_name,$nofoncaw,$kodcaw,$cal3->norujukan,$cal3->tempoh));
|
||||
dispatch(new SMSPelangganSAGLAMA($nokp,$customer->telefon,$caw_name,$nofoncaw,$kodcaw,$cal3->norujukan,$cal3->tempoh));
|
||||
}
|
||||
}
|
||||
else{
|
||||
return response()->json('failed');
|
||||
}
|
||||
}
|
||||
}
|
||||
return response()->json('success');
|
||||
|
||||
}
|
||||
|
||||
public function rekodblast($kodcaw,Request $request)
|
||||
{
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
|
||||
$rekodblast = BlastWasap::on('mysql7')
|
||||
->where('kodcaw','=',$kodcaw);
|
||||
$arraynorujukan = $rekodblast->pluck('norujukan')->toArray();
|
||||
$rekodaudit = $rekodblast->orderBy('id', 'asc')->get();
|
||||
$keybynorujukan = $rekodaudit->keyBy('norujukan');
|
||||
|
||||
$gadainokp = Gadai::on($cawangan['mysql'])->whereIn('norujukan', $arraynorujukan)
|
||||
->select('nokp')
|
||||
->groupBy('nokp')
|
||||
->get();
|
||||
$gadai_all_groupby_nokp = $rekodaudit->groupBy('nokp');
|
||||
// dd($gadai_all_groupby_nokp);
|
||||
|
||||
foreach($gadainokp as $index1=>$cal){
|
||||
|
||||
if($gadai_all_groupby_nokp[$cal->nokp]){
|
||||
$gadainokp[$index1]['rekodblast'] = $gadai_all_groupby_nokp[$cal->nokp];
|
||||
}
|
||||
$customer = Customer::on('mysql7')->where('kpbaru','=',$cal['nokp'])
|
||||
->orWhere('kplama','=',$cal['nokp'])
|
||||
->first();
|
||||
|
||||
$listsag = Gadai::on($cawangan['mysql'])->whereIn('norujukan', $arraynorujukan)
|
||||
->where('nokp', 'like', '%'.$cal['nokp'].'%')
|
||||
->get();
|
||||
// dd($listsag);
|
||||
$gadainokp[$index1]['info'] = $customer;
|
||||
$gadainokp[$index1]['listsag'] = $listsag;
|
||||
}
|
||||
|
||||
if($listsag ?? ''){
|
||||
$totalrekod = $listsag->sum('pinjaman');
|
||||
$totalberat = $listsag->sum('berat');
|
||||
$totalnilaimarhun = $listsag->sum('nilaimarhun');
|
||||
$totalpinjaman = $listsag->sum('pinjaman');
|
||||
$totalbakipjm = $listsag->sum('bakipjm');
|
||||
$totaltunggakan = $listsag->sum('tunggakan');
|
||||
}
|
||||
|
||||
$arrayrekod = ['rekod' => $gadainokp ?? null,
|
||||
'total' => $totalrekod ?? null,
|
||||
'totalberat' => $totalberat ?? null,
|
||||
'totalnilaimarhun' => $totalnilaimarhun ?? null,
|
||||
'totalpinjaman'=>$totalpinjaman ?? null,
|
||||
'totalbakipjm'=>$totalbakipjm ?? null,
|
||||
'totaltunggakan'=>$totaltunggakan ?? null];
|
||||
return response()->json($arrayrekod,200);
|
||||
}
|
||||
|
||||
public function rekodblastsms($kodcaw,Request $request)
|
||||
{
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
|
||||
$rekodblast = BlastSMS::on('mysql7')
|
||||
->where('kodcaw','=',$kodcaw);
|
||||
$arraynorujukan = $rekodblast->pluck('norujukan')->toArray();
|
||||
$rekodaudit = $rekodblast->orderBy('id', 'asc')->get();
|
||||
$keybynorujukan = $rekodaudit->keyBy('norujukan');
|
||||
|
||||
$gadainokp = Gadai::on($cawangan['mysql'])->whereIn('norujukan', $arraynorujukan)
|
||||
->select('nokp')
|
||||
->groupBy('nokp')
|
||||
->get();
|
||||
$gadai_all_groupby_nokp = $rekodaudit->groupBy('nokp');
|
||||
// dd($gadai_all_groupby_nokp);
|
||||
|
||||
foreach($gadainokp as $index1=>$cal){
|
||||
|
||||
if($gadai_all_groupby_nokp[$cal->nokp]){
|
||||
$gadainokp[$index1]['rekodblast'] = $gadai_all_groupby_nokp[$cal->nokp];
|
||||
}
|
||||
$customer = Customer::on('mysql7')->where('kpbaru','=',$cal['nokp'])
|
||||
->orWhere('kplama','=',$cal['nokp'])
|
||||
->first();
|
||||
|
||||
$listsag = Gadai::on($cawangan['mysql'])->whereIn('norujukan', $arraynorujukan)
|
||||
->where('nokp', 'like', '%'.$cal['nokp'].'%')
|
||||
->get();
|
||||
// dd($listsag);
|
||||
$gadainokp[$index1]['info'] = $customer;
|
||||
$gadainokp[$index1]['listsag'] = $listsag;
|
||||
}
|
||||
|
||||
if($listsag ?? ''){
|
||||
$totalrekod = $listsag->sum('pinjaman');
|
||||
$totalberat = $listsag->sum('berat');
|
||||
$totalnilaimarhun = $listsag->sum('nilaimarhun');
|
||||
$totalpinjaman = $listsag->sum('pinjaman');
|
||||
$totalbakipjm = $listsag->sum('bakipjm');
|
||||
$totaltunggakan = $listsag->sum('tunggakan');
|
||||
}
|
||||
|
||||
$arrayrekod = ['rekod' => $gadainokp ?? null,
|
||||
'total' => $totalrekod ?? null,
|
||||
'totalberat' => $totalberat ?? null,
|
||||
'totalnilaimarhun' => $totalnilaimarhun ?? null,
|
||||
'totalpinjaman'=>$totalpinjaman ?? null,
|
||||
'totalbakipjm'=>$totalbakipjm ?? null,
|
||||
'totaltunggakan'=>$totaltunggakan ?? null];
|
||||
return response()->json($arrayrekod,200);
|
||||
}
|
||||
}
|
||||
@@ -739,7 +739,6 @@ class TebusController extends Controller
|
||||
$customer_info = Customer::on('mysql7')->where('kplama','=',$tebusData['nokp'])->orWhere('kpbaru','=',$tebusData['nokp'])->first();
|
||||
|
||||
$trans = TransaksiKeuntungan::on('mysql7')->where('norujukan',$tebusData['norujukan'])->orderBy('tarikh_bayaran','desc')->first();
|
||||
|
||||
array_push($tebus,[
|
||||
"t_tebus"=>$tebusData['t_tebus'],
|
||||
"t_gadai"=>$tebusData['t_gadai'],
|
||||
@@ -757,7 +756,58 @@ class TebusController extends Controller
|
||||
"norujukan"=>$tebusData['norujukan'],
|
||||
"nama"=>$customer_info['nama'],
|
||||
"nokp"=>$tebusData['nokp'],
|
||||
"jbg"=>$tebusData['jbg']
|
||||
"jbg"=>$tebusData['jbg'],
|
||||
"ujrah"=>$tebusData['ujrah'],
|
||||
"onepercent"=>$tebusData['onepercent']
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json($tebus);
|
||||
}
|
||||
|
||||
|
||||
public function getLaporanTebusUjrah($kodcaw, Request $request){
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
|
||||
$tebus_data = Tebus::on($cawangan['mysql'])
|
||||
->select('tebus.t_tebus', 'gad.t_gadai','gad.hargajualan','gad.bakihargajualan','gad.bakipjm as gadaibakipjm','tebus.nilaimarhun','tebus.tagterima', 'tebus.teller','tebus.jenistebus','tebus.pinjaman','tebus.bakiupah','tebus.bakipjm','gad.norujukan','gad.nokp','tebus.jbg','tebus.ujrah','tebus.onepercent','gad.tagbaru')
|
||||
->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
|
||||
->where('tebus.t_tebus','>=',$request->mula)
|
||||
->where('tebus.t_tebus','<=',$request->akhir)
|
||||
->groupBy('tebus.norujukan')
|
||||
->orderBy('tebus.teller')
|
||||
->orderBy('tebus.sirit')
|
||||
->get();
|
||||
|
||||
$tebus = [];
|
||||
if($tebus_data){
|
||||
foreach($tebus_data as $index=>$tebusData){
|
||||
$customer_info = Customer::on('mysql7')->where('kplama','=',$tebusData['nokp'])->orWhere('kpbaru','=',$tebusData['nokp'])->first();
|
||||
|
||||
$trans = TransaksiKeuntungan::on('mysql7')->where('norujukan',$tebusData['norujukan'])->orderBy('tarikh_bayaran','desc')->first();
|
||||
array_push($tebus,[
|
||||
"t_tebus"=>$tebusData['t_tebus'],
|
||||
"t_gadai"=>$tebusData['t_gadai'],
|
||||
"hargajualan"=>$tebusData['hargajualan'],
|
||||
"bakihargajualan"=>$tebusData['bakihargajualan'],
|
||||
"gadaibakipjm"=>$tebusData['gadaibakipjm'],
|
||||
"tarikh_bayaran"=>$trans['tarikh_bayaran'],
|
||||
"nilaimarhun"=>$tebusData['nilaimarhun'],
|
||||
"tagterima"=>$tebusData['tagterima'],
|
||||
"teller"=>$tebusData['teller'],
|
||||
"jenistebus"=>$tebusData['jenistebus'],
|
||||
"pinjaman"=>$tebusData['pinjaman'],
|
||||
"bakiupah"=>$tebusData['bakiupah'],
|
||||
"bakipjm"=>$tebusData['bakipjm'],
|
||||
"norujukan"=>$tebusData['norujukan'],
|
||||
"nama"=>$customer_info['nama'],
|
||||
"nokp"=>$tebusData['nokp'],
|
||||
"jbg"=>$tebusData['jbg'],
|
||||
"ujrah"=>$tebusData['ujrah'],
|
||||
"onepercent"=>$tebusData['onepercent']
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -777,6 +827,9 @@ class TebusController extends Controller
|
||||
$totalpenebusanarrahn = $tebusarrahn->sum('tebus.pinjaman');
|
||||
$bilpenebusanarrahn = $tebusarrahn->count();
|
||||
$totalkeuntunganarrahn = $tebusarrahn->sum('tebus.bakiupah');
|
||||
$totalujraharrahn = $tebusarrahn->sum('tebus.ujrah');
|
||||
$totalonepercentarrahn = $tebusarrahn->sum('tebus.onepercent');
|
||||
|
||||
|
||||
$tebustawarruq = Tebus::on($cawangan['mysql'])
|
||||
->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
|
||||
@@ -797,10 +850,91 @@ class TebusController extends Controller
|
||||
$bilpenebusantawarruq = $tebustawarruq->count();
|
||||
$totalrebatetawarruq = $tebustawarruq->sum('tebus.rebate');
|
||||
$totalkeuntungantawarruq = $tebustawarruq->sum('tebus.bakiupah');
|
||||
$totalujrahtawarruq = $tebustawarruq->sum('tebus.ujrah');
|
||||
$totalonepercenttawarruq = $tebustawarruq->sum('tebus.onepercent');
|
||||
|
||||
|
||||
|
||||
// dd($totalkeuntunganarrahn,$totalkeuntungantawarruq);
|
||||
|
||||
$array_penebusan = ['bilarrahn' => $bilpenebusanarrahn, 'totalarrahn' => $totalpenebusanarrahn, 'keuntunganarrahn' => $totalkeuntunganarrahn, 'biltawarruq' => $bilpenebusantawarruq, 'totaltawarruq' => $totalpenebusantawarruq,'totalrebate' => $totalrebatetawarruq,'keuntungantawarruq' => $totalkeuntungantawarruq];
|
||||
$array_penebusan = [
|
||||
'bilarrahn' => $bilpenebusanarrahn,
|
||||
'totalarrahn' => $totalpenebusanarrahn,
|
||||
'keuntunganarrahn' => $totalkeuntunganarrahn,
|
||||
'ujraharrahn' => $totalujraharrahn,
|
||||
'onepercentarrahn' => $totalonepercentarrahn,
|
||||
|
||||
'biltawarruq' => $bilpenebusantawarruq,
|
||||
'totaltawarruq' => $totalpenebusantawarruq,
|
||||
'totalrebate' => $totalrebatetawarruq,
|
||||
'keuntungantawarruq' => $totalkeuntungantawarruq,
|
||||
'ujrahtawarruq' => $totalujrahtawarruq,
|
||||
'onepercenttawarruq' => $totalonepercenttawarruq
|
||||
];
|
||||
|
||||
return response()->json($array_penebusan);
|
||||
}
|
||||
|
||||
public function getLaporanTebusPengasinganUjrah($kodcaw,Request $request){
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
|
||||
$tebusarrahn = Tebus::on($cawangan['mysql'])
|
||||
->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
|
||||
->where('tebus.t_tebus','>=',$request->mula)
|
||||
->where('tebus.t_tebus','<=',$request->akhir)
|
||||
->whereNull('hargajualan');
|
||||
|
||||
$totalpenebusanarrahn = $tebusarrahn->sum('tebus.pinjaman');
|
||||
$bilpenebusanarrahn = $tebusarrahn->count();
|
||||
$totalkeuntunganarrahn = $tebusarrahn->sum('tebus.bakiupah');
|
||||
$totalujraharrahn = $tebusarrahn->sum('tebus.ujrah');
|
||||
$totalonepercentarrahn = $tebusarrahn->sum('tebus.onepercent');
|
||||
|
||||
|
||||
$tebustawarruq = Tebus::on($cawangan['mysql'])
|
||||
->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
|
||||
->where('tebus.t_tebus','>=',$request->mula)
|
||||
->where('tebus.t_tebus','<=',$request->akhir)
|
||||
->whereNotNull('hargajualan');
|
||||
|
||||
$tebustawarruqansuran = Tebus::on($cawangan['mysql'])
|
||||
->select('tebus.bakiupah','tebus.norujukan')
|
||||
->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
|
||||
->where('tebus.t_tebus','>=',$request->mula)
|
||||
->where('tebus.t_tebus','<=',$request->akhir)
|
||||
->whereNotNull('hargajualan')
|
||||
->where('gad.tagbaru','=',1)
|
||||
->where('hargajualan','<>','bakihargajualan');
|
||||
|
||||
// dd($tebustawarruqansuran);
|
||||
|
||||
// $totalpenebusantawarruq = ($tebustawarruq->sum('tebus.pinjaman') - $tebustawarruqansuran->sum('gad.pinjaman')) + $tebustawarruqansuran->sum('gad.bakipjm');
|
||||
$totalpenebusantawarruq = $tebustawarruq->sum('tebus.pinjaman');
|
||||
$bilpenebusantawarruq = $tebustawarruq->count();
|
||||
$totalrebatetawarruq = $tebustawarruq->sum('tebus.rebate');
|
||||
$totalkeuntungantawarruq = $tebustawarruq->sum('tebus.bakiupah');
|
||||
$totalujrahtawarruq = $tebustawarruq->sum('tebus.ujrah');
|
||||
$totalonepercenttawarruq = $tebustawarruq->sum('tebus.onepercent');
|
||||
|
||||
|
||||
|
||||
// dd($totalkeuntunganarrahn,$totalkeuntungantawarruq);
|
||||
|
||||
$array_penebusan = [
|
||||
'bilarrahn' => $bilpenebusanarrahn,
|
||||
'totalarrahn' => $totalpenebusanarrahn,
|
||||
'keuntunganarrahn' => $totalkeuntunganarrahn,
|
||||
'ujraharrahn' => $totalujraharrahn,
|
||||
'onepercentarrahn' => $totalonepercentarrahn,
|
||||
|
||||
'biltawarruq' => $bilpenebusantawarruq,
|
||||
'totaltawarruq' => $totalpenebusantawarruq,
|
||||
'totalrebate' => $totalrebatetawarruq,
|
||||
'keuntungantawarruq' => $totalkeuntungantawarruq,
|
||||
'ujrahtawarruq' => $totalujrahtawarruq,
|
||||
'onepercenttawarruq' => $totalonepercenttawarruq
|
||||
];
|
||||
|
||||
return response()->json($array_penebusan);
|
||||
}
|
||||
@@ -1077,13 +1211,26 @@ class TebusController extends Controller
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
|
||||
$listadvansur = Advansur::on($cawangan['mysql'])
|
||||
->where('tarikh','>=',$request->mula)->where('tarikh','<=',$request->akhir);
|
||||
$listadvansurkaunter = Advansur::on($cawangan['mysql'])
|
||||
->where('tarikh','>=',$request->mula)
|
||||
->where('tarikh','<=',$request->akhir)
|
||||
->where('teller','<>','Online');
|
||||
|
||||
$countadvansur = $listadvansur->count();
|
||||
$totaladvansur = $listadvansur->sum('upahdibayar');
|
||||
$listadvansuronline = Advansur::on($cawangan['mysql'])
|
||||
->where('tarikh','>=',$request->mula)
|
||||
->where('tarikh','<=',$request->akhir)
|
||||
->where('teller','=','Online');
|
||||
|
||||
$arrayadvansur = ['bil' => $countadvansur, 'total' => $totaladvansur];
|
||||
$countadvansurkaunter = $listadvansurkaunter->count();
|
||||
$totaladvansurkaunter = $listadvansurkaunter->sum('upahdibayar');
|
||||
|
||||
$countadvansuronline = $listadvansuronline->count();
|
||||
$totaladvansuronline = $listadvansuronline->sum('upahdibayar');
|
||||
|
||||
$arrayadvansur = ['bilkaunter' => $countadvansurkaunter,
|
||||
'totalkaunter' => $totaladvansurkaunter,
|
||||
'bilonline' => $countadvansuronline,
|
||||
'totalonline' => $totaladvansuronline];
|
||||
|
||||
return response()->json($arrayadvansur,200);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\BlastSMS;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class SMSPelangganSAGLAMA extends Job
|
||||
{
|
||||
public $nokp;
|
||||
public $telefon;
|
||||
public $caw_name;
|
||||
public $nofoncaw;
|
||||
public $kodcaw;
|
||||
public $norujukan;
|
||||
public $tempoh;
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($nokp, $telefon, $caw_name,$nofoncaw,$kodcaw,$norujukan,$tempoh)
|
||||
{
|
||||
$this->nokp = $nokp;
|
||||
$this->telefon = $telefon;
|
||||
$this->caw_name = $caw_name;
|
||||
$this->nofoncaw = $nofoncaw;
|
||||
$this->kodcaw = $kodcaw;
|
||||
$this->norujukan = $norujukan;
|
||||
$this->tempoh = $tempoh;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
// $mobile_no = ltrim($this->telefon, '+6');
|
||||
$mobile_no = '60178916936';
|
||||
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, selaras penambahbaikan Sistem Ar-Rahn, Tuan/Puan diminta hadir ke premis sebelum 15/7/2024 bagi menukar SAG dengan cara:
|
||||
1. Tebus atau
|
||||
2. Tebus Gadai Semula
|
||||
Hubungi '.$this->nofoncaw.' untuk maklumat lanjut.';
|
||||
if(env('APP_ENV') != 'production'){
|
||||
$mobile_no = env('ADMIN_PHONE_NUMBER');
|
||||
}
|
||||
$response = Http::get(env('ONEWAYSMS_API'), [
|
||||
'apiusername' => env('ONEWAYSMS_AUTH_USER'),
|
||||
'apipassword' => env('ONEWAYSMS_AUTH_PASS'),
|
||||
'senderid' => 'INFO',
|
||||
'mobileno' => $mobile_no,
|
||||
'message' => $message,
|
||||
'languagetype' => 1
|
||||
]);
|
||||
|
||||
//insert log blast sms
|
||||
$logblastsms = new BlastSMS();
|
||||
$logblastsms->kodcaw = $this->kodcaw;
|
||||
$logblastsms->nokp = $this->nokp;
|
||||
$logblastsms->notelefon = $this->telefon;
|
||||
$logblastsms->norujukan = $this->norujukan;
|
||||
$logblastsms->tempoh = $this->tempoh;
|
||||
$logblastsms->status = $response;
|
||||
$logblastsms->created_at = $current;
|
||||
$logblastsms->updated_at = $current;
|
||||
$logblastsms->save();
|
||||
|
||||
Log::info("SMS - Pelanggan ".$this->caw_name." SAG Tawarruq Lama -".$mobile_no);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\BlastWasap;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class WhatsappPelangganSAGLAMA extends Job
|
||||
{
|
||||
public $nokp;
|
||||
public $telefon;
|
||||
public $caw_name;
|
||||
public $nofoncaw;
|
||||
public $kodcaw;
|
||||
public $norujukan;
|
||||
public $tempoh;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($nokp, $telefon, $caw_name,$nofoncaw,$kodcaw,$norujukan,$tempoh)
|
||||
{
|
||||
$this->nokp = $nokp;
|
||||
$this->telefon = $telefon;
|
||||
$this->caw_name = $caw_name;
|
||||
$this->nofoncaw = $nofoncaw;
|
||||
$this->kodcaw = $kodcaw;
|
||||
$this->norujukan = $norujukan;
|
||||
$this->tempoh = $tempoh;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
// $mobile_no = ltrim($this->telefon, '+6');
|
||||
//$mobile_no = '60178916936';
|
||||
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, selaras penambahbaikan Sistem Ar-Rahn, Tuan/Puan diminta hadir ke premis *sebelum 15/7/2024* bagi menukar SAG dengan cara:
|
||||
|
||||
1. Tebus
|
||||
atau
|
||||
2. Tebus Gadai Semula
|
||||
|
||||
Hubungi '.$this->nofoncaw.' untuk maklumat lanjut.';
|
||||
if(env('APP_ENV') != 'production'){
|
||||
$mobile_no = env('ADMIN_PHONE_NUMBER');
|
||||
}
|
||||
$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')
|
||||
]);
|
||||
|
||||
//insert log blast wasap
|
||||
$logblastwasap = new BlastWasap();
|
||||
$logblastwasap->kodcaw = $this->kodcaw;
|
||||
$logblastwasap->nokp = $this->nokp;
|
||||
$logblastwasap->notelefon = $this->telefon;
|
||||
$logblastwasap->norujukan = $this->norujukan;
|
||||
$logblastwasap->tempoh = $this->tempoh;
|
||||
$logblastwasap->status = $response;
|
||||
$logblastwasap->created_at = $current;
|
||||
$logblastwasap->updated_at = $current;
|
||||
$logblastwasap->save();
|
||||
|
||||
Log::info("WABOT - Pelanggan SAG Tawarruq Lama".$response);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use App\Gadai;
|
||||
use App\Marhun;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Helper;
|
||||
|
||||
class GadaianService
|
||||
{
|
||||
@@ -82,8 +83,8 @@ class GadaianService
|
||||
|
||||
$data = [
|
||||
'query' => [
|
||||
'startDate' => formatDate($this->startDate),
|
||||
'endDate' => formatDate($this->endDate),
|
||||
'startDate' => Helper::formatDate($this->startDate),
|
||||
'endDate' => Helper::formatDate($this->endDate),
|
||||
],
|
||||
'cawangan_detail' => $cawangan_detail,
|
||||
'gadaian' => $total_gadaian,
|
||||
|
||||
+13
-14
@@ -1,26 +1,25 @@
|
||||
|
||||
<?php
|
||||
namespace App;
|
||||
|
||||
use DateTime;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
if (!function_exists('formatNumber')) {
|
||||
function formatNumber ($amount) {
|
||||
class Helper
|
||||
{
|
||||
|
||||
public static function formatNumber($amount)
|
||||
{
|
||||
$formattedAmount = number_format($amount, 2, '.', ',');
|
||||
|
||||
return $formattedAmount;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static function formatDate($date_string)
|
||||
{
|
||||
return (new DateTime($date_string))->format("d-m-Y");
|
||||
}
|
||||
|
||||
if (!function_exists('formatDate')) {
|
||||
function formatDate ($date_string) {
|
||||
return (new DateTime($date_string))->format("d-m-Y");
|
||||
};
|
||||
}
|
||||
|
||||
if (!function_exists('getActiveCawanganDbConnection')) {
|
||||
|
||||
function getActiveCawanganDbConnection()
|
||||
public static function getActiveCawanganDbConnection()
|
||||
{
|
||||
|
||||
$all_active_db_keys = array_filter(array_keys(config('database.connections')), function ($connection) {
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "laravel/lumen",
|
||||
"description": "The Laravel Lumen Framework.",
|
||||
"keywords": ["framework", "laravel", "lumen"],
|
||||
"license": "MIT",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"php": "^7.2.5",
|
||||
"auth0/auth0-php": "^7.4",
|
||||
"laravel/lumen-framework": "^7.0",
|
||||
"rap2hpoutre/laravel-log-viewer": "^1.7"
|
||||
},
|
||||
"require-dev": {
|
||||
"fzaninotto/faker": "^1.9.1",
|
||||
"mockery/mockery": "^1.3.1",
|
||||
"phpunit/phpunit": "^8.5"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"database/seeds",
|
||||
"database/factories"
|
||||
],
|
||||
"psr-4": {
|
||||
"App\\": "app/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"classmap": [
|
||||
"tests/"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"optimize-autoloader": true
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"scripts": {
|
||||
"post-root-package-install": [
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||
]
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel CORS Options
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The allowed_methods and allowed_headers options are case-insensitive.
|
||||
|
|
||||
| You don't need to provide both allowed_origins and allowed_origins_patterns.
|
||||
| If one of the strings passed matches, it is considered a valid origin.
|
||||
|
|
||||
| If ['*'] is provided to allowed_methods, allowed_origins or allowed_headers
|
||||
| all methods / origins / headers are allowed.
|
||||
|
|
||||
*/
|
||||
|
||||
/*
|
||||
* You can enable CORS for 1 or multiple paths.
|
||||
* Example: ['api/*']
|
||||
*/
|
||||
'paths' => ['api/*'],
|
||||
|
||||
/*
|
||||
* Matches the request method. `['*']` allows all methods.
|
||||
*/
|
||||
'allowed_methods' => ['*'],
|
||||
|
||||
/*
|
||||
* Matches the request origin. `['*']` allows all origins. Wildcards can be used, eg `*.mydomain.com`
|
||||
*/
|
||||
'allowed_origins' => ['*'],
|
||||
|
||||
/*
|
||||
* Patterns that can be used with `preg_match` to match the origin.
|
||||
*/
|
||||
'allowed_origins_patterns' => [],
|
||||
|
||||
/*
|
||||
* Sets the Access-Control-Allow-Headers response header. `['*']` allows all headers.
|
||||
*/
|
||||
'allowed_headers' => ['*'],
|
||||
|
||||
/*
|
||||
* Sets the Access-Control-Expose-Headers response header with these headers.
|
||||
*/
|
||||
'exposed_headers' => [],
|
||||
|
||||
/*
|
||||
* Sets the Access-Control-Max-Age response header when > 0.
|
||||
*/
|
||||
'max_age' => 86400,
|
||||
|
||||
/*
|
||||
* Sets the Access-Control-Allow-Credentials header.
|
||||
*/
|
||||
'supports_credentials' => true,
|
||||
];
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
return [
|
||||
|
||||
'default' => 'mysql',
|
||||
'default' => 'mysql7',
|
||||
'migrations' => 'migrations',
|
||||
'connections' => [
|
||||
'lelong' => [
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateJobsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateLogBlastWasap extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('log_blast_wasap', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('kodcaw')->nullable();
|
||||
$table->string('nokp')->nullable();
|
||||
$table->string('notelefon')->nullable();
|
||||
$table->string('norujukan')->nullable();
|
||||
$table->string('tempoh')->nullable();
|
||||
$table->text('status')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('log_blast_wasap');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class LogBlastSms extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('log_blast_sms', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('kodcaw')->nullable();
|
||||
$table->string('nokp')->nullable();
|
||||
$table->string('notelefon')->nullable();
|
||||
$table->string('norujukan')->nullable();
|
||||
$table->string('tempoh')->nullable();
|
||||
$table->text('status')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('log_blast_sms');
|
||||
}
|
||||
}
|
||||
@@ -115,6 +115,16 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
||||
$router->get('tebus/laporan/{kodcaw}/{tarikh}',['uses'=>'TebusController@getLaporanTebus']);
|
||||
$router->get('tebus/laporanjenistawarruq/{kodcaw}',['uses'=>'TebusController@getLaporanTebusPengasingan']);
|
||||
|
||||
//Tebus Ujrah (Laporan Range Date)
|
||||
$router->get('tebusujrah/laporan/{kodcaw}',['uses'=>'TebusController@getLaporanTebusUjrah']);
|
||||
$router->get('tebus/laporanjenistawarruqujrah/{kodcaw}',['uses'=>'TebusController@getLaporanTebusPengasinganUjrah']);
|
||||
|
||||
//Ansuran Ujrah (Laporan Range Date)
|
||||
$router->get('ansuranujrah/laporan/{kodcaw}',['uses'=>'GadaiController@getLaporanAnsuranUjrah']);
|
||||
|
||||
|
||||
|
||||
|
||||
$router->get('moratorium/details',['uses'=>'TebusController@getMoratorium']);
|
||||
|
||||
//Maintenance API TEBUS
|
||||
@@ -239,6 +249,7 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
||||
//ANSURAN UPAH API
|
||||
$router->get('ansuran/laporan/{kodcaw}',['uses'=>'GadaiController@getLaporanAnsuran']);
|
||||
$router->get('ansuransummary/{kodcaw}',['uses'=>'GadaiController@getAnsuranSummary']);
|
||||
$router->get('ansuransummaryrange/{kodcaw}',['uses'=>'GadaiController@getAnsuranSummaryRange']);
|
||||
$router->get('ansuran/{kodcaw}/{norujukan}',['uses'=>'TebusController@getAdvansur']);
|
||||
$router->get('AnsuranByTarikh/{kodcaw}',['uses'=>'TebusController@SenaraiAdvansur']);
|
||||
$router->get('AnsuranByRangeTarikh/{kodcaw}',['uses'=>'TebusController@SenaraiAdvansurRangeDate']);
|
||||
@@ -579,6 +590,15 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
||||
$router->get('kadarujrah',['uses' => 'GadaiController@getKadarUjrah']);
|
||||
$router->post('onepercent',['uses' => 'GadaiController@getOnePercent']);
|
||||
|
||||
//STOKAUDITKHAS
|
||||
$router->get('stokauditkhas/aktif/{kodcaw}',['uses'=>'StokAuditController@LaporanAuditKhasAktif']);
|
||||
|
||||
//API BLAST WASAP
|
||||
$router->post('blastwasap/{kodcaw}',['uses'=>'StokAuditController@blastwasap']);
|
||||
$router->get('rekodblast/{kodcaw}',['uses'=>'StokAuditController@rekodblast']);
|
||||
$router->get('rekodblastsms/{kodcaw}',['uses'=>'StokAuditController@rekodblastsms']);
|
||||
|
||||
|
||||
});
|
||||
|
||||
$router->group(['prefix'=>'e-arrahn'], function () use ($router){
|
||||
@@ -777,6 +797,7 @@ $router->group(['prefix'=>'admin'], function () use ($router){
|
||||
});
|
||||
|
||||
$router->group(['prefix'=>'lelong'], function () use ($router){
|
||||
$router->get('upahrebettawarruq/{kodcaw}/{norujukan}/{jeniskeuntungan}',['uses'=>'TebusController@upahRebetTawarruq']);
|
||||
$router->post('taglel/update',['uses'=>'GadaiController@updateTagLelong']);
|
||||
$router->post('taglel/revert',['uses'=>'GadaiController@revertTagLelong']);
|
||||
$router->post('exportLelong',['uses'=>'LelongController@exportLelong']);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
$all_active_db_keys = array_filter(array_keys(config('database.connections')), function ($connection) {
|
||||
try {
|
||||
DB::connection($connection)->getPdo();
|
||||
return true;
|
||||
} catch (\Throwable $th) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$non_cawangan_database = ['lelong', 'online_arrahn', 'kaunterpkb'];
|
||||
|
||||
$all_cawangan_db = array_filter($all_active_db_keys, function($db_key) use($non_cawangan_database){
|
||||
$isNotCawangan = in_array(config('database.connections.' . $db_key . '.database'), $non_cawangan_database);
|
||||
|
||||
if($isNotCawangan){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return $all_cawangan_db;
|
||||
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
use App\Cawangan;
|
||||
use App\CawanganDetail;
|
||||
use App\Customer;
|
||||
use App\Gadai;
|
||||
use App\Marhun;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Helper;
|
||||
|
||||
// test variable
|
||||
$request = new Request();
|
||||
$request->all();
|
||||
$request->merge([
|
||||
'startDate' => '2023-8-21',
|
||||
'endDate' => '2023-10-22',
|
||||
'kod_cawangan' => 'KB2',
|
||||
]);
|
||||
// test variable
|
||||
|
||||
function getCawanganDetail($cawangan_connection)
|
||||
{
|
||||
$cawangan_detail = CawanganDetail::on($cawangan_connection)->get()
|
||||
->map(function ($detail) {
|
||||
return [
|
||||
'nama' => $detail['namacaw'],
|
||||
'code' => $detail['kodcaw'] . ' Ar-Rahn ' . $detail['cawangan'],
|
||||
'alamat' => $detail['alamat1'],
|
||||
'waktu_operasi' => $detail['alamat4'],
|
||||
];
|
||||
});
|
||||
|
||||
return $cawangan_detail;
|
||||
|
||||
}
|
||||
|
||||
function getTotalSummaryGadaian(Builder $query_total_gadaian)
|
||||
{
|
||||
$formatNumber = function ($amount) {
|
||||
$formattedAmount = number_format($amount, 2, '.', ',');
|
||||
|
||||
return $formattedAmount;
|
||||
};
|
||||
|
||||
$total_summary_gadaian = (clone $query_total_gadaian)
|
||||
->selectRaw('sum(berat) as total_berat, sum(nilaimarhun) as total_nilai_marhun, sum(pinjaman) as total_pembiayaan')
|
||||
->get()
|
||||
->map(function ($x) use ($formatNumber) {
|
||||
return [
|
||||
'total_berat' => $formatNumber($x['total_berat']),
|
||||
'total_nilai_marhun' => $formatNumber($x['total_nilai_marhun']),
|
||||
'total_pembiayaan' => $formatNumber($x['total_pembiayaan']),
|
||||
];
|
||||
});
|
||||
|
||||
return $total_summary_gadaian;
|
||||
}
|
||||
|
||||
function getTotalSummaryGadaianGroupByTeller(Builder $query_total_gadaian)
|
||||
{
|
||||
|
||||
$total_summary_gadaian_groupByTeller = (clone $query_total_gadaian)
|
||||
->selectRaw('sum(berat) as total_berat, sum(nilaimarhun) as total_nilai_marhun, sum(pinjaman) as total_pembiayaan')
|
||||
->groupBy('teller')
|
||||
->get();
|
||||
return $total_summary_gadaian_groupByTeller;
|
||||
}
|
||||
|
||||
function getTotalGadaian(Builder $query_total_gadaian)
|
||||
{
|
||||
$total_gadaian = (clone $query_total_gadaian)
|
||||
->select('t_gadai', 'norujukan', 'nokp', 'semakbarcode', 'masa', 'berat', 'nilaimarhun', 'pinjaman', 'upah12', 'percentpinj', 'teller', 'nokp')
|
||||
->orderBy('teller')
|
||||
->orderBy('sirig')
|
||||
->get();
|
||||
return $total_gadaian;
|
||||
}
|
||||
|
||||
function getCustomerInfo($total_gadaian)
|
||||
{
|
||||
|
||||
$extract_nokp = $total_gadaian->pluck('nokp');
|
||||
|
||||
$customer_info = Customer::on('mysql7')
|
||||
->select(['nama', 'alamat1', 'kpbaru', 'kplama'])
|
||||
->where(function ($query) use ($extract_nokp) {
|
||||
$query->whereIn('kpbaru', $extract_nokp)
|
||||
->orWhereIn('kplama', $extract_nokp);
|
||||
})
|
||||
->get();
|
||||
|
||||
$customer_info = collect($extract_nokp)->map(function ($nokp) use ($customer_info) {
|
||||
return $customer_info->where('kpbaru', $nokp)->first() ?? $customer_info->where('kplama', $nokp)->first();
|
||||
})->toArray();
|
||||
|
||||
return $customer_info;
|
||||
}
|
||||
|
||||
function getMarhunGadaian($total_gadaian, $cawangan_connection)
|
||||
{
|
||||
|
||||
$extract_norujukan = $total_gadaian->pluck('norujukan');
|
||||
|
||||
$marhun_gadaian = Marhun::on($cawangan_connection)
|
||||
->select('norujukan', 'bil', 'marhun')
|
||||
->whereIn('norujukan', $extract_norujukan)
|
||||
->get()
|
||||
->groupBy('norujukan')
|
||||
->toArray();
|
||||
|
||||
$marhun_gadaian = array_map(function ($gadaian) {
|
||||
return array_map(function ($norujukan) {
|
||||
return $norujukan['bil'] . ' ' . $norujukan['marhun'];
|
||||
}, $gadaian);
|
||||
}, $marhun_gadaian);
|
||||
|
||||
$marhun_gadaian = array_map(function ($gadaian) {
|
||||
return implode(',', $gadaian);
|
||||
}, $marhun_gadaian);
|
||||
|
||||
return $marhun_gadaian;
|
||||
}
|
||||
|
||||
function getReportGadaian(Request $request)
|
||||
{
|
||||
$cawangan_connection = Cawangan::where('kodcaw', $request->kod_cawangan)->first()->mysql;
|
||||
|
||||
$query_total_gadaian = Gadai::on($cawangan_connection);
|
||||
|
||||
$query_total_gadaian->when($request->filled('startDate') and $request->filled('endDate'), function ($q) use ($request) {
|
||||
return $q->where('t_gadai', '>=', $request->startDate)
|
||||
->where('t_gadai', '<=', $request->endDate);
|
||||
});
|
||||
|
||||
$total_gadaian = getTotalGadaian($query_total_gadaian);
|
||||
$total_summary_gadaian_teller = getTotalSummaryGadaianGroupByTeller($query_total_gadaian);
|
||||
$total_summary_gadaian = getTotalSummaryGadaian($query_total_gadaian);
|
||||
$customer_info = getCustomerInfo($total_gadaian);
|
||||
$marhun_gadaian = getMarhunGadaian($total_gadaian, $cawangan_connection);
|
||||
$cawangan_detail = getCawanganDetail($cawangan_connection);
|
||||
|
||||
$total_gadaian = $total_gadaian->zip($customer_info, $marhun_gadaian)->map(function ($data) {
|
||||
|
||||
[$gadai, $customer_info, $marhun_gadaian] = $data;
|
||||
|
||||
return [
|
||||
'no_rujukan' => $gadai['norujukan'],
|
||||
'nama' => $customer_info['nama'],
|
||||
'alamat' => $customer_info['alamat1'],
|
||||
'no_kp' => $gadai['nokp'],
|
||||
'masa' => $gadai['masa'],
|
||||
'marhun' => $marhun_gadaian,
|
||||
'berat' => Helper::formatNumber($gadai['berat']),
|
||||
'nilai_marhun' => Helper::formatNumber($gadai['nilaimarhun']),
|
||||
'pembiayaan' => Helper::formatNumber($gadai['pinjaman']),
|
||||
'peratusan_margin_pinjaman' => $gadai['percentpinj'],
|
||||
'teller' => $gadai['teller'],
|
||||
];
|
||||
|
||||
});
|
||||
|
||||
$total_gadaian = $total_gadaian
|
||||
->groupBy('teller')
|
||||
->zip($total_summary_gadaian_teller)
|
||||
->map(function ($data) {
|
||||
[$gadaian, $summary] = $data;
|
||||
|
||||
return [$gadaian, $summary];
|
||||
});
|
||||
|
||||
$data = [
|
||||
'query' => [
|
||||
'startDate' => Helper::formatDate($request->startDate),
|
||||
'endDate' => Helper::formatDate($request->endDate),
|
||||
],
|
||||
'cawangan_detail' => $cawangan_detail,
|
||||
'gadaian' => $total_gadaian,
|
||||
'summary_gadaian' => $total_summary_gadaian,
|
||||
];
|
||||
|
||||
return json_encode($data);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
use App\Cawangan;
|
||||
use App\Customer;
|
||||
use App\Gadai;
|
||||
use App\Helper;
|
||||
|
||||
$tarikh = '2023-11-01';
|
||||
|
||||
$active_cawangan_db_connection = Helper::getActiveCawanganDbConnection();
|
||||
|
||||
$active_cawangan_db = array_map(function($connection){
|
||||
return config('database.connections.' . $connection)['database'];
|
||||
}, $active_cawangan_db_connection);
|
||||
|
||||
$active_cawangan_name = Cawangan::whereIn('db_name', $active_cawangan_db)->pluck('details_caw')->toArray();
|
||||
|
||||
$gadai_data = array_map(function ($db_connection) use ($tarikh) {
|
||||
$gadai = Gadai::on($db_connection)->select('t_gadai', 'norujukan', 'nokp', 'semakbarcode', 'masa', 'berat', 'nilaimarhun', 'pinjaman', 'upah12', 'percentpinj', 'teller', 'nokp')
|
||||
->where('t_gadai', '=', $tarikh)
|
||||
->orderBy('teller')
|
||||
->orderBy('sirig')
|
||||
->get();
|
||||
|
||||
return $gadai->toArray();
|
||||
}, $active_cawangan_db_connection);
|
||||
|
||||
$gadai_data_with_key = array_combine($active_cawangan_name, $gadai_data);
|
||||
|
||||
$overall_data_gadai = array_map(function ($gadaian_cawangan) {
|
||||
return array_map(function ($gadai) {
|
||||
|
||||
$customer_info = Customer::on('mysql7')->where('kplama', '=', $gadai['nokp'])->orWhere('kpbaru', '=', $gadai['nokp'])->first()->toArray();
|
||||
|
||||
return [
|
||||
"t_gadai" => $gadai['t_gadai'],
|
||||
"norujukan" => $gadai['norujukan'],
|
||||
"nama" => $customer_info['nama'],
|
||||
"nokp" => $gadai['nokp'],
|
||||
"semakbarcode" => $gadai['semakbarcode'],
|
||||
"masa" => $gadai['masa'],
|
||||
"berat" => $gadai['berat'],
|
||||
"nilaimarhun" => $gadai['nilaimarhun'],
|
||||
"pinjaman" => $gadai['pinjaman'],
|
||||
"upah12" => $gadai['upah12'],
|
||||
"percentpinj" => $gadai['percentpinj'],
|
||||
"alamat1" => $customer_info['alamat1'],
|
||||
"teller" => $gadai['teller'],
|
||||
];
|
||||
|
||||
}, $gadaian_cawangan);
|
||||
|
||||
}, $gadai_data_with_key);
|
||||
|
||||
dump($overall_data_gadai);
|
||||
return $overall_data_gadai;
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use App\Cawangan;
|
||||
use App\Gadai;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Helper;
|
||||
|
||||
$tarikh = '2023-11-01';
|
||||
$active_cawangan_db_connection = Helper::getActiveCawanganDbConnection();
|
||||
|
||||
$active_cawangan_db_name = array_map(function($db_connection){
|
||||
return config('database.connections' . '.' . $db_connection. '.' . 'database' );
|
||||
}, $active_cawangan_db_connection);
|
||||
|
||||
$active_cawangan_detail = Cawangan::select('kodcaw', 'details_caw')->whereIn('db_name', $active_cawangan_db_name)->get()->toArray();
|
||||
|
||||
$summary_gadaian_data = array_map(function ($db_connection) use ($tarikh) {
|
||||
$gadai = Gadai::on($db_connection)
|
||||
->select(DB::raw('count(norujukan) as total_gadaian, sum(berat) as sum_berat, sum(nilaimarhun) as sum_nilai_marhun, sum(pinjaman) as sum_pinjaman'))
|
||||
->where('t_gadai', '=', $tarikh)
|
||||
->get();
|
||||
|
||||
return $gadai->toArray();
|
||||
}, $active_cawangan_db_connection);
|
||||
|
||||
$response = array_map(function($cawangan_detail, $summary_gadaian_data){
|
||||
return array_merge($cawangan_detail, $summary_gadaian_data[0]);
|
||||
}, $active_cawangan_detail, $summary_gadaian_data);
|
||||
|
||||
return json_encode($response);
|
||||
Reference in New Issue
Block a user