Commit 3a1de564 by hannan

user can insert insert input into mandays hours and auto calculate to days. add…

user can insert insert input into mandays hours and auto calculate to days. add new project team, will add to in project mandays
parent e263a363
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php $limit = count($role); ?> <?php $limit = count($limitrole); ?>
@foreach($role as $key => $value) @foreach($role as $key => $value)
<tr> <tr>
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
name="hours[{{data_get($value,'role.id')}}]" name="hours[{{data_get($value,'role.id')}}]"
id="hours[{{data_get($value,'role.id')}}]" id="hours[{{data_get($value,'role.id')}}]"
value="{{$h}}" value="{{$h}}"
readonly="readonly"> onchange="calcDays(this.value,{{$limit}},{{data_get($value,'role.id')}})">
</td> </td>
</tr> </tr>
@endforeach @endforeach
...@@ -104,9 +104,9 @@ ...@@ -104,9 +104,9 @@
days = parseFloat(parseFloat(days).toFixed(1)); days = parseFloat(parseFloat(days).toFixed(1));
var totdays = tothours = totaldays = totalhours = 0; var totdays = tothours = totaldays = 0;
for (var i = 1; i < 7; i++) { for (var i = 1; i < limit+1; i++) {
var day = document.getElementById('days['+i+']'); var day = document.getElementById('days['+i+']');
...@@ -134,6 +134,41 @@ ...@@ -134,6 +134,41 @@
tothours = document.getElementById('totalhours'); tothours = document.getElementById('totalhours');
tothours.value = totaldays * 8; tothours.value = totaldays * 8;
}
function calcDays(hours,limit,rid) {
hours = parseFloat(parseFloat(hours).toFixed(1));
var totdays = tothours = totalhours = 0;
for (var i = 1; i < limit+1; i++) {
var hour = document.getElementById('hours['+i+']');
var days = hours / 8;
var calcdays = document.getElementById('days['+rid+']');
calcdays.value = days;
if(hour) {
var currhours = parseFloat(parseFloat(hour.value).toFixed(1));
if (isNaN(currhours)) {
currhours = 0;
}
totalhours += currhours;
}
}
tothours = document.getElementById('totalhours');
tothours.value = totalhours;
totdays = document.getElementById('totaldays');
totdays.value = totalhours/8;
} }
</script> </script>
......
...@@ -184,11 +184,14 @@ class MaintenanceController extends Controller ...@@ -184,11 +184,14 @@ class MaintenanceController extends Controller
public function mandays(Request $request) public function mandays(Request $request)
{ {
$limitrole = Role::where('status', 1)->get();
$data = Pmandays::where('fk_project', $request->id)->get(); $data = Pmandays::where('fk_project', $request->id)->get();
// dd($data); // dd($data);
$role = VwMandays::where('fk_project_id', $request->id) $role = VwMandays::where('fk_project_id', $request->id)
->with('role') ->with('role')
->orderBy('role_id')
->get(); ->get();
// dd($role); // dd($role);
...@@ -196,13 +199,12 @@ class MaintenanceController extends Controller ...@@ -196,13 +199,12 @@ class MaintenanceController extends Controller
$id = $request->id; $id = $request->id;
// dd($pid); // dd($pid);
return view('timesheet::maintenance.mandays',compact('id', 'role', 'data')); return view('timesheet::maintenance.mandays',compact('id', 'role', 'data', 'limitrole'));
} }
public function savemandays(Request $request) public function savemandays(Request $request)
{ {
// dump($request); // dd($request);
// dd(Pmandays::where('fk_project', $request->id)->get());
$staffid = Users::find(Auth::id()) $staffid = Users::find(Auth::id())
->u_staffID; ->u_staffID;
...@@ -337,6 +339,12 @@ class MaintenanceController extends Controller ...@@ -337,6 +339,12 @@ class MaintenanceController extends Controller
$pt->pt_project_type = $chargeable; $pt->pt_project_type = $chargeable;
$pt->save(); $pt->save();
$md = new Pmandays;
$md->fk_project = $request->pid;
$md->pm_roles = $request->role;
$md->updated_by = $request->userId;
$md->save();
} }
} }
......
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