Browse Source

Merge pull request 'Dev-Farhan' (#305) from Dev-Farhan into staging

Reviewed-on: ordo/adw-backend#305
pull/1/head
farhantock 1 year ago
parent
commit
270e05f783
  1. 45
      app/Helpers/MasterFunctionsHelper.php
  2. 5
      app/Http/Controllers/AuthController.php
  3. 110
      app/Http/Controllers/CompanyController.php
  4. 73
      app/Http/Controllers/Controller.php
  5. 15
      app/Http/Controllers/DashboardBoDController.php
  6. 195
      app/Http/Controllers/MenuCompanyController.php
  7. 131
      app/Http/Controllers/ProjectController.php
  8. 37
      app/Models/Company.php
  9. 6
      app/Models/Divisi.php
  10. 3
      app/Models/HumanResource.php
  11. 27
      app/Models/MenuCompany.php
  12. 5
      app/Models/Project.php
  13. 2
      app/Models/ProjectPhase.php
  14. 2
      app/Models/ProjectRole.php
  15. 2
      app/Models/ProjectType.php
  16. 2
      app/Models/Role.php
  17. 2
      app/Models/RoleMenu.php
  18. 2
      app/Models/Satuan.php
  19. 16
      routes/web.php

45
app/Helpers/MasterFunctionsHelper.php

@ -36,7 +36,8 @@ class MasterFunctionsHelper
return json_decode($output);
}
public static function countDays($ganttId, $start, $end){
public static function countDays($ganttId, $start, $end)
{
$dayOffs = VersionGantt::where('id', $ganttId)->first()->config_dayoff;
$diff = date_diff($start, $end);
$endCount = clone $end;
@ -291,7 +292,6 @@ class MasterFunctionsHelper
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
}
// $weeklyPlan = $weekCount > 0 ? $keyPlanM->bobot_planning / $weekCount : 0;
@ -539,7 +539,11 @@ class MasterFunctionsHelper
$dataActualM = DB::table('report_activity_material as ram')
->join('m_activity as ma', 'ma.id', '=', 'ram.activity_id')
->select('ram.activity_id', 'ram.qty as qty_actual', 'ma.bobot_planning', 'ma.name',
->select(
'ram.activity_id',
'ram.qty as qty_actual',
'ma.bobot_planning',
'ma.name',
DB::raw('(SELECT SUM(amta.qty_planning) FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS qty_plan'),
DB::raw('(SELECT SUM(ram.qty) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS sum_qty_actual'),
DB::raw('(SELECT DISTINCT status_activity FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS status_activity'),
@ -615,8 +619,7 @@ class MasterFunctionsHelper
}
if ($keyActualM->status_activity == 'done') {
$progressActualWeek = $keyActualM->bobot_planning / $keyActualM->count_report;
}
else{
} else {
$progressActualWeek = $progressActualWeek > ($keyActualM->bobot_planning * 95) / 100 ? ($keyActualM->bobot_planning * 95) / 100 : $progressActualWeek;
}
$dataActivityActual[] = array(
@ -640,13 +643,13 @@ class MasterFunctionsHelper
"tmpProgressActualWeek" => $tmpProgressActualWeek,
"progressPlanWeek" => $tmpProgressPlanWeek
);
}
$dataFinal[] = array(
// "date" => $dateWeek,
"proyek_name" => $dataProject->nama,
"data" => ["date" => $dateWeek,
"data" => [
"date" => $dateWeek,
"percentagePlan" => $progressPlanKomulatifWeek,
"percentageReal" => $progressActualKomulatifWeek,
"data_details" => $dataActivityPlanDate
@ -1115,7 +1118,6 @@ class MasterFunctionsHelper
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
}
// $weeklyPlan = $sumVolPlan->ttl_qty_plan / $weekCount;
@ -1422,7 +1424,11 @@ class MasterFunctionsHelper
$dataActualM = DB::table('report_activity_material as ram')
->join('m_activity as ma', 'ma.id', '=', 'ram.activity_id')
->select('ram.activity_id', 'ram.qty as qty_actual', 'ma.bobot_planning', 'ma.name',
->select(
'ram.activity_id',
'ram.qty as qty_actual',
'ma.bobot_planning',
'ma.name',
DB::raw('(SELECT SUM(amta.qty_planning) FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS qty_plan'),
DB::raw('(SELECT SUM(ram.qty) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS sum_qty_actual'),
DB::raw('(SELECT DISTINCT status_activity FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS status_activity'),
@ -1513,8 +1519,7 @@ class MasterFunctionsHelper
// $progressActualWeek = $progressActualWeek > $keyActualM->bobot_planning ? $keyActualM->bobot_planning : $progressActualWeek;
// jika report lebih dari 1 x, maka harusnya di bagi sabanyak jumlah report,
// contoh ada 3 report, report ke 1 adalah 5 maka 100/3 dan di looping
}
else{
} else {
$progressActualWeek = $progressActualWeek > ($keyActualM->bobot_planning * 95) / 100 ? ($keyActualM->bobot_planning * 95) / 100 : $progressActualWeek;
}
$dataActivityActual[] = array(
@ -1539,13 +1544,13 @@ class MasterFunctionsHelper
"tmpProgressActualWeek" => $tmpProgressActualWeek,
"progressPlanWeek" => $tmpProgressPlanWeek
);
}
$dataFinal[] = array(
// "date" => $dateWeek,
"proyek_name" => $dataProject->nama,
"data" => ["date" => $dateWeek,
"data" => [
"date" => $dateWeek,
"percentagePlan" => $progressPlanKomulatifWeek,
"percentageReal" => $progressActualKomulatifWeek
// "data_details" => $dataActivityPlanDate
@ -1671,7 +1676,11 @@ class MasterFunctionsHelper
->join('m_version_gantt as mvg', 'mvg.hierarchy_ftth_id', '=', 'mhf.id')
->join('m_activity as ma', 'ma.version_gantt_id', '=', 'mvg.id')
->join('report_activity_material as ram', 'ram.activity_id', '=', 'ma.id')
->select('ram.activity_id', 'ram.qty as qty_actual', 'ma.bobot_planning', 'ma.name',
->select(
'ram.activity_id',
'ram.qty as qty_actual',
'ma.bobot_planning',
'ma.name',
DB::raw('(SELECT SUM(amta.qty_planning) FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS qty_plan'),
DB::raw('(SELECT SUM(ram.qty) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS sum_qty_actual'),
DB::raw('(SELECT DISTINCT status_activity FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS status_activity'),
@ -1769,8 +1778,7 @@ class MasterFunctionsHelper
// $progressActualWeek = $progressActualWeek > $keyActualM->bobot_planning ? $keyActualM->bobot_planning : $progressActualWeek;
// jika report lebih dari 1 x, maka harusnya di bagi sabanyak jumlah report,
// contoh ada 3 report, report ke 1 adalah 5 maka 100/3 dan di looping
}
else{
} else {
$progressActualWeek = $progressActualWeek > ($keyActualM->bobot_planning * 95) / 100 ? ($keyActualM->bobot_planning * 95) / 100 : $progressActualWeek;
}
$dataActivityActual[] = array(
@ -1795,13 +1803,13 @@ class MasterFunctionsHelper
"tmpProgressActualWeek" => $tmpProgressActualWeek,
"progressPlanWeek" => $tmpProgressPlanWeek
);
}
$dataFinal[] = array(
// "date" => $dateWeek,
"proyek_name" => $dataProject->nama,
"data" => ["date" => $dateWeek,
"data" => [
"date" => $dateWeek,
"percentagePlan" => $progressPlanKomulatifWeek,
"percentageReal" => $progressActualKomulatifWeek
// "data_details" => $dataActivityPlanDate
@ -2040,5 +2048,4 @@ class MasterFunctionsHelper
return $dataFinal;
}
}

5
app/Http/Controllers/AuthController.php

@ -11,6 +11,7 @@ use App\Models\Role;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Password;
use Illuminate\Validation\ValidationException;
class AuthController extends Controller
{
public function __construct()
@ -56,10 +57,14 @@ class AuthController extends Controller
}
$dataRole = Role::find($user->role_id);
$dataHierarchy = $this->getDataHierarchy($user->divisi_id, $user->id);
if ($dataRole)
$user->role = $dataRole;
if ($dataHierarchy)
$user->hierarchy = $dataHierarchy;
if (!$token = Auth::login($user))
return response()->json(['error' => 'Unauthorized'], 401);

110
app/Http/Controllers/CompanyController.php

@ -0,0 +1,110 @@
<?php
namespace App\Http\Controllers;
use App\Models\Company;
use Illuminate\Http\Request;
class CompanyController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required',
'description' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = Company::create($data);
if ($result) {
return response()->json(['status' => 'success', 'message' => 'add Company successfully!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'add data Company failed!', 'code' => 400], 400);
}
}
public function edit($id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
die();
}
$result = Company::find($id);
if ($result) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get data Company, please try again later!', 'code' => 400], 400);
}
}
public function update(Request $request, $id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
}
$data = Company::find($id);
if ($data) {
$result = $data->update($request->all());
} else {
return response()->json(['status' => 'failed', 'message' => 'data Company not found!', 'code' => 400], 400);
die();
}
if ($result) {
return response()->json(['status' => 'success', 'message' => 'data Company successfully updated!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data Company failed updated!', 'code' => 400], 400);
}
}
public function delete($id)
{
$data = Company::find($id);
if ($data) {
$delete = $data->delete();
} else {
return response()->json(['status' => 'failed', 'message' => 'data Company not found!', 'code' => 400], 400);
die();
}
if ($delete) {
return response()->json(['status' => 'success', 'message' => 'data Company successfully deleted!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data Company failed deleted!', 'code' => 400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_company');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
}
public function list()
{
$data = Company::all();
$countData = $data->count();
if ($data) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get list Company, please try again later!', 'code' => 400], 400);
}
}
}

73
app/Http/Controllers/Controller.php

@ -1,11 +1,14 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use App\Models\UserToActivity;
use App\Models\Activity;
use App\Models\AssignMaterial;
use App\Models\Divisi;
use App\Models\User;
use Laravel\Lumen\Routing\Controller as BaseController;
use App\Models\ReportK3Detail;
@ -16,18 +19,21 @@ class Controller extends BaseController
protected $pathDocument = "assets/file/project/";
protected $pathTmpImport = "assets/file/tmpimport/";
protected $pathActivityDocument = "assets/file/activity/";
protected $listJoinAll = ['first', 'second', 'third', 'fourth', 'fifth',
'sixth', 'seventh', 'eighth', 'ninth', 'tenth'];
protected $listJoinAll = [
'first', 'second', 'third', 'fourth', 'fifth',
'sixth', 'seventh', 'eighth', 'ninth', 'tenth'
];
protected $currentDate;
protected $currentName;
protected $currentId;
protected $companyId;
public function __construct()
{
$this->currentDate = date("Y-m-d H:i:s");
$this->currentName = auth()->user() ? auth()->user()->name : "system";
$this->currentId = auth()->user() ? auth()->user()->id : 0;
$this->companyId = auth()->user() ? auth()->user()->company_id : 0;
$this->pathImage = config('assets.image');
$this->pathDocument = config('assets.project');
$this->pathActivityDocument = config('assets.activity');
@ -184,7 +190,8 @@ class Controller extends BaseController
return $query;
}
private function whereConditionSingleTable($oldQuery, $operator, $column, $value, $value2){
private function whereConditionSingleTable($oldQuery, $operator, $column, $value, $value2)
{
$query = $oldQuery;
if ($operator == "range") {
$query = $query->whereBetween($column, [$value, $value2]);
@ -225,7 +232,8 @@ class Controller extends BaseController
return $query;
}
protected function calculateAllCost($activity_id, $proyek_id){
protected function calculateAllCost($activity_id, $proyek_id)
{
$humanCostPlanning = $this->calculateAllHumanCost($activity_id, $proyek_id);
$materialCostPlanning = $this->calculateMaterialCost($activity_id, $proyek_id);
$toolsCostPlanning = 0;
@ -273,7 +281,8 @@ class Controller extends BaseController
return $totalCost;
}
protected function getLoc($lat, $lng){
protected function getLoc($lat, $lng)
{
// $response = Http::get(config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json");
// return $response->json;
@ -283,7 +292,8 @@ class Controller extends BaseController
return $response;
}
private function curlRequest($url){
private function curlRequest($url)
{
$ch = curl_init();
// $headers = [
// 'Authorization: '.$token
@ -300,7 +310,8 @@ class Controller extends BaseController
return json_decode($response);
}
protected function addDetailK3($dataDetail, $report_id){
protected function addDetailK3($dataDetail, $report_id)
{
foreach ($dataDetail as $value) {
$dataNew = array(
"report_k3_id" => $report_id,
@ -312,4 +323,50 @@ class Controller extends BaseController
ReportK3Detail::create($dataNew);
}
}
protected function getDataHierarchy($divisi, $paramUserId)
{
$parentDivisi = Divisi::where('id', $divisi)->get();
$divisions = [];
$tempUser = [];
$userId = [$paramUserId];
// if ($parentDivisi->parent == null){
// }else{
foreach ($parentDivisi as $key) {
$data = $this->getAllChildrenDivisi($key->id);
$divisions[] = $data;
}
if (count($divisions) > 0) {
for ($i = 0; $i < count($divisions[0]); $i++) {
if (User::select('id', 'name', 'divisi_id')->where('divisi_id', $divisions[0][$i]->id)->exists()) {
$tempUser[] = User::select('id', 'name', 'divisi_id')->where('divisi_id', $divisions[0][$i]->id)->get();
}
}
for ($x = 0; $x < count($tempUser); $x++) {
for ($y = 0; $y < count($tempUser[$x]); $y++) {
$userId[] = $tempUser[$x][$y]->id;
}
}
}
return $userId;
// }
// return $userId;
}
private function getAllChildrenDivisi($divisi)
{
$finalData = [];
$divisi = Divisi::where('parent', $divisi)->get();
if (count($divisi) > 0) {
foreach ($divisi as $key) {
$childDivisi = $this->getAllChildrenDivisi($key->id);
$finalData[] = $key;
$finalData = array_merge($finalData, $childDivisi);
}
}
return $finalData;
}
}

15
app/Http/Controllers/DashboardBoDController.php

@ -83,7 +83,6 @@ class DashboardBoDController extends Controller
$totalInvoice += $resp->data->total_invoice_amount ?? 0;
$totalPaidInvoice += $resp->data->total_invoice_paid_amount ?? 0;
}
}
return response()->json([
@ -148,15 +147,13 @@ class DashboardBoDController extends Controller
}
$selisihProgress = $planningProgress - $actualProgress;
try {
if ($selisihProgress > 0 && $selisihProgress <= 5){
if ($selisihProgress > 0 && $selisihProgress <= 20) {
$return['warning'] += 1;
$projects[$index]->status = 'warning';
}
elseif ($selisihProgress == 0){
} elseif ($selisihProgress == 0) {
$return['on-schedule'] += 1;
$projects[$index]->status = 'on-schedule';
}
else {
} else {
$return['behind-schedule'] += 1;
$projects[$index]->status = 'behind-schedule';
}
@ -194,11 +191,9 @@ class DashboardBoDController extends Controller
$selisihProgress = $planningProgress - $actualProgress;
if ($selisihProgress > 0 && $selisihProgress <= 5) {
$warning++;
}
elseif ($selisihProgress == 0){
} elseif ($selisihProgress == 0) {
$onSchedule++;
}
else {
} else {
$behindSchedule++;
}
}

195
app/Http/Controllers/MenuCompanyController.php

@ -0,0 +1,195 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\MenuCompany;
use App\Models\RoleMenu;
use Illuminate\Support\Facades\Log;
class MenuCompanyController extends Controller
{
// public function add(Request $request)
// {
// $this->validate($request, [
// 'icon' => 'required',
// 'name' => 'string|required',
// 'url' => 'required|unique:m_company_menu,url',
// 'sequence' => 'required|integer',
// ]);
// $data = $request->all();
// $data['created_by'] = $this->currentName;
// $result = MenuCompany::create($data);
// if ($result) {
// return response()->json(['status' => 'success', 'message' => 'add data menu successfully!', 'code' => 200], 200);
// } else {
// return response()->json(['status' => 'failed', 'message' => 'add data menu failed!', 'code' => 400], 400);
// }
// }
public function addMultiple(Request $request)
{
$menus = $request->all();
if (is_array($menus) && count($menus) > 0) {
$countRes = 0;
foreach ($menus as $menu) {
$dataInsert = array(
"menu_id" => $menu['menu_id'],
"parent_menu_id" => $menu['parent_id'],
"company_id" => $menu['company_id'],
"icon" => $menu['icon'],
"alias_name" => $menu['alias_name'],
"url" => $menu['url'],
"sequence" => $menu['sequence'],
"created_by" => $this->currentName
);
$result = MenuCompany::create($dataInsert);
if ($result) {
$countRes++;
} else {
$countRes--;
}
}
if ($countRes > 0) {
return response()->json(['status' => 'success', 'message' => 'add data menu successfully!', 'code' => 200]);
} else {
return response()->json(['status' => 'failed', 'message' => 'add data menu failed created!', 'code' => 400]);
}
} else {
return response()->json(['status' => 'failed', 'message' => 'add data menu failed created!', 'code' => 400]);
}
}
public function edit($id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
die();
}
$result = MenuCompany::find($id);
if ($result) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get data menu, please try again later!', 'code' => 400], 400);
}
}
public function update(Request $request, $id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
}
$this->validate($request, [
'icon' => 'required',
'sequence' => 'required|integer',
]);
$data = MenuCompany::find($id);
if ($data) {
$result = $data->update($request->all());
} else {
return response()->json(['status' => 'failed', 'message' => 'data menu not found!', 'code' => 400], 400);
die();
}
if ($result) {
return response()->json(['status' => 'success', 'message' => 'data menu successfully updated!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data menu failed updated!', 'code' => 400], 400);
}
}
public function delete($id)
{
$data = MenuCompany::find($id);
if ($data) {
$delete = $data->delete();
} else {
return response()->json(['status' => 'failed', 'message' => 'data menu not found!', 'code' => 400], 400);
die();
}
if ($delete) {
return response()->json(['status' => 'success', 'message' => 'data menu successfully deleted!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data menu failed deleted!', 'code' => 400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_company_menu');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
}
public function listMenu($id)
{
$dataParent = RoleMenu::select("m_company_menu.*")
->join('m_company_menu', 'm_company_menu.id', '=', 't_roles_menu.menu_id')
->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id')
->whereNull('m_company_menu.parent_id')
->where('m_roles.id', $id)
->orderBy('m_company_menu.sequence', 'ASC')
->get();
$finalData = [];
foreach ($dataParent as $data) {
$data->children = $this->getChildrenMenu($data->id, $id);
$finalData[] = $data;
}
return response()->json(['status' => 'success', 'code' => 200, 'data' => $finalData], 200);
}
protected function getChildrenMenu($id, $role_id)
{
$dataChildren = RoleMenu::select("m_company_menu.*")
->join('m_company_menu', 'm_company_menu.id', '=', 't_roles_menu.menu_id')
->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id')
->where('m_roles.id', $role_id)
->where('m_company_menu.parent_id', $id)
->orderBy('m_company_menu.sequence', 'ASC')
->get();
$children = [];
if ($dataChildren) {
foreach ($dataChildren as $data) {
$data->children = $this->getChildrenMenu($data->id, $role_id);
$children[] = $data;
}
}
return $children;
}
public function list()
{
$data = MenuCompany::all();
$countData = $data->count();
if ($data) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get list menu, please try again later!', 'code' => 400], 400);
}
}
}

131
app/Http/Controllers/ProjectController.php

@ -60,6 +60,7 @@ class ProjectController extends Controller
$data = $request->all();
$data['created_by'] = $this->currentName;
$data['created_by_id'] = $this->currentId;
if (empty($data['phase_id']))
$data['phase_id'] = 1;
@ -90,11 +91,40 @@ class ProjectController extends Controller
// $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')
$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'
)
->join('m_divisi as md', 'md.id', '=', 'm_proyek.divisi_id')
->where('m_proyek.id', $id)
->first();
@ -341,10 +371,13 @@ class ProjectController extends Controller
'projectsByPhase' => $projectsByPhase,
'projectTypes' => $projectTypes,
'projectsByType' => $projectsByType,
], 200);
],
200
);
}
public function getListProjectTask($id){
public function getListProjectTask($id)
{
$data = UserToActivity::select("assign_hr_to_activity.user_id as user_id", "m_proyek.*")
->where("assign_hr_to_activity.user_id", $id)
->join('m_proyek', 'assign_hr_to_activity.proyek_id', '=', 'm_proyek.id')
@ -357,23 +390,27 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
}
public function getSCurve(Request $request){
public function getSCurve(Request $request)
{
$data = MasterFunctionsHelper::getSCurve($request);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
}
// testing
public function calculateSCurvetest(Request $request){
public function calculateSCurvetest(Request $request)
{
$data = MasterFunctionsHelper::calculateSCurve($request->project_id);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
}
public function calculateSCurve(Request $request){
public function calculateSCurve(Request $request)
{
$sCurve = Project::select('scurve')->where('id', $request->project_id)->first();
return response()->json(['status' => 'success', 'code' => 200, 'data' => json_decode($sCurve->scurve)], 200);
}
public function sCurveCommand(Request $request){
public function sCurveCommand(Request $request)
{
Artisan::call('calculate:scurve', [
'project_id' => $request->project_id
]);
@ -388,12 +425,14 @@ class ProjectController extends Controller
// return response()->json(['message' => 'Project not found'], 404);
}
public function getLinearSCurve(Request $request){
public function getLinearSCurve(Request $request)
{
$data = MasterFunctionsHelper::getLinearSCurve($request);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
}
public static function setSyncDate($activity_id, $activity, $report) {
public static function setSyncDate($activity_id, $activity, $report)
{
$status = AssignMaterial::where('activity_id', $activity_id)->first();
if (!isset($status)) {
$reports = array(
@ -492,7 +531,8 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'message' => 'Set baseline success!', 'code' => 200], 200);
}
public function getInvoiceIntegration(Request $request) {
public function getInvoiceIntegration(Request $request)
{
$ganttCount = VersionGantt::where('proyek_id', $request->id)->count();
$search = urlencode($request->search);
if (empty($search))
@ -524,7 +564,8 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200);
}
public function detail(Request $request, $id, $gantt_id = null, $s_curve = null){
public function detail(Request $request, $id, $gantt_id = null, $s_curve = null)
{
if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
@ -543,14 +584,12 @@ class ProjectController extends Controller
if (isset($s_curve)) {
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->first();
$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();
$query = Activity::where('proyek_id', $id);
$maxEndDate = Activity::where('proyek_id', $id)->select('end_date')
->orderBy('end_date', 'desc')
->first();
} else {
// $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists();
$maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date')
@ -594,7 +633,8 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result, 'gantt' => $ganttId], 200);
}
public function getOverdueActivities(Request $request){
public function getOverdueActivities(Request $request)
{
$payload = $request->all();
if (empty($payload['id']) || !is_int((int)$payload['id']))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
@ -613,8 +653,7 @@ class ProjectController extends Controller
} else {
$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'])) {
$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 {
@ -626,15 +665,26 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
}
public function getReportDistribution(Request $request){
public function getReportDistribution(Request $request)
{
$payload = $request->all();
if (empty($payload['project_id']) || !is_int((int)$payload['project_id']))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$reports = DB::table('assign_material_to_activity as ama')
->select('u.name', 'a.name as activity_name', 'ama.qty_planning', 'ram.qty as qty_real','rm.description as material_name', 'rm.uom as material_unit',
'ram.lat', 'ram.lon', 'ram.description as report_notes', 'ram.report_date')
->select(
'u.name',
'a.name as activity_name',
'ama.qty_planning',
'ram.qty as qty_real',
'rm.description as material_name',
'rm.uom as material_unit',
'ram.lat',
'ram.lon',
'ram.description as report_notes',
'ram.report_date'
)
->join('report_activity_material as ram', 'ram.assign_material_id', '=', 'ama.id')
->join('m_req_material as rm', 'rm.id', '=', 'ama.material_id')
->join('m_activity as a', 'a.id', '=', 'ama.activity_id')
@ -646,12 +696,14 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $reports], 200);
}
public function getManpower($proyek_id){
public function getManpower($proyek_id)
{
$manCount = UserToProyek::where('proyek_id', $proyek_id)->count();
return response()->json(['totalRecord' => $manCount]);
}
public function getAssignedHR($gantt_id){
public function getAssignedHR($gantt_id)
{
$results = UserToActivity::select('assign_hr_to_activity.proyek_id', 'assign_hr_to_activity.user_id', 'm_activity.id', 'm_activity.name', 'm_activity.start_date', 'm_activity.end_date')
->join('m_activity', 'm_activity.id', '=', 'assign_hr_to_activity.activity_id')
->where('assign_hr_to_activity.version_gantt_id', $gantt_id)
@ -662,8 +714,17 @@ class ProjectController extends Controller
public function dashboard($id)
{
$data = DB::table('m_proyek as mp')
->select('mp.kode_sortname', 'mp.nama as name_project', 'mp.mulai_proyek as start', 'mp.akhir_proyek as finish',
'mp.rencana_biaya', 'mp.company', 'mp.currency_symbol', 'mu.name as pm', 'mp.budget_health')
->select(
'mp.kode_sortname',
'mp.nama as name_project',
'mp.mulai_proyek as start',
'mp.akhir_proyek as finish',
'mp.rencana_biaya',
'mp.company',
'mp.currency_symbol',
'mu.name as pm',
'mp.budget_health'
)
->join('m_users as mu', 'mu.id', '=', 'mp.pm_id')
->where('mp.id', $id)
->first();
@ -678,8 +739,13 @@ class ProjectController extends Controller
$progress = @$rootActivity->persentase_progress ?? 0;
$commentActivity = DB::table('m_comment_activity as mca')
->select('mca.activity_id', 'mca.comment as comment', 'mca.created_by as comment_by', 'mca.created_at as comment_created',
'ma.name as activity')
->select(
'mca.activity_id',
'mca.comment as comment',
'mca.created_by as comment_by',
'mca.created_at as comment_created',
'ma.name as activity'
)
->join('m_activity as ma', 'ma.id', '=', 'mca.activity_id')
->where('ma.proyek_id', $id)
->orderBy('comment_by')
@ -694,7 +760,8 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
}
private function httpReq($search){
private function httpReq($search)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION));
@ -710,6 +777,4 @@ class ProjectController extends Controller
return json_decode($output);
}
}

37
app/Models/Company.php

@ -0,0 +1,37 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Company extends Model
{
protected $table = 'm_company';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
"registration_no",
"company_name",
"address",
"phone_no",
"email",
"description",
"logo_login",
"logo_header",
"favicon_image",
"login_instruction",
"about",
"html_title",
"app_name",
"base_url",
"is_active",
"template_id",
'created_at',
'created_by',
'updated_at',
'updated_by',
'company_id'
];
}

6
app/Models/Divisi.php

@ -19,10 +19,12 @@ class Divisi extends Model
'created_at',
'created_by',
'updated_at',
'updated_by'
'updated_by',
'company_id'
];
public static function boot() {
public static function boot()
{
parent::boot();
static::deleting(function ($data) {

3
app/Models/HumanResource.php

@ -33,6 +33,7 @@ class HumanResource extends Model
'updated_at',
'updated_by',
'divisi_id',
'status_boundary'
'status_boundary',
'company_id'
];
}

27
app/Models/MenuCompany.php

@ -0,0 +1,27 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class MenuCompany extends Model
{
protected $table = 'm_company_menu';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'menu_id',
'parent_menu_id',
'company_id',
'icon',
'alias_name',
'url',
'sequence',
'created_at',
'created_by',
'updated_at',
'updated_by'
];
}

5
app/Models/Project.php

@ -50,8 +50,7 @@ class Project extends Model
'created_at',
'created_by',
'updated_at',
'updated_by'
'updated_by',
'created_by_id'
];
}

2
app/Models/ProjectPhase.php

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

2
app/Models/ProjectRole.php

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

2
app/Models/ProjectType.php

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

2
app/Models/Role.php

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

2
app/Models/RoleMenu.php

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

2
app/Models/Satuan.php

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

16
routes/web.php

@ -503,6 +503,20 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->post('/broadcast/search', 'BroadcastController@search');
$router->delete('/broadcast/delete/{id}', 'BroadcastController@delete');
$router->get('/broadcast/list', 'BroadcastController@list');
});
$router->post('/company-management/add', 'CompanyController@add');
$router->get('/company-management/edit/{id}', 'CompanyController@edit');
$router->put('/company-management/update/{id}', 'CompanyController@update');
$router->post('/company-management/search', 'CompanyController@search');
$router->delete('/company-management/delete/{id}', 'CompanyController@delete');
$router->get('/company-management/list', 'CompanyController@list');
$router->post('/menu-company/add-multiple', 'MenuCompanyController@addMultiple');
$router->get('/menu-company/edit/{id}', 'MenuCompanyController@edit');
$router->put('/menu-company/update/{id}', 'MenuCompanyController@update');
$router->delete('/menu-company/delete/{id}', 'MenuCompanyController@delete');
$router->post('/menu-company/search', 'MenuCompanyController@search');
$router->get('/menu-company/management/{id}', 'MenuCompanyController@listMenu');
$router->get('/menu-company/list', 'MenuCompanyController@list');
});
});

Loading…
Cancel
Save