Browse Source

Merge branch 'master' of https://git.oslog.id/ordo/adw-backend into Dev-Farhan

pull/1/head
farhantock 11 months ago
parent
commit
ce9cec79a9
  1. 30
      app/Helpers/MasterFunctionsHelper.php
  2. 9
      app/Http/Controllers/ActivityController.php
  3. 32
      app/Http/Controllers/AssignMaterialController.php
  4. 1
      app/Http/Controllers/AuthController.php
  5. 3
      app/Http/Controllers/Controller.php
  6. 8
      app/Http/Controllers/DashboardBoDController.php
  7. 27
      app/Http/Controllers/DivisiController.php
  8. 109
      app/Http/Controllers/ProjectController.php
  9. 16
      app/Http/Controllers/ReportActivityMaterialController.php
  10. 33
      app/Http/Controllers/UserToActivityController.php
  11. 3
      app/Http/Controllers/UserToProyekController.php
  12. 8
      app/Http/Controllers/VersionGanttController.php
  13. 1
      app/Models/HumanResource.php
  14. 3
      app/Models/Project.php
  15. 2
      app/Models/ProjectRole.php
  16. 2
      app/Models/RoleMenu.php
  17. 2
      app/Models/Satuan.php
  18. 2
      routes/web.php

30
app/Helpers/MasterFunctionsHelper.php

