Browse Source

Merge pull request 'dev-wahyu' (#313) from dev-wahyu into staging

Reviewed-on: ordo/adw-backend#313
pull/1/head
ibnu 10 months ago
parent
commit
711e9756eb
  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',
'persentase_progress',
'selfTable.start_date',
'selfTable.id',
'selfTable.end_date',
'selfTable.planned_start',
'selfTable.planned_end',

34
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 = '<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-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="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="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;
})
->rawColumns(['action'])->make(true);

4
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) {

Loading…
Cancel
Save