Skip to content

Commit

Permalink
Merge branch 'meor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rookiextreme committed Sep 15, 2022
2 parents b8ba6fe + 01ae78f commit cb65d30
Show file tree
Hide file tree
Showing 21 changed files with 569 additions and 752 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php
namespace App\Http\Controllers\Segment\Admin\Tempahan\Bilik;

use App\Http\Controllers\Common\CommonController;
use App\Http\Controllers\Controller;
use App\Models\Mykj\ListPegawai2;
use App\Models\Tempahan\TempahanBilik;
use App\Models\Tetapan\Fasiliti;
use Illuminate\Http\Request;
use Yajra\DataTables\DataTables;

class AdminTempahanBilikController extends Controller{
public function __construct()
{
$this->middleware('auth');
}

public function index(){
return view('segment.admin.tempahan.bilik.index');
}

public function getTempahanBilikList(){
$model = TempahanBilik::where('delete_id', 0);

return DataTables::of($model)
->setRowAttr([
'data-tempahan-id' => function($data) {
return $data->id;
},
])
->addColumn('nama', function($data){
return $data->tempahanBilik->nama.'<br> '.$data->tempahanBilik->kapasiti.' orang<br> Aras '.$data->tempahanBilik->aras.'<br> Bangunan '.$data->tempahanBilik->bilikBangunan->bangunanLokasi->nama.'('.$data->tempahanBilik->bilikBangunan->nama.')' ;
})
->addColumn('maklumat', function($data){
$getUrusetia = ListPegawai2::getMaklumatPegawai($data->nokp_urusetia);
return 'Tujuan: '.$data->nama.'<br> Urusetia: '.$getUrusetia['name'].'<br> Pengerusi: '.$data->pengerusi;
})
->addColumn('tempoh', function($data){
return 'Dari: '.date('d-m-Y H:i', strtotime($data->masa_mula)).' <br> Hingga: '.date('d-m-Y H:i', strtotime($data->masa_tamat));
})
->addColumn('status', function($data){
$label = '';
if($data->status == 0){
$label = '<span style="color:blue">Belum Lulus</span>';
}else if($data->status == 1){
$label = '<span style="color:green">Lulus</span>';
}
else if($data->status == 2){
$label = '<span style="color:red">Tidak Lulus</span>';
}
return $label;
})
->addColumn('action', function($data){
})
->rawColumns(['action', 'nama', 'maklumat', 'tempoh', 'status'])
->make(true);
}

public function getTempahanBilik(Request $request){
$id = $request->input('id');
$model = TempahanBilik::find($id);

$data = [];
$data['tempahan'] = [
'tempahan' => date('d-m-Y H:i', strtotime($model->created_at)),
'masa_mula' => date('d-m-Y H:i', strtotime($model->masa_mula)),
'masa_tamat' => date('d-m-Y H:i', strtotime($model->masa_tamat)),
'bilik' => $model->tempahanBilik->nama
];

$getUrusetia = ListPegawai2::getMaklumatPegawai($model->nokp_urusetia);
$data['maklumat'] = [
'nama' => $model->nama,
'urusetia' => $getUrusetia['name'],
'pengerusi' => $model->pengerusi,
'bil_agensi_d' => $model->bil_agensi_d,
'bil_agensi_l' => $model->bil_agensi_l,
'nota' => $model->nota
];

return response()->json([
'success' => 1,
'data' => $data
]);
}

public function lulusTempahanBilik(Request $request){
$status = $request->input('status');
$id = $request->input('id');

$model = CommonController::getModel(TempahanBilik::class, 1, $id);
$model->status = $status;
$model->save();

return response()->json([
'success' => 1,
'data' => $status
]);
}
}
14 changes: 14 additions & 0 deletions app/Http/Controllers/Segment/Dashboard/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
namespace App\Http\Controllers\Segment\Dashboard;

