Commit 1a368f11 by Azhan Hannan

Edit team, boleh edit nama juga. Maksudnya, boleh select semula department dn nama staf

parent 6b2c86d2
...@@ -592,10 +592,10 @@ ...@@ -592,10 +592,10 @@
<br> <br>
@if($curruser->id == $user->penyokong) @if($curruser->id == $user->penyokong)
<button type="button" class="ui green button" onclick="window.location.href='{{ route('timesheet::dashboard.timesheetReview',[ 'phase' => $phase, 'month' => $month ]) }}';">Back</button> <!-- <button type="button" class="ui green button" onclick="window.location.href='{{ route('timesheet::dashboard.timesheetReview',[ 'phase' => $phase, 'month' => $month ]) }}';">Back</button> -->
@elseif($curruser->id == $user->pelulus) @elseif($curruser->id == $user->pelulus)
<button type="button" class="ui green button" onclick="window.location.href='{{ route('timesheet::dashboard.timesheetApproval',[ 'phase' => $phase, 'month' => $month ]) }}';">Back</button> <!-- <button type="button" class="ui green button" onclick="window.location.href='{{ route('timesheet::dashboard.timesheetApproval',[ 'phase' => $phase, 'month' => $month ]) }}';">Back</button> -->
@else @else
@if($check != null) @if($check != null)
......
...@@ -10,9 +10,39 @@ ...@@ -10,9 +10,39 @@
<input type="hidden" name="id" value="{{data_get($team,'id')}} "> <input type="hidden" name="id" value="{{data_get($team,'id')}} ">
<input type="hidden" name="pid" value="{{data_get($team,'fk_project_id')}} "> <input type="hidden" name="pid" value="{{data_get($team,'fk_project_id')}} ">
<div class="field">
<!-- <div class="field">
<label for="projectteam">Project Team</label> <label for="projectteam">Project Team</label>
<input type="text" name="projectteam" value="{{data_get($team,'pt_team')}}" readonly="readonly"> <input type="text" name="projectteam" value="{{data_get($team,'pt_team')}}" readonly="readonly">
</div> -->
<div class="field">
<label>Department</label>
<select onchange="selectDepartment(value);" name="department" id="department" class="ui fluid dropdown">
<option value="{{data_get($team,'staffdetail.deptname.id')}}">{{data_get($team,'staffdetail.deptname.description')}}</option>
@foreach($departments as $key => $department)
<option value="{{data_get($department,'id')}}">{{data_get($department,'code')}} | {{data_get($department,'description')}} </option>
@endforeach
</select>
</div>
<div class="field">
<label>Staff Name</label>
<div class="ui selection dropdown">
<input type="hidden" name="staffId" value="{{data_get($team,'staffdetail.id')}}">
<i class="dropdown icon"></i>
<div class="default text">{{data_get($team,'staffdetail.fullname')}}</div>
<div class="menu" id="divstaff" name="divstaff">
<div class="item" data-value="{{data_get($team,'staffdetail.id')}}" data-text="{{data_get($team,'staffdetail.fullname')}}">
{{data_get($team,'staffdetail.fullname')}}
</div>
@foreach($staffs as $key => $staff)
<div class="item" data-value="{{data_get($staff,'id')}}" data-text="{{data_get($staff,'fullname')}}">
{{data_get($staff,'fullname')}}
</div>
@endforeach
</div>
</div>
</div> </div>
<div class="field"> <div class="field">
...@@ -39,3 +69,34 @@ ...@@ -39,3 +69,34 @@
</div> </div>
@endsection @endsection
@push('script')
<script>
function selectDepartment(i) {
// alert(i);
$.ajax({
url: "{{ URL::to('ajax/stafflist')}}"+"/"+i,
type: "get",
beforeSend: function ()
{
// $("#exampleModalCenter").modal('show');
block('loading-screen');
},
success: function(html)
{
// document.getElementById('nhtml2').style.display = 'none';
// $("#exampleModalCenter").modal('hide');
$('#divstaff').html(html);
// window.location.replace("{{ URL::to('ad/index')}}");
unblock('loading-screen');
}
});
}
</script>
@endpush
\ No newline at end of file
...@@ -11,8 +11,9 @@ ...@@ -11,8 +11,9 @@
<input type="hidden" name="pname" value="{{ data_get($project,'p_project_description') }}"> <input type="hidden" name="pname" value="{{ data_get($project,'p_project_description') }}">
<div class="field"> <div class="field">
<label>Project Code</label> <label>Project Code</label>
<input onselect="myDepartment()" type="text" name="projectcode" placeholder="Project Code" value="{{ data_get($project,'p_project_code') }} | {{ data_get($project,'p_project_description') }}" readonly="readonly"> <input type="text" name="projectcode" placeholder="Project Code" value="{{ data_get($project,'p_project_code') }} | {{ data_get($project,'p_project_description') }}" readonly="readonly">
</div> </div>
<div class="field"> <div class="field">
<label>Department</label> <label>Department</label>
<select onchange="selectDepartment(value);" name="department" id="department" class="ui fluid dropdown"> <select onchange="selectDepartment(value);" name="department" id="department" class="ui fluid dropdown">
...@@ -22,6 +23,7 @@ ...@@ -22,6 +23,7 @@
@endforeach @endforeach
</select> </select>
</div> </div>
<div class="field"> <div class="field">
<label>Staff Name</label> <label>Staff Name</label>
<div class="ui fluid multiple search selection dropdown"> <div class="ui fluid multiple search selection dropdown">
...@@ -37,6 +39,7 @@ ...@@ -37,6 +39,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="field"> <div class="field">
<label>Role</label> <label>Role</label>
<select name="role" class="ui fluid dropdown"> <select name="role" class="ui fluid dropdown">
...@@ -46,6 +49,7 @@ ...@@ -46,6 +49,7 @@
@endforeach @endforeach
</select> </select>
</div> </div>
<div class="field"> <div class="field">
<label>Project Status</label> <label>Project Status</label>
<select name="status" class="ui fluid dropdown"> <select name="status" class="ui fluid dropdown">
...@@ -54,6 +58,7 @@ ...@@ -54,6 +58,7 @@
<option value="0">Inactive</option> <option value="0">Inactive</option>
</select> </select>
</div> </div>
<button class="ui blue button" type="submit">Add</button> <button class="ui blue button" type="submit">Add</button>
<button class="ui green button" type="button" onclick="window.location.href='{{ route('timesheet::maintenance.senaraiProjectTeam', ['id'=> $pid] ) }} ';">Back</button> <button class="ui green button" type="button" onclick="window.location.href='{{ route('timesheet::maintenance.senaraiProjectTeam', ['id'=> $pid] ) }} ';">Back</button>
</form> </form>
...@@ -62,11 +67,11 @@ ...@@ -62,11 +67,11 @@
@endsection @endsection
@push('script') @push('script')
<script> <!-- <script>
function myDepartment() { function myDepartment() {
alert('{{ data_get($project,'p_project_description') }}'); alert('{{ data_get($project,'p_project_description') }}');
} }
</script> </script> -->
<script> <script>
function selectDepartment(i) { function selectDepartment(i) {
......
...@@ -284,10 +284,8 @@ class MaintenanceController extends Controller ...@@ -284,10 +284,8 @@ class MaintenanceController extends Controller
->orderBy('pt_project_task_sts', 'DESC') ->orderBy('pt_project_task_sts', 'DESC')
->orderBy('role_id') ->orderBy('role_id')
->get(); ->get();
$projectlist = [];
// dd($projectlistct);
// nanti project code query dari table project: $projectlist = [];
foreach ($project as $key => $value) { foreach ($project as $key => $value) {
// dd($value->toRole->role); // dd($value->toRole->role);
...@@ -389,7 +387,17 @@ class MaintenanceController extends Controller ...@@ -389,7 +387,17 @@ class MaintenanceController extends Controller
public function editprojectteam(Request $request) public function editprojectteam(Request $request)
{ {
$team = Pteam::where('id', $request->id) $team = Pteam::where('id', $request->id)
->with('staffdetail')
->first(); ->first();
// dd($team->staffdetail);
$departments = Department::all()
->except([7]);
foreach ($departments as $key => $value)
{
$staffs = Staff_info::where('fk_lkp_department', $value->id)
->get();
}
$teamRole = Role::where('id', $team->role_id) $teamRole = Role::where('id', $team->role_id)
->first(); ->first();
...@@ -398,41 +406,31 @@ class MaintenanceController extends Controller ...@@ -398,41 +406,31 @@ class MaintenanceController extends Controller
$pid = $team->fk_project_id; $pid = $team->fk_project_id;
return view('timesheet::maintenance.editProjectTeam', compact('team', 'pid', 'role', 'teamRole')); return view('timesheet::maintenance.editProjectTeam', compact('staffs' ,'departments' ,'team', 'pid', 'role', 'teamRole'));
} }
public function updateprojectteam(Request $request) public function updateprojectteam(Request $request)
{ {
// dd($request);
$pid = $request->pid; $pid = $request->pid;
$userId = users::find(Auth::id()) $userId = users::find(Auth::id())
->u_staffID; ->u_staffID;
// dd($request);
$data = Staff_info::where('id', $request->staffId)
->first();
$team = Pteam::where('id', $request->id)->first(); $team = Pteam::where('id', $request->id)->first();
$team->pt_project_task_sts = $request->status;
$team->role_id = $request->role; $team->role_id = $request->role;
$team->pt_project_task_sts = $request->status;
$team->pt_team = $data->fullname;
$team->pt_staff_id = $data->staff_id;
$team->updated_by = $userId; $team->updated_by = $userId;
// letak query utk update role
// $team->pt_role = $request->role;
$team->save(); $team->save();
// $project = Pteam::where('fk_project_id',$request->pid)
// ->get();
// $projectlist = [];
// foreach ($project as $key => $value) {
// $projectlist[] = [
// 'id' => $value->id,
// 'projectcode' => $value->toProject->p_project_code,
// 'projectname' => $value->pt_project_description,
// 'projectteam' => $value->pt_team,
// 'status' => $value->pt_project_task_sts,
// ];
// }
return redirect()->route('timesheet::maintenance.senaraiProjectTeam', ['id' => $pid]) return redirect()->route('timesheet::maintenance.senaraiProjectTeam', ['id' => $pid])
->with('success', 'Project Team Edited Successfully');; ->with('success', 'Project Team Updated Successfully');;
} }
public function senaraiPeranan() public function senaraiPeranan()
......
...@@ -23,6 +23,13 @@ class Pteam extends Model ...@@ -23,6 +23,13 @@ class Pteam extends Model
return $this->hasOne('Portal\Timesheet\Model\Role','id', 'role_id'); return $this->hasOne('Portal\Timesheet\Model\Role','id', 'role_id');
} }
public function staffdetail()
{
// dd('1');
return $this->hasOne('Portal\Timesheet\Model\Staff_info','staff_id', 'pt_staff_id')->with('deptname');
}
/** /**
* undocumented function * undocumented function
* *
......
...@@ -23,6 +23,11 @@ class Staff_info extends Model ...@@ -23,6 +23,11 @@ class Staff_info extends Model
return $this->hasOne('Portal\Timesheet\Model\Users', 'u_staffID', 'staff_id'); return $this->hasOne('Portal\Timesheet\Model\Users', 'u_staffID', 'staff_id');
} }
public function deptname()
{
return $this->hasOne('Portal\Timesheet\Model\Department','id','fk_lkp_department');
}
// public function project_code() // public function project_code()
// { // {
// return $this->hasMany('Portal\Timesheet\Model\Ts_detail','td_project','id'); // 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