public function init() { $criteria = new CDbCriteria(); $criteria->select = 'kindparent, id_parent'; $kindparent = Kindparent::model()->findAll($criteria); foreach ($kindparent as $object) { $mainlist[] = $object->kindparent; $inkinds[$object->kindparent] = $object->inkinds(array('condition' => 'id_parent=' . "'{$object->id_parent}'")); foreach ($inkinds as $data) { foreach ($data as $object1) { $list[$object->kindparent][$object1->id_inkind] = $object1->inkind; $inkinds = []; } } } //var_dump($mainlist); //var_dump($list); foreach ($list as $key => $val) { //For ($j=0;$j<count($val);$j++){ //$inkinds[]=$object->inkinds(array('condition'=>"$list[$i]")); foreach ($val as $Kkey => $Vval) { $menuitems[] = array('label' => "{$Vval}", 'url' => array("/product/index/", 'id_inkind' => $Kkey)); } $this->items[] = array('label' => "{$key}", 'url' => array("/product/search/", 'searchString' => $key), 'items' => $menuitems); $menuitems = []; } if (isset($this->htmlOptions['id'])) { $this->id = $this->htmlOptions['id']; } else { $this->htmlOptions['id'] = $this->id; } $route = $this->getController()->getRoute(); $this->items = $this->normalizeItems($this->items, $route, $hasActiveChild); }
public function run() { $criteria = new CDbCriteria(); $criteria->select = 'inkind'; $criteria->distinct = true; $t['unselectValue'] = NULL; $this->inkind = Inkind::model()->findAll($criteria); //var_dump($this->inkind); for ($i = 0; $i < count($this->inkind); $i++) { $t[$this->inkind[$i]->inkind] = $this->inkind[$i]->inkind; } $t['unselectValue'] = ''; $this->inkind = $t; $t = []; // var_dump($this->inkind); $criteria = new CDbCriteria(); $criteria->select = 'kindparent'; $criteria->distinct = true; $t['unselectValue'] = NULL; $this->kindparent = Kindparent::model()->findAll($criteria); //var_dump($this->inkind); for ($i = 0; $i < count($this->kindparent); $i++) { $t[$this->kindparent[$i]->kindparent] = $this->kindparent[$i]->kindparent; } $this->kindparent = $t; $t = []; // var_dump($this->kindparent); $criteria = new CDbCriteria(); $criteria->select = 'producer'; $criteria->distinct = true; //$t['uncheckValue']=NULL; $this->producer = Producer::model()->findAll($criteria); //var_dump($this->inkind); for ($i = 0; $i < count($this->producer); $i++) { $t[$this->producer[$i]->producer] = $this->producer[$i]->producer; } $this->producer = $t; $t = []; $form = new ProductSelectForm(); $form->clearErrors(); if (isset($_POST['ProductSelectForm'])) { $form->attributes = $_POST['ProductSelectForm']; } // if (isset($_POST['ProductSelectForm'])) { // $form->kindparent=$_POST['ProductSelectForm']['kindparent']; // $form->inkind=$_POST['ProductSelectForm']['inkind']; // $form->producer=$_POST['ProductSelectForm']['producer'];} //$form->min=$_POST['ProductSelectForm']['min']; //$form->max=$_POST['ProductSelectForm']['max']; // var_dump($_POST['ProductSelectForm']); // } //var_dump($_POST); // var_dump($form->validate()); // if (isset($_POST['ProductSelectForm'])&&(!$form->validate())) { // unset($_POST['SiteSearchForm']); // $form->clearErrors(); // $form->addError('ProductSelectForm','Задайте условия поиска'); // $z=$form->getErrors(); // var_dump($z); // } // } // var_dump($_GET); $this->render('productSelect', array('form' => $form, 'inkind' => $this->inkind, 'kindparent' => $this->kindparent, 'producer' => $this->producer)); $form->clearErrors(); }
/** * 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 Kindparent the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Kindparent::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }