* @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $ */ class TopJob extends BaseTopJob { public function __toString() { sfContext::getInstance()->getConfiguration()->loadHelpers('Date'); return format_date($this->getValidFrom(), 'p').' až '.format_date($this->getValidTo(), 'p').' pro inzerát: '.$this->getJob()->getName(); } public function isActive() { return $this->getIsActive(); } public function isActiveNow() { return $this->isActive() && strtotime($this->getValidFrom()) <= time() && strtotime($this->getValidTo()) >= time(); } public function activate() { $job = $this->getJob(); if(strtotime($job->getValidTo()) < strtotime($this->getValidTo())) { $job->setValidTo($this->getValidTo()); } $job->save(); $this->setIsActive(true); } public function deactivate() { $this->setIsActive(false); } /** * * @return boolean */ public function isReadyForActive() { $actual = Doctrine::getTable('TopJob')->getTopJob($this->getValidFrom(), $this->getValidTo(), $this); return !($actual instanceof TopJob); } /** * Vrátí počet dní tvrdání TOP inzerátu * * @return integer */ public function getDaysCount() { $s = strtotime($this->getValidTo()) - strtotime($this->getValidFrom()); return round($s / 60 / 60 / 24); } }