use App\Http\Controllers\Controller;
use App\Models\Tempahan\TempahanBilik;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class DashboardController extends Controller{
public function __construct()
Expand All @@ -12,4 +15,15 @@ public function __construct()
public function index(){
return view('segment.dashboard.index');
}

public function getEvents(Request $request){
$model = DB::select(DB::raw("SELECT CONCAT(j.nama, ', ', bb.nama , ', Bangunan ', b.nama, ', ', l.nama) as title, DATE(j.masa_mula) as start, DATE(j.masa_tamat) as end from tempahan_biliks j
join bangunan_biliks bb on j.bangunan_biliks_id = bb.id
join bangunans b on b.id = bb.bangunans_id
join lokasis l on l.id = b.lokasis_id
where j.status = 1
"));

return response()->json($model);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getTempahanBilik(Request $request){
}

public function deleteTempahanBilik(Request $request){
CommonController::softDeleteRecord(BangunanBilik::class, $request->input('id'));
CommonController::softDeleteRecord(TempahanBilik::class, $request->input('id'));
return response()->json([
'success' => 1,
]);
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Tempahan/TempahanBilik.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function storeUpdate(Request $request){
$model->nama = $v->tempahan_bilik_name;
$model->masa_mula = date('Y-m-d H:i', strtotime($v->tempahan_masa_mula));
$model->masa_tamat = date('Y-m-d H:i', strtotime($v->tempahan_masa_tamat));
$model->nokp_urusetia = 010202022;
$model->nokp_urusetia = $v->tempahan_bilik_urusetia;
$model->tel_urusetia = $v->tempahan_bilik_notel_urusetia;
$model->pengerusi = $v->tempahan_bilik_pengerusi;
$model->bil_agensi_d = $v->tempahan_bilik_agensi;
Expand Down
56 changes: 56 additions & 0 deletions public/app_js_helper/segment/admin/tempahan/bilik/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
class FasilitiController extends Ajax{
static storeUpdateFasiliti({url, data, trigger}){
this.runAjax({
url : url,
data: data,
func: function(success){
ToastAlert.toasting('Success', trigger == 0 ? 'Fasiliti Ditambah' : 'Fasiliti Dikemaskini', 'success');
DatatableUI.reloadTable('.fasiliti-table');
$('#fasiliti-modal').modal('hide');
}
});
}

static deleteFasiliti({url, data}){
SwalUI.init({
title: 'Adakah Anda Pasti?',
subtitle: 'Fasiliti Akan Dipadam!',
icon: 'error',
confirmText: 'Delete',
confirmButtonClass: 'btn btn-danger',
callback: function (){
Ajax.runAjax({
url: url,
data: data,
func: function () {
SwalUI.fireSwal({
icon: 'error',
title: 'Fasiliti Dipadam!',
subtitle: 'Tindakan Tidak Boleh Dipadam!'
});
DatatableUI.reloadTable('.fasiliti-table');
}
});
}
});
}

static lulusTempahan({url, data}){
this.runAjax({
url : url,
data: data,
func: function(data){
let status = data.data.status;

if(status == 1){
ToastAlert.toasting('Lulus', 'Tempahan Diluluskan', 'success');
}else if(status == 2){
ToastAlert.toasting('Tidak Lulus', 'Tempahan Dibatalkan', 'error');
}

DatatableUI.reloadTable('.tempahan-table');
$('#tempahan-modal').modal('hide');
}
});
}
}
45 changes: 45 additions & 0 deletions public/app_js_helper/segment/admin/tempahan/bilik/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
$(document).on('click', '.tempahan-edit', function(){
let id = $(this).closest('tr').attr('data-tempahan-id');
$('#tempahan-id').val(id);
ModalUI.modal({
selector: '#tempahan-modal',
mode: 'show',
color: 'modal-warning',
label: 'Tempahan Bilik',
callback: function(){
let v = Common.emptyRequest();
v.append('id', id);
Ajax.runAjax({
url: 'admin/tempahan/bilik/get-tempahan',
data: v,
func: function(data){
$('#tempah-pada').html(data.data.tempahan.tempahan);
$('#tempah-masa-mula').html(data.data.tempahan.masa_mula);
$('#tempah-masa-tamat').html(data.data.tempahan.masa_tamat);
$('#tempah-nama-bilik').html(data.data.tempahan.bilik);

$('#tempah-tujuan').html(data.data.maklumat.nama);
$('#tempah-urusetia').html(data.data.maklumat.urusetia);
$('#tempah-pengerusi').html(data.data.maklumat.pengerusi);
$('#tempah-agensi-d').html(data.data.maklumat.bil_agensi_d);
$('#tempah-agensi-l').html(data.data.maklumat.bil_agensi_l);
}
});
}
});
});

$(document).on('click', '#tempahan-edit', function(){
let curThis = $(this);
let trigger = '';

let data = Common.emptyRequest();
data.append('status', curThis.attr('data-status'));
data.append('id', $('#tempahan-id').val());

FasilitiController.lulusTempahan({
url: 'admin/tempahan/bilik/lulus',
data: data,
trigger: trigger
});
});
35 changes: 35 additions & 0 deletions public/app_js_helper/segment/admin/tempahan/bilik/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
DatatableUI.init({
selector: '.tempahan-table',
columnList: [
{ data: 'nama' },
{ data: 'maklumat' },
{ data: 'tempoh' },
{ data: 'status' },
{ data: 'action' },
],
url: '/admin/tempahan/bilik/get-list',
columnDef: [
{
// Actions
targets: -1,
title: 'Actions',
orderable: false,
render: function (data, type, full, meta) {
let activate = full.status;

let val = '';
if(activate !== 0){
val = '-';
}else{
val = '<div class="btn-group" role="group" aria-label="Basic example">' +
'<button type="button" class="btn btn-outline-primary tempahan-edit" data-bs-toggle="tooltip" data-bs-placement="top" title="Kelulusan">' + feather.icons['edit-3'].toSvg() +'</button>' +
'</div>';
}


return val;
}
}
],
label: 'List Lokasi'
});
19 changes: 13 additions & 6 deletions public/app_js_helper/segment/pengguna/tempahan/bilik/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@ DatatableUI.init({
title: 'Tindakan',
orderable: false,
render: function (data, type, full, meta) {
let activate = full.flag;
let activateStat = activate == 0 ? 'btn-outline-danger' : 'btn-outline-success' + '';
return (
'<div class="btn-group" role="group" aria-label="Basic example">' +
let status = full.status;

if(status === 0){
return (
'<div class="btn-group" role="group" aria-label="Basic example">' +
'<button type="button" class="btn btn-outline-danger tempahan-bilik-delete" data-bs-toggle="tooltip" data-bs-placement="top" title="Padam">' + feather.icons['trash-2'].toSvg() +'</button>' +
'</div>'
);
'</div>'
);
}else{
return (
'-'
);
}

}
}
],
Expand Down
4 changes: 2 additions & 2 deletions resources/views/segment/admin/bilik/modal/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success" id="bilik-add">Add</button>
<button type="button" class="btn btn-warning" id="bilik-edit">Edit</button>
<button type="button" class="btn btn-success" id="bilik-add">Tambah</button>
<button type="button" class="btn btn-warning" id="bilik-edit">Kemaskini</button>
</div>
</div>
</div>
Expand Down
71 changes: 71 additions & 0 deletions resources/views/segment/admin/tempahan/bilik/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@extends('segment.layouts.main')

@section('CSS')
@include('segment.layouts.custom_view_links.toast.css.index')
@include('segment.layouts.custom_view_links.datatable.css.index')
@include('segment.layouts.custom_view_links.swal.css.index')
@endsection

@section('customCSS')
@endsection

@section('content')
<div class="content-header row">
<div class="content-header-left col-md-9 col-12 mb-2">
<div class="row breadcrumbs-top">
<div class="col-12">
<h2 class="content-header-title float-start mb-0">Tetapan Biasa</h2>
<div class="breadcrumb-wrapper">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Fasiliti</a>
</li>
</ol>
</div>
</div>
</div>
</div>
</div>
<div class="content-body">
<div class="row">
<div class="col-12">
<div class="card">
<table class="tempahan-table table">
<thead>
<tr>
<th>Nama Bilik</th>
<th>Maklumat</th>
<th>Tempoh</th>
<th>Status</th>
<th>Tindakan</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Nama Bilik</th>
<th>Maklumat</th>
<th>Tempoh</th>
<th>Status</th>
<th>Tindakan</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
@include('segment.admin.tempahan.bilik.modal.index')
@endsection

@section('JS')
@include('segment.layouts.custom_view_links.toast.js.index')
@include('segment.layouts.custom_view_links.datatable.js.index')
@include('segment.layouts.custom_view_links.modals.js.index')
@include('segment.layouts.custom_view_links.swal.js.index')
@endsection

@section('customJS')
@include('segment.layouts.custom_view_links.customjavascript.index')
<script src="{{ asset('app_js_helper/segment/admin/tempahan/bilik/settings.js') }}"></script>
<script src="{{ asset('app_js_helper/segment/admin/tempahan/bilik/controller.js') }}"></script>
<script src="{{ asset('app_js_helper/segment/admin/tempahan/bilik/main.js') }}"></script>
@endsection
Loading

0 comments on commit cb65d30

Please sign in to comment.