106 lines
3.0 KiB
PHP
106 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Polis;
|
|
use App\Cawangan;
|
|
use App\LookupAlasan;
|
|
use Illuminate\Http\Request;
|
|
|
|
use Carbon\Carbon;
|
|
|
|
class PolisController extends Controller
|
|
{
|
|
public function getPolis(Request $request){
|
|
|
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
|
|
|
$polis = Polis::on($cawangan['mysql'])
|
|
->where('norujukan','=',$request->norujukan)
|
|
->get();
|
|
|
|
return response()->json($polis);
|
|
}
|
|
|
|
public function PolischangeTebus(Request $request){
|
|
|
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
|
|
|
$polis = Polis::on($cawangan['mysql'])
|
|
->where('norujukan','=',$request->norujukan)
|
|
->update(['tebus' => $request->tebus]);
|
|
|
|
return response()->json($polis);
|
|
}
|
|
|
|
public function createPolis(Request $request)
|
|
{
|
|
$harini = Carbon::now();
|
|
$harini = new Carbon;
|
|
|
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
|
|
|
$polis = Polis::on($cawangan['mysql'])
|
|
->create([
|
|
'tarikh' => $harini->toDateString(),
|
|
'kodcaw' => $request->kodcaw,
|
|
'norujukan' => $request->norujukan,
|
|
'komen1' => $request->komen1,
|
|
'komen2' => $request->komen2,
|
|
'tebus' => 0,
|
|
'teller' => $request->teller,
|
|
'caj' => 0.00,
|
|
'kodnegeri' => $request->kodnegeri,
|
|
'koddaerah' => $request->koddaerah
|
|
]);
|
|
|
|
return response()->json($polis);
|
|
|
|
}
|
|
|
|
public function editPolis(Request $request)
|
|
{
|
|
$harini = Carbon::now();
|
|
$harini = new Carbon;
|
|
|
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
|
|
|
$polis = Polis::on($cawangan['mysql'])
|
|
->where('norujukan','=',$request->norujukan)
|
|
->update([
|
|
'komen1' => $request->komen1,
|
|
'komen2' => $request->komen2,
|
|
'teller' => $request->teller,
|
|
'kodnegeri' => $request->kodnegeri,
|
|
'koddaerah' => $request->koddaerah
|
|
]);
|
|
|
|
return response()->json($polis);
|
|
|
|
}
|
|
|
|
public function LookupAlasan(Request $request)
|
|
{
|
|
$harini = Carbon::now();
|
|
$harini = new Carbon;
|
|
|
|
|
|
$alasan = LookupAlasan::on('mysql7')
|
|
->get();
|
|
|
|
return response()->json($alasan);
|
|
|
|
}
|
|
|
|
public function LaporanPolis(Request $request){
|
|
|
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
|
|
|
$polis = Polis::on($cawangan['mysql'])
|
|
->where('komen1','=',$request->alasan)
|
|
->where('tarikh','=',$request->tarikh)
|
|
->get();
|
|
|
|
return response()->json($polis);
|
|
}
|
|
} |