add jenis emas and lelong api
This commit is contained in:
@@ -6,6 +6,8 @@ use App\Gadai;
|
||||
use App\Cawangan;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class GadaiController extends Controller
|
||||
{
|
||||
|
||||
@@ -36,7 +38,20 @@ class GadaiController extends Controller
|
||||
return response()->json($gadai_all);
|
||||
}
|
||||
|
||||
public function showOneGadaibyRujukan($kodcaw,$norujukan)
|
||||
public function showOneGadaiByNorujukan($norujukan){
|
||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
||||
$gadai_all = [];
|
||||
foreach($cawangan_all as $index=>$cawangan){
|
||||
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->get();
|
||||
if(sizeof($gadai) != 0){
|
||||
array_push($gadai_all,$gadai);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json($gadai_all);
|
||||
}
|
||||
|
||||
public function showOneGadaibyRujukanAndCawangan($kodcaw,$norujukan)
|
||||
{
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->get();
|
||||
@@ -44,10 +59,40 @@ class GadaiController extends Controller
|
||||
return response()->json($gadai);
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
public function create($kodcaw,Request $request)
|
||||
{
|
||||
$gadai = Gadai::create($request->all());
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$gadai = Gadai::on($cawangan['mysql'])->create([
|
||||
'kodcaw'=>$kodcaw,
|
||||
'norujukan' => $request->norujukan,
|
||||
'nopelanggan' => $request->nopelanggan,
|
||||
'nokp' => $request->nokp,
|
||||
't_gadai' => $current->toDateString(),
|
||||
'masa' =>$current->toTimeString(),
|
||||
'nilaimarhun' => $request->nilaimarhun,
|
||||
'n_marhuns' => $request->nilaimarhun,
|
||||
'berat' => $request->berat,
|
||||
'pinjaman' => $request->pinjaman,
|
||||
'kadarupah' => $request->kadarupah,
|
||||
'tempoh' => 6,
|
||||
't_matang' => $current->addMonths(6)->subDays(1),
|
||||
'sttebus' => '',
|
||||
'marhun' => $request->marhun,
|
||||
'jantina' => $request->jantina,
|
||||
'bangsa' => $request->bangsa,
|
||||
'jenistebus' => '',
|
||||
'penilai' => 'AFIQ',
|
||||
'namapenilai' => 'Afiq',
|
||||
'namapelulus' => 'Afiq',
|
||||
'percentpinj' => $request->percentpinj,
|
||||
'namateller' => 'Afiq',
|
||||
'tagpalsu' => 0,
|
||||
'tellernew' => '',
|
||||
'tagcall' => ''
|
||||
]);
|
||||
return response()->json($gadai, 201);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,16 @@ class HargaEmasController extends Controller
|
||||
{
|
||||
public function showAllHargaEmas()
|
||||
{
|
||||
return response()->json(HargaEmas::all());
|
||||
return response()->json(HargaEmas::on('mysql7')->orderby('recno')->get());
|
||||
}
|
||||
|
||||
public function getOneHargaEmas($karat){
|
||||
|
||||
$karat_string = str_replace('-','.',$karat);
|
||||
|
||||
$harga_emas = HargaEmas::on('mysql7')->select('harga2')->where('karat','=',$karat_string)->first();
|
||||
|
||||
return response()->json($harga_emas);
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Lelong;
|
||||
use App\Cawangan;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LelongController extends Controller
|
||||
@@ -10,12 +11,22 @@ class LelongController extends Controller
|
||||
|
||||
public function showAllLelongs()
|
||||
{
|
||||
return response()->json(Lelong::all());
|
||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
||||
$lelong_all = [];
|
||||
foreach ($cawangan_all as $index => $cawangan){
|
||||
$lelong = Lelong::on($cawangan['mysql'])->get();
|
||||
if(sizeof($lelong) != 0){
|
||||
array_push($lelong_all,$lelong);
|
||||
}
|
||||
}
|
||||
return response()->json($lelong_all);
|
||||
}
|
||||
|
||||
public function showOneLelong($id)
|
||||
public function showAllLelongByCawangan($kodcaw)
|
||||
{
|
||||
return response()->json(Lelong::find($id));
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$lelong = Lelong::on($cawangan['mysql'])->get();
|
||||
return response()->json($lelong);
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Marhun;
|
||||
use App\Jemas;
|
||||
use App\Cawangan;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class MarhunController extends Controller
|
||||
{
|
||||
|
||||
@@ -13,15 +17,62 @@ class MarhunController extends Controller
|
||||
return response()->json(Marhun::all());
|
||||
}
|
||||
|
||||
public function showOneMarhun($id)
|
||||
public function showOneMarhun($norujukan)
|
||||
{
|
||||
$marhun = Marhun::where('noRujukan','=',$norujukan)->get();
|
||||
return response()->json($marhun);
|
||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
||||
$marhun_all = [];
|
||||
foreach($cawangan_all as $index=>$cawangan){
|
||||
$marhun = Marhun::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->get();
|
||||
if(sizeof($marhun) != 0){
|
||||
array_push($marhun_all,$marhun);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json($marhun_all);
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
public function getAllJemas($kodcaw){
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$jemas = Jemas::on($cawangan['mysql'])->get();
|
||||
|
||||
return response()->json($jemas);
|
||||
}
|
||||
|
||||
public function create($kodcaw,Request $request)
|
||||
{
|
||||
$marhun = Marhun::create($request->all());
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$nota = "";
|
||||
if($request->rosak != ""){
|
||||
$nota = $nota . $request->rosak;
|
||||
}
|
||||
if($request->putus != ""){
|
||||
$nota = $nota . ', ' . $request->putus;
|
||||
}
|
||||
if($request->patah != ""){
|
||||
$nota = $nota . ', ' . $request->patah;
|
||||
}
|
||||
if($request->permata != ""){
|
||||
$nota = $nota . ', ' . $request->permata;
|
||||
}
|
||||
if($request->sebelah != ""){
|
||||
$nota = $nota . ', ' . $request->sebelah;
|
||||
}
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$marhun = Marhun::on($cawangan['mysql'])->create([
|
||||
'kodcaw'=> $kodcaw,
|
||||
'norujukan'=> $request->norujukan,
|
||||
't_gadai' => $current->toDateString(),
|
||||
'bil' => 1,
|
||||
'marhun' => $request->marhun,
|
||||
'nota' => $nota,
|
||||
'karat' => $request->karat,
|
||||
'berat' => $request->berat_emas,
|
||||
'harga' => $request->harga,
|
||||
'n_marhun' => $request->nilai_marhun
|
||||
]);
|
||||
|
||||
return response()->json($marhun, 201);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user