getBehOd(),"d")." - ".format_date($this->getBehDo(),"d"); } public function getPokrocilostAndTemaToString(){ return $this->getPokrocilost()." , ".$this->getTema(); } public function getJednotCenaToString(){ if($this->getFjCena()!= null && $this->getFjHodnota()!= null && $this->getMeritko($this->getFjMeritko())!= null) return $this->getFjCena()." Kč
za ".$this->getFjHodnota()." ".$this->getMeritko($this->getFjMeritko()); return ""; } private function getMeritko($str){ return str_replace("beh_kurzu","běh kurzu",$str); } public function getAgenturaToString(){ return $this->Agentura->getNazev(); } public function getLektorToString(){ return $this->Lektor->getLektorHtmlLongHref(); } public function archivate($level){ foreach($this->Kurz_hodina_list as $kurz_hodina){ $kurz_hodina->archivate($level); } foreach($this->Rozpocet_list as $rozpocet){ $rozpocet->archivate($level); } $this->archive($level); } public function getEndBeh(){ $beh = Doctrine::getTable('Kurz_beh')->find($this->getId()); $dateFrom = strtotime($beh->getBehOd()); $dateTo = strtotime($beh->getBehDo()); $error = true; if($dateFrom > time()) $error = false; if($dateTo < time()) $error = false; return $error; } public function getCountHour($mount,$year){ return Doctrine::getTable('Kurz_hodina')->createQuery("a")->where("datum LIKE '".$year."-".$mount."-%'") ->andWhere('a.kurz_beh_id = '.$this->getId()) ->count(); } public function getCountPaidHours($mount,$year){ return Doctrine::getTable('Kurz_hodina')->createQuery("a")->where("datum LIKE '".$year."-".$mount."-%'") ->andWhere('a.kurz_beh_id = '.$this->getId()) ->andWhere("a.zruseno <> 'agentura'") ->andWhere("a.zruseno <> 'vcas'") ->count(); } public function getSumFakt($mount,$year){ // Whiski - nepoužívá se // použít pro kontrolu!!!! - nesedí nejspíš cena pracovníka oproti celkové sumě $sum = 0; $kurz_hodiny = Doctrine::getTable('Kurz_hodina')->createQuery("a")->where("datum LIKE '".$year."-".$mount."-%'") ->andWhere('a.kurz_beh_id = '.$this->getId()) ->andWhere("a.zruseno <> 'agentura'") ->execute(); foreach($kurz_hodiny as $kurz_hodina){ foreach($kurz_hodina->Dochazka_list as $doch) $sum += $doch->getCena(); } return $sum; } public function getFiles(){ $str = ""; foreach($this->Agentura_beh_soubor as $files){ $str .= "".$files->getNazev()."
"; } return $str; } public function cenaNaHlavu($pocet_hlav) { return ($this->getFjCena()/$pocet_hlav); } public function fulldelete() { Doctrine::getTable('Pracovnik_rozpocet')->setOption('ignore_archive', true); foreach($this->getRozpocet_list() as $rozpocet) { $rozpocet->delete(); } Doctrine::getTable('Kurz_hodina')->setOption('ignore_archive', true); foreach($this->getKurz_hodina_list() as $hodina) { $hodina->delete(); } $this->delete(); } public function hasPermission(Zakaznik $zakaznik) { return $this->getKurz()->hasPermission($zakaznik); } public function getAppendDirChoices($is_agentura = false) { $choices = array('' => ''); foreach($this->getRootDocuments($is_agentura) as $document) { if($document->isDir()) { $choices[$document->getId()] = $document->getName(); $choices = $choices + $document->getDirChoices('-', $is_agentura); } } return $choices; } public function getRootDocuments($is_agentura = false) { $query = Doctrine::getTable('Document')->createQuery() ->addWhere('zakaznik_id = ?', $this->getKurz()->getZakaznikId()) ->addWhere('((beh_id = ? AND parent_id IS NULL) OR (beh_id IS NOT NULL AND is_global = ?)) AND !(beh_id = ? AND parent_id IS NOT NULL AND is_global = ?)', array($this->getId(), true, $this->getId(), true)) ->addWhere('parent_id IS NULL') ->orderBy('is_global DESC'); if($is_agentura) { $query->addWhere('agentura_read = ?', true); } return $query->execute(); } public function pracovnici() { return Doctrine::getTable('Pracovnik')->createQuery("p") ->innerJoin('p.Dochazka_list d') ->innerJoin('d.Kurz_hodina h') ->addwhere('h.kurz_beh_id = '.$this->getId()) ->orderBy('p.prijmeni ASC, p.jmeno ASC') ->execute(); } public function dokumentyPracovniku() { $result = array(); foreach($this->pracovnici() as $pracovnik) { foreach($pracovnik->getRootDocuments() as $document) { $result[] = $document; } } return $result; } /** * Vrátí počat hodin v daném období. * * @param date $od * @param date $do * @return integer */ public function pocetHodin($od = null, $do = null) { $query = Doctrine::getTable('Kurz_hodina')->createQuery('hodina') ->innerJoin('hodina.Kurz_beh beh') ->addWhere('beh.id = ?', $this->getId()); if(!is_null($od)) { $query->addWhere('hodina.datum >= ?', $od); } if(!is_null($do)) { $query->addWhere('hodina.datum <= ?', $do); } return $query->count(); } public function __toString() { return 'běh od '.$this->getBehOd().' do '.$this->getBehDo().' kurzu '.$this->Kurz->getNazev(); } }