@ -589,15 +589,13 @@ class MasterFunctionsHelper
// if (new \DateTime($loopDay) < $today) { // if (new \DateTime($loopDay) < $today) {
// $statusCutOfDate = true; // $statusCutOfDate = true;
// } // }
if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')) {
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek, 2); $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek, 2);
if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) { if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 2); // $tempPercentageReal[] = round($tempTtlPercentActual, 2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2); $progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2);
}
$dateWeek[] = [$loopDay];
} }
$dateWeek[] = [$loopDay];
// $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek; // $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek;
foreach ($dataPlanM as $keyPlanM) { foreach ($dataPlanM as $keyPlanM) {
# hitung untuk persentase progress planning # hitung untuk persentase progress planning
@ -1471,15 +1469,13 @@ class MasterFunctionsHelper
$dataActivityPlan = []; $dataActivityPlan = [];
$dataActivityActual = []; $dataActivityActual = [];
$today = date('Y-m-d'); $today = date('Y-m-d');
if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')) {
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek, 2); $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek, 2);
if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) { if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 2); // $tempPercentageReal[] = round($tempTtlPercentActual, 2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2); $progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2);
}
$dateWeek[] = [$loopDay];
} }
$dateWeek[] = [$loopDay];
// $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek; // $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek;
// if (count($dataPlanM) > 0 && count($dataPlanM[0]) > 0) { // if (count($dataPlanM) > 0 && count($dataPlanM[0]) > 0) {
foreach ($dataPlanM as $keyPlanM) { foreach ($dataPlanM as $keyPlanM) {
@ -1740,6 +1736,9 @@ class MasterFunctionsHelper
// if($keyPlanM->duration == 0){ // if($keyPlanM->duration == 0){
// $duration = 2; // $duration = 2;
// Tanggal awal // Tanggal awal
if (count($keyPlanM) == 0) {
continue;
}
$startDate = new DateTime($keyPlanM->planned_start); $startDate = new DateTime($keyPlanM->planned_start);
// Tanggal akhir // Tanggal akhir
$endDate = new DateTime($keyPlanM->planned_end); $endDate = new DateTime($keyPlanM->planned_end);
@ -1771,6 +1770,9 @@ class MasterFunctionsHelper
// hitung progress actual // hitung progress actual
// if (count($dataActualM) > 0 && count($dataActualM[0]) > 0) { // if (count($dataActualM) > 0 && count($dataActualM[0]) > 0) {
foreach ($dataActualM as $keyActualM) { foreach ($dataActualM as $keyActualM) {
if (count($keyPlanM) == 0) {
continue;
}
# hitung untuk persentase progress actual # hitung untuk persentase progress actual
// $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100; // $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100;
// jika total report > dari planning // jika total report > dari planning

9
app/Http/Controllers/ActivityController.php

@ -691,6 +691,7 @@ class ActivityController extends Controller
'selfTable.name', 'selfTable.name',
'persentase_progress', 'persentase_progress',
'selfTable.start_date', 'selfTable.start_date',
'selfTable.id',
'selfTable.end_date', 'selfTable.end_date',
'selfTable.planned_start', 'selfTable.planned_start',
'selfTable.planned_end', 'selfTable.planned_end',
@ -700,9 +701,10 @@ class ActivityController extends Controller
'm_version_gantt.name_version', 'm_version_gantt.name_version',
DB::raw('user_names.user_name as user_name'), DB::raw('user_names.user_name as user_name'),
DB::raw('SUM(report_activity_material.qty) as qty'), DB::raw('SUM(report_activity_material.qty) as qty'),
'assign_material_to_activity.qty_planning', // DB::raw('SUM(assign_material_to_activity.qty_planning) as qty_planning'),
'assign_material_to_activity.id as join_third_id' 'assign_material_to_activity.id as join_third_id'
) )
->addSelect(DB::raw('(SELECT SUM(assign_material_to_activity.qty_planning) FROM assign_material_to_activity WHERE assign_material_to_activity.activity_id = report_activity_material.activity_id) as qty_planning'))
->join('m_version_gantt', 'm_version_gantt.id', '=', 'selfTable.version_gantt_id') ->join('m_version_gantt', 'm_version_gantt.id', '=', 'selfTable.version_gantt_id')
->leftJoin('assign_hr_to_activity', 'assign_hr_to_activity.activity_id', '=', 'selfTable.id') ->leftJoin('assign_hr_to_activity', 'assign_hr_to_activity.activity_id', '=', 'selfTable.id')
->leftJoin('report_activity_material', 'report_activity_material.activity_id', '=', 'selfTable.id') ->leftJoin('report_activity_material', 'report_activity_material.activity_id', '=', 'selfTable.id')
@ -713,13 +715,12 @@ class ActivityController extends Controller
GROUP BY activity_id) as user_names'), function ($join) { GROUP BY activity_id) as user_names'), function ($join) {
$join->on('user_names.activity_id', '=', 'selfTable.id'); $join->on('user_names.activity_id', '=', 'selfTable.id');
}) })
->where('assign_material_to_activity.id', '=', DB::raw('report_activity_material.assign_material_id'))
->groupBy('selfTable.id') ->groupBy('selfTable.id')
->groupBy('selfTable.name')
->groupBy('selfTable.persentase_progress')
->groupBy('m_version_gantt.name_version') ->groupBy('m_version_gantt.name_version')
->groupBy('assign_material_to_activity.qty_planning')
->groupBy('assign_material_to_activity.id') ->groupBy('assign_material_to_activity.id')
->groupBy('user_names.user_name') ->groupBy('user_names.user_name')
->groupBy('report_activity_material.activity_id')
->get(); ->get();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet], 200);
} }

32
app/Http/Controllers/AssignMaterialController.php

@ -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,29 @@ 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",
) )
->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.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()
->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 +198,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);

1
app/Http/Controllers/AuthController.php

