Ejemplo n.º 1
0
 public function formatOutput(Seats $seats)
 {
     $output = '';
     foreach ($seats->getSeats() as $str) {
         $output .= $str == '' ? '-' : $str;
     }
     return $output;
 }
Ejemplo n.º 2
0
 public function actionThanks()
 {
     $this->layout = "vote";
     if (isset($_POST['election_id'])) {
         $chosen = Yii::app()->session['chosenones'];
         $donevote = true;
         if (isset($_POST['token_id'])) {
             $token = Tokens::model()->find('id=:token', array(':token' => $_POST['token_id']));
             if (!$token->done_vote) {
                 $token->done_vote = 1;
                 $token->date_vote = date('Y-m-d H:i');
                 $token->save();
                 $donevote = false;
             }
         }
         if (!$donevote) {
             $seats = Seats::model()->findAll(array("condition" => "election_id=" . $_POST['election_id'], "order" => "priority asc"));
             foreach ($seats as $seat) {
                 foreach ($chosen[$seat->id] as $candidate_id) {
                     $vote = new Votes();
                     $vote->token_id = $token->id;
                     $vote->candidate_id = $candidate_id;
                     $vote->save();
                 }
             }
         }
         $this->render('thanks', array('election' => Elections::model()->find('id=:election_id', array(':election_id' => $_POST['election_id']))));
     }
 }
Ejemplo n.º 3
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Seats::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 4
0
namespace Ventus\Exams;

//============================================================================================
// Session, configuration file, localization constructor
//============================================================================================
require '../includes/php/bootstrap.php';
$SESSION = new \Zend_Session_Namespace('internal', true);
if (!isset($SESSION->lang)) {
    $SESSION->lang = DEFAULT_LANGUAGE;
}
\Locale::setDefault($SESSION->lang);
$l10n->setLanguage($SESSION->lang);
//============================================================================================
// Model
//============================================================================================
$model = new Seats($dbo);
$follow = new \Ventus\Specialist\FollowUps($dbo);
//============================================================================================
// Load the page requested by the user
//============================================================================================
if (!isset($_GET['page'])) {
    $render = true;
    $thisPage = "seat-management";
    $allBuildings = $model->getAllBuildings();
    foreach ($allBuildings as &$a) {
        $a['rooms'] = $model->getNumberOfRooms($a['building_id']);
    }
    unset($a);
    $l10n->addResource(__DIR__ . '/l10n/seat-management.json');
    $viewFile = 'views/seat-management.php';
} elseif ($_GET['page'] === 'show-rooms') {
Ejemplo n.º 5
0
 public function actionPrint()
 {
     $this->layout = 'blankback';
     if (isset($_GET['election_id'])) {
         $election = Elections::model()->findByPk($_GET['election_id']);
         $seats = Seats::model()->with(array('candidates.votes' => array('order' => 'candidates.name')))->findAll(array('condition' => 't.election_id=' . $_GET['election_id'], 'order' => 'priority asc'));
         $dataProvider = Tokens::model()->findAll(array('condition' => 'election_id=' . $_GET['election_id'], 'order' => 'token asc'));
     } else {
         $this->redirect('Elections/index');
     }
     $mPDF1 = Yii::app()->ePdf->mpdf();
     $mPDF1->WriteHTML($this->render('print', array('tokens' => $dataProvider, 'seats' => $seats, 'election' => $election), true));
     $mPDF1->Output('tokensaudit-' . $election->name . '.pdf', 'I');
 }
Ejemplo n.º 6
0
// Session, configuration file, localization constructor
//============================================================================================
require '../includes/php/bootstrap.php';
$SESSION = new \Zend_Session_Namespace('internal', true);
if (!isset($SESSION->lang)) {
    $SESSION->lang = DEFAULT_LANGUAGE;
}
\Locale::setDefault($SESSION->lang);
$l10n->setLanguage($SESSION->lang);
//============================================================================================
// Model
//============================================================================================
$follow = new \Ventus\Specialist\FollowUps($dbo);
$assignments = new SeatAssignment($dbo);
$model = new Requests($dbo);
$seatManagement = new Seats($dbo);
//============================================================================================
// Load the page requested by the user
//============================================================================================
if (!isset($_GET['page'])) {
    $render = true;
    $thisPage = 'seat-assignments';
    $default_date_range = unserialize(EXAMS_AND_PROCTOR_DEFAULT_DATE_FILTER_RANGE);
    if (!empty($_GET['start']) && !empty($_GET['end'])) {
        $startDate = \DateTime::createFromFormat('Y-m-d', urldecode($_GET['start']));
        $endDate = \DateTime::createFromFormat('Y-m-d', urldecode($_GET['end']));
    }
    if (!$startDate) {
        $startDate = new \DateTime($default_date_range['start']);
    }
    if (!$endDate) {
Ejemplo n.º 7
0
 /**
  * @expectedException NagoyaPHP\Vol10\Exception\RuntimeException
  * @expectedExceptionMessage Can not find empty seat for "B"
  */
 public function testProcessStringException()
 {
     $obj = new Seats(1);
     $obj->processString('A');
     $obj->processString('B');
 }
Ejemplo n.º 8
0
 public function actionResultform($id)
 {
     $this->layout = 'blankback';
     $seats = Seats::model()->with(array('candidates.votes' => array('order' => 'candidates.votescount desc')))->findAll(array('condition' => 't.election_id=' . $id, 'order' => 'priority asc'));
     $election = Elections::model()->with('tokens')->findByPk($id);
     $usedtokens = Tokens::model()->used($id)->findAll();
     $mPDF1 = Yii::app()->ePdf->mpdf();
     $mPDF1->WriteHTML($this->render('resultform', array('seats' => $seats, 'election' => $election, 'usedtokens' => $usedtokens), true));
     $mPDF1->Output('results-' . $election->name . '.pdf', 'I');
 }
Ejemplo n.º 9
0
<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'station-seat-form', 'enableAjaxValidation' => false));
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php 
echo $form->errorSummary($model);
?>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'seat_id');
?>
		<?php 
