fix skit2
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class BajetController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
|
||||
return view('bajet.home');
|
||||
}
|
||||
|
||||
public function tambahbajet(){
|
||||
|
||||
return view('bajet.tambahbajet');
|
||||
}
|
||||
|
||||
public function checkTambah(Request $request){
|
||||
|
||||
$bajet = Http::get(config('api.url').'/admin/checkBajet',['kodcaw' => Auth::user()->cawangan, 'year' => $request->year, 'jenisbajet' => $request->jenisbajet])->json();
|
||||
|
||||
if(sizeof($bajet) > 0)
|
||||
{
|
||||
|
||||
Session::flash('type', 'error');
|
||||
Session::flash('message', 'Tidak berjaya kerana sudah ada data!');
|
||||
Session::flash('title', 'Tidak Berjaya Disimpan');
|
||||
|
||||
return redirect()->route('bajet');
|
||||
}else{
|
||||
return $this->engineTambah($request);
|
||||
}
|
||||
}
|
||||
|
||||
public function engineTambah(Request $request){
|
||||
|
||||
|
||||
$arraybulan = [
|
||||
['bulan' => 'Januari','bajet' => 0],
|
||||
['bulan' => 'Februari','bajet' => 0],
|
||||
['bulan' => 'Mac','bajet' => 0],
|
||||
['bulan' => 'April','bajet' => 0],
|
||||
['bulan' => 'Mei','bajet' => 0],
|
||||
['bulan' => 'Jun','bajet' => 0],
|
||||
['bulan' => 'Julai','bajet' => 0],
|
||||
['bulan' => 'Ogos','bajet' => 0],
|
||||
['bulan' => 'September','bajet' => 0],
|
||||
['bulan' => 'Oktober','bajet' => 0],
|
||||
['bulan' => 'November','bajet' => 0],
|
||||
['bulan' => 'Disember','bajet' => 0],
|
||||
];
|
||||
|
||||
|
||||
foreach($arraybulan as $index => $bulan)
|
||||
$arraybulan[$index]['bajet'] = intval($request->bajet[$index]);
|
||||
|
||||
$year = $request->year;
|
||||
$jenisbajet = $request->jenisbajet;
|
||||
$kodcaw = Auth::user()->cawangan;
|
||||
$username = Auth::user()->name;
|
||||
|
||||
$bajeting = Http::post(config('api.url') . '/admin/simpanBajet',[
|
||||
'year'=> $year,
|
||||
'jenisbajet'=> $jenisbajet,
|
||||
'kodcaw'=> $kodcaw,
|
||||
'bulan'=> $arraybulan,
|
||||
'username' => $username
|
||||
])->json();
|
||||
|
||||
Session::flash('type', 'success');
|
||||
Session::flash('message', 'Bajet sudah berjaya disimpan!');
|
||||
Session::flash('title', 'Berjaya disimpan');
|
||||
|
||||
return redirect()->route('bajet');
|
||||
|
||||
}
|
||||
|
||||
public function kemaskinibajet(){
|
||||
|
||||
return view('bajet.kemaskinibajet');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user