@ -13,6 +13,7 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Password; use Illuminate\Support\Facades\Password;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
class AuthController extends Controller class AuthController extends Controller
{ {
public function __construct() public function __construct()

3
app/Http/Controllers/Controller.php

@ -7,8 +7,8 @@ use Illuminate\Support\Facades\Http;
use App\Models\UserToActivity; use App\Models\UserToActivity;
use App\Models\Activity; use App\Models\Activity;
use App\Models\AssignMaterial; use App\Models\AssignMaterial;
use App\Models\User;
use App\Models\Divisi; use App\Models\Divisi;
use App\Models\User;
use Laravel\Lumen\Routing\Controller as BaseController; use Laravel\Lumen\Routing\Controller as BaseController;
use App\Models\ReportK3Detail; use App\Models\ReportK3Detail;
@ -33,7 +33,6 @@ class Controller extends BaseController
$this->currentDate = date("Y-m-d H:i:s"); $this->currentDate = date("Y-m-d H:i:s");
$this->currentName = auth()->user() ? auth()->user()->name : "system"; $this->currentName = auth()->user() ? auth()->user()->name : "system";
$this->currentId = auth()->user() ? auth()->user()->id : 0; $this->currentId = auth()->user() ? auth()->user()->id : 0;
$this->companyId = auth()->user() ? auth()->user()->company_id : 0;
$this->pathImage = config('assets.image'); $this->pathImage = config('assets.image');
$this->pathDocument = config('assets.project'); $this->pathDocument = config('assets.project');
$this->pathActivityDocument = config('assets.activity'); $this->pathActivityDocument = config('assets.activity');

8
app/Http/Controllers/DashboardBoDController.php

@ -47,13 +47,17 @@ class DashboardBoDController extends Controller
{ {
if (empty($search)) if (empty($search))
return response()->json(['status' => 'error', 'message' => 'Empty query string!'], 400); return response()->json(['status' => 'error', 'message' => 'Empty query string!'], 400);
if (empty($search))
return response()->json(['status' => 'error', 'message' => 'Empty query string!'], 400);
$url = str_replace("SEARCH", $search, config('api.adw') . '/project_cost?project_no=SEARCH');
$url = str_replace("SEARCH", $search, config('api.adw') . '/project_cost?project_no=SEARCH'); $url = str_replace("SEARCH", $search, config('api.adw') . '/project_cost?project_no=SEARCH');
$token = config('api.adw_token'); $token = config('api.adw_token');
$response = $this->curlReq($url, $token); $response = $this->curlReq($url, $token);
if (@$response->data->project_no == "") if (@$response->data->project_no == "")
return null; if (@$response->data->project_no == "")
return null;
return $response; return $response;
} }
@ -309,7 +313,7 @@ class DashboardBoDController extends Controller
} }
$selisihProgress = $planningProgress - $actualProgress; $selisihProgress = $planningProgress - $actualProgress;
try { try {
if ($selisihProgress > 0 && $selisihProgress <= 5) { if ($selisihProgress > 0 && $selisihProgress <= 20) {
$return['warning'] += 1; $return['warning'] += 1;
$projects[$index]->status = 'warning'; $projects[$index]->status = 'warning';
} elseif ($selisihProgress == 0) { } elseif ($selisihProgress == 0) {

27
app/Http/Controllers/DivisiController.php

@ -83,13 +83,26 @@ class DivisiController extends Controller
public function search(Request $request) public function search(Request $request)
{ {
$payload = $request->all(); $parentDivisi = Divisi::whereNull('parent')->with('children')->get();
$dataBuilder = $this->setUpPayload($payload, 'm_divisi'); $divisions = [];
$builder = $dataBuilder['builder']; foreach ($parentDivisi as $objRow) {
$countBuilder = $dataBuilder['count']; $objRow->children = $this->getAllChildren($objRow);
$dataGet = $builder->get(); // $objRow->key = rand(1, 1000);
$totalRecord = $countBuilder->count(); $divisions[] = $objRow;
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); }
$countData = count($divisions);
if ($countData == 0)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $divisions, 'totalRecord' => $countData], 200);
// $payload = $request->all();
// $dataBuilder = $this->setUpPayload($payload, 'm_divisi');
// $builder = $dataBuilder['builder'];
// $countBuilder = $dataBuilder['count'];
// $dataGet = $builder->get();
// $totalRecord = $countBuilder->count();
// return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
//return $this->list(); //return $this->list();
// cant use builder for this case // cant use builder for this case
} }

109
app/Http/Controllers/ProjectController.php

@ -51,9 +51,11 @@ class ProjectController extends Controller
$this->validate($request, [ $this->validate($request, [
'nama' => 'required', 'nama' => 'required',
'mulai_proyek' => 'required', 'mulai_proyek' => 'required',
'mulai_proyek' => 'required',
'akhir_proyek' => 'required', 'akhir_proyek' => 'required',
'rencana_biaya' => 'required', 'rencana_biaya' => 'required',
'type_proyek_id' => 'required' 'type_proyek_id' => 'required',
'value_proyek' => 'required'
]); ]);
$data = $request->all(); $data = $request->all();
@ -80,18 +82,54 @@ class ProjectController extends Controller
if (empty($id) || !is_int((int)$id)) if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$result = Project::query() // $result = Project::query()
->from('m_proyek AS mp') // ->from('m_proyek AS mp')
->where('mp.id', $id) // ->where('mp.id', $id)
->selectRaw('value_proyek,scoupe_of_work,kode_sortname,jumlah_stakeholder,nama,mulai_proyek,akhir_proyek,area_kerja,rencana_biaya,biaya_actual,company,pm_id,type_proyek_id,divisi_id,persentase_progress,keterangan,durasi_proyek,progress_by_worklog,currency_symbol,late_consequence,assumtion,currency_code,currency_name,project_objectives,considered_success_when,potential_risk,testing_environment,budget_health,phase_id,calculation_status'); // ->selectRaw('value_proyek,scoupe_of_work,kode_sortname,jumlah_stakeholder,nama,mulai_proyek,akhir_proyek,
// area_kerja,rencana_biaya,biaya_actual,company,pm_id,type_proyek_id,divisi_id,persentase_progress,keterangan,durasi_proyek,progress_by_worklog,currency_symbol,late_consequence,assumtion,currency_code,currency_name,project_objectives,considered_success_when,potential_risk,testing_environment,budget_health,phase_id,calculation_status');
if (!is_null($result->first()['divisi_id'])) {
$result->leftJoin('m_divisi', 'mp.divisi_id', '=', 'm_divisi.id')
->addSelect(DB::raw('m_divisi.name AS nama_divisi'));
}
$result = $result->first();
// if (!is_null($result->first()['divisi_id'])) {
// $result->leftJoin('m_divisi', 'mp.divisi_id', '=', 'm_divisi.id')
// ->addSelect(DB::raw('m_divisi.name AS nama_divisi'));
// }
$result = Project::select(
'value_proyek',
'scoupe_of_work',
'kode_sortname',
'jumlah_stakeholder',
'nama',
'mulai_proyek',
'akhir_proyek',
'area_kerja',
'rencana_biaya',
'biaya_actual',
'company',
'pm_id',
'type_proyek_id',
'divisi_id',
'persentase_progress',
'keterangan',
'durasi_proyek',
'progress_by_worklog',
'currency_symbol',
'late_consequence',
'assumtion',
'currency_code',
'currency_name',
'project_objectives',
'considered_success_when',
'potential_risk',
'testing_environment',
'budget_health',
'phase_id',
'calculation_status',
'md.name as divisi_name',
'nickname',
'sponsor'
)
->join('m_divisi as md', 'md.id', '=', 'm_proyek.divisi_id')
->where('m_proyek.id', $id)
->first();
if (!$result) if (!$result)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
@ -510,29 +548,20 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'data' => $response, 'code' => 200], 200); return response()->json(['status' => 'success', 'data' => $response, 'code' => 200], 200);
} }
public function getByUser($id) { public function getByUser($id)
{
$alias = "utp";
$userProyek = UserToProyek::query() $userProyek = UserToProyek::query()
->from('assign_hr_to_proyek AS ahtp') ->from('assign_hr_to_proyek AS ' . $alias)
->where([ ->where([
['is_customer', true], ['is_customer', true],
['user_id', $id] ['user_id', $id]
]) ])
->leftJoin('m_users', 'ahtp.user_id', '=', 'm_users.id') ->leftJoin('m_users', $alias . '.user_id', '=', 'm_users.id')
->leftJoin('m_proyek AS mp', 'ahtp.proyek_id', '=', 'mp.id') ->leftJoin('m_proyek', $alias . '.proyek_id', '=', 'm_proyek.id')
->leftJoin('m_type_proyek', 'mp.type_proyek_id', '=', 'm_type_proyek.id') ->leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id')
->select( ->select('m_proyek.*', 'm_type_proyek.name AS join_second_name', 'm_users.name AS join_first_name')
'mp.id', ->get();
'mp.nama',
'mp.rencana_biaya',
'mp.type_proyek_id',
'mp.currency_symbol',
'mp.mulai_proyek',
'mp.akhir_proyek',
'm_users.name AS join_first_name',
'm_users.username AS join_first_username',
'm_type_proyek.name AS join_second_name',
'm_type_proyek.name AS join_second_description'
)->get();
$totalRecord = $userProyek->count(); $totalRecord = $userProyek->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200);
@ -559,7 +588,7 @@ class ProjectController extends Controller
$actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists(); $actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists();
if ($result['type_proyek_id'] === 9) { if ($result['type_proyek_id'] === 9) {
// $actualEndExist = Activity::where('proyek_id', $id)->exists(); // $actualEndExist = Activity::where('proyek_id', $id)->exists();
// $query = Activity::where('proyek_id', $id); $query = Activity::where('proyek_id', $id);
$maxEndDate = Activity::where('proyek_id', $id)->select('end_date') $maxEndDate = Activity::where('proyek_id', $id)->select('end_date')
->orderBy('end_date', 'desc') ->orderBy('end_date', 'desc')
->first(); ->first();
@ -599,10 +628,12 @@ class ProjectController extends Controller
$plannedEnd = Activity::where('version_gantt_id', $ganttId) $plannedEnd = Activity::where('version_gantt_id', $ganttId)
->orderByDesc('planned_end') ->orderByDesc('planned_end')
->value('planned_end'); ->value('planned_end');
$result->header->start_date = $startDate; if (isset($result->header)) {
$result->header->end_date = $maxEndDate->end_date; $result->header->start_date = $startDate;
$result->header->planned_start = $plannedStart; $result->header->end_date = $maxEndDate->end_date;
$result->header->planned_end = $plannedEnd; $result->header->planned_start = $plannedStart;
$result->header->planned_end = $plannedEnd;
}
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result, 'gantt' => $ganttId], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $result, 'gantt' => $ganttId], 200);
} }
@ -622,15 +653,15 @@ class ProjectController extends Controller
->value('end_date'); ->value('end_date');
if (isset($payload['till_date'])) { if (isset($payload['till_date'])) {
if (isset($payload['scurve'])) { if (isset($payload['scurve'])) {
$overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date', '<=', $endDate)->orderBy('end_date', 'asc')->get(); $overdueActivities = Activity::join('m_version_gantt', 'm_activity.version_gantt_id', '=', 'm_version_gantt.id')->where('m_activity.proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date', '<=', $endDate)->orderBy('end_date', 'asc')->get();
} else { } else {
$overdueActivities = Activity::where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date', '<=', $endDate)->orderBy('end_date', 'asc')->get(); $overdueActivities = Activity::join('m_version_gantt', 'm_activity.version_gantt_id', '=', 'm_version_gantt.id')->where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date', '<=', $endDate)->orderBy('end_date', 'asc')->get();
} }
} else { } else {
if (isset($payload['scurve'])) { if (isset($payload['scurve'])) {
$overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); $overdueActivities = Activity::join('m_version_gantt', 'm_activity.version_gantt_id', '=', 'm_version_gantt.id')->where('m_activity.proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get();
} else { } else {
$overdueActivities = Activity::where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); $overdueActivities = Activity::join('m_version_gantt', 'm_activity.version_gantt_id', '=', 'm_version_gantt.id')->where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get();
} }
} }
$result->overdueActivities = $overdueActivities; $result->overdueActivities = $overdueActivities;

