コード例 #1
0
 public function actionAwareness()
 {
     $awarenessItems = AwarenessItem::model()->findAll();
     if (isset($_GET['awareness_id'])) {
         $awareness_id = $_GET['awareness_id'];
         Yii::trace("SR.actionAwarenesss called for {$awareness_id}", 'application.controllers.SurveyReportsController');
         if (strlen($awareness_id) > 0) {
             $crit = array('awareness_id' => $awareness_id);
         } else {
             $crit = array();
         }
         $awarenessDist = AwarenessData::model()->findAllByAttributes($crit, array('select' => 'awareness_id, value, count(id) val_count', 'group' => 'awareness_id, value'));
         $this->renderPartial('awareness_report', array('awarenessDist' => $awarenessDist, 'awarenessItems' => $awarenessItems));
         return;
     }
     $this->render('awareness', array('awarenessItems' => $awarenessItems));
 }
コード例 #2
0
 public function actionSurvey($id)
 {
     $model = $this->loadModel($id);
     if (isset($_POST['SatisfactionData'])) {
         foreach ($_POST['SatisfactionData'] as $sid => $value) {
             $sd = SatisfactionData::model()->findByAttributes(array('family_id' => $id, 'satisfaction_item_id' => $sid));
             if (!$sd) {
                 $sd = new SatisfactionData();
             }
             $sd->attributes = $value;
             $sd->family_id = $id;
             $sd->satisfaction_item_id = $sid;
             $sd->save();
         }
     }
     if (isset($_POST['NeedData'])) {
         foreach ($_POST['NeedData'] as $nid => $value) {
             $nd = NeedData::model()->findByAttributes(array('family_id' => $id, 'need_id' => $nid));
             if (!$nd) {
                 $nd = new NeedData();
             }
             $nd->attributes = $value;
             $nd->family_id = $id;
             $nd->need_id = $nid;
             $nd->save();
         }
     }
     if (isset($_POST['AwarenessData'])) {
         Yii::trace("FC.survey awareness reached", 'application.controllers.FamilyController');
         $awarenessItems = AwarenessItem::model()->findAll();
         foreach ($awarenessItems as $aRow) {
             $aid = $aRow->id;
             $value = isset($_POST['AwarenessData'][$aid]) ? $_POST['AwarenessData'][$aid] : 1;
             $ad = AwarenessData::model()->findByAttributes(array('family_id' => $id, 'awareness_id' => $aid));
             if (!$ad) {
                 $ad = new AwarenessData();
             }
             $ad->value = $value;
             $ad->family_id = $id;
             $ad->awareness_id = $aid;
             $ad->save();
         }
     }
     if (isset($_POST['OpenData'])) {
         foreach ($_POST['OpenData'] as $qid => $value) {
             $od = OpenData::model()->findByAttributes(array('family_id' => $id, 'question_id' => $qid));
             if (!$od) {
                 $od = new OpenData();
             }
             $od->attributes = $value;
             $od->family_id = $id;
             $od->question_id = $qid;
             $od->save();
         }
     }
     $satisfactionItems = SatisfactionItem::model()->findAll();
     $needItems = NeedItem::model()->findAll();
     $openQuestions = OpenQuestion::model()->findAll(array('order' => 'seq'));
     $awarenessItems = AwarenessItem::model()->findAll();
     $this->render('survey', array('model' => $model, 'satisfactionItems' => $satisfactionItems, 'satisfactionData' => Families::satisfactionData($id), 'needItems' => $needItems, 'needData' => Families::needData($id), 'awarenessItems' => $awarenessItems, 'awarenessData' => Families::awarenessData($id), 'openQuestions' => $openQuestions));
 }
コード例 #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 $id the ID of the model to be loaded
  * @return AwarenessData the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = AwarenessData::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }