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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class KomuditiProduk extends Model
|
||||
{
|
||||
protected $table = 'komuditi_produk';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'kodproduk','description','unit'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
// protected $hidden = [];
|
||||
}
|
||||
@@ -14,7 +14,7 @@ class KomuditiPurchase extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'unit_komuditi','purchased_by','date_purchase'
|
||||
'unit_komuditi','purchased_by','date_purchase','nilai','no_sijil','kodproduct'
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
+26
-18
@@ -244,35 +244,43 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
||||
$router->put('DenominasiUpdate/{kodcaw}',['uses'=>'DenominasiController@updatedenominasi']);
|
||||
$router->post('DenominasiCreate/{kodcaw}',['uses'=>'DenominasiController@createdenominasi']);
|
||||
|
||||
|
||||
//Komuditi Pukal
|
||||
$router->get('komuditi/check',['uses'=>'KomuditiController@checkKomuditi']);
|
||||
$router->post('komuditi/pendahuluan',['uses'=>'KomuditiController@beliKomuditi']);
|
||||
$router->post('komuditi/pembelian',['uses'=>'KomuditiController@beliKomuditi']);
|
||||
$router->put('komuditi/update',['uses'=>'KomuditiController@updateKomuditi']);
|
||||
$router->put('komuditi/transaksi',['uses'=>'KomuditiController@transaksiKomuditi']);
|
||||
|
||||
$router->get('komuditi/produk',['uses'=>'KomuditiController@getKomuditiProduct']);
|
||||
$router->get('komuditi/unit',['uses'=>'KomuditiController@getKomuditiProductUnit']);
|
||||
$router->get('komuditi/description',['uses'=>'KomuditiController@getKomuditiProductDescription']);
|
||||
});
|
||||
|
||||
$router->group(['prefix'=>'e-arrahn'], function () use ($router){
|
||||
});
|
||||
|
||||
$router->group(['prefix'=>'mobile'], function () use ($router){
|
||||
|
||||
$router->get('customers/{ic}',['uses'=>'CustomerController@showOneCustomerByICMobile']);
|
||||
$router->get('customers/{ic}/gadai/{status}/{kodcaw}',['uses'=>'CustomerController@showOneCustomerGadaiByCawanganMobile']);
|
||||
$router->get('customers/{ic}/gadai/amaran/lelong',['uses'=>'CustomerController@show6BlnGadai']);
|
||||
|
||||
$router->get('harga_emas',['uses'=>'HargaEmasController@showAllHargaEmasMobile']);
|
||||
|
||||
$router->get('gadai/norujukan/{nokp}',['uses'=>'CustomerController@listNorujukanMobile']);
|
||||
$router->get('gadai/norujukan/count/{nokp}',['uses'=>'CustomerController@countNorujukanMobile']);
|
||||
$router->post('gadai/detail/norujukan',['uses'=>'CustomerController@getGadaiDetailMobile']);
|
||||
|
||||
$router->put('customers/update/{nokp}', ['uses' => 'CustomerController@customerUpdate']);
|
||||
|
||||
$router->get('otp/{nokp}',['uses'=>'OtpController@getOtp']);
|
||||
$router->get('otp/check/{otp_token}',['uses'=>'OtpController@checkToken']);
|
||||
$router->put('otp/update_otp',['uses'=>'OtpController@usedOTP']);
|
||||
|
||||
$router->get('gadai/{noic}',['uses'=>'GadaiController@showOneGadaiMobile']);
|
||||
|
||||
//utama
|
||||
$router->get('customers/{ic}/gadai/amaran/lelong',['uses'=>'CustomerController@show6BlnGadai']);
|
||||
$router->get('harga_emas',['uses'=>'HargaEmasController@showAllHargaEmasMobile']);
|
||||
$router->get('gadai/norujukan/count/{nokp}',['uses'=>'CustomerController@countNorujukanMobile']);
|
||||
$router->get('gadai/norujukan/{nokp}',['uses'=>'CustomerController@listNorujukanMobile']);
|
||||
|
||||
//gadaian
|
||||
$router->get('gadai/{noic}',['uses'=>'GadaiController@showOneGadaiMobile']);
|
||||
$router->get('customers/{ic}/gadaitebuslelong/{kodcaw}',['uses'=>'CustomerController@gadaiTebusLelongByCawanganMobile']);
|
||||
|
||||
$router->post('gadai/detail/norujukan',['uses'=>'CustomerController@getGadaiDetailMobile']);
|
||||
$router->put('customers/update/{nokp}', ['uses' => 'CustomerController@customerUpdate']);
|
||||
|
||||
//register
|
||||
$router->get('otp/{nokp}',['uses'=>'OtpController@getOtp']);
|
||||
$router->get('otp/check/{otp_token}',['uses'=>'OtpController@checkToken']);
|
||||
$router->put('otp/update_otp',['uses'=>'OtpController@usedOTP']);
|
||||
|
||||
|
||||
});
|
||||
|
||||
$router->group(['prefix'=>'dashboard'], function () use ($router){
|
||||
|
||||
Reference in New Issue
Block a user