16
app/Http/Controllers/ReportActivityMaterialController.php

@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Helpers\MasterFunctionsHelper; use App\Helpers\MasterFunctionsHelper;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\ReportActivityMaterial; use App\Models\ReportActivityMaterial;
use App\Models\Activity; use App\Models\Activity;
use App\Models\AssignMaterial; use App\Models\AssignMaterial;
@ -64,10 +65,18 @@ class ReportActivityMaterialController extends Controller
} else { } else {
$sumAssignMaterial = AssignMaterial::where('activity_id', $request->activity_id)->sum('qty_planning'); $sumAssignMaterial = AssignMaterial::where('activity_id', $request->activity_id)->sum('qty_planning');
$sumReportActivityMaterial = ReportActivityMaterial::where('activity_id', $request->activity_id)->sum('qty'); $sumReportActivityMaterial = ReportActivityMaterial::where('activity_id', $request->activity_id)->sum('qty');
// if actual >= plan
if ($sumReportActivityMaterial >= $sumAssignMaterial){
$persentaseProgress = 95;
}else{
// actual < plan
$persentaseProgress = $sumReportActivityMaterial/$sumAssignMaterial*100;
}
$dataUpdate = array( $dataUpdate = array(
"actual_start" => null, "actual_start" => null,
"actual_end" => null, "actual_end" => null,
"persentase_progress" => $sumReportActivityMaterial/$sumAssignMaterial*100, "persentase_progress" => $persentaseProgress,
"updated_by" => $this->currentName "updated_by" => $this->currentName
); );
if ($sumReportActivityMaterial > 0) { if ($sumReportActivityMaterial > 0) {
@ -124,8 +133,10 @@ class ReportActivityMaterialController extends Controller
public function datatables(Request $request){ public function datatables(Request $request){
$id_activity = $request->query('idAct'); $id_activity = $request->query('idAct');
$id_am = $request->query('idAmi');
$type = $request->query('type'); $type = $request->query('type');
$materialName = $request->query('materialName'); $materialName = $request->query('materialName');
$materialId = $request->query('materialId');
if($type == 'plan'){ if($type == 'plan'){
$activity = Activity::findOrFail($id_activity); $activity = Activity::findOrFail($id_activity);
$baselineDuration = 0; $baselineDuration = 0;
@ -135,6 +146,7 @@ class ReportActivityMaterialController extends Controller
$data = AssignMaterial::select("assign_material_to_activity.*","m.description as material_name", "m.uom as uom") $data = AssignMaterial::select("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.id', $id_am)
->where('m.description', $materialName) ->where('m.description', $materialName)
->orderBy('assign_material_to_activity.id', 'asc') ->orderBy('assign_material_to_activity.id', 'asc')
->get(); ->get();

33
app/Http/Controllers/UserToActivityController.php

@ -158,7 +158,7 @@ class UserToActivityController extends Controller
$dataBuilder = $this->setUpPayload($payload, 'assign_hr_to_activity'); $dataBuilder = $this->setUpPayload($payload, 'assign_hr_to_activity');
$builder = $dataBuilder['builder']; $builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count']; // $countBuilder = $dataBuilder['count'];
if (isset($join_column)) { if (isset($join_column)) {
$startDate = $join_column['start_date']; $startDate = $join_column['start_date'];
$endDate = $join_column['end_date']; $endDate = $join_column['end_date'];
@ -187,8 +187,35 @@ class UserToActivityController extends Controller
} }
$dataGet = $filteredData; $dataGet = $filteredData;
} }
$totalRecord = $countBuilder->count(); // $totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>count($dataGet)], 200);
}
public function activityUser(Request $request){
$payload = $request->all();
$activity = DB::table('m_activity as ma')
->select('ahta.id', 'ma.id as activity_id', 'ma.proyek_id', 'ma.name as join_second_name', 'ma.start_date as join_second_start_date',
'ma.end_date as join_second_end_date', 'ma.persentase_progress', 'mvg.name_version', 'mp.nama as nama_proyek', 'mp.type_proyek_id')
->join('assign_hr_to_activity as ahta', 'ahta.activity_id', '=', 'ma.id')
->join('m_version_gantt as mvg', 'mvg.id', '=', 'ma.version_gantt_id')
->join('m_proyek as mp', 'mp.id', '=', 'ma.proyek_id')
->where('ahta.user_id', $payload['user_id'])
->where('ma.start_date', '<=', $payload['end_date'])
->where('ma.end_date', '>=', $payload['start_date'])
->where('ma.proyek_id', $payload['proyek_id'])
->get();
if ($payload['status'] != "") {
$filteredData = [];
foreach ($activity as $value) {
$assignMaterial = AssignMaterial::where('activity_id', $value->activity_id)->first();
if ($assignMaterial->status_activity == $payload['status']) {
$filteredData[] = $value;
}
}
$activity = $filteredData;
}
return response()->json(['status'=>'success','code'=>200,'data'=>$activity, 'totalRecord'=>count($activity)], 200);
} }
public function list() public function list()

3
app/Http/Controllers/UserToProyekController.php

@ -50,7 +50,8 @@ class UserToProyekController extends Controller
"user_id" => $item, "user_id" => $item,
"proyek_id" => $request->proyek_id, "proyek_id" => $request->proyek_id,
"created_by" => $this->currentName, "created_by" => $this->currentName,
'is_customer'=>true 'is_customer'=>true,
'project_role'=> $request->project_role
); );
$result = UserToProyek::create($dataInsert); $result = UserToProyek::create($dataInsert);

8
app/Http/Controllers/VersionGanttController.php

@ -121,11 +121,9 @@ class VersionGanttController extends Controller
->where('m_activity.parent_id', null) ->where('m_activity.parent_id', null)
->get(); ->get();
foreach ($progress as $item) { foreach ($progress as $item) {
if ($item->persentase_progress) { $item->progress = $item->persentase_progress;
$item->progress = $item->persentase_progress; $item->bobot = $item->bobot_planning;
$item->bobot = $item->bobot_planning; $item->save();
$item->save();
}
} }
} }

