Browse Source

fix real progress

pull/3/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
8a6cb2b894
  1. 21
      app/Http/Controllers/ProjectController.php
  2. 10
      app/Models/ReportActivity.php

21
app/Http/Controllers/ProjectController.php

@ -20,6 +20,7 @@ use App\Models\ProjectParticipants;
use App\Models\ProjectPhase;
use App\Models\ProjectType;
use App\Models\ReportActivity;
use App\Models\ReportActivityMaterial;
use App\Models\ShowHideColumn;
use App\Models\User;
use App\Models\UserToActivity;
@ -384,7 +385,7 @@ class ProjectController extends Controller
->where("ama.proyek_id", $keyGantt['proyek_id'])
->join('m_activity as a', 'a.id', '=', 'ama.activity_id')
->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id'])
->max("planned_end");
->max("plan_date");
/* ->whereNull('deleted_at') */
/* ->get(); */
/* ->max("plan_date"); */ // plan date overlapped with assign_material_to_activity's, it should be m_activity's
@ -407,6 +408,9 @@ class ProjectController extends Controller
$currentACWP = 0;
$currentBCWP = 0;
/* foreach($period as $x){ */
/* echo $x->format("Y-m-d")."\n"; */
/* } exit(); */
foreach ($period as $dt) {
$dataPlanM = DB::table('assign_material_to_activity as ama')
->select('ama.activity_id', 'ama.qty_planning', 'ama.plan_date', 'ama.start_activity', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress')
@ -420,7 +424,8 @@ class ProjectController extends Controller
->join('m_activity as a', 'a.id', '=', 'ram.activity_id')
->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id'])
->where('a.proyek_id', '=', $keyGantt['proyek_id'])
->whereDate('ram.report_date', $dt->format("Y-m-d"))
->whereDate('ram.report_date', '<',$dt->format("Y-m-d"))
->whereDate('ram.report_date', '>',$dt->modify('-7 day')->format("Y-m-d"))
->get();
$dataTempPlan = [];
$x = 0;
@ -683,9 +688,9 @@ class ProjectController extends Controller
foreach($activities as $activity) {
$activity_id = $activity->id;
$countReports = ReportActivity::where('activity_id', $activity_id)->count();
$countReports = ReportActivityMaterial::where('activity_id', $activity_id)->count();
if ($countReports === 1) {
$dataReports = ReportActivity::where('activity_id', $activity_id)->orderBy('report_date')->get();
$dataReports = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->get();
foreach($dataReports as $dr) {
$reports[] = array(
'activity_id'=>$activity_id,
@ -695,16 +700,18 @@ class ProjectController extends Controller
}
}
if ($countReports > 1) {
$firstReport = ReportActivity::where('activity_id', $activity_id)->orderBy('report_date')->first();
$lastReport = ReportActivity::where('activity_id', $activity_id)->orderByDesc('report_date')->first();
$firstReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->first();
$lastReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderByDesc('report_date')->first();
$reports[] = array(
'activity_id'=>$activity_id,
'min_date'=>$firstReport->report_date,
'max_date'=>date_modify(date_create($lastReport->report_date), "1 days")
);
}
$activity->reports = $reports;
}
/* return response()->json(['status'=>'success','data'=> $reports,'code'=>200], 200); */
/* return response()->json(['status'=>'success','data'=> $activities,'code'=>200], 200); */
for ($i=0; $i < count($reports); $i++) {
$activity = Activity::find($reports[$i]['activity_id']);

10
app/Models/ReportActivity.php

@ -12,16 +12,16 @@ class ReportActivity extends Model
const UPDATED_AT = 'updated_at';
protected $fillable = [
'activity_id',
'user_id',
'activity_id',
'user_id',
'report_date',
'job_count_report',
'description',
'lat',
'lon',
'created_at',
'created_by',
'updated_at',
'created_at',
'created_by',
'updated_at',
'updated_by'
];
}

Loading…
Cancel
Save