Browse Source

fix conflict

pull/3/head
Wahyu Ramadhan 2 years ago
parent
commit
44229b2839
  1. 115
      app/Http/Controllers/DashboardBoDController.php
  2. 29
      app/Models/Activity.php

115
app/Http/Controllers/DashboardBoDController.php

@ -2,7 +2,6 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
<<<<<<< HEAD
use App\Helpers\MasterFunctionsHelper; use App\Helpers\MasterFunctionsHelper;
use App\Models\Divisi; use App\Models\Divisi;
use App\Models\Project; use App\Models\Project;
@ -11,13 +10,6 @@ use App\Models\User;
use App\Models\UserToVersionGantt; use App\Models\UserToVersionGantt;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
=======
use App\Models\Project;
use App\Models\Divisi;
use App\Models\ProjectPhase;
use Illuminate\Support\Collection;
use DB;
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
class DashboardBoDController extends Controller class DashboardBoDController extends Controller
{ {
@ -27,7 +19,6 @@ class DashboardBoDController extends Controller
return $year; return $year;
} }
<<<<<<< HEAD
private function curlReq($url, $token){ private function curlReq($url, $token){
$ch = curl_init(); $ch = curl_init();
$headers = [ $headers = [
@ -63,15 +54,10 @@ class DashboardBoDController extends Controller
public function getCompanyCashFlow($year = '%') { public function getCompanyCashFlow($year = '%') {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$totalExpenditure = $totalInvoice = $totalPaidInvoice = 0; $totalExpenditure = $totalInvoice = $totalPaidInvoice = 0;
=======
public function getCompanyCashFlow($year = '%') {
$year = $this->interpolateYear($year);
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
// we can't use eloquent's sum() method because someone decided to use varchar as datatype in rencana_biaya field // we can't use eloquent's sum() method because someone decided to use varchar as datatype in rencana_biaya field
$totalBudgets = Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))')) $totalBudgets = Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))'))
->where('mulai_proyek', 'like', $year) ->where('mulai_proyek', 'like', $year)
<<<<<<< HEAD
/* ->orWhere('akhir_proyek', 'like', $year) */ /* ->orWhere('akhir_proyek', 'like', $year) */
->pluck('sum') ->pluck('sum')
->first(); ->first();
@ -101,22 +87,10 @@ class DashboardBoDController extends Controller
'total_expenditure' => $totalExpenditure, 'total_expenditure' => $totalExpenditure,
'total_invoice' => $totalInvoice, 'total_invoice' => $totalInvoice,
'total_paid_invoice' => $totalPaidInvoice , 'total_paid_invoice' => $totalPaidInvoice ,
=======
->pluck('sum')
->first();
return response()->json([
'data' => [
'total_budget' => (int) $totalBudgets ?? rand(0,10),
'total_expenditure' => rand(0,10), // to do integrasi
'total_invoice' => rand(0,10),
'total_paid_invoice' => rand(0,10),
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
] ]
], 200); ], 200);
} }
<<<<<<< HEAD
public function getInvoiceOutstanding($year = '%'){ public function getInvoiceOutstanding($year = '%'){
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$projects = Project::where('mulai_proyek', 'like', $year) $projects = Project::where('mulai_proyek', 'like', $year)
@ -170,27 +144,10 @@ class DashboardBoDController extends Controller
} }
public function getTotalProjectScheduleHealthPerDivision($year = '%'){ public function getTotalProjectScheduleHealthPerDivision($year = '%'){
=======
public function getProjectPerScheduleHealth($year = '%'){
$year = $this->interpolateYear($year);
// get data plan (vol) in %
// get data actual in %
return response()->json([
'data' => [
'behind-schedule' => rand(0,10),
'warning' => rand(0,10),
'on-schedule' => rand(0,10),
]
], 200);
}
public function getProjectScheduleHealthPerDivision($year = '%'){
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::whereNull('parent')->get(); $divisions = Divisi::whereNull('parent')->get();
foreach($divisions as $division){ foreach($divisions as $division){
<<<<<<< HEAD
$scheduleData = new Collection(); $scheduleData = new Collection();
$behindSchedule = $warning = $onSchedule = 0; $behindSchedule = $warning = $onSchedule = 0;
@ -209,12 +166,6 @@ class DashboardBoDController extends Controller
$scheduleData->prepend($behindSchedule, 'behindSchedule'); $scheduleData->prepend($behindSchedule, 'behindSchedule');
$scheduleData->prepend($warning, 'warning'); $scheduleData->prepend($warning, 'warning');
$scheduleData->prepend($onSchedule, 'onSchedule'); $scheduleData->prepend($onSchedule, 'onSchedule');
=======
$scheduleData = new Collection();
$scheduleData->prepend(rand(0, 10), 'behindSchedule');
$scheduleData->prepend(rand(0, 10), 'warning');
$scheduleData->prepend(rand(0, 10), 'onSchedule');
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
$division->scheduleData = $scheduleData; $division->scheduleData = $scheduleData;
} }
return response()->json([ return response()->json([
@ -224,7 +175,6 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
<<<<<<< HEAD
public function getTotalProjectPerBudgetHealth($year = '%'){ public function getTotalProjectPerBudgetHealth($year = '%'){
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
return response()->json([ return response()->json([
@ -232,20 +182,10 @@ class DashboardBoDController extends Controller
'overrun' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'overrun')->count(), 'overrun' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'overrun')->count(),
'warning' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'warning')->count(), 'warning' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'warning')->count(),
'on-budget' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'on-budget')->count(), 'on-budget' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'on-budget')->count(),
=======
public function getProjectPerBudgetHealth($year = '%'){
$year = $this->interpolateYear($year);
return response()->json([
'data' => [
'overrun' => rand(0,10),
'warning' => rand(0,10),
'on-budget' => rand(0,10),
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
] ]
], 200); ], 200);
} }
<<<<<<< HEAD
private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health){ private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health){
return Project::where('divisi_id', $divisi) return Project::where('divisi_id', $divisi)
->where('mulai_proyek', 'like', $year) ->where('mulai_proyek', 'like', $year)
@ -277,19 +217,6 @@ class DashboardBoDController extends Controller
} }
foreach($divisions as $division){ foreach($divisions as $division){
} }
=======
public function getProjectBudgetHealthPerDivision($year = '%'){
$year = $this->interpolateYear($year);
$divisions = Divisi::whereNull('parent')->get();
foreach($divisions as $division){
$budgetData = new Collection();
$budgetData->prepend(rand(0, 10), 'overrun');
$budgetData->prepend(rand(0, 10), 'warning');
$budgetData->prepend(rand(0, 10), 'onBudget');
$division->budgetData = $budgetData;
}
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
return response()->json([ return response()->json([
'data' => [ 'data' => [
$divisions $divisions
@ -297,7 +224,6 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
<<<<<<< HEAD
public function getTotalProjectPerPhase($year = '%'){ public function getTotalProjectPerPhase($year = '%'){
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$projectPhases = ProjectPhase::orderBy('order')->get(); $projectPhases = ProjectPhase::orderBy('order')->get();
@ -306,13 +232,6 @@ class DashboardBoDController extends Controller
->where('mulai_proyek', 'like', $year) ->where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */ /* ->orWhere('akhir_proyek', 'like', $year) */
->count(); ->count();
=======
public function getProjectPerPhase($year = '%'){
$year = $this->interpolateYear($year);
$projectPhases = ProjectPhase::orderBy('order')->get();
foreach($projectPhases as $phase){
$phase->totalProject = rand(0,10);
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
} }
return response()->json([ return response()->json([
'data' => [ 'data' => [
@ -324,31 +243,19 @@ class DashboardBoDController extends Controller
private function countTotalProjectInDivision($id, $year){ private function countTotalProjectInDivision($id, $year){
return Project::where('divisi_id', $id) return Project::where('divisi_id', $id)
->where('mulai_proyek', 'like', $year) ->where('mulai_proyek', 'like', $year)
<<<<<<< HEAD
/* ->orWhere('akhir_proyek', 'like', $year) */
=======
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
->count(); ->count();
} }
public function getTotalProjectPerDivision($year = '%') { public function getTotalProjectPerDivision($year = '%') {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
<<<<<<< HEAD
$divisions = Divisi::select('id','name') $divisions = Divisi::select('id','name')
=======
$totalProjectPerDivision = Divisi::select('id','name')
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
->with('children') ->with('children')
->whereNull('parent') ->whereNull('parent')
->get(); ->get();
// to do : count in more than 1 level child // to do : count in more than 1 level child
<<<<<<< HEAD
foreach($divisions as $v){ foreach($divisions as $v){
=======
foreach($totalProjectPerDivision as $v){
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
$v->total = $this->countTotalProjectInDivision($v->id, $year); $v->total = $this->countTotalProjectInDivision($v->id, $year);
foreach($v->children as $d){ foreach($v->children as $d){
$v->total += $this->countTotalProjectInDivision($d->id, $year); $v->total += $this->countTotalProjectInDivision($d->id, $year);
@ -357,21 +264,14 @@ class DashboardBoDController extends Controller
} }
return response()->json([ return response()->json([
<<<<<<< HEAD
'data' => $divisions 'data' => $divisions
=======
'data' => $totalProjectPerDivision
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
], 200); ], 200);
} }
private function countTotalProjectValueInDivision($id, $year){ private function countTotalProjectValueInDivision($id, $year){
return Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))')) return Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))'))
->where('mulai_proyek', 'like', $year) ->where('mulai_proyek', 'like', $year)
<<<<<<< HEAD
/* ->orWhere('akhir_proyek', 'like', $year) */ /* ->orWhere('akhir_proyek', 'like', $year) */
=======
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
->where('divisi_id', $id) ->where('divisi_id', $id)
->pluck('sum') ->pluck('sum')
->first(); ->first();
@ -380,21 +280,13 @@ class DashboardBoDController extends Controller
public function getTotalProjectValuePerDivision($year = '%') { public function getTotalProjectValuePerDivision($year = '%') {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
<<<<<<< HEAD
$divisions = Divisi::select('id','name') $divisions = Divisi::select('id','name')
=======
$totalProjectValuePerDivision = Divisi::select('id','name')
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
->with('children') ->with('children')
->whereNull('parent') ->whereNull('parent')
->get(); ->get();
// to do : count in more than 1 level child // to do : count in more than 1 level child
<<<<<<< HEAD
foreach($divisions as $v){ foreach($divisions as $v){
=======
foreach($totalProjectValuePerDivision as $v){
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
$v->total = $this->countTotalProjectValueInDivision($v->id, $year); $v->total = $this->countTotalProjectValueInDivision($v->id, $year);
foreach($v->children as $d){ foreach($v->children as $d){
$v->total += $this->countTotalProjectValueInDivision($d->id, $year); $v->total += $this->countTotalProjectValueInDivision($d->id, $year);
@ -403,7 +295,6 @@ class DashboardBoDController extends Controller
} }
return response()->json([ return response()->json([
<<<<<<< HEAD
'data' => $divisions 'data' => $divisions
], 200); ], 200);
} }
@ -438,11 +329,5 @@ class DashboardBoDController extends Controller
'total_manpowers' => User::count() 'total_manpowers' => User::count()
], 200); ], 200);
} }
=======
'data' => $totalProjectValuePerDivision
], 200);
}
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
} }

29
app/Models/Activity.php

@ -85,32 +85,10 @@ class Activity extends Model
private function updateBobot($isDelete = false) private function updateBobot($isDelete = false)
{ {
<<<<<<< HEAD
$root = Activity::where('version_gantt_id', $this->version_gantt_id) $root = Activity::where('version_gantt_id', $this->version_gantt_id)
->where("proyek_id", $this->proyek_id) ->where("proyek_id", $this->proyek_id)
->whereNull('parent_id') ->whereNull('parent_id')
->first(); ->first();
=======
$rootActivity = Activity::where('version_gantt_id', $this->version_gantt_id)
->where("proyek_id", $this->proyek_id)
->where('type_activity', 'header')
->first();
if(Activity::where('version_gantt_id', $this->version_gantt_id)->where("proyek_id", $this->proyek_id)->where('type_activity', 'header')->count() == 0) {
$totalCost = Activity::select(
DB::raw('sum(cast(rencana_biaya as double precision))')
)
->where("proyek_id", $this->proyek_id)
->where("version_gantt_id", $this->version_gantt_id)
->whereNull("parent_id")
->first();
} else {
$totalCost = Activity::select(DB::raw('sum(cast(rencana_biaya as double precision))'))
->where("proyek_id", $this->proyek_id)
->where("version_gantt_id", $this->version_gantt_id)
->where("parent_id", $rootActivity->id)
->first();
}
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
if($root->rencana_biaya > 0){ if($root->rencana_biaya > 0){
$activities = Activity::where("proyek_id", $this->proyek_id)->where("version_gantt_id", $this->version_gantt_id)->get(); $activities = Activity::where("proyek_id", $this->proyek_id)->where("version_gantt_id", $this->version_gantt_id)->get();
@ -206,14 +184,7 @@ class Activity extends Model
public function getJobsDoneAttribute() public function getJobsDoneAttribute()
{ {
<<<<<<< HEAD
if(!ReportActivityMaterial::where('activity_id', $this->id)->first()) if(!ReportActivityMaterial::where('activity_id', $this->id)->first())
=======
$tmpPercentage = [];
if(!ReportActivityMaterial::where('activity_id', $this->id)->first())
return 0;
if(!$dataPlan = AssignMaterial::where('activity_id', $this->id)->get())
>>>>>>> 3f193ec38ec78bd3d323b4aa304c5e1ab52425b6
return 0; return 0;
if(!$dataPlan = AssignMaterial::where('activity_id', $this->id)->get()) if(!$dataPlan = AssignMaterial::where('activity_id', $this->id)->get())
return 0; return 0;

Loading…
Cancel
Save