. */ include("./include/include.php"); require_once(FILESYSTEMROOTPATH."jc/include/classes/DefaultLayout.php"); //get ids if (isset($_GET['proposal_id'])){ $pid = $_GET['proposal_id']; $type = 'proposal'; $pService = $GLOBALS['ClassFactory']->getProposalsService(); $proposal = $pService->load($pid); $pmService = $GLOBALS['ClassFactory']->getProposals_ManagementService(); $pm = $pmService->loadByPID($pid, 'plenary'); $url = 'voting3.php?pm_id='.$pm->getId().'&agora_id='.$proposal->getAgora_id(); } elseif (isset($_GET['rollcall_id'])){ $pid = $_GET['rollcall_id']; $type = 'rollcall'; $pmService = $GLOBALS['ClassFactory']->getRollcallsService(); $pm = $pmService->load($pid); $url ='rollcall3.php?agora_id='.$pm->getAgora_Id().'&id='.$pid; } $layout = new DefaultLayout("JC_MANAGE", "./jc/"); $layout->init(); if ($pm->getClose() > date("Y-m-d H:i:s")){ $layout->echoln('Voting period is still open'); $layout->page_footer(); }else{ $votesService = $GLOBALS['ClassFactory']->getVotesService(); $results = $votesService->count_votes($pid, $type); $pm->setBodies_available($results['bodies_available']); $pm->setBodies_present($results['bodies_present']); $pm->setVotes_available($results['votes_available']); $pm->setVotes_in_favour($results['in_favour']); $pm->setVotes_against($results['against']); $pm->setVotes_abstention($results['abstention']); $positive = false; if ($pm->getMajority()=='simple'){ if ($results['in_favour']>$results['against']){ $positive = true; } }elseif($pm->getMajority()=='absolute'){ if ($results['in_favour']>$results['against']+$results['abstention']){ $positive = true; } }elseif($pm->getMajority()=='two third'){ if ($results['in_favour']>2*($results['against']+$results['abstention'])){ $positive = true; } } if($positive){ $pm->setResult('Agora Accepted'); if($type=='proposal'){ $proposal->setStatus('Agora Accepted'); $pService->SaveOrUpdate($proposal); } } else{ $pm->setResult('Agora Rejected'); if($type=='proposal'){ $proposal->setStatus('Agora Rejected'); $pService->SaveOrUpdate($proposal); } } $pmService->SaveOrUpdate($pm); $layout->redirect($url); } $layout->page_footer(); ?>