public function setplaceAction() { $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); if (is_numeric($this->request->getPost('cat_id')) && $this->request->hasPost('cat_id') && $this->request->isAjax()) { $cat_id = $this->request->getPost('cat_id'); foreach (FieldType::find() as $fl) { if ($fl->id == 4) { $field[$fl->id] = array($fl->name, $fl->dtype, $fl->pref); } } if (!$this->request->hasPost('sub')) { foreach (Categories::find(array("id ={$cat_id} or id_sub ={$cat_id}")) as $categ) { foreach ($categ->fieldtype as $fil) { if (strpos($fil->dtype, "a:") !== false) { $field[$fil->id] = array($fil->name, unserialize($fil->dtype), $fil->pref); } else { $field[$fil->id] = array($fil->name, $fil->dtype, $fil->pref); } } } } else { $ct = Categories::findFirst($cat_id)->id_sub; foreach (Categories::find(array("id ={$ct} or id ={$cat_id}")) as $categ) { foreach ($categ->fieldtype as $fil) { if (strpos($fil->dtype, "a:") !== false) { $field[$fil->id] = array($fil->name, unserialize($fil->dtype), $fil->pref); } else { $field[$fil->id] = array($fil->name, $fil->dtype, $fil->pref); } } } } $this->view->setVars(array('field' => $field = isset($field) ? $field : false)); } else { $this->view->setVars(array('field' => $field = isset($field) ? $field : false)); } }
public function redofferAction() { $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); if ($this->request->hasPost('offer_id')) { foreach (FieldType::find() as $field) { $fil[$field->id] = $field->name; } $offer = Offers::findFirst($this->request->getPost('offer_id')); foreach ($offer->dannoffers as $dan) { $dan_fil[$dan->fieldtype->id] = $dan->dann; } $cat = $offer->categories; $cat_id = $cat->id; foreach (Categories::find(array("id_sub =0")) as $categ) { $category[$categ->id] = $categ->name; } // Получение родительской категории if (count(Categories::find(array("id_sub = {$cat->id}"))) > 0) { foreach (Categories::find(array("id_sub = {$cat->id}")) as $categ) { $sub_cat[$categ->id] = $categ->name; } } else { foreach (Categories::find(array("id = {$cat->id_sub}")) as $categ) { $par_cat = $categ->id; foreach (Categories::find(array("id_sub = {$categ->id}")) as $cate) { $sub_cat[$cate->id] = $cate->name; } } } if (count(Categories::find(array("id = {$cat->id_sub}"))) > 0) { foreach (Categories::findFirst(array("id = {$cat->id_sub}"))->fieldtype as $cat_field) { $cat_fd[$cat_field->id] = array($cat_field->name, $cat_field->pref, $cat_field->dtype); } } foreach ($cat->fieldtype as $cat_field) { $cat_f[$cat_field->id] = array($cat_field->name, $cat_field->pref, $cat_field->dtype); } // $this->elements->var_print($dan_fil); if (!isset($sub_cat)) { $par_cat = $cat_id; } $this->view->setVars(array('field' => $fil, 'cat_field' => $cat_f = isset($cat_f) ? $cat_f : false, 'cat_fieldf' => $cat_fd = isset($cat_fd) ? $cat_fd : false, 'offer_name' => $offer_name = isset($offer->name) ? $offer->name : false, 'offer_text' => $off = isset($offer->text) ? $offer->text : false, 'offer_id' => $off = isset($offer->id) ? $offer->id : false, 'dan_fil' => $dan_fil = isset($dan_fil) ? $dan_fil : false, 'par_cat' => $par_cat = isset($par_cat) ? $par_cat : false, 'cat_id' => $cat_id = isset($cat_id) ? $cat_id : false, 'cat' => $category = isset($category) ? $category : false, 'sub_cat' => $sub_cat = isset($sub_cat) ? $sub_cat : false)); } }