Browse Source

Merge pull request 'Fix date range' (#125) from dev-wahyu into staging

Reviewed-on: ordo/adw-backend#125
pull/3/head
ibnu 1 year ago
parent
commit
09bd63c8da
  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 = new \DateInterval('P7D');
} 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'])
->join('m_activity as a', 'a.id', '=', 'ama.activity_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
$end = new \DateTime($maxDate . ' Friday');
$end->modify('next Friday');
$end->modify('next Friday');
->max("a.end_date"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's
$plannedMaxDate = DB::table('assign_material_to_activity as ama')
->where("ama.proyek_id", $keyGantt['proyek_id'])
->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');
}
$period = new \DatePeriod($begin, $interval, $end);

Loading…
Cancel
Save