api dashboard
This commit is contained in:
@@ -676,4 +676,23 @@ class CustomerController extends Controller
|
|||||||
|
|
||||||
return response()->json($custcawangan);
|
return response()->json($custcawangan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTotalNewCustomerToday(){
|
||||||
|
$current = Carbon::now();
|
||||||
|
$current = new Carbon();
|
||||||
|
$harini = $current->toDateString();
|
||||||
|
$lastweek = $current->subWeek()->toDateString();
|
||||||
|
|
||||||
|
$newcustomertoday = Customer::on('mysql7')->where('tarikhdaftar',$harini)->count();
|
||||||
|
$newcustomerlastweek = Customer::on('mysql7')->where('tarikhdaftar',$lastweek)->count();
|
||||||
|
|
||||||
|
$diffCustomerPercent = 0;
|
||||||
|
if($newcustomerlastweek != 0){
|
||||||
|
$diffCustomerPercent = (($newcustomertoday - $newcustomerlastweek)/$newcustomerlastweek)*100;
|
||||||
|
}
|
||||||
|
$dataCustomer = [];
|
||||||
|
array_push($dataCustomer,['newCustomerToday'=>$newcustomertoday,'percentDiff'=>$diffCustomerPercent]);
|
||||||
|
|
||||||
|
return response()->json($dataCustomer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1667,7 +1667,7 @@ class GadaiController extends Controller
|
|||||||
}
|
}
|
||||||
$diffTebusPercent = 0;
|
$diffTebusPercent = 0;
|
||||||
if($tebusLastWeek != 0){
|
if($tebusLastWeek != 0){
|
||||||
$diffTebusPercent = (($tebusToday - $tebusLastWeek)/$tebusLastWeek)/100;
|
$diffTebusPercent = (($tebusToday - $tebusLastWeek)/$tebusLastWeek)*100;
|
||||||
}
|
}
|
||||||
$dataTebus = [];
|
$dataTebus = [];
|
||||||
array_push($dataTebus,['tebusToday'=>$tebusToday,'percentDiff'=>$diffTebusPercent]);
|
array_push($dataTebus,['tebusToday'=>$tebusToday,'percentDiff'=>$diffTebusPercent]);
|
||||||
@@ -3315,4 +3315,24 @@ class GadaiController extends Controller
|
|||||||
$deleteGadai = Gadai::on($cawangan['mysql'])->whereIn('norujukan',$gadaiData)->delete();
|
$deleteGadai = Gadai::on($cawangan['mysql'])->whereIn('norujukan',$gadaiData)->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function KomoditiDashboard(){
|
||||||
|
$current = Carbon::now();
|
||||||
|
$current = new Carbon();
|
||||||
|
$harini = $current->toDateString();
|
||||||
|
$totalKomoditi = Komuditi::on('mysql7')->where([['date_purchase',$harini],['transaction_type','Beli Komoditi']])->sum('unit_komuditi');
|
||||||
|
$totalUse = KomuditiTransaksi::on('mysql7')->where('tarikh',$harini)->sum('unit_komuditi');
|
||||||
|
|
||||||
|
$bakiKomoditi = $totalKomoditi - $totalUse;
|
||||||
|
$percentUse = 0;
|
||||||
|
if($totalKomoditi != 0){
|
||||||
|
$percentUse = ($totalUse/$totalKomoditi)*100;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dataKomoditi = [];
|
||||||
|
|
||||||
|
array_push($dataKomoditi,['totalKomoditi'=>$totalKomoditi,'bakiKomoditi'=>$bakiKomoditi,'percentUse'=>$percentUse]);
|
||||||
|
|
||||||
|
return response()->json($dataKomoditi);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class TransactionOnlineController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function updateTransactionOnline(){
|
public function updateTransactionOnline(){
|
||||||
$transactions = TransactionOnline::on('mysql7')->where([['status','PAID'],['update_status',0]])->get();
|
$transactions = TransactionOnline::on('mysql7')->where([['status','=','PAID'],['update_status',0]])->get();
|
||||||
$current = Carbon::now();
|
$current = Carbon::now();
|
||||||
$current = new Carbon();
|
$current = new Carbon();
|
||||||
foreach($transactions as $index=>$transaction){
|
foreach($transactions as $index=>$transaction){
|
||||||
|
|||||||
@@ -576,6 +576,9 @@ $router->group(['prefix'=>'dashboard'], function () use ($router){
|
|||||||
|
|
||||||
$router->get('oneweekdata',['uses'=>'GadaiController@oneWeekData']);
|
$router->get('oneweekdata',['uses'=>'GadaiController@oneWeekData']);
|
||||||
|
|
||||||
|
$router->get('newcustomertoday',['uses'=>'CustomerController@getTotalNewCustomerToday']);
|
||||||
|
$router->get('statistik/komoditi/harini',['uses'=>'GadaiController@KomoditiDashboard']);
|
||||||
|
|
||||||
$router->post('prestasi/cawangan',['uses'=>'GadaiController@prestasiCawangan']);
|
$router->post('prestasi/cawangan',['uses'=>'GadaiController@prestasiCawangan']);
|
||||||
|
|
||||||
$router->post('peti_besi',['uses'=>'GadaiController@petiBesiCawangan']);
|
$router->post('peti_besi',['uses'=>'GadaiController@petiBesiCawangan']);
|
||||||
|
|||||||
Reference in New Issue
Block a user