Browse Source

Fix date range

pull/3/head
Wahyu Ramadhan 1 year ago
parent
commit
d782797bef
  1. 15
      app/Helpers/MasterFunctionsHelper.php

15
app/Helpers/MasterFunctionsHelper.php

@ -189,14 +189,19 @@ class MasterFunctionsHelper
/* $interval = \DateInterval::createFromDateString('1 day'); */// should be using this but its bugged /* $interval = \DateInterval::createFromDateString('1 day'); */// should be using this but its bugged
$interval = new \DateInterval('P7D'); $interval = new \DateInterval('P7D');
} else { } else {
$maxDate = DB::table('assign_material_to_activity as ama') $actualMaxDate = DB::table('assign_material_to_activity as ama')
->where("ama.proyek_id", $keyGantt['proyek_id']) ->where("ama.proyek_id", $keyGantt['proyek_id'])
->join('m_activity as a', 'a.id', '=', 'ama.activity_id') ->join('m_activity as a', 'a.id', '=', 'ama.activity_id')
->where('a.version_gantt_id', '=', $keyGantt['id']) ->where('a.version_gantt_id', '=', $keyGantt['id'])
->max("plan_date"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's ->max("a.end_date"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's
$end = new \DateTime($maxDate . ' Friday'); $plannedMaxDate = DB::table('assign_material_to_activity as ama')
$end->modify('next Friday'); ->where("ama.proyek_id", $keyGantt['proyek_id'])
$end->modify('next Friday'); ->join('m_activity as a', 'a.id', '=', 'ama.activity_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'
$maxDate = max(new \DateTime($plannedMaxDate), new \DateTime($actualMaxDate));
$end = $maxDate;
$end->modify('last month');
$interval = new \DateInterval('P7D'); $interval = new \DateInterval('P7D');
} }
$period = new \DatePeriod($begin, $interval, $end); $period = new \DatePeriod($begin, $interval, $end);

Loading…
Cancel
Save