public function execute() { $dayBo = new CalemDashWoOrigDayBo(); $mdBo = new CalemDashWoOrigMdBo(); $woDbo = CalemFactory::getDbo('workorder'); $woDbo->deleteBySql('delete from dash_wo_orig_day'); $woDbo->deleteBySql('delete from dash_wo_orig_md'); //Now recals based on wo info try { $rows = $woDbo->fetchBySql("select * from workorder"); } catch (CalemDboDataNotFoundException $e) { return "No data in workorder. WO count is reset."; } global $_CALEM_conf; $lastDay = strtotime($_CALEM_conf['dash_conf']['dash_wo_orig_day']['limit'] . " day ago"); $lastSvrDay = CalemText::getServerDatetime($lastDay); foreach ($rows as $row) { $mdBo->onDataInserted_CalemWoDbo(array('baseData' => $row)); if ($row['orig_time'] < $lastSvrDay) { continue; } //Too far back not considering $dayBo->onDataInserted_CalemWoDbo(array('baseData' => $row)); } return "WO count updated successfully."; }