Пример #1
0
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $model = new Paciente('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Paciente'])) {
         $model->attributes = $_GET['Paciente'];
     }
     $this->render('admin', array('model' => $model));
 }
 public function actionExportar()
 {
     $clave = Configuraciones::model()->findByPk(1);
     if ($_POST['clave'] == $clave->super_usuario) {
         if ($_POST['filtro'] == 1) {
             $laFechaDesde = Yii::app()->dateformatter->format("yyyy-MM-dd", $_POST['fecha_desde']);
             $laFechaHasta = Yii::app()->dateformatter->format("yyyy-MM-dd", $_POST['fecha_hasta']);
             $attribs = array();
             $criteria = new CDbCriteria(array('order' => 'id DESC'));
             $criteria->addBetweenCondition('fecha', $laFechaDesde, $laFechaHasta);
             $rows = RelacionHojaGastos::model()->findAllByAttributes($attribs, $criteria);
         } else {
             $rows = RelacionHojaGastos::model()->findAll();
         }
         // Export it
         $this->toExcel($rows, array('id::ID', 'paciente.nombreCompleto::Paciente', 'n_identificacion::Cedula', 'hoja', 'asistencial.nombreCompleto::Asistencial', 'lineaServicio.nombre::Linea de Servicio', 'fecha', 'costo', 'personal.nombreCompleto::Registrado por'));
     } else {
         Yii::app()->user->setFlash('error', "Clave incorrecta para realizar la exportación.");
         $model = new Paciente('search');
         $model->unsetAttributes();
         // clear any default values
         if (isset($_GET['Paciente'])) {
             $model->attributes = $_GET['Paciente'];
         }
         $this->render('admin', array('model' => $model));
     }
 }