1
app/Models/HumanResource.php

@ -34,6 +34,5 @@ class HumanResource extends Model
'updated_by', 'updated_by',
'divisi_id', 'divisi_id',
'status_boundary', 'status_boundary',
'company_id'
]; ];
} }

3
app/Models/Project.php

@ -15,6 +15,7 @@ class Project extends Model
'kode_sortname', 'kode_sortname',
'jumlah_stakeholder', 'jumlah_stakeholder',
'nama', 'nama',
'nickname',
'mulai_proyek', 'mulai_proyek',
'akhir_proyek', 'akhir_proyek',
'area_kerja', 'area_kerja',
@ -23,8 +24,10 @@ class Project extends Model
'biaya_actual', 'biaya_actual',
'company', 'company',
'pm_id', 'pm_id',
'scoupe_of_work',
'type_proyek_id', 'type_proyek_id',
'divisi_id', 'divisi_id',
'value_proyek',
'persentase_progress', 'persentase_progress',
'keterangan', 'keterangan',
'durasi_proyek', 'durasi_proyek',

2
app/Models/ProjectRole.php

@ -12,6 +12,6 @@ class ProjectRole extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by'
]; ];
} }

2
app/Models/RoleMenu.php

@ -12,6 +12,6 @@ class RoleMenu extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'role_id', 'menu_id', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id', "create", "read", "update", "delete" 'role_id', 'menu_id', 'created_at', 'created_by', 'updated_at', 'updated_by'
]; ];
} }

