|
|
@ -104,11 +104,13 @@ class AssignMaterialController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
public function datatables(Request $request){ |
|
|
|
public function datatables(Request $request){ |
|
|
|
$id_activity = $request->query('idact'); |
|
|
|
$id_activity = $request->query('idact'); |
|
|
|
|
|
|
|
$type = $request->query('type') ?? "material"; |
|
|
|
$data = AssignMaterial::select( |
|
|
|
$data = AssignMaterial::select( |
|
|
|
"assign_material_to_activity.*","m.description as material_name", "m.uom as uom" |
|
|
|
"assign_material_to_activity.*","m.description as material_name", "m.uom as uom" |
|
|
|
) |
|
|
|
) |
|
|
|
->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.type', $type) |
|
|
|
->orderBy('plan_date', 'desc') |
|
|
|
->orderBy('plan_date', 'desc') |
|
|
|
->get(); |
|
|
|
->get(); |
|
|
|
return Datatables::of($data) |
|
|
|
return Datatables::of($data) |
|
|
@ -124,14 +126,15 @@ class AssignMaterialController extends Controller |
|
|
|
$id_activity = $request->query('idact'); |
|
|
|
$id_activity = $request->query('idact'); |
|
|
|
$data = |
|
|
|
$data = |
|
|
|
AssignMaterial::select( |
|
|
|
AssignMaterial::select( |
|
|
|
AssignMaterial::raw( |
|
|
|
AssignMaterial::raw('SUM(qty_planning) as qty_planning'), |
|
|
|
'SUM(qty_planning) as qty_planning'), |
|
|
|
|
|
|
|
"m.description as material_name", |
|
|
|
"m.description as material_name", |
|
|
|
"assign_material_to_activity.activity_id as activity_id" |
|
|
|
"assign_material_to_activity.activity_id", |
|
|
|
|
|
|
|
"assign_material_to_activity.type", |
|
|
|
) |
|
|
|
) |
|
|
|
->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") |
|
|
|
->groupBy("m.description") |
|
|
|
->groupBy("m.description") |
|
|
|
->groupBy("assign_material_to_activity.activity_id") |
|
|
|
->groupBy("assign_material_to_activity.activity_id") |
|
|
|
|
|
|
|
->groupBy("assign_material_to_activity.type") |
|
|
|
->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() |
|
|
@ -171,8 +174,10 @@ class AssignMaterialController extends Controller |
|
|
|
return $val_uom ? $val_uom->uom : null; |
|
|
|
return $val_uom ? $val_uom->uom : null; |
|
|
|
}) |
|
|
|
}) |
|
|
|
->addColumn('action', function($row){ |
|
|
|
->addColumn('action', function($row){ |
|
|
|
$actionBtn = '<a href="javascript:void(0)" data-id="'.$row->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>'; |
|
|
|
$dataPlan = AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") |
|
|
|
$actionBtn .= '<a href="javascript:void(0)" data-id="'.$row->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>'; |
|
|
|
->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>'; |
|
|
|
return $actionBtn; |
|
|
|
return $actionBtn; |
|
|
|
}) |
|
|
|
}) |
|
|
|
->rawColumns(['action'])->make(true); |
|
|
|
->rawColumns(['action'])->make(true); |
|
|
@ -184,8 +189,6 @@ class AssignMaterialController 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)->get(); |
|
|
|
->where('assign_material_to_activity.activity_id', $id_activity)->get(); |
|
|
|
foreach ($data as $key) { |
|
|
|
foreach ($data as $key) { |
|
|
|
# code... |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$val_qty_sum = ReportActivityMaterial::where('assign_material_id', '=', $key->id)->sum("qty"); |
|
|
|
$val_qty_sum = ReportActivityMaterial::where('assign_material_id', '=', $key->id)->sum("qty"); |
|
|
|
} |
|
|
|
} |
|
|
|
$countData = $data->count(); |
|
|
|
$countData = $data->count(); |
|
|
|