Browse Source

Merge branch 'staging' of https://git.oslog.id/ordo/adw-backend into dev-ibnu

pull/3/head
ibnu 1 year ago
parent
commit
ecca24ccfc
  1. 29
      app/Helpers/MasterFunctionsHelper.php
  2. 5
      app/Http/Controllers/ActivityController.php
  3. 49
      app/Http/Controllers/DashboardBoDController.php
  4. 7
      app/Http/Controllers/ProjectController.php
  5. 2
      app/Models/AssignMaterial.php
  6. 2
      app/Models/UserToProyek.php

29
app/Helpers/MasterFunctionsHelper.php

@ -200,8 +200,8 @@ class MasterFunctionsHelper
->where('a.version_gantt_id', '=', $keyGantt['id']) ->where('a.version_gantt_id', '=', $keyGantt['id'])
->max("a.planned_end"); // plan date overlapped with assign_material_to_activity's, it should be m_activity' ->max("a.planned_end"); // plan date overlapped with assign_material_to_activity's, it should be m_activity'
$maxDate = max(new \DateTime($plannedMaxDate), new \DateTime($actualMaxDate)); $maxDate = max(new \DateTime($plannedMaxDate), new \DateTime($actualMaxDate));
$end = $maxDate; $end = new \DateTime($maxDate->format('Y-m-d') . ' Friday');
$end->modify('last month'); $end->modify('next Friday');
$interval = new \DateInterval('P7D'); $interval = new \DateInterval('P7D');
} }
$period = new \DatePeriod($begin, $interval, $end); $period = new \DatePeriod($begin, $interval, $end);
@ -605,6 +605,12 @@ class MasterFunctionsHelper
->where('activity_id', '=', $keyActualM->activity_id) ->where('activity_id', '=', $keyActualM->activity_id)
->groupBy('activity_id') ->groupBy('activity_id')
->first(); ->first();
if (!isset($sumVolActual)) {
$sumVolActual = (object) [
'activity_id' => $keyActualM->activity_id,
'ttl_qty_plan' => "0"
];
}
$sumReportActual = DB::table('report_activity_material') $sumReportActual = DB::table('report_activity_material')
->where('activity_id', $keyActualM->activity_id) ->where('activity_id', $keyActualM->activity_id)
->sum('qty'); ->sum('qty');
@ -624,18 +630,29 @@ class MasterFunctionsHelper
->where('activity_id', '=', $keyActualM->activity_id) ->where('activity_id', '=', $keyActualM->activity_id)
->orderBy('status_activity', 'ASC') ->orderBy('status_activity', 'ASC')
->first(); ->first();
$dataTempReport[$w]['percentage'] = ($keyActualM->qty / $sumVolActual->ttl_qty_plan) * $keyActualM->bobot_planning; if (!isset($checkStatusActivity)) {
$checkStatusActivity = (object) [
'activity_id' => $keyActualM->activity_id,
'status_activity' => 'open'
];
}
if ($sumVolActual->ttl_qty_plan == "0") {
$actual = 0;
} else {
$actual = $keyActualM->qty / $sumVolActual->ttl_qty_plan;
}
$dataTempReport[$w]['percentage'] = $actual * $keyActualM->bobot_planning;
// $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; // $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
// if($keyActualM->qty/$sumVolActual->ttl_qty_plan >= 1){ // if($keyActualM->qty/$sumVolActual->ttl_qty_plan >= 1){
if ($checkStatusActivity->status_activity == 'done') { if ($checkStatusActivity->status_activity == 'done') {
$sumPercentageActual += $keyActualM->bobot_planning / $reportCount; $sumPercentageActual += $keyActualM->bobot_planning / $reportCount;
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual; // $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} else { } else {
if ($keyActualM->qty / $sumVolActual->ttl_qty_plan >= 1 || (int) $sumVolActual->ttl_qty_plan == (int) $sumReportActual) { if ( $actual >= 1 || (int) $sumVolActual->ttl_qty_plan == (int) $sumReportActual) {
$sumPercentageActual += (($keyActualM->qty / $sumVolActual->ttl_qty_plan) * $keyActualM->bobot_planning) * (95 / 100); $sumPercentageActual += ($actual * $keyActualM->bobot_planning) * (95 / 100);
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual; // $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} else { } else {
$sumPercentageActual += ($keyActualM->qty / $sumVolActual->ttl_qty_plan) * $keyActualM->bobot_planning; $sumPercentageActual += $actual * $keyActualM->bobot_planning;
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual; // $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} }
} }

5
app/Http/Controllers/ActivityController.php

@ -248,7 +248,9 @@ class ActivityController extends Controller
$data['created_by'] = $this->currentName; $data['created_by'] = $this->currentName;
$max = Activity::where('version_gantt_id', $request->version_gantt_id)->max('sortorder'); $max = Activity::where('version_gantt_id', $request->version_gantt_id)->max('sortorder');
$data['sortorder'] = $max + 1; $data['sortorder'] = $max + 1;
if (!isset($data['type_activity'])) {
$data['type_activity'] = "task"; $data['type_activity'] = "task";
}
$parent = $data['parent_id'] ?? null; $parent = $data['parent_id'] ?? null;
if ($parent) { if ($parent) {
@ -360,6 +362,9 @@ class ActivityController extends Controller
$activityToUpdate = $activity->firstWhere('id', $entity['data']['id']); $activityToUpdate = $activity->firstWhere('id', $entity['data']['id']);
$entity['data']['name'] = $entity['data']['text']; $entity['data']['name'] = $entity['data']['text'];
$entity['data']['persentase_progress'] = $entity['data']['progress'] * 100; $entity['data']['persentase_progress'] = $entity['data']['progress'] * 100;
if (isset($entity['data']['target'])) {
$this->updateOrder($entity['data']['id'], $entity['data']['target']);
}
if(!$activityToUpdate->update($entity['data'])) if(!$activityToUpdate->update($entity['data']))
return response()->json(['status' => 'failed', 'message' => 'Failed to update activity !', 'code' => 500], 500); return response()->json(['status' => 'failed', 'message' => 'Failed to update activity !', 'code' => 500], 500);
$updatedJobsDone = $activityToUpdate->jobs_done; $updatedJobsDone = $activityToUpdate->jobs_done;

49
app/Http/Controllers/DashboardBoDController.php

@ -14,13 +14,15 @@ use Illuminate\Support\Facades\Log;
class DashboardBoDController extends Controller class DashboardBoDController extends Controller
{ {
private function interpolateYear($year){ private function interpolateYear($year)
{
if ($year) if ($year)
$year = '%' . $year . '%'; $year = '%' . $year . '%';
return $year; return $year;
} }
private function curlReq($url, $token){ private function curlReq($url, $token)
{
$ch = curl_init(); $ch = curl_init();
$headers = [ $headers = [
'Authorization: ' . $token 'Authorization: ' . $token
@ -37,7 +39,8 @@ class DashboardBoDController extends Controller
return json_decode($response); return json_decode($response);
} }
private function getInvoiceIntegration($search) { private function getInvoiceIntegration($search)
{
// 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);
// //
@ -52,7 +55,8 @@ class DashboardBoDController extends Controller
} }
// to do // to do
public function getCompanyCashFlow($year = '%') { public function getCompanyCashFlow($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$totalExpenditure = $totalInvoice = $totalPaidInvoice = 0; $totalExpenditure = $totalInvoice = $totalPaidInvoice = 0;
@ -92,7 +96,8 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
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)
/* ->orWhere('akhir_proyek', 'like', $year) */ /* ->orWhere('akhir_proyek', 'like', $year) */
@ -117,7 +122,8 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
public function getTotalProjectPerScheduleHealth($year = '%'){ public function getTotalProjectPerScheduleHealth($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$return = [ $return = [
@ -152,7 +158,8 @@ class DashboardBoDController extends Controller
return response()->json(['data' => $return, 'q' => $projects], 200); return response()->json(['data' => $return, 'q' => $projects], 200);
} }
public function getTotalProjectScheduleHealthPerDivision($year = '%'){ public function getTotalProjectScheduleHealthPerDivision($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::whereNull('parent')->get(); $divisions = Divisi::whereNull('parent')->get();
@ -184,7 +191,8 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
public function getTotalProjectPerBudgetHealth($year = '%'){ public function getTotalProjectPerBudgetHealth($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
return response()->json([ return response()->json([
'data' => [ 'data' => [
@ -195,7 +203,8 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
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)
/* ->orWhere('akhir_proyek', 'like', $year) */ /* ->orWhere('akhir_proyek', 'like', $year) */
@ -204,7 +213,8 @@ class DashboardBoDController extends Controller
} }
public function getTotalProjectBudgetHealthPerDivision($year = '%'){ public function getTotalProjectBudgetHealthPerDivision($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name') $divisions = Divisi::select('id', 'name')
->with('children') ->with('children')
@ -233,7 +243,8 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
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();
foreach ($projectPhases as $phase) { foreach ($projectPhases as $phase) {
@ -249,13 +260,15 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
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)
->count(); ->count();
} }
public function getTotalProjectPerDivision($year = '%') { public function getTotalProjectPerDivision($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name') $divisions = Divisi::select('id', 'name')
@ -277,7 +290,8 @@ class DashboardBoDController extends Controller
], 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)
/* ->orWhere('akhir_proyek', 'like', $year) */ /* ->orWhere('akhir_proyek', 'like', $year) */
@ -286,7 +300,8 @@ class DashboardBoDController extends Controller
->first(); ->first();
} }
public function getTotalProjectValuePerDivision($year = '%') { public function getTotalProjectValuePerDivision($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name') $divisions = Divisi::select('id', 'name')
@ -309,7 +324,8 @@ class DashboardBoDController extends Controller
} }
public function getDetailExpenditure($year = '%'){ public function getDetailExpenditure($year = '%')
{
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$projects = Project::where('mulai_proyek', 'like', $year) $projects = Project::where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */ /* ->orWhere('akhir_proyek', 'like', $year) */
@ -343,4 +359,3 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
} }

7
app/Http/Controllers/ProjectController.php

@ -278,7 +278,7 @@ class ProjectController extends Controller
} }
try { try {
$projectsByType = DB::table('m_proyek') $projectsByType = DB::table('m_proyek')
->select('m_type_proyek.name', DB::raw('count(id) as total')) ->select('m_type_proyek.name', DB::raw('count(m_type_proyek.id) as total'))
->join('m_type_proyek', 'm_type_proyek.id', '=', 'm_proyek.type_proyek_id') ->join('m_type_proyek', 'm_type_proyek.id', '=', 'm_proyek.type_proyek_id')
->groupBy('m_type_proyek.name') ->groupBy('m_type_proyek.name')
->get(); ->get();
@ -340,7 +340,10 @@ class ProjectController extends Controller
public static function setSyncDate($activity_id, $activity, $report) { public static function setSyncDate($activity_id, $activity, $report) {
$status = AssignMaterial::select('status_activity')->where('activity_id', $activity_id)->first(); $status = AssignMaterial::select('status_activity')->where('activity_id', $activity_id)->first();
if (isset($status->status_activity) && $status->status_activity != 'done') { if (!isset($status->status_activity)) {
$status->status_activity = 'open';
}
if ($status->status_activity != 'done') {
$minDate = date_create($report->report_date); $minDate = date_create($report->report_date);
$maxDate = date_create($report->report_date); $maxDate = date_create($report->report_date);
date_add($maxDate, date_interval_create_from_date_string($activity->duration . " days")); date_add($maxDate, date_interval_create_from_date_string($activity->duration . " days"));

2
app/Models/AssignMaterial.php

@ -5,6 +5,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use App\Models\RequestMaterial; use App\Models\RequestMaterial;
use App\Models\Activity; use App\Models\Activity;
use App\Models\ReportActivityMaterial;
class AssignMaterial extends Model class AssignMaterial extends Model
{ {
@ -35,6 +36,7 @@ class AssignMaterial extends Model
}); });
static::deleted(function($data) { static::deleted(function($data) {
$reportActivities = ReportActivityMaterial::where('assign_material_id', $data->id)->delete();
$activity = Activity::where('id', $data->activity_id)->first(); $activity = Activity::where('id', $data->activity_id)->first();
$activity->rencana_biaya -= floatval($data->budget) * floatval($data->qty_planning); $activity->rencana_biaya -= floatval($data->budget) * floatval($data->qty_planning);
$activity->save(); $activity->save();

2
app/Models/UserToProyek.php

@ -14,6 +14,6 @@ class UserToProyek extends Model
protected $fillable = [ protected $fillable = [
'user_id', 'proyek_id', 'rbs', 'project_role', 'group_r', 'max_used', 'standart_rate', 'user_id', 'proyek_id', 'rbs', 'project_role', 'group_r', 'max_used', 'standart_rate',
'uom_standart_rate', 'overtime_rate', 'uom_overtime_rate', 'cost_per_used', 'accrue_at', 'uom_standart_rate', 'overtime_rate', 'uom_overtime_rate', 'cost_per_used', 'accrue_at',
'base_calender', 'created_at', 'created_by', 'updated_at', 'updated_by' 'base_calender', 'is_customer', 'created_at', 'created_by', 'updated_at', 'updated_by'
]; ];
} }

Loading…
Cancel
Save