Beispiel #1
0
 public static function delete($multipleId)
 {
     if (empty($multipleId)) {
         throw new \Exception('Missing id');
     }
     $multiple = self::build($multipleId, new Resource());
     if (!Election::allowChange($multiple->getElectionId())) {
         throw new \Exception('Cannot delete ballot in ongoing election');
     }
     $multiple->setActive(false);
     self::saveResource($multiple);
 }
Beispiel #2
0
 public static function delete($referendumId)
 {
     if (empty($referendumId)) {
         throw new \Exception('Missing id');
     }
     $referendum = self::build($referendumId, new Resource());
     $electionId = $referendum->getElectionId();
     if (!Election::allowChange($electionId)) {
         throw new \Exception('Cannot referendum in ongoing election');
     }
     $referendum->setActive(false);
     self::saveResource($referendum);
 }
Beispiel #3
0
 public static function delete($ticketId)
 {
     if (empty($ticketId)) {
         throw new \Exception('Missing ticket id');
     }
     $ticket = self::build($ticketId, new Resource());
     $electionId = self::getElectionId($ticket->getId());
     if (!Election::allowChange($electionId)) {
         throw new \Exception('Cannot delete a ticket in ongoing election');
     }
     $ticket->setActive(false);
     self::saveResource($ticket);
 }
Beispiel #4
0
    private function edit($electionId)
    {
        javascript('datetimepicker');
        $allowChange = Factory::allowChange($electionId) ? 'true' : 'false';
        $script[] = '<script type="text/javascript">var allowChange=' . $allowChange . ';var electionId = ' . $electionId . ';</script>';
        $script[] = $this->getScript('election');
        $react = implode("\n", $script);
        $date_format = '<script type="text/javascript">var dateFormat = "' . ELECTION_DATETIME_FORMAT . '";var tomorrow="' . strftime('%Y/%m/%d', time() + 86400) . '";</script>';
        \Layout::addStyle('election', 'Admin/style.css');
        $content = <<<EOF
{$date_format}
<div id="election-dashboard"></div>
{$react}
EOF;
        return $content;
    }
Beispiel #5
0
 public static function delete($candidateId)
 {
     if (empty($candidateId)) {
         throw new \Exception('Missing id');
     }
     $candidate = self::build($candidateId, new Resource());
     $election_id = self::getElectionId($candidate);
     if (!Election::allowChange($election_id)) {
         throw new \Exception('Cannot delete candidate in active election');
     }
     $candidate->setActive(false);
     self::saveResource($candidate);
 }