Browse Source

Merge pull request 'upload 2023-12-13' (#24) from staging into master

Reviewed-on: ibnu/generic-ospro-backend#24
pull/1/head
farhantock 11 months ago
parent
commit
366ea839f4
  1. 40
      app/Http/Controllers/ProjectCarausellController.php
  2. 27
      app/Http/Controllers/ProjectController.php
  3. 2
      routes/web.php

40
app/Http/Controllers/ProjectCarausellController.php

@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\{ use App\Models\{
User, User,
Project, Project,
@ -9,33 +10,46 @@ use App\Models\{
ProjectIssues, ProjectIssues,
ProjectRisks ProjectRisks
}; };
class ProjectCarausellController extends Controller class ProjectCarausellController extends Controller
{ {
public function invoke() { public function invoke(Request $request)
{
// Master Data // Master Data
$projectData = Project::query() $company_id = $request->route('company_id');
->select("id","nama","kode_sortname","pm_id","budget_health","calculation_status","mulai_proyek","akhir_proyek","rencana_biaya","company","scurve") $all_project = $request->route('all_project');
->get(); $hierarchy = $request->route('hierarchy');
$query = Project::query()
->select("id", "nama", "kode_sortname", "pm_id", "budget_health", "calculation_status", "mulai_proyek", "akhir_proyek", "rencana_biaya", "company", "scurve");
if ($all_project) {
$query->where('company_id', $company_id);
} else {
$query->where('created_by_id', $hierarchy);
}
$projectData = $query->get();
$arr = []; $arr = [];
foreach($projectData as $project) { foreach ($projectData as $project) {
$projectRisk = ProjectRisks::query() $projectRisk = ProjectRisks::query()
->select('proyek_id','description','level_risk','preventive_risk') ->select('proyek_id', 'description', 'level_risk', 'preventive_risk')
->where('proyek_id', $project['id']) ->where('proyek_id', $project['id'])
->get() ->get()
->toArray(); ->toArray();
$projectIssue = ProjectIssues::query() $projectIssue = ProjectIssues::query()
->select('proyek_id','description','level_issue') ->select('proyek_id', 'description', 'level_issue')
->where('proyek_id',$project['id']) ->where('proyek_id', $project['id'])
->get() ->get()
->toArray(); ->toArray();
$ganttData = VersionGantt::query() $ganttData = VersionGantt::query()
->select('id', 'name_version','hierarchy_ftth_id','cost_to_complete','proyek_id','calculation_type') ->select('id', 'name_version', 'hierarchy_ftth_id', 'cost_to_complete', 'proyek_id', 'calculation_type')
->where('proyek_id',$project['id']) ->where('proyek_id', $project['id'])
->orderByDesc('id') ->orderByDesc('id')
->first(); ->first();
$projectManager = User::where('id', $project['pm_id'])->value('name'); $projectManager = User::where('id', $project['pm_id'])->value('name');
$arr[]= [ $arr[] = [
"project" => [ "project" => [
"id" => $project['id'], "id" => $project['id'],
"pm_id" => $project['pm_id'], "pm_id" => $project['pm_id'],
@ -52,9 +66,9 @@ class ProjectCarausellController extends Controller
"project_manager" => $projectManager, "project_manager" => $projectManager,
"project_risk" => $projectRisk, "project_risk" => $projectRisk,
"project_issue" => $projectIssue, "project_issue" => $projectIssue,
"gantt"=> $ganttData "gantt" => $ganttData
]; ];
} }
return response()->json(['status'=>'success','code'=> 200,'data'=> $arr, "total_project"=>count($arr)], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $arr, "total_project" => count($arr)], 200);
} }
} }

27
app/Http/Controllers/ProjectController.php

@ -510,20 +510,29 @@ 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 ' . $alias) ->from('assign_hr_to_proyek AS ahtp')
->where([ ->where([
['is_customer', true], ['is_customer', true],
['user_id', $id] ['user_id', $id]
]) ])
->leftJoin('m_users', $alias . '.user_id', '=', 'm_users.id') ->leftJoin('m_users', 'ahtp.user_id', '=', 'm_users.id')
->leftJoin('m_proyek', $alias . '.proyek_id', '=', 'm_proyek.id') ->leftJoin('m_proyek AS mp', 'ahtp.proyek_id', '=', 'mp.id')
->leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id') ->leftJoin('m_type_proyek', 'mp.type_proyek_id', '=', 'm_type_proyek.id')
->select('m_proyek.*', 'm_type_proyek.name AS join_second_name', 'm_users.name AS join_first_name') ->select(
->get(); 'mp.id',
'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);

2
routes/web.php

@ -81,7 +81,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
/* $router->get('/project/get-status-health-schedule/{id}', 'ProjectController@getStatusSchedule'); */ /* $router->get('/project/get-status-health-schedule/{id}', 'ProjectController@getStatusSchedule'); */
/* $router->get('/project/get-status-health-budget/{id}', 'ProjectController@getStatusBudget'); */ /* $router->get('/project/get-status-health-budget/{id}', 'ProjectController@getStatusBudget'); */
$router->get('/project-carausell', 'ProjectCarausellController@invoke'); $router->get('/project-carausell/{company_id}/{all_project}/{hierarchy}', 'ProjectCarausellController@invoke');
$router->post('/project-charter/search', 'ProjectCharterController@search'); $router->post('/project-charter/search', 'ProjectCharterController@search');
$router->post('/project-charter/add', 'ProjectCharterController@add'); $router->post('/project-charter/add', 'ProjectCharterController@add');

Loading…
Cancel
Save