Commit 1b125b1e by hannan

filter pm selection, changes in overhead description modal, validation and check null error

parent 8f784e21
@foreach($staffs as $key => $staff)
<div class="item" data-value="{{$staff->id}}" data-text="{{$staff->fullname}}">
{{$staff->fullname}}
</div>
@endforeach
\ No newline at end of file
@if($staffs)
@foreach($staffs as $key => $staff)
<div class="item" data-value="{{$staff->id}}" data-text="{{$staff->fullname}}">
{{$staff->fullname}}
</div>
@endforeach
@else
@endif
\ No newline at end of file
......@@ -45,7 +45,7 @@ input[type=number] {
<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">
<table class="ui celled structured table unstackable">
<thead>
<tr>
<th colspan="2">Chargeable</th>
......
......@@ -16,7 +16,7 @@
<div class="field">
<label>Role</label>
<select name="role" class="ui fluid dropdown">
<option value="">Role</option>
<option value="{{$team->role_id}}">{{$teamRole->role}}</option>
@foreach($role as $key => $value)
<option value="{{$value->id}} ">{{$value->role}}</option>
@endforeach
......
......@@ -29,9 +29,9 @@ input[type=number] {
<input type="hidden" name="chargeableProject">
<i class="dropdown icon"></i>
<div class="default text">Task</div>
<div class="menu">
<div class="menu">
@foreach($nonchargeables as $key => $nonchargeable)
<div class="item" data-value="{{ $nonchargeable->id }}">{{$nonchargeable->p_project_description}}</div>
<div class="item" data-value="{{ $nonchargeable->id }}">{{ data_get($nonchargeable, 'p_project_description')}}</div>
@endforeach
</div>
</div>
......@@ -98,7 +98,7 @@ input[type=number] {
<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">
<table class="ui celled structured table unstackable">
<thead>
<tr>
<th class="single line">Non-Chargeable</th>
......
......@@ -45,7 +45,8 @@ input[type=number] {
<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">
<table class="ui celled structured unstackable table" >
<thead>
<tr>
<th>Overhead</th>
......@@ -101,7 +102,7 @@ input[type=number] {
}
?>
<td >
<input type="text" onkeypress="onlynumber(event)" id="hour[{{$project['td_project']}}][{{$i+1}}]" name="hour[{{$project['td_project']}}][{{$i+1}}]" value="@if($valuehour){{$valuehour->td_hours}}@else @endif" min="0" max="24" style="padding:2px;margin:unset" onchange="limiter(this,'{{$project['td_project']}}');">
<input type="text" onkeypress="onlynumber(event)" id="hour[{{$project['td_project']}}][{{$i+1}}]" name="hour[{{$project['td_project']}}][{{$i+1}}]" value="@if($valuehour){{$valuehour->td_hours}}@else @endif" min="0" max="24" size="2" style="padding:2px;margin:unset" onchange="limiter(this,'{{$project['td_project']}}');">
</td>
@endfor
@else
......@@ -122,7 +123,6 @@ input[type=number] {
$total += data_get($valuehour,'td_hours');
}
?>
<td >
<input type="text" onkeypress="onlynumber(event)" id="hour[{{$project['td_project']}}][{{$i+1}}]" name="hour[{{$project['td_project']}}][{{$i+1}}]" value="@if($valuehour){{$valuehour->td_hours}}@else @endif" min="0" max="24" style="padding:2px;margin:unset" onchange="limiter(this,'{{$project['td_project']}}');">
......@@ -130,9 +130,7 @@ input[type=number] {
@endfor
@endif
<td>
<button class="ui center blue button">
<i class="ui center edit white icon"></i>
</button>
<input type="text" name="desc" value="icon">
</td>
<td>
<input type="text" onkeypress="onlynumber(event)" name="total-{{$project['td_project']}}" id="total-{{$project['td_project']}}" style="padding-right: 4px;padding-left: 4px;" onchange="limiter(this,'{{$project['td_project']}}');" readonly="" value={{$total}}>
......@@ -153,7 +151,8 @@ input[type=number] {
<i class="angle double left icon"></i>
Phase 1
</button>
@endif
@endif
</div>
@endsection
......
......@@ -18,19 +18,21 @@
<label>Project Manager</label>
<select name="projectmanager" class="ui fluid dropdown">
<option value="">Project Manager</option>
<option value="842">Rashdan</option>
<option value="920">Maimunah</option>
@foreach($pm as $key => $value)
<option value="{{$value->staff_id}}">{{$value->fullname}}</option>
@endforeach
</select>
</div>
<div class="field">
<label>Project Status</label>
<select name="status" class="ui fluid dropdown">
<option value="">Project Status</option>
<!-- <option value="">Project Status</option> -->
<option value="1">Active</option>
<option value="0">Inactive</option>
</select>
</div>
<button class="ui button" type="submit">Submit</button>
<button class="ui blue button" type="submit">Submit</button>
<button class="ui green button" type="button" onclick="window.location.href='{{ route('timesheet::dashboard.senaraiProject') }} ';">Back</button>
</form>
</div>
......
......@@ -49,7 +49,7 @@
<div class="field">
<label>Project Status</label>
<select name="status" class="ui fluid dropdown">
<option value="">Project Team Status</option>
<!-- <option value="">Project Team Status</option> -->
<option value="1">Active</option>
<option value="0">Inactive</option>
</select>
......
......@@ -22,10 +22,10 @@
@foreach($projectlist as $key => $project)
<tr>
<td>{{$key+1}} </td>
<td>{{$project['projectcode']}} </td>
<td>{{$project['projectname']}} </td>
<td>{{$project['projectmanager']}} </td>
<td>{{$project['status']}} </td>
<td>{{ data_get($project,'projectcode') }} </td>
<td>{{ data_get($project,'projectname') }} </td>
<td>{{ data_get($project,'projectmanager') }} </td>
<td>{{ data_get($project,'status') }} </td>
<td><a href="{{ route('timesheet::dashboard.senaraiProjectTeam', ['id' => $project['id']]) }}">Project Team</a></td>
</tr>
@endforeach
......
......@@ -9,8 +9,10 @@ Route::group(
],
function () {
//dashboard
Route::get('home',['uses' => 'DashboardController@index', 'as' => 'dashboard.index']);
//maintenance
Route::get('senaraiProject',['uses' => 'DashboardController@senaraiProject', 'as' => 'dashboard.senaraiProject']);
Route::get('penambahanProject',['uses' => 'DashboardController@penambahanProject', 'as' => 'dashboard.penambahanProject']);
Route::get('senaraiProjectTeam',['uses' => 'DashboardController@senaraiProjectTeam', 'as' => 'dashboard.senaraiProjectTeam']);
......@@ -29,14 +31,14 @@ Route::group(
Route::post('updaterole',['uses' => 'DashboardController@updaterole', 'as' => 'dashboard.updaterole']);
// nonChargeableForm
Route::post('addnonchargeabletask',['uses' => 'DashboardController@addnonchargeabletask', 'as' => 'dashboard.addnonchargeabletask']);
Route::post('addnonchargeabletask',['uses' => 'DashboardController@addnonchargeabletask', 'as' => 'dashboard.addnonchargeabletask']);
// route to form
Route::get('chargeableForm',['uses' => 'DashboardController@chargeableForm', 'as' => 'dashboard.chargeableForm']);
Route::get('nonChargeableForm',['uses' => 'DashboardController@nonChargeableForm', 'as' => 'dashboard.nonChargeableForm']);
Route::get('overheadForm',['uses' => 'DashboardController@overheadForm', 'as' => 'dashboard.overheadForm']);
//calendar
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']);
......
......@@ -78,68 +78,123 @@ class DashboardController extends Controller
public function senaraiProject()
{
$project = Project::all();
$chargeable = 1;
$project = Project::where('p_project_type', $chargeable)
->get();
$projectlist = [];
// nanti project code query dari table project:
if(count($project) > 0)
{
foreach ($project as $key => $value) {
if(count($project) > 0) {
foreach ($project as $key => $value){
$pm = Pteam::where('fk_project_id', $value->id)
->where('role_id', 1)
->where('pt_project_task_sts', 1)
->first();
// dd($pm->pt_team);
$projectlist[] = [
'id' => $value->id,
'projectcode' => $value->p_project_code,
'projectname' => $value->p_project_description,
'projectmanager' => $value->projectManager->fullname,
'projectmanager' => $pm->pt_team,
'status' => $value->p_project_sts,
];
}
}
else
}
else
{
$projectlist = null;
$projectlist = [];
}
// dd($projectlist);
return view('timesheet::dashboard.senaraiProject',compact('projectlist'));
}
public function penambahanProject()
{
return view('timesheet::dashboard.penambahanProject');
$pms = 4;
$pm = DB::table('staff_info')
// ->where('fk_lkp_department', $pms)
->where('flag_pm', 1)
->where('status', 1)
// ->join('users', 'u_staffID', '=', 'staff_id')
->get();
// dd($pm);
return view('timesheet::dashboard.penambahanProject', compact('pm'));
}
public function addnewproject(Request $request)
{
$chargeable = 1;
$nonchargeable = 2;
$userId = users::find(Auth::id())
->u_staffID;
$project = new Project;
$project->p_project_code = $request->projectcode;
$project->p_project_description = $request->projectname;
$project->p_project_type = $chargeable;
$project->p_project_task_team = $request->projectmanager;
$project->p_project_sts = $request->status;
$project->updated_by = $userId;
$project->save();
if ($request->projectcode == null || $request->projectname == null || $request->projectmanager == null) {
return redirect()->route('timesheet::dashboard.penambahanProject')
return redirect()->route('timesheet::dashboard.penambahanProject')
->withErrors('The information is not complete. Please re-enter!');
} else {
// dd($request);
$project = new Project;
$project->p_project_code = $request->projectcode;
$project->p_project_description = $request->projectname;
$project->p_project_type = $chargeable;
$project->p_project_task_team = $request->projectmanager;
$project->p_project_sts = $request->status;
$project->updated_by = $userId;
$project->save();
$noncharge = new Project;
$noncharge->p_project_description = $request->projectname;
$noncharge->p_project_type = $nonchargeable;
$noncharge->p_project_sts = $request->status;
$noncharge->updated_by = $userId;
$noncharge->save();
$projectId = Project::select('id')
->where('p_project_code', $request->projectcode)
->value('id');
$sname = Staff_info::select('fullname')
->where('staff_id', $request->projectmanager)
->value('fullname');
// dd($projectId);
$team = new Pteam;
$team->role_id = 1;
$team->pt_project_description = $request->projectname;
$team->fk_project_id = $projectId;
$team->pt_staff_id = $request->projectmanager;
$team->pt_team = $sname;
$team->pt_project_type = $chargeable;
$team->pt_project_task_sts = 1;
$team->updated_by = $userId;
$team->save();
}
return redirect()->route('timesheet::dashboard.senaraiProject')
->with('success', 'New Project Added');
}
public function senaraiProjectTeam(Request $request)
{
$chargeable = 1;
$pid = $request->id;
$project = Pteam::where('fk_project_id',$request->id)
->where('pt_project_type', $chargeable)
// ->where('pt_project_task_sts', 1)
->orderBy('pt_project_task_sts', 'DESC')
->orderBy('role_id')
->get();
$projectlist = [];
......@@ -172,12 +227,12 @@ class DashboardController extends Controller
->first(); //find($request->id);
$departments = Department::all()
->except([7,8]);
->except([7]);
// ->except($departments->code,['']);
foreach ($departments as $key => $value)
{
$staffs = Staff_info::where('fk_lkp_department', $value->id)
$staffs = Staff_info::where('fk_lkp_department', $value->id)
->get();
// dd($value->id);
}
......@@ -198,27 +253,35 @@ class DashboardController extends Controller
$expstaff = explode(',', $request->staffId);
foreach ($expstaff as $key => $value)
{
$staff = Staff_info::where('fk_users', $value)
->first();
// dd($request);
$pt = new Pteam;
$pt->fk_project_id = $request->pid;
$pt->pt_project_description = $request->pname;
$pt->pt_team = $staff->fullname;
$pt->pt_staff_id = $staff->staff_id;
// $pt->pt_staff_id = $value;
$pt->pt_project_task_sts = $request->status;
$pt->role_id = $request->role;
$pt->updated_by = $userId;
$pt->pt_project_type = $chargeable;
$pt->save();
if ($request->staffId == null || $request->role == null) {
dd($request);
return redirect()->route('timesheet::dashboard.penambahanProjectTeam', ['pcode'=>$request->pcode, 'pname'=>$request->pname, $request->id]);
} else {
foreach ($expstaff as $key => $value)
{
$staff = Staff_info::where('fk_users', $value)
->first();
// dd($request);
$pt = new Pteam;
$pt->fk_project_id = $request->pid;
$pt->pt_project_description = $request->pname;
$pt->pt_team = $staff->fullname;
$pt->pt_staff_id = $staff->staff_id;
// $pt->pt_staff_id = $value;
$pt->pt_project_task_sts = $request->status;
$pt->role_id = $request->role;
$pt->updated_by = $userId;
$pt->pt_project_type = $chargeable;
$pt->save();
}
}
return redirect()->route('timesheet::dashboard.senaraiProject')
->with('success', 'Project Team Added Successfully');
}
......@@ -228,11 +291,15 @@ class DashboardController extends Controller
$team = Pteam::where('id', $request->id)
->first();
$teamRole = Role::where('id', $team->role_id)
->first();
// dd($team);
$role = Role::all();
// dd($role);
$pid = $team->fk_project_id;
return view('timesheet::dashboard.editprojectteam', compact('team', 'pid', 'role'));
return view('timesheet::dashboard.editprojectteam', compact('team', 'pid', 'role', 'teamRole'));
}
public function updateprojectteam(Request $request)
......@@ -419,19 +486,22 @@ class DashboardController extends Controller
{
$hour = null;
}
return view('timesheet::dashboard.chargeableForm', compact('projectlist','userId','month','phase','daymonth','year','day','hour'));
}
public function nonChargeableForm(Request $request)
{
$nonchargeable = 2;
$userId = users::find(Auth::id())
->u_staffID;
$nonchargeables = Project::all();
$nonchargeables = Project::where('p_project_type', $nonchargeable)
->get();
$project = Pteam::where('pt_staff_id',$userId)
->where('pt_project_type', 2)
->where('pt_project_type', $nonchargeable)
->get();
$projectlist = [];
......@@ -738,7 +808,7 @@ class DashboardController extends Controller
$date = $request->year.'-'.$request->month.'-'.sprintf('%02d', $keyday);
$checkTimesheetDetail = Ts_detail::where('td_project', $projectid)
->where('td_project_type', $nonchargeable)
->where('td_project_type', $chargeable)
->where('td_date', $date)
->where('tm_phase', $request->phase)
->first();
......
......@@ -18,6 +18,11 @@ class Project extends Model
return $this->hasOne('Portal\Timesheet\Model\Staff_info','staff_id','p_project_task_team');
}
public function projectTeam()
{
return $this->hasOne('Portal\Timesheet\Model\Pteam','fk_project_id','id');
}
/**
* undocumented function
*
......
......@@ -18,6 +18,11 @@ class Staff_info extends Model
return $this->hasMany('Portal\Timesheet\Model\Department','id','fk_lkp_department');
}
public function toUser()
{
return $this->hasOne('Portal\Timesheet\Model\Users', 'u_staffID', 'staff_id');
}
// public function project_code()
// {
// return $this->hasMany('Portal\Timesheet\Model\Ts_detail','td_project','id');
......
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