. */ require_once(FILESYSTEMROOTPATH."jc/include/dao/VotesDao.php"); class VotesService { private $votesDao; public function __construct(VotesDao $votesDao) { $this->votesDao = $votesDao; } public function load($id) { //don't use it! return ''; } public function loadPublic($pid, $type) { $dDao = $GLOBALS['ClassFactory']->getDelegatesDao(); $bodies = $dDao->getBodyNames(); $votes = $this->votesDao->loadByPID($pid, $type); $votes_table = array(); foreach($votes as $vote){ if(isset($votes_table[$vote['bodyCode']])){ $votes_table[$vote['bodyCode']][$vote['vote']] += 1; } else{ $votes_table[$vote['bodyCode']] = array('bodyName'=>$bodies[$vote['bodyCode']],'in_favour'=>0,'against'=>0,'abstention'=>0); $votes_table[$vote['bodyCode']][$vote['vote']] += 1; } } return $votes_table; } public function SaveOrUpdate($vote){ return $this->votesDao->saveOrUpdate($vote); } public function get_my_votes($uid, $pid, $type){ return $this->votesDao->get_my_votes($uid, $pid, $type); } public function get_max_votes($uid, $pid, $type){ return $this->votesDao->get_max_votes($uid, $pid, $type); } public function get_min_votes($uid){ return $this->votesDao->get_min_votes($uid); } public function getMyLocal($uid){ return $this->votesDao->getMyLocal($uid); } public function getLocal_delegates($bodyCode){ return $this->votesDao->getLocal_delegates($bodyCode); } public function getLocal_votes($bodyCode){ return $this->votesDao->getLocal_votes($bodyCode); } public function count_votes($pid, $type){ return $this->votesDao->count_votes($pid, $type); } public function get_cast_votes($uid, $pid, $type){ return $this->votesDao->get_cast_votes($uid, $pid, $type); } public function votes_to_be_cast(){ return $this->votesDao->votes_to_be_cast(); } public function votes_cast($proposal_id, $type){ return $this->votesDao->votes_cast($proposal_id, $type); } public function getMyLocalVotes($pid,$type,$bodyCode){ return $this->votesDao->getMyLocalVotes($pid,$type, $bodyCode); } public function get_local_cast_votes($bodyCode, $pid, $type){ return $this->votesDao->get_local_cast_votes($bodyCode, $pid, $type); } public function isRegistered($uid){ return $this->votesDao->isRegistered($uid); } public function get_registered_bodies($aid){ return $this->votesDao->get_registered_bodies($aid); } } ?>