pembuatan api
This commit is contained in:
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Cawangan;
|
||||
use App\Tunai;
|
||||
use App\AddTunai;
|
||||
use App\RequestTeller;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class TunaiController extends Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
public function listTunai($kodcaw)
|
||||
{
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
|
||||
|
||||
$tunai=Tunai::on($cawangan['mysql'])->where([['kodcaw','=',$kodcaw],['tarikh','=',$current->toDateString()]])->get();
|
||||
return response()->json($tunai);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function sumBakiTunai($kodcaw)
|
||||
{
|
||||
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$tunai=Tunai::on($cawangan['mysql'])->where('tarikh','=',$current->toDateString())->sum('baki');
|
||||
|
||||
return response()->json($tunai);
|
||||
|
||||
}
|
||||
|
||||
public function UpdateTunai($kodcaw, $kodlaluan, Request $request)
|
||||
{
|
||||
|
||||
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$updatetunai=Tunai::on($cawangan['mysql'])->where( [['tarikh','=', $current->toDateString()],['kodlaluan','=', $kodlaluan] ])->
|
||||
update(array(
|
||||
'tambah'=>$request->tambah,
|
||||
'kurang'=>$request->kurang,
|
||||
'baki'=>$request->bakiakhir
|
||||
));
|
||||
|
||||
return response()->json($updatetunai, 200);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function DaftarTunai($kodcaw, Request $request)
|
||||
{
|
||||
|
||||
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$tunai=Tunai::on($cawangan['mysql'])->create([
|
||||
|
||||
'tarikh' => $current->toDateString(),
|
||||
'kodcaw'=> $request->kodcaw,
|
||||
'kodlaluan'=>$request->teller,
|
||||
'bakiawal'=>$request->bakiawal,
|
||||
'masuk'=>$request->masuk,
|
||||
'yuran'=>$request->yuran,
|
||||
'keluar'=>$request->keluar,
|
||||
'baki'=>$request->baki,
|
||||
'tambah'=>$request->tambah,
|
||||
'kurang'=>$request->kurang
|
||||
|
||||
]);
|
||||
|
||||
return response()->json($tunai,201);
|
||||
|
||||
}
|
||||
|
||||
public function getCurrentTunai($kodcaw,$kodlaluan)
|
||||
{
|
||||
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
|
||||
$tunai=Tunai::on($cawangan['mysql'])
|
||||
->where([['kodcaw','=',$kodcaw],['tarikh','<=',$current->toDateString()],['kodlaluan','=',$kodlaluan]])
|
||||
->orderBy('tarikh','desc')
|
||||
->first();
|
||||
return response()->json($tunai);
|
||||
|
||||
}
|
||||
|
||||
|
||||
///API FARIS
|
||||
|
||||
|
||||
public function create($kodcaw,Request $request)
|
||||
{
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
|
||||
|
||||
|
||||
$addtunai=AddTunai::on($cawangan['mysql'])->create([
|
||||
|
||||
'tarikh' => $current->toDateString(),
|
||||
'kodcaw'=> $request->kodcaw,
|
||||
'kodlaluan'=>$request->KodLaluan,
|
||||
'tambah'=>$request->tambah,
|
||||
'kurang'=>$request->kurang,
|
||||
'nota'=>$request->nota
|
||||
]);
|
||||
|
||||
return response()->json($addtunai,201);
|
||||
|
||||
}
|
||||
|
||||
public function getAddTunai($kodcaw,$tarikh)
|
||||
{
|
||||
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$addtunai=AddTunai::on($cawangan['mysql'])->where([['kodcaw','=',$kodcaw],['tarikh','=',$tarikh]])->get();
|
||||
return response()->json($addtunai);
|
||||
}
|
||||
|
||||
public function getRequestTeller($kodcaw,$kodlaluan)
|
||||
{
|
||||
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$requestteller=RequestTeller::on('mysql7')->where([['kodcaw','=',$kodcaw],['KodLaluan','=',$kodlaluan],['update','=',0]])->get();
|
||||
return response()->json($requestteller);
|
||||
}
|
||||
|
||||
public function createRequestTeller($kodcaw,$kodlaluan,Request $request)
|
||||
{
|
||||
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$reqteller=RequestTeller::on('mysql7')->create([
|
||||
|
||||
'tarikh' => $current->toDateString(),
|
||||
'kodcaw' => $kodcaw,
|
||||
'KodLaluan'=> $kodlaluan,
|
||||
'modal'=>$request->modal,
|
||||
'serahan'=>$request->serahan,
|
||||
'update' => '0'
|
||||
]);
|
||||
|
||||
return response()->json($reqteller,200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user