Esempio n. 1
0
 /**
  * Get montly timesheets for the specified workspace, member and year
  * @param object $workspace target Workspace instance
  * @param object $account target Account instance
  * @param int $year target year
  * @return object Andy\Api\LiquidPlanner\TimesheetYear instance
  */
 public function getMemberYearlyTimesheet(Workspace $workspace, Account $account, $year)
 {
     // Get all available day instances
     // @note: limit source data pool
     $days = $this->getMemberTimesheetDays($workspace, $account);
     // Get initial instance
     $result = TimesheetYear::loadForYear($year);
     // Create month instances
     for ($month = 1; $month <= 12; ++$month) {
         // Create new month
         $instance = TimesheetMonth::loadForDate($year . '-' . $month);
         // Go trough days
         foreach ($days as $day) {
             if ($day->getYear() !== $instance->getYear()) {
                 continue;
             }
             if ($day->getMonth() !== $instance->getMonth()) {
                 continue;
             }
             $instance->addDay($day);
         }
         // Add to list
         $result->addMonth($instance);
     }
     // Set employment time
     $result->setEmployedTime($account->getCreatedTime());
     return $result;
 }
Esempio n. 2
0
 /**
  * Get month instances for each month in this year
  * @return array list of Andy\Api\LiquidPlanner\TimesheetMonth instances
  *               indexed by month number
  */
 public function getYearMonths()
 {
     $result = array();
     // Limit months when dealing with active month
     $last = intval(date('Y')) === $this->getYear() ? intval(date('n')) : 12;
     // Make sure we have instances for each day in month
     for ($i = 1, $j = $last; $i <= $j; ++$i) {
         $result[$i] = TimesheetMonth::loadForDate(sprintf('%s-%s-01', $this->getYear(), $i));
     }
     return $result;
 }