fix: information overhead in report #1

Merged
farhantock merged 1 commits from dev-wahyun into master 6 months ago
  1. 31
      app/Http/Controllers/AssignMaterialController.php

31
app/Http/Controllers/AssignMaterialController.php

@ -152,22 +152,21 @@ class AssignMaterialController extends Controller
{ {
$id_activity = $request->query('idact'); $id_activity = $request->query('idact');
$query = AssignMaterial::select( $query = AssignMaterial::select(
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(assign_material_to_activity.qty_planning) 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" DB::raw('SUM(assign_material_to_activity.id) as id'),
) "m.uom",
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id"); )
if (!AssignMaterial::join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id")->where("assign_material_to_activity.activity_id", $id_activity)->exists()) { ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id");
$query->leftJoin("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id");
} else {
$query->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id"); $data = $query->groupBy("m.description")
} ->groupBy("assign_material_to_activity.activity_id")
$data = $query->groupBy("m.description") ->groupBy("m.uom")
->groupBy("ram.activity_id") // ->groupBy("assign_material_to_activity.id")
->groupBy("assign_material_to_activity.activity_id") ->where("assign_material_to_activity.activity_id", $id_activity)
->where("assign_material_to_activity.activity_id", $id_activity) ->get();
->get();
return Datatables::of($data) return Datatables::of($data)
->addIndexColumn() ->addIndexColumn()
// ->addColumn('qty_planning', function($row){ // ->addColumn('qty_planning', function($row){

Loading…
Cancel
Save