?> <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'attribute' => 'fechaExamen', 'language' => 'es', 'themeUrl' => Yii::app()->baseUrl . '/css/jquery-ui-themes/themes', 'theme' => 'bootstrap', 'flat' => true, 'options' => array('onSelect' => 'js: test', 'dateFormat' => 'dd-mm-yy', 'showOtherMonths' => true, 'selectOtherMonths' => true, 'changeYear' => true, 'changeMonth' => true, 'showButtonPanel' => true, 'yearRange' => '2013:2099'), 'htmlOptions' => array('size' => '7', 'readonly' => "readonly", 'maxlength' => '10'))); ?> <?php echo $form->error($model, 'fechaExamen'); ?> </div> </div> <div id="right-content"> <div class="row"> <?php echo $form->labelEx($model, 'tipoexamen_id'); ?> <?php echo CHtml::dropDownList('Examen[tipoexamen_id]', $model->tipoexamen_id, CHtml::listData(Tipoexamen::model()->getTiposExamenes($model->materia_id), 'id', 'nombreTipoExamen') + array(-1 => 'Otro...'), array('id' => 'Examen_tipoexamen_id')); ?> <?php echo $form->error($model, 'tipoexamen_id'); ?> </div> <div id="tipoPersonalizado" class="row"> <?php echo $form->labelEx($model, 'TipoExamenPersonalizado'); ?> <?php echo $form->textField($model, 'TipoExamenPersonalizado', array('size' => 45, 'maxlength' => 60)); ?> <?php echo $form->error($model, 'TipoExamenPersonalizado'); ?>
/** * Dada una materia devuelve los tipos de examen para esa materia en formato json */ public function actionGetTipos($id) { $resp = Tipoexamen::model()->getTiposExamenes($id); header("Content-type: application/json"); echo CJSON::encode($resp); }
public function existsInDatabase($nombreTipoExamen, $Materia_id, $id) { $criteria = new CDbCriteria(); $criteria->select = 'nombreTipoExamen, Materia_id'; $criteria->condition = 'LOWER(nombreTipoExamen)=:nombreTipoExamen AND Materia_id=:Materia_id AND id!=:id'; $criteria->params = array(':nombreTipoExamen' => strtolower($nombreTipoExamen), ':Materia_id' => $Materia_id, ':id' => $id); $records = Tipoexamen::model()->find($criteria); return count($records) > 0; }
<?php $this->pageTitle = Yii::app()->name . ' - Examenes.'; Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n \$('.search-form').toggle();\n return false;\n});\n\$('.search-form form').submit(function(){\n \$('#examen-grid').yiiGridView('update', {\n data: \$(this).serialize()\n });\n return false;\n});\n"); ?> <div class="titulo"> <h1>Examenes</h1> </div> <?php $this->widget('bootstrap.widgets.TbMenu', array('type' => 'pills', 'items' => array(array('label' => 'Nuevo', 'icon' => 'icon-plus', 'url' => Yii::app()->controller->createUrl('create')), array('label' => 'Listado', 'icon' => 'icon-th-list', 'url' => Yii::app()->controller->createUrl('index'), 'active' => true, 'linkOptions' => array()), array('label' => 'Exportar a PDF', 'icon' => 'icon-download', 'url' => Yii::app()->controller->createUrl('GeneratePdf'), 'linkOptions' => array('target' => '_blank'), 'visible' => true), array('label' => 'Exportar a Excel', 'icon' => 'icon-download', 'url' => Yii::app()->controller->createUrl('GenerateExcel'), 'linkOptions' => array('target' => '_blank'), 'visible' => true), array('itemOptions' => array('id' => 'deleteAll', 'onclick' => 'delete_all_records()'), 'label' => 'Eliminar todos los examenes', 'icon' => 'icon-remove-sign', 'url' => '#', 'linkOptions' => array('class' => ' btn-danger btn-small '), 'visible' => Yii::app()->user->isAdmin()), array('itemOptions' => array('id' => 'deleteAll', 'onclick' => 'delete_all_my_records(' . Yii::app()->user->name . ')'), 'label' => 'Eliminar todos mis examenes', 'icon' => 'icon-remove-sign', 'url' => '#', 'linkOptions' => array('class' => ' btn-danger btn-small '), 'visible' => !Yii::app()->user->isAdmin())))); $grid = $this->widget('bootstrap.widgets.TbGridView', array('id' => 'examen-grid', 'dataProvider' => $model->search(), 'type' => $this->table_style, 'template' => $this->table_template, 'filter' => $model, 'columns' => array(array('header' => 'Fecha', 'name' => 'fechaExamen', 'headerHtmlOptions' => array('style' => 'width:145px'), 'value' => 'Yii::app()->dateFormatter->format("dd MMM y",strtotime($data->fechaExamen))', 'filter' => CHtml::listData(Examen::model()->findAll(), 'fechaExamen', 'formattedDate')), array('header' => 'Materia', 'name' => 'materia_id', 'value' => '$data->materia->id." - ".$data->materia->nombreMateria', 'headerHtmlOptions' => array('style' => 'width:550px'), 'filter' => CHtml::listData(Materia::model()->getTodasLasMaterias('nombreMateria'), 'id', 'concatened')), array('header' => 'Tipo de examen', 'name' => 'tipoexamen_id', 'value' => '$data->tipoexamen->nombreTipoExamen', 'headerHtmlOptions' => array('style' => 'width:200px'), 'filter' => CHtml::listData(Tipoexamen::model()->findAll(array('order' => 'nombreTipoExamen')), 'id', 'nombreTipoExamen')), array('type' => 'raw', 'value' => ' Yii::app()->user->getName()==$data->materia_id || Yii::app()->user->isAdmin() ? "<a href=\'javascript:void(0);\' onclick=\'renderView(".$data->id.")\' class=\'btn btn-small view\' ><i class=\'icon-eye-open\'></i></a><a href=\'index.php?r=examen/update&id=$data->id\' onclick=\'renderUpdateForm(".$data->id.")\' class=\'btn btn-small view\' ><i class=\'icon-pencil\'></i></a> <a href=\'javascript:void(0);\' onclick=\'delete_record(".$data->id.")\' class=\'btn btn-small view\' ><i class=\'icon-trash\'></i></a> ": "<a href=\'javascript:void(0);\' onclick=\'renderView(".$data->id.")\' class=\'btn btn-small view\' ><i class=\'icon-eye-open\'></i></a>"', 'headerHtmlOptions' => array('style' => 'width:95px;text-align:left'))))); $this->renderPartial("_ajax_view"); ?> <script type="text/javascript"> function delete_record(id) { var id; this.id = id; bootbox.confirm("<img src='images/warning.png'/> ¿Está seguro de eliminar este examen?<br/><br/>", function (result) { if (!result) return; // $('#ajaxtest-view-modal').modal('hide'); var data = "id=" + id; jQuery.ajax({ type: 'POST', url: '<?php echo Yii::app()->createAbsoluteUrl("examen/delete"); ?> ', data: data,
/** * 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 the ID of the model to be loaded */ public function loadModel($id) { $model = Tipoexamen::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'La página solicitada no existe.'); } return $model; }
?> <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $modelos[$i], 'attribute' => "[{$i}]fechaExamen", 'language' => 'es', 'name' => "[{$i}]fechaExamen", 'themeUrl' => Yii::app()->baseUrl . '/css/jquery-ui-themes/themes', 'theme' => 'bootstrap', 'flat' => false, 'options' => array('onSelect' => 'js: CheckExamenOnSameDay', 'dateFormat' => 'dd-mm-yy', 'showOtherMonths' => true, 'selectOtherMonths' => true, 'changeYear' => true, 'changeMonth' => true, 'showButtonPanel' => true, 'yearRange' => '2013:2099'), 'htmlOptions' => array('size' => '7', 'readonly' => "readonly", 'maxlength' => '10'))); ?> </div> </div> <div id="right-content"> <div class="row"> <?php echo $form->error($modelos[$i], 'tipoexamen_id'); ?> <?php echo $form->labelEx($modelos[$i], "[{$i}]tipoexamen_id"); ?> <?php echo CHtml::activeDropDownList($modelos[$i], "[{$i}]tipoexamen_id", CHtml::listData(Tipoexamen::model()->getTiposExamenes(Yii::app()->user->name), 'id', 'nombreTipoExamen') + array(-1 => 'otro'), array('onChange' => 'javascript:test(this)'), array('options' => array($modelos[$i]->tipoexamen_id => array('selected' => true)), 'empty' => '-Por favor seleccione-')); ?> </div> <div <?php echo 'class="row tipoPersonalizado" id="tipoPersonalizado_' . $i . '"'; ?> > <?php echo $form->labelEx($modelos[$i], 'TipoExamenPersonalizado'); ?> <?php echo $form->textField($modelos[$i], "[{$i}]TipoExamenPersonalizado", array('size' => 45, 'maxlength' => 60)); ?> <?php echo $form->error($modelos[$i], 'TipoExamenPersonalizado'); ?>