/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { // Load crash group $model = $this->loadModel($id); // Check that user is authorized to access this model $this->checkAuthorization($model); // Create new crash report model as search conditions container. $crashReport = new CrashReport(); $crashReport->groupid = $model->id; // Fill search conditions if (isset($_GET['q'])) { $crashReport->filter = $_GET['q']; } else { if (isset($_POST['CrashReport'])) { // Advanced search $crashReport->isAdvancedSearch = true; // Fill form with data $crashReport->attributes = $_POST['CrashReport']; } } // Perform search $crashReportDataProvider = $crashReport->search(); // Render view $this->render('view', array('model' => $model, 'crashReportModel' => $crashReport, 'crashReportDataProvider' => $crashReportDataProvider)); }
/** * This action lists all models. */ public function actionIndex() { // Check if user is authorized to perform the action $this->checkAuthorization(null); $model = new CrashReport('search'); if (isset($_GET['q'])) { $model->filter = $_GET['q']; } else { if (isset($_POST['CrashReport'])) { // Advanced search $model->isAdvancedSearch = true; // Fill form with data $model->attributes = $_POST['CrashReport']; } } $dataProvider = $model->search(); $this->render('index', array('dataProvider' => $dataProvider, 'model' => $model)); }
public function testAdvancedSearch() { // Login as root $model = new LoginForm('RegularLogin'); $model->username = "******"; $model->password = "******"; $this->assertTrue($model->login()); // Test simple search $crashReport = new CrashReport('search'); $crashReport->isAdvancedSearch = true; $crashReport->ipaddress = '127.0.0.1'; $crashReport->emailfrom = 'test@localhost'; $crashReport->status = CrashReport::STATUS_PENDING_PROCESSING; $crashReport->receivedFrom = date("m/d/Y", mktime(0, 0, 0, 4, 14, 2012)); $crashReport->receivedTo = date("m/d/Y", mktime(0, 0, 0, 4, 16, 2012)); // Perform search $dataProvider = $crashReport->search(); // Ensure something found $this->assertTrue(count($dataProvider->data) != 0); }