Ejemplo n.º 1
0
 static function CompetitorOptions($position_id)
 {
     $competitors = ClassCommittee::model()->findByPk($position_id)->competitors;
     $results = array('0' => '请选择竞争者');
     foreach ($competitors as $row) {
         $results[$row->competitor_id] = Student::model()->findByPk($row->competitor_id)->student_name;
     }
     return $results;
 }
 /**
  * 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 $id the ID of the model to be loaded
  * @return ClassCommittee the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = ClassCommittee::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 3
0
echo $form->labelEx($model, 'competitor_id');
?>
		<?php 
echo $form->textField($model, 'competitor_id', array('size' => 10, 'maxlength' => 10));
?>
		<?php 
echo $form->error($model, 'competitor_id');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'position_id');
?>
		<?php 
echo $form->dropDownList($model, 'position_id', ClassCommittee::positionOptions());
?>
		<?php 
echo $form->error($model, 'position_id');
?>
	</div>

	<!-- <div class="row">
		<?php 
echo $form->labelEx($model, 'votes');
?>
		<?php 
echo $form->textField($model, 'votes');
?>
		<?php 
echo $form->error($model, 'votes');
Ejemplo n.º 4
0
 public function actionCommittee($position_id = -1)
 {
     if ($position_id == -1) {
         $criteria = new CDbCriteria();
         $criteria->addCondition('class_id=' . Yii::app()->user->class_id);
         $model = ClassCommittee::model()->findAll($criteria);
         $this->render('committees', array('model' => $model));
     } else {
         $model = ClassCommittee::model()->findByPk($position_id);
         $this->render('committee', array('model' => $model));
     }
 }
 public function actionPositions()
 {
     $criteria = new CDbCriteria();
     $criteria->select = 'position_id, position_name';
     $criteria->addCondition('class_id=' . Yii::app()->user->class_id);
     $model = ClassCommittee::model()->findAll($criteria);
     foreach ($model as $i) {
         echo $i->position_name . '<br>';
         foreach ($i->competitors as $j) {
             echo Student::model()->findByPk($j->competitor_id)->student_name;
             echo '&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp';
         }
         echo '<br/>', '<hr/>';
     }
 }
Ejemplo n.º 6
0
 static function positionOptions()
 {
     $criteria = new CDbCriteria();
     $criteria->select = 'position_id, position_name';
     $criteria->addCondition('class_id=' . Yii::app()->user->class_id);
     $model = ClassCommittee::model()->findAll($criteria);
     $postions = array('' => '请选择竞选岗位');
     foreach ($model as $row) {
         $postions[$row->position_id] = $row->position_name;
     }
     return $postions;
 }