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] {
<hr>
<form class="ui form" action="{{ url('saveHours' )}}" method="POST">
{{csrf_field()}}
<input type="hidden" value="{{$userId}}">
<input type="hidden" value="{{$year}}">
<input type="hidden" value="{{$month}}">
<input type="hidden" value="{{$phase}}">
<input type="hidden" name="userId" value="{{$userId}}">
<input type="hidden" name="year" value="{{$year}}">
<input type="hidden" name="month" value="{{$month}}">
<input type="hidden" name="phase" value="{{$phase}}">
<table class="ui celled structured table">
<thead>
<tr>
<th colspan="2">Chargeable</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</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>
Save
</button>
......@@ -103,18 +103,19 @@ input[type=number] {
@endforeach
</tbody>
</table>
</form>
<br>
@if($phase == 1)
<button class="center aligned ui green compact right labeled icon button" onclick="phase2($phase);" id="phase2">
<i class="angle double right icon"></i>
Phase 2
</button>
@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>
Phase 1
</button>
@endif
</form>
</div>
@endsection
......@@ -126,9 +127,16 @@ input[type=number] {
function phase2(p)
{
phase = p;
phase++;
phase = phase+1;
document.getElementById('phase2') = phase;
}
function phase1(p)
{
phase = p;
phase = phase-1;
document.getElementById('phase1') = phase;
}
</script>
<script>
......
......@@ -16,6 +16,10 @@ Route::group(
Route::get('kalendarCharge',['uses' => 'DashboardController@kalendarCharge', 'as' => 'dashboard.kalendarCharge']);
Route::get('kalendarNonCharge',['uses' => 'DashboardController@kalendarNonCharge', 'as' => 'dashboard.kalendarNonCharge']);
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('phase2/{phase}',['uses' => 'DashboardController@phase2', 'as' => 'dashboard.phase2']);
Route::post('saveHours',['uses' => 'DashboardController@saveHours', 'as' => 'dashboard.saveHours']);
......
......@@ -7,6 +7,7 @@ use Carbon\Carbon;
use DB;
use Portal\Timesheet\Model\Users;
use Portal\Timesheet\Model\Ts_master;
use Portal\Timesheet\Model\Ts_detail;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use File;
......@@ -24,7 +25,6 @@ class DashboardController extends Controller
public function index()
{
$items = array();
$events = array();
$keyword = request('search');
......@@ -146,7 +146,7 @@ class DashboardController extends Controller
//sample dulu
$phase = 2;
$phase = 1;
$month = date('n');
$year = date('Y');
$day = date('j');
......@@ -172,17 +172,21 @@ class DashboardController extends Controller
//check dlam db, kalau dah ada detail hours, kuar form edit, kalau belum, kuar form create
$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_month', $month)
->where('tm_phase', $phase)
->whereNotNull('tm_chargeable_hrs')
->whereNotNull('td_hours')
->first();
//kalau ada, dia gi ke edit
if($check)
// kalau ada, dia gi ke edit
if($checkTimesheetDetail)
{
$data = Ts_master::where('id',$request->id)->first();
$data = Ts_detail::where('id',$request->id)->first();
}
//klu xde g create.php
else
......@@ -190,6 +194,28 @@ class DashboardController extends Controller
$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
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
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();
$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')
//me - check dalam db, table ts_detail, kalau dah ada detail hours, edit.
$checkTimesheetDetail = Ts_detail::where('tm_staff_id', $user->u_staffID)
->where('tm_year', $request->year)
->where('tm_month', $request->month)
->where('tm_phase', $request->phase)
->whereNotNull('td_hours')
->first();
//kalau ada, dia gi ke edit
if(check)
//update total chargeable hrs
if($checkTimesheetDetail)
{
$data = Ts_master::where('id',$request->id)->first();
$data -> tm_chargeable_hrs = 10;
$data -> update();
$data = Ts_detail::where('id',$request->id)->first();
$data ->td_hours = 10;
$data ->update();
}
//klu xde g create.php
//kalau takda, save().
else
{
$data = Ts_master::where('id',$request->id)->first();
$data -> tm_month = $request -> month;
$data -> tm_year = $request -> year;
$data -> tm_phase = $request -> phase;
$data -> tm_chargeable_hrs = 8;
$data -> save();
dd($checkTimesheetDetail);
$data = new Ts_detail;
$data ->id = $request ->id;
$data ->tm_year = $request ->year;
$data ->tm_month = $request ->month;
$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
// tm_master = Ts_master::where('tm_staff_id','=',Auth::id())
......@@ -264,15 +331,25 @@ class DashboardController extends Controller
// return redirect('home');
}
// public function phase1($phase)
// {
// $phase = $phase + 1;
// return view('timesheet::dashboard.borangBolehCaj', compact('phase'));
// }
public function timesheetApproval()
{
return view('timesheet::dashboard.timesheetApproval');
}
// public function phase2($phase)
// {
// $phase = $phase - 1;
// return view('timesheet::dashboard.borangBolehCaj', compact('phase'));
// }
public function timesheetReport()
{
return view('timesheet::dashboard.timesheetReport');
}
public function timesheetReview()
{
return view('timesheet::dashboard.timesheetReview');
}
public function timesheetViewer()
{
return view('timesheet::dashboard.timesheetViewer');
}
}
......@@ -54,16 +54,26 @@ class ServiceProvider extends BaseServiceProvider
$dashboard->add(__('Halaman Utama'), url('/home/'))
->data('icon', 'tachometer alternate icon')
->active('home/*');
$dashboard->add(__('Timesheet Calendar'))
->data('icon', 'calendar alternate outline');
$dashboard->add(__('Timesheet Viewer'))
->data('icon', 'eye icon');
$dashboard->add(__('Timesheet Review'))
->data('icon', 'file alternate icon');
$dashboard->add(__('Timesheet Approval'))
->data('icon', 'check square icon');
$dashboard->add(__('Timesheet Report'))
->data('icon', 'file alternate icon');
$dashboard->add(__('Timesheet Calendar'), route('timesheet::dashboard.kalendar'))
->data('icon', 'calendar alternate outline')
->active('kalendar/*')
->data('permission', Permission::kehadiran);
$dashboard->add(__('Timesheet Viewer'), route('timesheet::dashboard.timesheetViewer'))
->data('icon', 'eye icon')
->active('timesheetViewer/*')
->data('permission', Permission::kehadiran);
$dashboard->add(__('Timesheet Review'), route('timesheet::dashboard.timesheetReview'))
->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->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