public function actionWrite($id) { $_SESSION['KCFINDER']['disabled'] = false; // enables the file browser in the admin $_SESSION['KCFINDER']['uploadURL'] = Yii::app()->baseUrl . "/uploads/"; // enables the file browser in the admin $_SESSION['KCFINDER']['uploadDir'] = Yii::app()->basePath . "/../uploads/"; // enables the file browser in the admin /*$model=EssaysHasCrugeUser::model()->findByPk($id); if(empty($model->essaysDetails) && !isset($_POST['EssaysDetail'])){ $model->addDetail(); } if (isset($_POST['EssaysDetail'])) { $model->setRelationRecords('essaysDetails',is_array(@$_POST['EssaysDetail']) ? $_POST['EssaysDetail'] : array()); if ($model->save()) { Yii::app()->user->setFlash('profile-flash','save'); $this->redirect(array('write','id'=>$id)); } } $this->render('write',array( 'model'=>$model,//'essay' => $essay, ));*/ $essay = EssaysHasCrugeUser::model()->findByPk($id); if (empty($essay->essaysDetails)) { $model = new EssaysDetail(); } else { $criteria = new CDbCriteria(); $criteria->condition = "essays_has_cruge_user_id_essay_cruge= :searched ORDER BY lastdate DESC"; $criteria->params = array(":searched" => $id); $model = EssaysDetail::model()->find($criteria); } if (isset($_POST['EssaysDetail'])) { /*echo "<pre>"; echo print_r($_POST); echo "</pre>"; Yii::app()->end();*/ $detail = new EssaysDetail(); $detail->attributes = $_POST['EssaysDetail']; $detail->lastdate = time(); $detail->essays_has_cruge_user_id_essay_cruge = $_POST['idEssay']; if (isset($_POST['send'])) { $historial = new EssaysHistorical(); $historial->attributes = $_POST['EssaysDetail']; $historial->lastdate = time(); $historial->file_name = $essay->title_essay . "-" . EssaysHistorical::model()->calcularVersion($_POST['idEssay']); $historial->version = EssaysHistorical::model()->calcularVersion($_POST['idEssay']); $historial->essays_has_cruge_user_id_essay_cruge = $_POST['idEssay']; $essay->status = 8; if ($detail->save() && $historial->save() && $essay->save()) { Yii::app()->user->setFlash('send', 'El Essay se ha enviado correctamente.'); $this->redirect(array('write', 'id' => $detail->essays_has_cruge_user_id_essay_cruge)); } } if (isset($_POST['upload']) && isset($_FILES)) { $name = $_FILES['EssaysHistorical']['name']['file_name']; $ruta = $_FILES['EssaysHistorical']['tmp_name']['file_name']; $name = htmlentities($name, ENT_QUOTES); $pos = strripos($name, '.'); //$tipo=explode(".",$name); //$type=strtolower($tipo[1]); $type = substr($name, $pos + 1, strlen($name)); if ($type == "pdf") { $version = Yii::app()->db->createCommand("SELECT COUNT(*) FROM essays_historical WHERE essays_has_cruge_user_id_essay_cruge=" . $_POST['idEssay'])->queryScalar() - 1; $historial = EssaysHistorical::model()->find('essays_has_cruge_user_id_essay_cruge=' . $_POST['idEssay'] . ' AND version="V' . $version . '"'); //$refencia=sha1(date("r")); $refencia = $essay->title_essay . "-" . $historial->version . "-CORR"; $file = $refencia . "." . $type; $directorio = "D:/htdocs/via-college/uploads/" . $file; //$directorio = "C:/xampp/htdocs/via-college/uploads/" . $file; //$directorio = "var/www/vhosts/via-college.com/app.via-college.com/uploads/" . $file; if (move_uploaded_file($ruta, $directorio)) { //print( "El archivo fue subido con éxito."); //Yii::app()->end(); $historial->attributes = $_POST['EssaysDetail']; $historial->lastdate = time(); $historial->file_name = $file; $historial->essays_has_cruge_user_id_essay_cruge = $_POST['idEssay']; $essay->status = 7; if ($historial->save() && $essay->save()) { Yii::app()->user->setFlash('upload', 'Las corrección del Essay se ha enviado correctamente.'); $this->redirect(array('write', 'id' => $model->essays_has_cruge_user_id_essay_cruge)); } } else { Yii::app()->user->setFlash('error', 'Error al intentar subir el archivo.'); $this->redirect(array('write', 'id' => $model->essays_has_cruge_user_id_essay_cruge)); //print("Error al intentar subir el archivo."); //Yii::app()->end(); } } else { //print("El tipo de archivo permitido no es el correcto."); //Yii::app()->end(); Yii::app()->user->setFlash('file', 'El tipo de archivo permitido para la correción no es el correcto.'); $this->redirect(array('write', 'id' => $model->essays_has_cruge_user_id_essay_cruge)); } } if ($detail->save()) { Yii::app()->user->setFlash('save', 'El Essay se ha agregado correctamente.'); $this->redirect(array('write', 'id' => $detail->essays_has_cruge_user_id_essay_cruge)); } } if (isset($_POST['end'])) { $version = Yii::app()->db->createCommand("SELECT COUNT(*) FROM essays_historical WHERE essays_has_cruge_user_id_essay_cruge=" . $_POST['idEssay'])->queryScalar() - 1; $historial = EssaysHistorical::model()->find('essays_has_cruge_user_id_essay_cruge=' . $_POST['idEssay'] . ' AND version="V' . $version . '"'); $name = $essay->title_essay; $historial->file_name = $name . "-VF"; $historial->version = "VF"; $essay->status = 10; if ($historial->save() && $essay->save()) { Yii::app()->user->setFlash('end', 'El Essay Final se ha enviado correctamente.'); $this->redirect(array('write', 'id' => $model->essays_has_cruge_user_id_essay_cruge)); } } if (isset($_POST['Status'])) { $essay->status = $_POST['Status']; if ($essay->save()) { Yii::app()->user->setFlash('status', 'El Status se ha cambiado correctamente.'); $this->redirect(array('write', 'id' => $essay->id_essay_cruge)); } } $this->render('write', array('model' => $model, 'essay' => $essay)); }
</legend> <div id="correcciones" style="display: none;"> <!-- Historial de Essay --> <?php $this->beginWidget('yiiwheels.widgets.box.WhBox', array('title' => 'Essays: Historico de Correcciones', 'headerIcon' => 'icon-th-list')); ?> <?php $dataProvider = new CActiveDataProvider('EssaysHistorical', array('criteria' => array('condition' => 'file_name IS NOT NULL AND essays_has_cruge_user_id_essay_cruge = :id ORDER BY lastdate DESC', 'params' => array(':id' => $essay->id_essay_cruge)))); $this->widget('yiiwheels.widgets.grid.WhGridView', array('type' => TbHtml::GRID_TYPE_STRIPED, 'dataProvider' => $dataProvider, 'template' => "{summary}{items}{pager}", 'enablePagination' => true, 'columns' => array(array('name' => 'ID', 'value' => '$data->id'), array('name' => 'Archivo', 'value' => function ($data, $row) { return EssaysHistorical::model()->nameFile($data->file_name); }), array('name' => 'Version', 'value' => '$data->version'), array('name' => 'Ultima Actualización', 'type' => 'datetime', 'value' => '$data->lastdate'), array('name' => 'Essays', 'type' => 'raw', 'value' => function ($data, $row) { return EssaysHistorical::model()->getLinkEssay($data->id); }), array('name' => 'Correcciones', 'type' => 'raw', 'value' => function ($data, $row) { return EssaysHistorical::model()->getLinkCorr($data->file_name, $data->version); })))); ?> <?php $this->endWidget(); ?> <!-- End Box de Estudents sin Essay --> </div> <?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'myModal', 'options' => array('title' => 'Cambiar Status', 'autoOpen' => false, 'modal' => true, 'width' => 400, 'height' => 300, 'resizable' => false))); $status = new Status(); echo $this->renderPartial('_chance', array('essay' => $essay, 'status' => $status)); $this->endWidget('zii.widgets.jui.CJuiDialog'); ?>
<?php /* @var $this GenerateController */ # render (full page) if (isset($_GET['id'])) { $essay = EssaysHistorical::model()->findByPk($_GET['id']); $essay_content = $essay['content']; } else { $this->redirect(array('essays/essays/index')); } //Configuracion $mPDF1 = Yii::app()->ePdf->mpdf(); $mPDF1 = Yii::app()->ePdf->mpdf('utf-8', 'Letter'); //Cabeceras $mPDF1->SetTitle('Essay - Via-College.com'); $stylesheet = file_get_contents(Yii::getPathOfAlias('webroot.css') . '/via-college-pdf.css'); $mPDF1->WriteHTML($stylesheet, 1); ?> <?php $mPDF1->WriteHTML("<div>"); $mPDF1->WriteHTML("<div><img src='" . Yii::app()->theme->baseUrl . "/img/logos/logo-requisito.png'/></div>"); $mPDF1->WriteHTML("<div></div>"); $mPDF1->WriteHTML("<div><table><tbody><tr><td class='title-college'>Essay"); $mPDF1->WriteHTML("</table></tbody></tr></div>"); $mPDF1->WriteHTML("</table></tbody></tr></div>"); $mPDF1->WriteHTML("<div class='essay-content'>{$essay_content}</div>"); $mPDF1->Output();