/** * 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 TestContextSeq the loaded model * @throws CHttpException */ public function loadModel($id) { $model = TestContextSeq::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionInidashboard($idTestContext) { $sql = 'SELECT * FROM test_context_seq WHERE id_test_context = ' . $idTestContext; $arrayModels = TestContextSeq::model()->findAllBySql($sql); $modelTestContext = TestContext::model()->findByPk($idTestContext); $raw_data_dashboard = array(); $totalTests = 0; $cont = 1; foreach ($arrayModels as $model) { $row_data_dashboard = array(); $row_data_dashboard[0] = $cont; $row_data_dashboard[1] = $model->variation; $row_data_dashboard[2] = $model->behavior; $screen = $model->behavior_screen; $row_data_dashboard[3] = $screen; array_push($raw_data_dashboard, $row_data_dashboard); $totalTests++; } $nomePlataforma = Platforms::model()->findByPk($modelTestContext->id_platform); $nomeApp = App::model()->findByPk($modelTestContext->id_app); $device = Device::model()->findByPk($modelTestContext->id_device); $user = Users::model()->findByPk($modelTestContext->id_user); $sql_countElements = "SELECT * FROM test_context JOIN element_inst ON (test_context.id = element_inst.id_test_context) WHERE test_context.id={$idTestContext} GROUP BY id_element"; $result_countElements = Yii::app()->db->createCommand($sql_countElements)->queryAll(); $totalElements = 0; foreach ($result_countElements as $item) { $totalElements = $totalElements + 1; } /*$dados_dashboard = array ( 'table' => $part4, );*/ $dados_dashboard = array(); $dados_dashboard['totalElements'] = null; $dados_dashboard['totalElements'] = $totalElements; $dados_dashboard['user'] = null; $dados_dashboard['user'] = $user->name; $dados_dashboard['Image'] = null; $dados_dashboard['Image'] = $nomePlataforma->image; $dados_dashboard['device'] = null; $dados_dashboard['device'] = $device; $dados_dashboard['nomePlataforma'] = null; $dados_dashboard['nomePlataforma'] = $nomePlataforma->name; $dados_dashboard['nomeApp'] = null; $dados_dashboard['nomeApp'] = $nomeApp->name; $dados_dashboard['model'] = null; $dados_dashboard['model'] = $modelTestContext; $dados_dashboard['totalTests'] = null; $dados_dashboard['totalTests'] = $totalTests; $dados_dashboard['dados'] = null; $dados_dashboard['dados'] = $raw_data_dashboard; $dados_dashboard['json'] = null; $dados_dashboard['json'] = json_encode($raw_data_dashboard); $dados_dashboard['nome_teste'] = $modelTestContext->description; Yii::app()->user->setState('dados_dashbord_final', $dados_dashboard); $this->redirect("/mtcontrool/index.php/testContext/dashboard"); }