Browse Source

update report datatable

pull/1/head
wahyu 11 months ago
parent
commit
588305ebaf
  1. 1
      app/Http/Controllers/ActivityController.php
  2. 34
      app/Http/Controllers/AssignMaterialController.php
  3. 4
      app/Http/Controllers/ReportActivityMaterialController.php

1
app/Http/Controllers/ActivityController.php

@ -688,6 +688,7 @@ class ActivityController extends Controller
'selfTable.name', 'selfTable.name',
'persentase_progress', 'persentase_progress',
'selfTable.start_date', 'selfTable.start_date',
'selfTable.id',
'selfTable.end_date', 'selfTable.end_date',
'selfTable.planned_start', 'selfTable.planned_start',
'selfTable.planned_end', 'selfTable.planned_end',

34
app/Http/Controllers/AssignMaterialController.php

@ -7,6 +7,7 @@ use App\Models\AssignMaterial;
use App\Models\RequestMaterial; use App\Models\RequestMaterial;
use App\Models\Activity; use App\Models\Activity;
use App\Models\ReportActivityMaterial; use App\Models\ReportActivityMaterial;
use Illuminate\Support\Facades\DB;
use Datatables; use Datatables;
class AssignMaterialController extends Controller class AssignMaterialController extends Controller
@ -140,28 +141,31 @@ class AssignMaterialController extends Controller
$id_activity = $request->query('idact'); $id_activity = $request->query('idact');
$data = $data =
AssignMaterial::select( AssignMaterial::select(
AssignMaterial::raw('SUM(qty_planning) as qty_planning'), DB::raw('(SELECT SUM(assign_material_to_activity.qty_planning) FROM assign_material_to_activity WHERE assign_material_to_activity.activity_id = ram.activity_id) as qty_planning'),
DB::raw('SUM(ram.qty) as qty_sum'),
"m.description as material_name", "m.description as material_name",
"assign_material_to_activity.activity_id", "assign_material_to_activity.activity_id",
"assign_material_to_activity.type" "assign_material_to_activity.material_id",
// "assign_material_to_activity.material_id",
) )
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id")
->groupBy("m.description") ->groupBy("m.description")
->groupBy("ram.activity_id")
->groupBy("assign_material_to_activity.activity_id") ->groupBy("assign_material_to_activity.activity_id")
->groupBy("assign_material_to_activity.type") ->groupBy("assign_material_to_activity.material_id")
->where("assign_material_to_activity.activity_id", $id_activity)->get(); ->where("assign_material_to_activity.activity_id", $id_activity)->get();
return Datatables::of($data) return Datatables::of($data)
->addIndexColumn() ->addIndexColumn()
->addColumn('qty_sum', function($row){ // ->addColumn('qty_planning', function($row){
$val_qty_act = AssignMaterial::select(ReportActivityMaterial::raw('SUM(ram.qty) as qty_sum'),"m.description as material_name1") // $val_qty_act = AssignMaterial::select(ReportActivityMaterial::raw('SUM(ram.qty) as qty_sum'),"m.description as material_name1","m.id")
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") // ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id") // ->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id")
->groupBy("m.description") // ->groupBy("m.description")
->where("m.description", strval($row->material_name)) // ->groupBy("m.id")
->where("ram.activity_id", $row->activity_id)->first(); // ->where("m.description", strval($row->material_name))
return $val_qty_act ? $val_qty_act->qty_sum : '-'; // ->where("ram.activity_id", $row->activity_id)->first();
}) // return $val_qty_act ? $val_qty_act->qty_sum : '-';
// })
->addColumn('status_activity', function($row){ ->addColumn('status_activity', function($row){
$val_status = AssignMaterial::select("status_activity") $val_status = AssignMaterial::select("status_activity")
->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id') ->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id')
@ -196,8 +200,8 @@ class AssignMaterialController extends Controller
->addColumn('action', function($row){ ->addColumn('action', function($row){
$dataPlan = AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") $dataPlan = AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->where('activity_id', $row->activity_id)->where('m.description', $row->material_name)->first(); ->where('activity_id', $row->activity_id)->where('m.description', $row->material_name)->first();
$actionBtn = '<a href="javascript:void(0)" data-id="'.$dataPlan->id.'" data-activity_id="'.$row->activity_id.'" data-material-name="'.$row->material_name.'" class="primary btn btn-primary btn-sm btn-lihat-plan" data-toggle="tooltip" title="Lihat Plan" data-placement="top"><i class="fa fa-align-justify"></i></a>'; $actionBtn = '<a href="javascript:void(0)" data-id="'.$dataPlan->id.'" data-activity_id="'.$row->activity_id.'" data-material-id="'.$row->material_id.'" data-material-name="'.$row->material_name.'" class="primary btn btn-primary btn-sm btn-lihat-plan" data-toggle="tooltip" title="Lihat Plan" data-placement="top"><i class="fa fa-align-justify"></i></a>';
$actionBtn .= '<a href="javascript:void(0)" data-id="'.$dataPlan->id.'" data-activity_id="'.$row->activity_id.'" data-material-name="'.$row->material_name.'" class="warning btn btn-warning btn-sm btn-lihat-actual" data-toggle="tooltip" title="Input Progress" data-placement="top"><i class="fa fa-edit" aria-hidden="true"></i></a>'; $actionBtn .= '<a href="javascript:void(0)" data-id="'.$dataPlan->id.'" data-activity_id="'.$row->activity_id.'" data-material-id="'.$row->material_id.'" data-material-name="'.$row->material_name.'" class="warning btn btn-warning btn-sm btn-lihat-actual" data-toggle="tooltip" title="Input Progress" data-placement="top"><i class="fa fa-edit" aria-hidden="true"></i></a>';
return $actionBtn; return $actionBtn;
}) })
->rawColumns(['action'])->make(true); ->rawColumns(['action'])->make(true);

4
app/Http/Controllers/ReportActivityMaterialController.php

@ -136,6 +136,7 @@ class ReportActivityMaterialController extends Controller
$id_am = $request->query('idAmi'); $id_am = $request->query('idAmi');
$type = $request->query('type'); $type = $request->query('type');
$materialName = $request->query('materialName'); $materialName = $request->query('materialName');
$materialId = $request->query('materialId');
if($type == 'plan'){ if($type == 'plan'){
$activity = Activity::findOrFail($id_activity); $activity = Activity::findOrFail($id_activity);
$baselineDuration = 0; $baselineDuration = 0;
@ -146,6 +147,7 @@ class ReportActivityMaterialController extends Controller
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->where('assign_material_to_activity.activity_id', $id_activity) ->where('assign_material_to_activity.activity_id', $id_activity)
->where('assign_material_to_activity.id', $id_am) ->where('assign_material_to_activity.id', $id_am)
->where('m.id', $materialId)
->orderBy('assign_material_to_activity.id', 'asc') ->orderBy('assign_material_to_activity.id', 'asc')
->get(); ->get();
if ($baselineDuration > 0) { if ($baselineDuration > 0) {
@ -174,7 +176,7 @@ class ReportActivityMaterialController extends Controller
->join("m_req_material as m", "m.id", "=", "amta.material_id") ->join("m_req_material as m", "m.id", "=", "amta.material_id")
->join("m_users as u", "u.id", "=", "report_activity_material.user_id") ->join("m_users as u", "u.id", "=", "report_activity_material.user_id")
->where('report_activity_material.activity_id', $id_activity) ->where('report_activity_material.activity_id', $id_activity)
->where('report_activity_material.assign_material_id', $id_am) ->where('m.id', $materialId)
->orderBy('report_activity_material.report_date', 'asc') ->orderBy('report_activity_material.report_date', 'asc')
->get(); ->get();
if ($baselineDuration > 0) { if ($baselineDuration > 0) {

Loading…
Cancel
Save