echo $form->dropDownList($model, 'seat_id', CHtml::listData(Seats::model()->findAll(), 'id', 'name'), array('prompt' => 'Select a seat'));
?>
		<?php 
echo $form->error($model, 'seat_id');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'station_id');
?>
		<?php 
echo $form->dropDownList($model, 'station_id', CHtml::listData(Stations::model()->findAll(), 'id', 'name'), array('prompt' => 'Select a station'));
?>
		<?php 
echo $form->error($model, 'station_id');
Ejemplo n.º 10
0
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     if (isset($_GET['seat_id'])) {
         $seat = Seats::model()->findByPk($_GET['seat_id']);
         $dataProvider = new CActiveDataProvider('Candidates', array('criteria' => array('condition' => 'seat_id=' . $_GET['seat_id'])));
     } else {
         $this->redirect('Elections/index');
     }
     $this->render('index', array('dataProvider' => $dataProvider, 'seat' => $seat));
 }
Ejemplo n.º 11
0
//============================================================================================
// Session, configuration file, localization constructor
//============================================================================================
require '../includes/php/bootstrap.php';
$SESSION = new \Zend_Session_Namespace('internal', true);
if (!isset($SESSION->lang)) {
    $SESSION->lang = DEFAULT_LANGUAGE;
}
\Locale::setDefault($SESSION->lang);
$l10n->setLanguage($SESSION->lang);
//============================================================================================
// Model
//============================================================================================
$model = new Requests($dbo);
$seatManagement = new Seats($dbo);
$follow = new \Ventus\Specialist\FollowUps($dbo);
$controlSheets = new ControlSheets($dbo);
$examFiles = new ExamFiles($dbo);
//============================================================================================
// Load the page requested by the user
//============================================================================================
if (!isset($_GET['page'])) {
    $render = true;
    $thisPage = "confirmed-requests";
    $default_date_range = unserialize(EXAMS_AND_PROCTOR_DEFAULT_DATE_FILTER_RANGE);
    if (!empty($_GET['start']) && !empty($_GET['end'])) {
        $startDate = \DateTime::createFromFormat('Y-m-d', urldecode($_GET['start']));
        $endDate = \DateTime::createFromFormat('Y-m-d', urldecode($_GET['end']));
    }
    if (!$startDate) {