/** * Date is formated as: YYYY-MM-DD */ public static function formatDateString($str) { if (!$str) { return null; } $dt = CalemText::parseServerDate($str); $datefmt = CalemText::getDateFormat(); return date($datefmt, $dt); }
/** * Update local data file - data collection for the report. */ public function generateChartData() { $conf = $this->conf['dash_wo_orig_md']; //First of all, let's get data out. $rtn = null; try { $rtn = $this->dbo->fetchBySql('select * from dash_wo_orig_md order by id'); } catch (CalemDboDataNotFoundException $e) { } //Next let's prepare data for the charts $series = "<xaxis>"; $ddData = $this->ddDbo->getData(); $graph = array(); $grp = 1; $xid = 0; foreach ($ddData as $key => $val) { $graph[$key] = '<graph gid="' . $grp++ . '" '; if (isset($conf['graph_attrs'][$key])) { $graph[$key] .= $conf['graph_attrs'][$key]; } else { $graph[$key] .= $conf['graph_attrs_default']; } $graph[$key] .= ' title="' . KEY_PREFIX . $key . '" >'; } //Now walk through the data in steps. $thisMd = gmdate('Y-m-01'); $startMd = null; for ($idx = 0; $rtn && $idx < count($rtn); $idx++) { $dbMd = $rtn[$idx]['id']; if (!$startMd) { $startMd = $dbMd; $startTime = CalemText::parseServerDate($startMd); } else { while ($startMd < $dbMd) { list($series, $graph, $startMd, $startTime, $xid) = $this->unserializeOneDay($startMd, $startTime, $xid, null, $series, $graph); } } list($series, $graph, $startMd, $startTime, $xid) = $this->unserializeOneDay($startMd, $startTime, $xid, $rtn[$idx]['counts'], $series, $graph); } //Let's make sure we're done here if (!$startMd) { //No data points list($series, $graph, $startMd, $startTime, $xid) = $this->unserializeOneDay($thisMd, null, $xid, null, $series, $graph); } else { while ($startMd <= $thisMd) { list($series, $graph, $startMd, $startTime, $xid) = $this->unserializeOneDay($startMd, $startTime, $xid, null, $series, $graph); } } //Now assemble the info together. $rtn = '<chart>' . $series . '</xaxis> <graphs> '; foreach ($graph as $key => $val) { $rtn .= $val . '</graph>' . "\n"; } $rtn .= '</graphs></chart>'; file_put_contents($this->dataFile, $rtn); }
public function batchSchedule($tran) { $users = array(); if (isset($tran['user_id'])) { $users[] = $tran['user_id']; } else { $userDbo = CalemFactory::getDbo('users'); $rows = $userDbo->fetchBySqlParam('select id from users where team_id=?', $tran['team_id']); foreach ($rows as $row) { $users[] = $row['id']; } } //Adding schedule for each user. try { $this->schedUserDbo->beginTransaction(); $startDate = CalemText::parseServerDate($tran['start_date']); $endDate = CalemText::parseServerDate($tran['end_date']); $shiftRow = $this->shiftData[$tran['shift_id']]; while ($startDate <= $endDate) { $dtStr = date('Y-m-d', $startDate); foreach ($users as $user) { if ($this->logger->isDebugEnabled()) { $this->logger->debug("Add schedule: user_id=" . $user . ", startDate=" . $dtStr . ", shift=" . $tran['shift_id']); } try { $rows = $this->schedUserDbo->fetchBySqlParam('select * from sched_user where user_id=? and sched_date=? and shift_id=?', array($user, $dtStr, $tran['shift_id'])); //No processing here. } catch (CalemDboDataNotFoundException $ex) { $ar['user_id'] = $user; $ar['sched_date'] = $dtStr; $ar['shift_id'] = $tran['shift_id']; $ar['total_hours'] = $shiftRow['total_hours']; $ar['sched_hours'] = $shiftRow['sched_hours']; $this->schedUserDbo->setChangeBulk($ar); $this->schedUserDbo->insert(); $this->schedUserDbo->unsetId(); } } //Adding a day $startDate = strtotime("+1 day", $startDate); } $this->schedUserDbo->commit(); } catch (Exception $ex) { $this->schedUserDbo->rollback(); throw $ex; } }
public function getLastReleaseDate($pmAssetRow) { return CalemText::parseServerDate($pmAssetRow['last_released']); }