2
app/Models/Satuan.php

@ -12,6 +12,6 @@ class Satuan extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by'
]; ];
} }

2
routes/web.php

@ -78,6 +78,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities'); $router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities');
$router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration'); $router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration');
$router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution'); $router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution');
$router->get('/project/get-integration-project-cost={name}', 'ProjectController@getProjectCostIntegration');
/* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */ /* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */
@ -228,6 +229,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->get('/user-to-activity/edit/{id}', 'UserToActivityController@edit'); $router->get('/user-to-activity/edit/{id}', 'UserToActivityController@edit');
$router->put('/user-to-activity/update/{id}', 'UserToActivityController@update'); $router->put('/user-to-activity/update/{id}', 'UserToActivityController@update');
$router->post('/user-to-activity/search', 'UserToActivityController@search'); $router->post('/user-to-activity/search', 'UserToActivityController@search');
$router->post('/user-to-activity/by-date-status', 'UserToActivityController@activityUser');
$router->post('/user-to-activity/search-analysis', 'UserToActivityController@searchAnalysis'); $router->post('/user-to-activity/search-analysis', 'UserToActivityController@searchAnalysis');
$router->post('/user-to-activity/list-filtered', 'UserToActivityController@listFiltered'); $router->post('/user-to-activity/list-filtered', 'UserToActivityController@listFiltered');
$router->delete('/user-to-activity/delete/{id}', 'UserToActivityController@delete'); $router->delete('/user-to-activity/delete/{id}', 'UserToActivityController@delete');

Loading…
Cancel
Save