public function searchPlat($idPlat)
 {
     $criteria = new CDbCriteria();
     //$criteria->select = "id";
     //   $criteria->alias = "t";
     $criteria->mergeWith(array('join' => 'LEFT JOIN characteristic_platforms as cp
                         ON t.id = cp.id_characteristic', 'condition' => 'cp.id_platform = ' . $idPlat));
     Characteristic::model()->findAll($criteria);
     // $criteria->addCondition(array("condtion"=>"id_app = $id_ap"));
     $criteria->compare('id', $this->id);
     $criteria->compare('name', $this->name, true);
     $criteria->compare('id_criteria', $this->id_criteria);
     return new CActiveDataProvider($this, array('criteria' => $criteria, 'pagination' => false));
 }
$selected_characteristic = array();
//para cada plataforma, insere os id_plataforma escolhidos no array
foreach ($model->characteristic as $characteristic) {
    array_push($selected_characteristic, $characteristic->id);
}
?>
			
			<div>
				<?php 
echo TbHtml::label($model->getAttributeLabel('characteristic'), 'Characteristic');
?>
			    <p class="help-block">Choose the platform's characteristics:</p>
                            <div class="model-char">	
				<div class="portlet-content">
				<?php 
echo TbHtml::CheckBoxList('Characteristic', $selected_characteristic, CHtml::listData(Characteristic::model()->findAll(), 'id', 'name'), array('template' => '{input} {label}'));
?>
				<?php 
echo $form->error($model, 'characteristic');
?>
				</div>
			</div>
    </div>
    </div>
    
    
    <?php 
$this->endWidget();
?>

</div><!-- form -->
 public function afterDelete()
 {
     # Проверка и очистка связей
     $characteristics = Characteristic::model()->findAll('Characteristic=:Characteristic', array(':Characteristic' => $this->id));
     if (count($characteristics) > 0) {
         foreach ($characteristics as $characteristic) {
             $characteristic->delete();
         }
     }
     Comment::model()->deleteAll('object_id=:object_id and type=' . L::ritem('CommentType', __CLASS__), array(':object_id' => $this->id));
     return parent::afterDelete();
 }
 /**
  * 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 Characteristic the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Characteristic::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 protected function saveChar($model)
 {
     if (!($brand = Brand::model()->find('alias=:alias', array(':alias' => $model->brand_alias)))) {
         $brand = new Brand();
     }
     $brand->title = $model->brand;
     $brand->alias = $model->brand_alias;
     $brand->save();
     if (!empty($brand->errors)) {
         d('brand ' . $brand->title);
         d($brand->errors);
     }
     if (!($car = Car::model()->find('alias=:alias', array(':alias' => $model->model_alias)))) {
         $car = new Car();
     }
     $car->brand_id = $brand->id;
     $car->title = $model->model;
     $car->alias = $model->model_alias;
     $car->manufacture_start = $model->modificationManufactureStart . '0101';
     $car->manufacture_end = $model->modificationManufactureEnd ? $model->modificationManufactureEnd . '0101' : null;
     $car->save();
     if (!empty($car->errors)) {
         d('model ' . $car->title);
         d($car->errors);
     }
     if (!($mod = Modification::model()->find('alias=:alias', array(':alias' => $model->mod_alias)))) {
         $mod = new Modification();
     }
     $mod->model_id = $car->id;
     $mod->title = $model->mod;
     $mod->alias = $model->mod_alias;
     $mod->manufacture_start = $model->modificationManufactureStart . '0101';
     $mod->manufacture_end = $model->modificationManufactureEnd ? $model->modificationManufactureEnd . '0101' : null;
     $mod->save();
     if (!empty($mod->errors)) {
         d('mod ' . $mod->title);
         d($mod->errors);
     }
     if (!($char = Characteristic::model()->find('modification_id=:mod_id', array(':mod_id' => $mod->id)))) {
         $char = new Characteristic();
     }
     $char->attributes = $model->char->attributes;
     $char->modification_id = $mod->id;
     $char->save();
     if (!empty($char->errors)) {
         d('char ' . $mod->title);
         d($char->errors);
         d($model->url);
     }
 }
 /**
  * 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.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = Characteristic::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
Esempio n. 7
0
		</div>
		
		<?php 
}
?>

		<?php 
if ($options['select'] != 'Brand' && $options['select'] != 'Car') {
    ?>
		
		<div id='<?php 
    echo $this->id;
    ?>
_modification' style='display: none;'>
			<label for='model_id'><?php 
    echo Characteristic::model()->getAttributeLabel('modification_id');
    ?>
</label><br />
			<?php 
    echo CHtml::dropDownList(get_class($model) . '[modification_id]', '', array());
    ?>
			<img src='/images/loader.gif' class='loader' style='display: none;'>
		</div>
		
		<?php 
}
?>
	
		<?php 
Yii::app()->getClientScript()->registerScript($this->id, "jQuery('#{$this->id}').catalogSelect({\r\n\t\t\t\tid:'{$this->id}', \r\n\t\t\t\tmodel_id:'" . $model->{$name} . "', \r\n\t\t\t\tselect: '" . EString::strtolower($options['select']) . "',\r\n\t\t\t\tmodel:'{$options['select']}',\r\n\t\t\t\tbrandSelect: \$('#" . get_class($model) . "_brand_id'),\r\n\t\t\t\tmodelSelect: \$('#" . get_class($model) . "_model_id'),\r\n\t\t\t\tmodificationSelect: \$('#" . get_class($model) . "_modification_id'),\r\n\t\t\t\turlCatalog: '{$options['urlCatalog']}',\r\n\t\t\t\turlBrand: '{$options['urlBrand']}',\r\n\t\t\t\turlModel: '{$options['urlModel']}',\r\n\t\t\t\tallowEmpty: " . ($options['allowEmpty'] ? 'true' : 'false') . "\r\n\t\t\t});");
?>
?>
	<?php 
echo $form->errorSummary($model);
?>
	
<div class="well">
        <div class="well-cinza">
                      <b>Add a Characteristic</b>
                  </div>
                                         <p class="help-block" >If you want add a new characteristic in this platform, choose the characteristic on the list:</p>
        
            <br/>
                                         <div style="overflow:scroll; height: 400px">
        
<?php 
$type_list = CHtml::listData(Characteristic::model()->findAllbySql('SELECT id, CONCAT(name) as name FROM characteristic
                        WHERE id NOT IN
                            (SELECT id_characteristic
                             FROM characteristic_platforms
                             WHERE id_platform =' . $id_plat . ')'), 'id', 'name');
echo $form->radioButtonList($model, 'id_characteristic', $type_list, array('labelOptions' => array('style' => 'font-size:14px')));
?>
            
            
            


        </div>                            
        
</div>
 public function actionSelectdos()
 {
     //$id_cri = $_POST['TestCase']['id_criteria'];
     $id_cri = $_POST['TestCase']['id_criteria'];
     $lista = Characteristic::model()->findAll('id_criteria  = :id_cri', array(':id_cri' => $id_cri));
     $lista = CHtml::listData($lista, 'id', 'name');
     //var_dump($lista);
     echo CHtml::tag('option', array('value' => ''), 'Select', TRUE);
     foreach ($lista as $valor => $name) {
         echo CHtml::tag('option', array('value' => $valor), CHtml::encode($name), true);
     }
 }