public function actionGeneratePdf($id) { //$id = Yii::app()->request->getParam('id'); $model = Programa::model()->findByPk($id); $incluye = ProgramaIncluye::model()->findAllByAttributes(array('programa_id' => $id)); $noIncluye = ProgramaNoIncluye::model()->findAllByAttributes(array('programa_id' => $id)); $suplemento = ProgramaSuplementoAereo::model()->findAllByAttributes(array('programa_id' => $id)); $condiciones = Condiciones::model()->findAll(); /*$combi=new ProgramaCombinacion('search'); $combi->unsetAttributes(); // clear any default values $combi->programa_id = $id;*/ $combi = ProgramaCombinacion::model()->findAllByAttributes(array('programa_id' => $id)); $filename = $this->string_sanitize($model->nombre); if (file_exists(Yii::app()->basePath . '/../images/pdf/' . $filename . '.pdf')) { $random = rand(100, 200); $filename = $filename . $random; } $mPDF1 = Yii::app()->ePdf->mpdf(); $stylesheet = file_get_contents(Yii::getPathOfAlias('ext.booster.assets.bootstrap.css') . DIRECTORY_SEPARATOR . 'bootstrap.min.css'); $stylesheet2 = file_get_contents(Yii::getPathOfAlias('webroot.css') . DIRECTORY_SEPARATOR . 'pdf.css'); $font = file_get_contents(Yii::getPathOfAlias('ext.booster.assets.font-awesome.css') . DIRECTORY_SEPARATOR . 'font-awesome.min.css'); $mPDF1->WriteHTML($stylesheet, 1); $mPDF1->WriteHTML($stylesheet2, 1); $mPDF1->WriteHTML($font, 1); //$mPDF1->SetHTMLHeader('<div class="header"><span class="direccion">http://23kycorp.com/</span></div>'); $mPDF1->setFooter('<div style="text-align:center;width:800px;font-weight:0;padding-top:5px;"> <p><span style="font-weight:bold;">Havanatur Chile – Operador Mayorista</span> / Padre Mariano 82 Of. 502</p> <p>Tel: (562) 22330844 - 22331381</p> <p>ventas1@havanatur.cl - ventas2@havanatur.cl – ventas3@havanatur.cl - ger.comercial@havanatur.cl </p> </div>'); $mPDF1->WriteHTML($this->renderPartial('application.views.programa.pdf2.programa_pdf', array('model' => $model, 'incluye' => $incluye, 'combi' => $combi, 'noIncluye' => $noIncluye, 'suplemento' => $suplemento, 'condiciones' => $condiciones), true)); $mPDF1->Output(Yii::app()->basePath . '/../images/pdf/' . $filename . '.pdf', 'F'); $old = $model->pdf; $model->pdf = $filename . '.pdf'; $model->update(); if ($old != '') { if ($old != $model->pdf) { unlink(Yii::app()->basePath . '/../images/pdf/' . $old); } } /* $pdf = Yii::app()->basePath.'/../images/pdf/'.$filename.'.pdf'; header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="'.$pdf.'"'); readfile($pdf);*/ }
public function actionPrograma() { Yii::app()->controller->menu_activo = 'programa'; $id = Yii::app()->request->getParam('id'); $model = Programa::model()->findByPK($id); $condiciones = Condiciones::model()->findAll(); $imagenes = array(); foreach ($model->programaImagens as $imagen) { $imagenes[] = array('div' => '<div style="height:400px;background-image: url(' . "'" . Yii::app()->request->baseUrl . '/images/programa/' . $imagen->imagen . "'" . ')"></div>'); } $criteria = new CDbCriteria(); $criteria->params = array(':id' => $id); $criteria->condition = 'programa_id=:id'; $dataProvider = new CActiveDataProvider('ProgramaCombinacion', array('pagination' => array('pageSize' => 5), 'criteria' => $criteria)); // renders the view file 'protected/views/site/index.php' // using the default layout 'protected/views/layouts/main.php' $this->render('programa', array('model' => $model, 'imagenes' => $imagenes, 'combi' => $dataProvider, 'condiciones' => $condiciones)); }
/** * 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 Condiciones the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Condiciones::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }