Browse Source

latest

master
Siti Rahayu 4 years ago
parent
commit
50efa0d84f

+ 1
- 1
app/Http/Controllers/Api/CompoundResourceController.php View File

@@ -565,7 +565,7 @@ class CompoundResourceController extends BaseController

$saved = '';

if($compound->modul != '03')
if(!($compound->modul == '03' && isset($compound->kpd)))
{
if($request->jenis == 'Pelbagai_KT'){
$kpd = $this->generateNumber($request->jenis, 'KT', '03');

+ 77
- 30
app/Http/Controllers/Main/TaskController.php View File

@@ -45,24 +45,24 @@ class TaskController extends Controller
$id = Auth::guard('sadmin')->id();
$user = Staff::with('StaffDetail')->find($id);

if($request->modul == '02')
{
$compound = Compound::with('ConfidentialFile')->where('non',$request->non)->first();
$faulty = Faulty::with('DeedLaw', 'Department') ->where('_id', $compound->seksyen_kesalahan_n)->first();
$jbkod = $compound->jbkod_n;
}
else{
$compound = Compound::with('ConfidentialFile')->where('kpd',$request->kpd)->first();
$faulty = Faulty::with('DeedLaw', 'Department') ->where('_id', $compound->seksyen_kesalahan)->first();
$jbkod = $compound->jbkod;
}

$file = ConfidentialFile::where('no_siri',$compound->ConfidentialFile->no_siri)->first();
$data = [];
$file = ConfidentialFile::where('no_siri',$request->confidential)->first();
$now = Carbon::now();
$gDate = $now->format('F Y');

if($request->dashboard == "true"){

if($request->modul == '02')
{
$compound = Compound::with('ConfidentialFile')->where('confidential_file_id',$request->confidential_id)->first();
$faulty = Faulty::with('DeedLaw', 'Department') ->where('_id', $compound->seksyen_kesalahan_n)->first();
$jbkod = $compound->jbkod_n;
}
else{
$compound = Compound::with('ConfidentialFile')->where('kpd',$request->kpd)->first();
$faulty = Faulty::with('DeedLaw', 'Department') ->where('_id', $compound->seksyen_kesalahan)->first();
$jbkod = $compound->jbkod;
}

$roles = Roles::where('kod', $request->kategori_modul)->first();

if($compound->modul == $request->kategori_modul){
@@ -83,8 +83,6 @@ class TaskController extends Controller
}
}


if(count($reg_id) > 0) {
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', url('api/push/notification'), [
@@ -96,9 +94,11 @@ class TaskController extends Controller
]
]);
}

$compound->modul = $request->kategori_modul;
$compound->save();
if(!($request->kategori_modul == '03' && $compound->modul == '02'))
{
$compound->modul = $request->kategori_modul;
$compound->save();
}

