示例#1
0
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $model = new Produto('search');
     $model->unsetAttributes();
     $oSearchForm = new SearchForm();
     $oProdutos = Produto::model()->findAll();
     $aCriteria = array();
     $aProdutos = array();
     if (!empty($oProdutos)) {
         foreach ($oProdutos as $produto) {
             if (!empty($produto->tipo_produto_id)) {
                 $aProdutos['tipo_produto_id'][] = $produto->tipo_produto_id;
             }
         }
         if (!empty($aProdutos['tipo_produto_id'])) {
             $aCriteria['condition'] = 'id in (' . implode(',', $aProdutos['tipo_produto_id']) . ')';
         }
     }
     $oTiposProdutos = TipoProduto::model()->ordenarTitulo()->findAll($aCriteria);
     if (isset($_GET['Produto'])) {
         $model->attributes = $_GET['Produto'];
         $oSearchForm->request = $_GET['Produto'];
     }
     $headers = $model->getHeadersRelatorio();
     $this->exportarRelatorio($model->search(), 'Relatório Produtos - ', $headers, date('YmdHis') . '_relatorio_produtos.csv');
     $this->render('admin', array('model' => $model, 'oTiposProdutos' => $oTiposProdutos, 'exibeFormularioBusca' => $oSearchForm->checaRequisicaoVazia()));
 }
示例#2
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 TipoProduto the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = TipoProduto::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }