@ -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.typ e")
->groupBy("assign_material_to_activity.ma terial_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);