Commit 7bdba129 by hannan

migration and changes on dashboard controller

parent f0636ed1
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddColumnTmYearToTimesheetDtlTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('timesheet_dtl', function (Blueprint $table) {
$table->integer('tm_year')->after('tm_month')->unsigned()->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('timesheet_dtl', function (Blueprint $table) {
$table->dropColumn('tm_year');
});
}
}
...@@ -30,17 +30,17 @@ input[type=number] { ...@@ -30,17 +30,17 @@ input[type=number] {
<hr> <hr>
<form class="ui form" action="{{ url('saveHours' )}}" method="POST"> <form class="ui form" action="{{ url('saveHours' )}}" method="POST">
{{csrf_field()}} {{csrf_field()}}
<input type="hidden" value="{{$userId}}"> <input type="hidden" name="userId" value="{{$userId}}">
<input type="hidden" value="{{$year}}"> <input type="hidden" name="year" value="{{$year}}">
<input type="hidden" value="{{$month}}"> <input type="hidden" name="month" value="{{$month}}">
<input type="hidden" value="{{$phase}}"> <input type="hidden" name="phase" value="{{$phase}}">
<table class="ui celled structured table"> <table class="ui celled structured table">
<thead> <thead>
<tr> <tr>
<th colspan="2">Chargeable</th> <th colspan="2">Chargeable</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th> <th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th> <th>
<button type="submit" class="center aligned ui blue compact labeled icon button"> <button type="submit" class="fluid center aligned ui blue compact labeled icon button">
<i class="save icon"></i> <i class="save icon"></i>
Save Save
</button> </button>
...@@ -103,18 +103,19 @@ input[type=number] { ...@@ -103,18 +103,19 @@ input[type=number] {
@endforeach @endforeach
</tbody> </tbody>
</table> </table>
</form>
<br>
@if($phase == 1) @if($phase == 1)
<button class="center aligned ui green compact right labeled icon button" onclick="phase2($phase);" id="phase2"> <button class="center aligned ui green compact right labeled icon button" onclick="phase2($phase);" id="phase2">
<i class="angle double right icon"></i> <i class="angle double right icon"></i>
Phase 2 Phase 2
</button> </button>
@else @else
<button class="center aligned ui green compact labeled icon button"> <button class="center aligned ui green compact labeled icon button" onclick="phase1($phase);" id="phase1">
<i class="angle double left icon"></i> <i class="angle double left icon"></i>
Phase 1 Phase 1
</button> </button>
@endif @endif
</form>
</div> </div>
@endsection @endsection
...@@ -126,9 +127,16 @@ input[type=number] { ...@@ -126,9 +127,16 @@ input[type=number] {
function phase2(p) function phase2(p)
{ {
phase = p; phase = p;
phase++; phase = phase+1;
document.getElementById('phase2') = phase; document.getElementById('phase2') = phase;
} }
function phase1(p)
{
phase = p;
phase = phase-1;
document.getElementById('phase1') = phase;
}
</script> </script>
<script> <script>
......
...@@ -16,6 +16,10 @@ Route::group( ...@@ -16,6 +16,10 @@ Route::group(
Route::get('kalendarCharge',['uses' => 'DashboardController@kalendarCharge', 'as' => 'dashboard.kalendarCharge']); Route::get('kalendarCharge',['uses' => 'DashboardController@kalendarCharge', 'as' => 'dashboard.kalendarCharge']);
Route::get('kalendarNonCharge',['uses' => 'DashboardController@kalendarNonCharge', 'as' => 'dashboard.kalendarNonCharge']); Route::get('kalendarNonCharge',['uses' => 'DashboardController@kalendarNonCharge', 'as' => 'dashboard.kalendarNonCharge']);
Route::get('kalendar',['uses' => 'DashboardController@kalendar', 'as' => 'dashboard.kalendar']); Route::get('kalendar',['uses' => 'DashboardController@kalendar', 'as' => 'dashboard.kalendar']);
Route::get('timesheet_approval',['uses' => 'DashboardController@timesheetApproval', 'as' => 'dashboard.timesheetApproval']);
Route::get('timesheet_report',['uses' => 'DashboardController@timesheetReport', 'as' => 'dashboard.timesheetReport']);
Route::get('timesheet_review',['uses' => 'DashboardController@timesheetReview', 'as' => 'dashboard.timesheetReview']);
Route::get('timesheet_viewer',['uses' => 'DashboardController@timesheetViewer', 'as' => 'dashboard.timesheetViewer']);
// Route::get('phase1/{phase}',['uses' => 'DashboardController@phase1', 'as' => 'dashboard.phase1']); // Route::get('phase1/{phase}',['uses' => 'DashboardController@phase1', 'as' => 'dashboard.phase1']);
// Route::get('phase2/{phase}',['uses' => 'DashboardController@phase2', 'as' => 'dashboard.phase2']); // Route::get('phase2/{phase}',['uses' => 'DashboardController@phase2', 'as' => 'dashboard.phase2']);
Route::post('saveHours',['uses' => 'DashboardController@saveHours', 'as' => 'dashboard.saveHours']); Route::post('saveHours',['uses' => 'DashboardController@saveHours', 'as' => 'dashboard.saveHours']);
......
...@@ -7,6 +7,7 @@ use Carbon\Carbon; ...@@ -7,6 +7,7 @@ use Carbon\Carbon;
use DB; use DB;
use Portal\Timesheet\Model\Users; use Portal\Timesheet\Model\Users;
use Portal\Timesheet\Model\Ts_master; use Portal\Timesheet\Model\Ts_master;
use Portal\Timesheet\Model\Ts_detail;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input; use Illuminate\Support\Facades\Input;
use File; use File;
...@@ -24,7 +25,6 @@ class DashboardController extends Controller ...@@ -24,7 +25,6 @@ class DashboardController extends Controller
public function index() public function index()
{ {
$items = array(); $items = array();
$events = array(); $events = array();
$keyword = request('search'); $keyword = request('search');
...@@ -146,7 +146,7 @@ class DashboardController extends Controller ...@@ -146,7 +146,7 @@ class DashboardController extends Controller
//sample dulu //sample dulu
$phase = 2; $phase = 1;
$month = date('n'); $month = date('n');
$year = date('Y'); $year = date('Y');
$day = date('j'); $day = date('j');
...@@ -172,17 +172,21 @@ class DashboardController extends Controller ...@@ -172,17 +172,21 @@ class DashboardController extends Controller
//check dlam db, kalau dah ada detail hours, kuar form edit, kalau belum, kuar form create //check dlam db, kalau dah ada detail hours, kuar form edit, kalau belum, kuar form create
$user = users::where('id', Auth::id())->first(); $user = users::where('id', Auth::id())->first();
$check = Ts_master::where('tm_staff_id', $user->u_staffID) // dd($user);
// check timesheet detail
$checkTimesheetDetail = Ts_detail::where('tm_staff_id', $user->u_staffID)
->where('tm_year', $year) ->where('tm_year', $year)
->where('tm_month', $month) ->where('tm_month', $month)
->where('tm_phase', $phase) ->where('tm_phase', $phase)
->whereNotNull('tm_chargeable_hrs') ->whereNotNull('td_hours')
->first(); ->first();
//kalau ada, dia gi ke edit // kalau ada, dia gi ke edit
if($check) if($checkTimesheetDetail)
{ {
$data = Ts_master::where('id',$request->id)->first(); $data = Ts_detail::where('id',$request->id)->first();
} }
//klu xde g create.php //klu xde g create.php
else else
...@@ -190,6 +194,28 @@ class DashboardController extends Controller ...@@ -190,6 +194,28 @@ class DashboardController extends Controller
$data = []; $data = [];
} }
// dd($checkTimesheetDetail);
//check timesheet master
// $check = Ts_master::where('tm_staff_id', $user->u_staffID)
// ->where('tm_year', $year)
// ->where('tm_month', $month)
// ->where('tm_phase', $phase)
// ->whereNotNull('tm_chargeable_hrs')
// ->first();
// //kalau ada, dia gi ke edit
// if($check)
// {
// $data = Ts_master::where('id',$request->id)->first();
// }
// //klu xde g create.php
// else
// {
// $data = [];
// }
//kalau ada juga = bawak data details //kalau ada juga = bawak data details
return view('timesheet::dashboard.borangBolehCaj', compact('userId','projectcode', 'projectname','month','phase','samplequery','daymonth','year','sampleTimesheet_dtl','day','data')); return view('timesheet::dashboard.borangBolehCaj', compact('userId','projectcode', 'projectname','month','phase','samplequery','daymonth','year','sampleTimesheet_dtl','day','data'));
...@@ -212,36 +238,77 @@ class DashboardController extends Controller ...@@ -212,36 +238,77 @@ class DashboardController extends Controller
public function saveHours(Request $request) public function saveHours(Request $request)
{ {
dd($request);
//check dlam db, kalau dah ada detail hours, kuar form edit, kalau belum, kuar form create //filter function save atau update akan buat kat blade.
//Form Baru
//Form Edit after rejected
//Form Baru
//check dalam db table ts-detail. Kalau dah ada details dalam td_hours -> update().
//Kalau belum -> save()
$user = users::where('id', Auth::id())->first(); $user = users::where('id', Auth::id())->first();
$check = Ts_master::where('tm_staff_id', $user->u_staffID)
->where('tm_year', $year) //me - check dalam db, table ts_detail, kalau dah ada detail hours, edit.
->where('tm_month', $month) $checkTimesheetDetail = Ts_detail::where('tm_staff_id', $user->u_staffID)
->where('tm_phase', $phase) ->where('tm_year', $request->year)
->whereNotNull('tm_chargeable_hrs') ->where('tm_month', $request->month)
->where('tm_phase', $request->phase)
->whereNotNull('td_hours')
->first(); ->first();
//kalau ada, dia gi ke edit
if(check) //update total chargeable hrs
if($checkTimesheetDetail)
{ {
$data = Ts_master::where('id',$request->id)->first(); $data = Ts_detail::where('id',$request->id)->first();
$data -> tm_chargeable_hrs = 10; $data ->td_hours = 10;
$data -> update(); $data ->update();
} }
//klu xde g create.php //kalau takda, save().
else else
{ {
$data = Ts_master::where('id',$request->id)->first(); dd($checkTimesheetDetail);
$data -> tm_month = $request -> month; $data = new Ts_detail;
$data -> tm_year = $request -> year; $data ->id = $request ->id;
$data -> tm_phase = $request -> phase; $data ->tm_year = $request ->year;
$data -> tm_chargeable_hrs = 8; $data ->tm_month = $request ->month;
$data -> save(); $data ->tm_phase = $request ->phase;
$data ->td_hours = 8;
$data ->save();
} }
// check table master. untuk total chargeable hours.
// $check = Ts_master::where('tm_staff_id', $user->u_staffID)
// ->where('tm_year', $request->year)
// ->where('tm_month', $request->month)
// ->where('tm_phase', $request->phase)
// ->whereNotNull('tm_chargeable_hrs')
// ->first();
// //kalau ada, update().
// //staff kena edit bila submission timesheet kena reject.
// if($check)
// {
// $data = Ts_master::where('id',$request->id)->first();
// //update total chargeable hrs
// $data -> tm_chargeable_hrs = 10;
// $data -> update();
// }
// //kalau takda, save().
// else
// {
// $data = new Ts_master;
// $data ->id = $request ->id;
// $data ->tm_year = $request ->year;
// $data ->tm_month = $request ->month;
// $data ->tm_phase = $request ->phase;
// $data ->tm_chargeable_hrs = 8;
// $data ->save();
// }
//kalau ada juga = bawak data details //kalau ada juga = bawak data details
// tm_master = Ts_master::where('tm_staff_id','=',Auth::id()) // tm_master = Ts_master::where('tm_staff_id','=',Auth::id())
...@@ -264,15 +331,25 @@ class DashboardController extends Controller ...@@ -264,15 +331,25 @@ class DashboardController extends Controller
// return redirect('home'); // return redirect('home');
} }
// public function phase1($phase) public function timesheetApproval()
// { {
// $phase = $phase + 1; return view('timesheet::dashboard.timesheetApproval');
// return view('timesheet::dashboard.borangBolehCaj', compact('phase')); }
// }
// public function phase2($phase) public function timesheetReport()
// { {
// $phase = $phase - 1; return view('timesheet::dashboard.timesheetReport');
// return view('timesheet::dashboard.borangBolehCaj', compact('phase')); }
// }
public function timesheetReview()
{
return view('timesheet::dashboard.timesheetReview');
}
public function timesheetViewer()
{
return view('timesheet::dashboard.timesheetViewer');
}
} }
...@@ -54,16 +54,26 @@ class ServiceProvider extends BaseServiceProvider ...@@ -54,16 +54,26 @@ class ServiceProvider extends BaseServiceProvider
$dashboard->add(__('Halaman Utama'), url('/home/')) $dashboard->add(__('Halaman Utama'), url('/home/'))
->data('icon', 'tachometer alternate icon') ->data('icon', 'tachometer alternate icon')
->active('home/*'); ->active('home/*');
$dashboard->add(__('Timesheet Calendar')) $dashboard->add(__('Timesheet Calendar'), route('timesheet::dashboard.kalendar'))
->data('icon', 'calendar alternate outline'); ->data('icon', 'calendar alternate outline')
$dashboard->add(__('Timesheet Viewer')) ->active('kalendar/*')
->data('icon', 'eye icon'); ->data('permission', Permission::kehadiran);
$dashboard->add(__('Timesheet Review')) $dashboard->add(__('Timesheet Viewer'), route('timesheet::dashboard.timesheetViewer'))
->data('icon', 'file alternate icon'); ->data('icon', 'eye icon')
$dashboard->add(__('Timesheet Approval')) ->active('timesheetViewer/*')
->data('icon', 'check square icon'); ->data('permission', Permission::kehadiran);
$dashboard->add(__('Timesheet Report')) $dashboard->add(__('Timesheet Review'), route('timesheet::dashboard.timesheetReview'))
->data('icon', 'file alternate icon'); ->data('icon', 'file alternate icon')
->active('timesheetReview/*')
->data('permission', Permission::kehadiran);
$dashboard->add(__('Timesheet Approval'), route('timesheet::dashboard.timesheetApproval'))
->data('icon', 'check square icon')
->active('timesheetApproval/*')
->data('permission', Permission::kehadiran);
$dashboard->add(__('Timesheet Report'), route('timesheet::dashboard.timesheetReport'))
->data('icon', 'file alternate icon')
->active('timesheetReport/*')
->data('permission', Permission::kehadiran);
$menu = $this->app['laravolt.menu']->add(__('Pengurusan'))->data('icon', 'align justify'); $menu = $this->app['laravolt.menu']->add(__('Pengurusan'))->data('icon', 'align justify');
$menu->add(__('Pengurusan Peranan'), route('timesheet::dashboard.pengurusan')) $menu->add(__('Pengurusan Peranan'), route('timesheet::dashboard.pengurusan'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment