示例#1
0
echo $form->labelEx($model, 'token_id');
?>
		<?php 
echo $form->textField($model, 'token_id');
?>
		<?php 
echo $form->error($model, 'token_id');
?>
	</div>

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

	<div class="row">
		<?php 
echo $form->labelEx($model, 'created_date');
?>
		<?php 
echo $form->textField($model, 'created_date');
?>
		<?php 
echo $form->error($model, 'created_date');
示例#2
0
 public function actionVerify()
 {
     $this->layout = "vote";
     if (isset($_POST['seat_id'])) {
         $chosen = Yii::app()->session['chosenones'];
         unset($chosen[$_POST['seat_id']]);
         foreach ($_POST as $ckey => $cval) {
             if (substr($ckey, 0, 5) == 'calon' && $cval) {
                 $chosen[$_POST['seat_id']][] = substr($ckey, 5);
             }
         }
         Yii::app()->session['chosenones'] = $chosen;
     }
     if (isset($_POST['election_id'])) {
         if (isset($_POST['token_id'])) {
             $token = Tokens::model()->find('id=:token', array(':token' => $_POST['token_id']));
         }
         $election = Elections::model()->find('id=:election', array(':election' => $_POST['election_id']));
         $chosen = Yii::app()->session['chosenones'];
         $seats = Seats::model()->findAll(array("condition" => "election_id=" . $election->id, "order" => "priority asc"));
         foreach ($seats as $seat) {
             $candidates[$seat->id] = Candidates::model()->findAll(array('condition' => 'id in (' . join($chosen[$seat->id], ',') . ')', 'order' => 'name asc'));
         }
         if ($token && $election) {
             $this->render('verify', array('election' => $election, 'token' => $token, 'candidates' => $candidates, 'seats' => $seats, 'cnumber' => Yii::app()->session['cnumber']));
         }
     }
 }
示例#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 = Candidates::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }