Browse Source

Merge pull request 'staging' (#201) from staging into master

Reviewed-on: ordo/adw-backend#201
pull/3/head
ibnu 1 year ago
parent
commit
c868bcca30
  1. 19
      app/Http/Controllers/ActivityController.php
  2. 4
      app/Http/Controllers/ProjectController.php
  3. 2
      app/Http/Controllers/ReportActivityMaterialController.php
  4. 2
      app/Models/ReportActivityMaterial.php

19
app/Http/Controllers/ActivityController.php

@ -3,6 +3,7 @@ namespace App\Http\Controllers;
use App\Helpers\MasterFunctionsHelper;
use App\Models\Activity;
use App\Models\AssignMaterial;
use App\Models\CommentActivity;
use App\Models\Link;
use App\Models\Project;
@ -422,7 +423,14 @@ class ActivityController extends Controller
return response()->json(['status' => 'failed', 'message' => 'Activities not found!', 'code' => 404], 404);
$duration = 0;
foreach ($activities as $key => $activity) {
if (isset($activity->planned_start) && isset($activity->planned_end)) {
$assignMaterial = AssignMaterial::where('activity_id', $activity->id)->first();
if (isset($assignMaterial)) {
$statusActivity = $assignMaterial->status_activity;
} else {
$statusActivity = '';
}
if (isset($activity->planned_start) && isset($activity->planned_end) && $statusActivity != "done") {
// todo check report for no report / progress == 0
$today = new DateTime();
$endDate = new DateTime($activity->end_date);
$startDate = new DateTime($activity->start_date);
@ -431,11 +439,12 @@ class ActivityController extends Controller
$duration = MasterFunctionsHelper::countDays($ganttId, $plannedStart, $plannedEnd);
if ($today >= $endDate) {
$endDate = $today;
$rerataBobot = $duration > 0 ? $activity->bobot_planning / $duration : 0;
$bobotActual = $activity->progress * $activity->bobot_planning;
$sisaBobot = $activity->bobot_planning - $bobotActual;
$bobotPlanning = (int) $activity->bobot_planning;
$rerataBobot = $duration > 0 ? $bobotPlanning / $duration : 0;
$bobotActual = (int) $activity->persentase_progress/100 * $bobotPlanning;
$sisaBobot = $bobotPlanning - $bobotActual;
$sisaHari = $rerataBobot > 0 ? $sisaBobot / $rerataBobot : 0;
$endDate->modify("+".$sisaHari." Days");
$endDate->modify("+".ceil($sisaHari)." Days");
$actualDuration = MasterFunctionsHelper::countDays($ganttId, $startDate, $endDate);
$activity->duration = $actualDuration;
$activity->end_date = $endDate;

4
app/Http/Controllers/ProjectController.php

@ -466,12 +466,16 @@ class ProjectController extends Controller
}
public function getInvoiceIntegration(Request $request) {
$ganttCount = VersionGantt::where('proyek_id', $request->id)->count();
$search = urlencode($request->search);
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');
$response = MasterFunctionsHelper::curlReq($url);
if (isset($request->gantt_id)) {
$response->data->total_cost = $response->data->total_cost / $ganttCount;
}
return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200);
}

2
app/Http/Controllers/ReportActivityMaterialController.php

@ -63,6 +63,8 @@ class ReportActivityMaterialController extends Controller
$sumAssignMaterial = AssignMaterial::where('activity_id', $request->activity_id)->sum('qty_planning');
$sumReportActivityMaterial = ReportActivityMaterial::where('activity_id', $request->activity_id)->sum('qty');
$dataUpdate = array(
"actual_start" => null,
"actual_end" => null,
"persentase_progress" => $sumReportActivityMaterial/$sumAssignMaterial*100,
"updated_by" => $this->currentName
);

2
app/Models/ReportActivityMaterial.php

@ -59,6 +59,8 @@ class ReportActivityMaterial extends Model
$assignedMaterial = AssignMaterial::find($data->assign_material_id);
$activity->biaya_actual -= floatval($assignedMaterial->budget) * floatval($data->qty);
$activity->actual_start = null;
$activity->actual_end = null;
$dataPlan = AssignMaterial::where('activity_id', $activity->id)->get();
$totalPlan = $dataPlan->sum('qty_planning');

Loading…
Cancel
Save