diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php
index e08ff7b..7b44585 100755
--- a/app/Http/Controllers/ActivityController.php
+++ b/app/Http/Controllers/ActivityController.php
@@ -688,6 +688,7 @@ class ActivityController extends Controller
'selfTable.name',
'persentase_progress',
'selfTable.start_date',
+ 'selfTable.id',
'selfTable.end_date',
'selfTable.planned_start',
'selfTable.planned_end',
diff --git a/app/Http/Controllers/AssignMaterialController.php b/app/Http/Controllers/AssignMaterialController.php
index 3d78384..8916063 100644
--- a/app/Http/Controllers/AssignMaterialController.php
+++ b/app/Http/Controllers/AssignMaterialController.php
@@ -7,6 +7,7 @@ use App\Models\AssignMaterial;
use App\Models\RequestMaterial;
use App\Models\Activity;
use App\Models\ReportActivityMaterial;
+use Illuminate\Support\Facades\DB;
use Datatables;
class AssignMaterialController extends Controller
@@ -140,28 +141,31 @@ class AssignMaterialController extends Controller
$id_activity = $request->query('idact');
$data =
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",
"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("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id")
->groupBy("m.description")
+ ->groupBy("ram.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();
return Datatables::of($data)
->addIndexColumn()
- ->addColumn('qty_sum', function($row){
- $val_qty_act = AssignMaterial::select(ReportActivityMaterial::raw('SUM(ram.qty) as qty_sum'),"m.description as material_name1")
- ->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")
- ->where("m.description", strval($row->material_name))
- ->where("ram.activity_id", $row->activity_id)->first();
- return $val_qty_act ? $val_qty_act->qty_sum : '-';
- })
+ // ->addColumn('qty_planning', function($row){
+ // $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("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id")
+ // ->groupBy("m.description")
+ // ->groupBy("m.id")
+ // ->where("m.description", strval($row->material_name))
+ // ->where("ram.activity_id", $row->activity_id)->first();
+ // return $val_qty_act ? $val_qty_act->qty_sum : '-';
+ // })
->addColumn('status_activity', function($row){
$val_status = AssignMaterial::select("status_activity")
->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){
$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();
- $actionBtn = '';
- $actionBtn .= '';
+ $actionBtn = '';
+ $actionBtn .= '';
return $actionBtn;
})
->rawColumns(['action'])->make(true);
diff --git a/app/Http/Controllers/ReportActivityMaterialController.php b/app/Http/Controllers/ReportActivityMaterialController.php
index 44b228b..b10cba7 100644
--- a/app/Http/Controllers/ReportActivityMaterialController.php
+++ b/app/Http/Controllers/ReportActivityMaterialController.php
@@ -136,6 +136,7 @@ class ReportActivityMaterialController extends Controller
$id_am = $request->query('idAmi');
$type = $request->query('type');
$materialName = $request->query('materialName');
+ $materialId = $request->query('materialId');
if($type == 'plan'){
$activity = Activity::findOrFail($id_activity);
$baselineDuration = 0;
@@ -146,6 +147,7 @@ class ReportActivityMaterialController extends Controller
->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.id', $id_am)
+ ->where('m.id', $materialId)
->orderBy('assign_material_to_activity.id', 'asc')
->get();
if ($baselineDuration > 0) {
@@ -174,7 +176,7 @@ class ReportActivityMaterialController extends Controller
->join("m_req_material as m", "m.id", "=", "amta.material_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.assign_material_id', $id_am)
+ ->where('m.id', $materialId)
->orderBy('report_activity_material.report_date', 'asc')
->get();
if ($baselineDuration > 0) {