public function getTimePeriodByDate(ServiceBase $api, $args) { if (!isset($args["date"]) || $args["date"] == 'undefined') { // return a 404 throw new SugarApiExceptionNotFound(); } $tp = TimePeriod::retrieveFromDate($args["date"]); return $tp ? $tp->toArray() : $tp; }
/** * Checks to see if a worksheet item being saved has jumped timeperiods. * * @param date $worksheetDate * @param date $objDate * * @return bool */ protected function timeperiodHasMigrated($worksheetDate, $objDate) { $return = false; //if the close dates are different, we need to see if the obj is in a new timeperiod if ($worksheetDate != $objDate) { $tp1 = TimePeriod::retrieveFromDate($worksheetDate); $tp2 = TimePeriod::retrieveFromDate($objDate); if (!empty($tp1) && !empty($tp2) && $tp1->id != $tp2->id) { $return = true; } } return $return; }