$historyData = [
'tarikh_kumpulan' => $gDate,
@@ -122,22 +122,34 @@ class TaskController extends Controller
return redirect()->back()->with('success_msg', '<strong>Berjaya Kemaskini!</strong> Kompaun ini berjaya diserahkan ke kategori modul '.$roles->name);
}
}else if($request->dashboard == "false"){

$compound = Compound::with('ConfidentialFile')->where('confidential_file_id',$request->confidential)->first();

$data = array();

if($compound->penguatkuasa == $request->penguatkuasa){

$staff = StaffDetail::where('_id',$request->penguatkuasa)->first();

return redirect()->back()->withInput()->with('error_msg','<strong>Tidak Berjaya!</strong> Kompaun ini sudah diserahkan kepada penguatkuasa ['.$staff->no_badan.'] '.$staff->full_name);
}else{

$staff = Staff::with('StaffDetail')->where('_id',$request->penguatkuasa)->where(function($q){
$q->where('roles_access','PenguatKuasa')->orWhere('roles_access','PPenguatKuasa');
})->first();
$role = Roles::where('kod', $compound->modul)->first();
$role = Roles::where('kod', $compound->modul)->first();

if($request->categori_modul == '03' && $compound->modul == '02')
{
if($compound->modul == '02')
{
$compound = Compound::with('ConfidentialFile')->where('non',$request->non)->first();
$faulty = Faulty::where('_id', $compound->seksyen_kesalahan_n)->first();
$department = Department::where('_id', $compound->jbkod_n)->first();
$deedlaw = DeedLaw::where('_id', $compound->akta_n)->first();
$jbkod = $compound->jbkod_n;

$this->dispatch(new StoreCompoundEPBT($request->all(), $compound->kpd, $user->StaffDetail->full_name, $user->StaffDetail->no_badan, $compound->seksyen_kesalahan));
// dd($faulty);

$data = [
array_push($data, array(
'non' => $compound->non,
'jenis' => $compound->jenis_n,
'nama' => $compound->nama,
@@ -148,13 +160,48 @@ class TaskController extends Controller
'nama_jalan' =>$compound->nama_jalan,
'catatan' => $compound->catatan,
'latlong' => $compound->latlong,
'jabatan' => $faulty->Department->jnama,
'akta' => $faulty->DeedLaw->nama,
'jabatan' => $department->jnama,
'akta' => $deedlaw->nama,
'seksyen' => $faulty->nama,
'tempoh' => $compound->tempoh,
'tindakan' => $compound->tindakan ?? "",
'created_n' => $compound->created_n,
];
}
));

}
else{
$compound = Compound::with('ConfidentialFile')->where('kpd',$request->kpd)->first();
$faulty = Faulty::with('DeedLaw', 'Department') ->where('_id', $compound->seksyen_kesalahan)->first();
$jbkod = $compound->jbkod;
}

// if($compound->modul == '02')
// {
// $this->dispatch(new StoreCompoundEPBT($request->all(), $compound->kpd, $user->StaffDetail->full_name, $user->StaffDetail->no_badan, $compound->seksyen_kesalahan));

// dd($faulty);

// array_push($data, array(
// 'non' => $compound->non,
// 'jenis' => $compound->jenis_n,
// 'nama' => $compound->nama,
// 'identity' => $compound->identity,
// 'alamat' => $compound->alamat,
// 'nama_kawasan' =>$compound->nama_kawasan,
// 'nama_taman' => $compound->nama_taman,
// 'nama_jalan' =>$compound->nama_jalan,
// 'catatan' => $compound->catatan,
// 'latlong' => $compound->latlong,
// 'jabatan' => $faulty['Department']['jnama'],
// 'akta' => $faulty['DeedLaw']['nama'],
// 'tempoh' => $compound->tempoh,
// 'tindakan' => $compound->tindakan ?? "",
// 'created_n' => $compound->created_n,
// ));

// }

info(json_encode($data));

if(!empty($staff)){
if($staff->token_firebase != '') {
@@ -163,13 +210,13 @@ class TaskController extends Controller
'verify' => false,
'form_params' => [
'title' => $role->name.' '.$compound->kpd,
'msg' => 'Kompaun ini berada di ruangan '.$role->name . '\n' .$data,
'msg' => 'Kompaun ini berada di ruangan '.$role->name ,
'data' => json_encode($data),
'register_id[]' => $staff->token_firebase,
]
]);
}


$compound->penguatkuasa = $request->penguatkuasa;
$compound->save();


+ 5
- 3
app/Http/Controllers/NotificationController.php View File

@@ -39,7 +39,7 @@ class NotificationController extends BaseController
* @return json
*/

public function createNotifications($title, $msg, array $token) {
public function createNotifications($title, $msg, $data, array $token) {

$fcmUrl = 'https://fcm.googleapis.com/fcm/send';

@@ -48,6 +48,7 @@ class NotificationController extends BaseController
'body' => $msg,
'icon' => '',
'sound' => true,
'data' => $data,
];

$extraNotificationData = ["message" => $notification];
@@ -84,8 +85,10 @@ class NotificationController extends BaseController
$data = $request->data;
$register_id = $request->register_id;

info($data);

if($register_id != null){
$result = $this->createNotifications($title, $msg, $register_id);
$result = $this->createNotifications($title, $msg, $data, $register_id);
$response = json_decode($result);

foreach ($response->results as $key => $r) {
@@ -96,7 +99,6 @@ class NotificationController extends BaseController
$dataNoti = [
'title' => $title,
'body' => $msg,
'data' => $data,
];
$staff->notification()->create($dataNoti);
}

+ 4
- 1
resources/views/main-dashboard/compound_detail/compound_job.blade.php View File

@@ -228,7 +228,7 @@
</div>
</div>
</form>
@if($compound->modul != '02' && $compound->modul != '04')
@if($compound->modul != '04')
<form method="POST" action="{{ url('/main/compound/update/action') }}">
<div class="row">
<div class="col-lg-12 col-md-12">
@@ -244,6 +244,9 @@
<div class="card-block">
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
<input type="hidden" name="kpd" value="{{ $compound->kpd }}">
<input type="hidden" name="non" value="{{ $compound->non }}">
<input type="hidden" name="confidential" value="{{ $compound->confidential_file_id }}">
{{-- <input type="hidden" name="modul" value="{{ $compound->modul }}"> --}}
<input type="hidden" name="dashboard" value="false">

<div class="row">

Loading…
Cancel
Save