Merge branch 'master' of https://gitlab.com/online-sistem1/api_arrahn into apiaku
This commit is contained in:
@@ -197,39 +197,62 @@ class CustomerController extends Controller
|
||||
return response()->json($gadai_all);
|
||||
}
|
||||
|
||||
public function showOneCustomerGadaiByCawanganMobile($ic,$status,$kodcaw){
|
||||
if($status == 'belum_tebus'){
|
||||
$gadai_status = '';
|
||||
}elseif($status == 'sudah_tebus'){
|
||||
$gadai_status = 'T';
|
||||
}elseif($status == 'lelong'){
|
||||
$gadai_status = 'L';
|
||||
}
|
||||
public function gadaiTebusLelongByCawanganMobile($ic,$kodcaw){
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$gadai_all = [];
|
||||
if($status == 'belum_tebus' || $status == 'sudah_tebus'){
|
||||
$gadai = Gadai::on($cawangan['mysql'])
|
||||
->where([['sttebus','=',$gadai_status],['nokp','=',$ic]])
|
||||
->get();
|
||||
if(sizeof($gadai) != 0){
|
||||
foreach($gadai as $index => $gadai_detail){
|
||||
array_push($gadai_all,['norujukan'=>$gadai_detail['norujukan'],'hargajualan'=>$gadai_detail['hargajualan'],'bakihargajualan'=>$gadai_detail['bakihargajualan']]);
|
||||
$sttebus_ = [];
|
||||
$sttebus_T = [];
|
||||
$sttebus_L = [];
|
||||
$array_all = [];
|
||||
|
||||
$gadai = Gadai::on($cawangan['mysql'])->where([['nokp','=',$ic]])->get();
|
||||
|
||||
//to check if gadai has data
|
||||
if(!empty($gadai))
|
||||
{
|
||||
//loop each array
|
||||
foreach($gadai as $gd){
|
||||
|
||||
if($gd->sttebus == '' || empty($gd->sttebus)){
|
||||
|
||||
array_push($sttebus_, array(
|
||||
'norujukan' => $gd->norujukan,
|
||||
'hargajualan' => $gd->hargajualan,
|
||||
'bakihargajualan' => $gd->bakihargajualan,
|
||||
));
|
||||
|
||||
}
|
||||
}
|
||||
}elseif($status == 'lelong'){
|
||||
$gadai = Gadai::on($cawangan['mysql'])
|
||||
->where([['sttebus','=',$gadai_status],['nokp','=',$ic]])
|
||||
->rightJoin('lelong', 'gadai.norujukan', '=', 'lelong.norujukan')
|
||||
->get();
|
||||
if(sizeof($gadai) != 0){
|
||||
foreach($gadai as $index => $gadai_detail){
|
||||
array_push($gadai_all,['norujukan'=>$gadai_detail['norujukan'],'hargajualan'=>$gadai_detail['hargajualan'],'bakihargajualan'=>$gadai_detail['bakihargajualan']]);
|
||||
elseif($gd->sttebus == 'T')
|
||||
{
|
||||
array_push($sttebus_T, array(
|
||||
'norujukan' => $gd->norujukan,
|
||||
'hargajualan' => $gd->hargajualan,
|
||||
'bakihargajualan' => $gd->bakihargajualan,
|
||||
));
|
||||
|
||||
}
|
||||
elseif($gd->sttebus == 'L')
|
||||
{
|
||||
array_push($sttebus_L, array(
|
||||
'norujukan' => $gd->norujukan,
|
||||
'hargajualan' => $gd->hargajualan,
|
||||
'bakihargajualan' => $gd->bakihargajualan,
|
||||
));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json($gadai_all);
|
||||
else
|
||||
{
|
||||
return response()->json('Data Not Found');
|
||||
}
|
||||
|
||||
array_push($array_all, array(
|
||||
'gadai' => $sttebus_,
|
||||
'tebus' => $sttebus_T,
|
||||
'lelong' => $sttebus_L
|
||||
));
|
||||
return response()->json($array_all);
|
||||
}
|
||||
|
||||
public function getLaporanCustomers($kodcaw, $tarikh)
|
||||
|
||||
@@ -1350,7 +1350,7 @@ class GadaiController extends Controller
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
foreach($cawangan_all as $index=>$cawangan){
|
||||
$gadai = Gadai::on($cawangan['mysql'])->where([['sttebus','=',''],['t_gadai','=','2020-10-05']])->sum('pinjaman');
|
||||
$gadai = Gadai::on($cawangan['mysql'])->where([['sttebus','=',''],['t_gadai','=',$current->toDateString()]])->sum('pinjaman');
|
||||
array_push($array_cawangan,['cawangan'=>$cawangan['details_caw'],'total_gadai'=>$gadai]);
|
||||
$total_gadaian_cawangan += $gadai;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
||||
use App\Komuditi;
|
||||
use App\KomuditiPurchase;
|
||||
use App\KomuditiTransaksi;
|
||||
use App\KomuditiProduk;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
@@ -12,11 +13,8 @@ use Carbon\Carbon;
|
||||
class KomuditiController extends Controller
|
||||
{
|
||||
public function checkKomuditi(){
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$komuditi = Komuditi::on('mysql7')->where('date_purchase','=',$current->toDateString())->first();
|
||||
|
||||
$komuditi = KomuditiPurchase::on('mysql7')->orderBy('created_at','desc')->first();
|
||||
return response()->json($komuditi);
|
||||
}
|
||||
|
||||
@@ -33,19 +31,16 @@ class KomuditiController extends Controller
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$komuditi = Komuditi::on('mysql7')->create([
|
||||
'unit_komuditi' => $request->unit_komuditi,
|
||||
'date_purchase' => $current->toDateString(),
|
||||
'purchased_by' => $request->purchased_by
|
||||
]);
|
||||
|
||||
$komuditi_purchase = KomuditiPurchase::on('mysql7')->create([
|
||||
'unit_komuditi' => $request->unit_komuditi,
|
||||
'date_purchase' => $current->toDateString(),
|
||||
'purchased_by' => $request->purchased_by
|
||||
'nilai' => $request->nilai,
|
||||
'no_sijil' => $request->nosijil,
|
||||
'kodproduct' => $request->kodproduct,
|
||||
'purchased_by' => $request->purchased_by,
|
||||
'date_purchase' => $current->toDateString()
|
||||
]);
|
||||
|
||||
return response()->json($komuditi);
|
||||
return response()->json($komuditi_purchase);
|
||||
}
|
||||
|
||||
public function updateKomuditi(Request $request){
|
||||
@@ -76,13 +71,13 @@ class KomuditiController extends Controller
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$komuditi_current = Komuditi::on('mysql7')->where('date_purchase','=',$current->toDateString())->first();
|
||||
|
||||
$komuditi_current = KomuditiPurchase::on('mysql7')->orderBy('created_at','desc')->first();
|
||||
// dd($komuditi_current);
|
||||
$unit_current = $komuditi_current['unit_komuditi'];
|
||||
|
||||
$update_unit = $unit_current - $request->unit_komuditi;
|
||||
|
||||
$update_komuditi = Komuditi::on('mysql7')->where('date_purchase','=',$current->toDateString())->update([
|
||||
$update_komuditi = KomuditiPurchase::on('mysql7')->where('id','=',$komuditi_current['id'])->update([
|
||||
'unit_komuditi' => $update_unit
|
||||
]);
|
||||
|
||||
@@ -97,4 +92,47 @@ class KomuditiController extends Controller
|
||||
|
||||
return response()->json($komuditi_transaksi);
|
||||
}
|
||||
|
||||
public function ubahKomuditi(Request $request){
|
||||
$komuditi_current = KomuditiPurchase::on('mysql7')->orderBy('created_at','desc')->first();
|
||||
// dd($komuditi_current);
|
||||
$unit_current = $komuditi_current['unit_komuditi'];
|
||||
|
||||
$update_unit = $unit_current + $request->unit_komuditi;
|
||||
}
|
||||
|
||||
public function batalKomuditi(Request $request){
|
||||
|
||||
$komuditi_current = KomuditiPurchase::on('mysql7')->orderBy('created_at','desc')->first();
|
||||
// dd($komuditi_current);
|
||||
$unit_current = $komuditi_current['unit_komuditi'];
|
||||
|
||||
$update_unit = $unit_current + $request->unit_komuditi;
|
||||
|
||||
$update_komuditi = KomuditiPurchase::on('mysql7')->where('id','=',$komuditi_current['id'])->update([
|
||||
'unit_komuditi' => $update_unit
|
||||
]);
|
||||
|
||||
$komuditi_transaksi = KomuditiTransaksi::on('mysql7')->where('norujukan','=',$request->norujukan)->delete();
|
||||
|
||||
return response()->json($komuditi_transaksi);
|
||||
}
|
||||
|
||||
public function getKomuditiProduct(){
|
||||
$produk = KomuditiProduk::on('mysql7')->get();
|
||||
|
||||
return response()->json($produk);
|
||||
}
|
||||
|
||||
public function getKomuditiProductUnit(Request $request){
|
||||
$produk = KomuditiProduk::on('mysql7')->where('kodproduk','=',$request->kodproduk)->first();
|
||||
// dd($produk['unit']);
|
||||
return response()->json($produk['unit']);
|
||||
}
|
||||
|
||||
public function getKomuditiProductDescription(Request $request){
|
||||
$produk = KomuditiProduk::on('mysql7')->where('kodproduk','=',$request->kodproduk)->first();
|
||||
|
||||
return response()->json($produk);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user