/** * Retorna el nombre para el archivo del essay */ public function getNameFileEssay($idColleges, $idTypeEssay) { return Colleges::model()->getNameCollege($idColleges) . "-" . EssayType::model()->findByPk($idTypeEssay)->short_name; }
<?php /* @var $this RequirementsController */ /* @var $model Requirements */ $this->breadcrumbs = array('Requisitos' => array('index'), 'Administrar'); $this->menu = array(array('label' => CHtml::image(Yii::app()->theme->baseUrl . "/img/operaciones/list29.png") . ' Listado', 'url' => array('index')), array('label' => CHtml::image(Yii::app()->theme->baseUrl . "/img/operaciones/plus27.png") . ' Crear Requirement', 'url' => array('create'))); ?> <legend>Gestionar Requirements</legend> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('bootstrap.widgets.TbGridView', array('id' => 'requirements-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', 'create_date', 'last_update', 'colleges_id' => array('name' => 'colleges_id', 'value' => '$data->colleges->name', 'filter' => CHtml::listData(Colleges::model()->findAll(array('order' => 'name ASC')), 'id', 'name')), array('class' => 'bootstrap.widgets.TbButtonColumn'))));
public function getNameCollege($id) { //$name = stristr(Colleges::model()->findByPk($id)->name, 'university', true); $condicion = array('university', 'college', 'school', 'institute', 'politechnic', 'of', ','); $name = trim(str_replace($condicion, ' ', strtolower(Colleges::model()->findByPk($id)->name))); return strtoupper($name) . "-" . $this->getTypeCollege($id); }
?> <?php /*echo $form->dropDownListControlGroup(Colleges::model(), 'id', CHtml::listData(Colleges::model()->findAll(array('order'=>'name ASC')), 'id','name'),array('multiple' => true,'class'=>'span5','maxlength'=>256) ); */ ?> <p>Colleges <span class="required">*</span></p> <?php $Options = array(); foreach ($model->colleges as $colleges) { $Options[$colleges->id] = array('selected' => 'selected'); } $form->widget('yiiwheels.widgets.multiselect.WhMultiSelect', array('name' => 'colleges', 'data' => CHtml::listData(Colleges::model()->findAll(array('order' => 'name ASC')), 'id', 'name'), 'pluginOptions' => array('includeSelectAllOption' => false, 'enableFiltering' => true, 'enableCaseInsensitiveFiltering' => true, 'buttonWidth' => '300', 'maxHeight' => '300'), 'htmlOptions' => array('options' => $Options))); ?> <br /> <br /> <?php echo $form->dropDownListControlGroup($model, 'categories_majors_id', CHtml::listData(CategoriesMajors::model()->findAll(array('order' => 'name ASC')), 'id', 'name')); ?> <?php echo $form->textAreaControlGroup($model, 'description', array('span' => 6, 'rows' => 10, 'maxlength' => 11000)); ?> </fieldset> <?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'essays-form', 'enableAjaxValidation' => false, 'htmlOptions' => array('enctype' => 'multipart/form-data'))); ?> <p class="help-block">Campos con <span class="required">*</span> son requeridos.</p> <?php echo $form->errorSummary($model); ?> <p>Nombre de College <span class="required">*</span></p> <p> <?php $criteria = new CDbCriteria(); //$criteria->condition = "EXISTS (SELECT 1 FROM colleges_has_majors WHERE colleges_id = id) ORDER BY name ASC"; $criteria->condition = "EXISTS (SELECT name FROM colleges) ORDER BY name ASC"; $data = Colleges::model()->findAll($criteria); $form->widget('yiiwheels.widgets.select2.WhSelect2', array('model' => $model, 'attribute' => 'colleges_has_majors_colleges_id', 'name' => 'selectCollege', 'asDropDownList' => true, 'data' => CHtml::listData($data, 'id', 'name'), 'pluginOptions' => array('allowClear' => true, 'width' => '40%'), 'htmlOptions' => array('prompt' => 'Seleccione un College...'))); ?> </p> <br /> <p>Nombre de Major <span class="required">*</span></p> <p> <?php $form->widget('yiiwheels.widgets.select2.WhSelect2', array('model' => $model, 'attribute' => 'colleges_has_majors_majors_id', 'name' => 'selectMajor', 'asDropDownList' => true, 'data' => array(''), 'pluginOptions' => array('allowClear' => true, 'width' => '40%'), 'htmlOptions' => array('prompt' => 'Seleccione un Major...', 'disabled' => false))); ?> </p> <br />
public function actionCargarMajor() { if (Yii::app()->request->isAjaxRequest && isset($_POST['idCollege'])) { //echo CHtml::encode(print_r($_POST, true));//imprimir si algo llega x post $searched = $_POST['idCollege']; $criteria = new CDbCriteria(); $criteria->condition = "id= :searched"; $criteria->params = array(":searched" => "{$searched}"); $college = Colleges::model()->findAll($criteria); /* $data = requerimiento::model()->findAll('PRY_Id=:parent_id', array(':parent_id'=>(int) $_POST['PRY_Id'])); */ $data = CHtml::listData($college[0]->majors, 'id', 'name'); foreach ($data as $id => $value) { echo CHtml::tag('option', array('value' => $id), CHtml::encode($value), true); } Yii::app()->end(); } }
<div class="form"> <?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'requirements-form', 'enableAjaxValidation' => false)); ?> <p class="help-block">Campos con <span class="required">*</span> son necesarios.</p> <?php echo $form->errorSummary($model); ?> <?php $sql = "SELECT * FROM `colleges` WHERE NOT EXISTS (SELECT * FROM `requirements` WHERE `requirements`.colleges_id = `colleges`.id) ORDER BY `colleges`.name ASC"; ?> <?php echo $form->dropDownListControlGroup($model, 'colleges_id', CHtml::listData(Colleges::model()->findAllBySql($sql), 'id', 'name')); ?> <?php /*$this->widget('yiiwheels.widgets.formhelpers.WhDatePickerHelper',array( 'name' => 'create_date', 'inputOptions' => array('class' => 'input-medium'), 'value' => date("Y-m-d"), ));*/ ?> <?php echo $form->hiddenField($model, 'create_date', array('type' => "hidden", 'value' => date("Y-m-d"))); ?>
/** * 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 = Colleges::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }