public function actionCxpp()
 {
     $model = new ProductoCompras('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['ProductoCompras'])) {
         $model->attributes = $_GET['ProductoCompras'];
     }
     $model->estado = "Pagada";
     $this->layout = 'main';
     $this->render('cxpp', array('model' => $model));
 }
 public function actionExportarCxp()
 {
     $clave = Configuraciones::model()->findByPk(1);
     if ($_POST['clave'] == $clave->super_usuario) {
         if ($_POST['filtro'] == 1) {
             $laFechaDesde = Yii::app()->dateformatter->format("yyyy-MM-dd H:i:s", $_POST['fecha_desde']);
             $laFechaHasta = Yii::app()->dateformatter->format("yyyy-MM-dd H:i:s", $_POST['fecha_hasta']);
             $attribs = array('estado' => 'Activo');
             $criteria = new CDbCriteria(array('order' => 'id DESC'));
             $criteria->addBetweenCondition('fecha', $laFechaDesde, $laFechaHasta);
             $rows = ProductoCompras::model()->findAllByAttributes($attribs, $criteria);
         } else {
             $rows = ProductoCompras::model()->findAll("estado = 'Activo'");
         }
         // Export it
         $this->toExcel($rows, array('id::Orden N°', 'productoProveedor.nombre::Proveedor', 'factura_n::Factura', 'total_compra', 'forma_pago', 'credito_dias', 'credito_fecha', 'saldo', 'estado'));
     } else {
         Yii::app()->user->setFlash('error', "Clave incorrecta para realizar la exportación.");
         $model = new ProductoCompras('search');
         $model->unsetAttributes();
         // clear any default values
         if (isset($_GET['ProductoCompras'])) {
             $model->attributes = $_GET['ProductoCompras'];
             $model->estado = "Activo";
         }
         $this->layout = 'main';
         $lasCompras = ProductoCompras::model()->count();
         if ($lasCompras == 0) {
             $this->render('vacio', array('model' => $model));
         } else {
             $this->render('cxp', array('model' => $model));
         }
     }
 }