public function executeIndex(sfWebRequest $request) { //get request parameters $this->selectedBrand = $this->getRequestParameter('brand'); $this->selectedSeries = $this->getRequestParameter('series'); $this->selectedModel = $this->getRequestParameter('model'); $cConfig = new Criteria(); $cConfig->addJoin(ConfigPeer::MODEL_ID, ModelPeer::ID); $cConfig->addJoin(ModelPeer::SERIES_ID, SeriesPeer::ID); $cConfig->addJoin(SeriesPeer::BRAND_ID, BrandPeer::ID); if ($this->selectedBrand) { $cConfig->add(BrandPeer::ID, $this->selectedBrand); } if ($this->selectedSeries) { $cConfig->add(SeriesPeer::SERIES_NAME, $this->selectedSeries, Criteria::LIKE); } if ($this->selectedModel) { $cConfig->add(ModelPeer::MODEL_NAME, $this->selectedModel, Criteria::LIKE); } //$this->Configs = ConfigPeer::doSelect($cConfig); //paginatiom $pager = new sfPropelPager('Config', 15); $pager->setCriteria($cConfig); $pager->setPage($this->getRequestParameter('page')); $pager->init(); $this->pager = $pager; //get config columns $c = new Criteria(); $c->addDescendingOrderByColumn(ConfigFieldCategoryPeer::WEIGHT); $this->configFieldCategories = ConfigFieldCategoryPeer::doSelect($c); //get brands $cBrand = new Criteria(); $this->brands = BrandPeer::doSelect($cBrand); }
public function execute($request) { /*$this->form = new sfForm(); $this->form->setWidgets(array( 'brand' => new sfWidgetFormInputText(), 'series' => new sfWidgetFormInputText(), 'model' => new sfWidgetFormInputText(), 'id' => new sfWidgetFormInputHidden(), 'cpu' => new sfWidgetFormInputText(), 'cache' => new sfWidgetFormInputText(), 'hdd' => new sfWidgetFormInputText(), 'ram' => new sfWidgetFormInputText(), 'graphic' => new sfWidgetFormInputText(), 'display' => new sfWidgetFormInputText(), 'weight' => new sfWidgetFormInputText(), 'optic' => new sfWidgetFormInputText(), 'network' => new sfWidgetFormInputText(), 'wifi' => new sfWidgetFormInputText(), 'wwan' => new sfWidgetFormInputText(), 'size' => new sfWidgetFormInputText(), 'battery' => new sfWidgetFormInputText(), 'os' => new sfWidgetFormInputText(), 'created_at' => new sfWidgetFormDateTime(), 'updated_at' => new sfWidgetFormDateTime(), ));*/ $this->isNew = true; //load config $this->config = new Config(); $this->configId = null; //load model $this->model = new Model(); //load other configuration for this model $this->configs = $this->model->getConfigs(); //load series $this->series = new Series(); //get brands $cBrand = new Criteria(); $this->brands = BrandPeer::doSelect($cBrand); $this->selectedBrand = null; $cFieldCat = new Criteria(); $cFieldCat->addDescendingOrderByColumn(ConfigFieldCategoryPeer::WEIGHT); $this->configFieldCategories = ConfigFieldCategoryPeer::doselect($cFieldCat); $this->setTemplate('config'); }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { //tabs array, we add tab items to it $this->tabs = array(); //get available brands $this->brands = BrandPeer::doSelect(new Criteria()); $tabIndex = 1; $this->tabs[$tabIndex]['title'] = 'برند'; $this->tabs[$tabIndex]['content'] = $this->renderBrands($this->brands); ++$tabIndex; //get field sets $this->configFieldCategories = ConfigFieldCategoryPeer::doSelect(new Criteria()); foreach ($this->configFieldCategories as $configFieldCategory) { $this->tabs[$tabIndex]['title'] = $configFieldCategory->getName(); $this->tabs[$tabIndex]['content'] = $this->renderFieldCategory($configFieldCategory); ++$tabIndex; } }
public function executeListMoveDown(sfWebRequest $request) { $id = $request->getParameter('id'); $current = BrandPeer::retrieveByPK($id); $items = BrandPeer::doSelect(new Criteria()); for ($i = count($items) - 2; $i >= 0; $i--) { //echo $items[$i]; if ($items[$i]->getId() == $id) { $tmp = $items[$i + 1]->getWeight(); $items[$i + 1]->setWeight($tmp != $items[$i]->getWeight() ? $items[$i]->getWeight() : $items[$i]->getWeight() + 1); $items[$i]->setWeight($tmp); $items[$i]->save(); $items[$i + 1]->save(); break; } } $this->redirect('brand'); }
public function execute($request) { $this->isNew = false; //load config $this->config = ConfigPeer::retrieveByPK($this->configId = $this->getRequestParameter('id')); $this->forward404Unless($this->config); $this->configId = $this->config->getId(); //load model $this->model = $this->config->getModel(); //load other configuration for this model $this->configs = $this->model->getConfigs(); //load series $this->series = $this->model->getSeries(); //get brands $cBrand = new Criteria(); $this->brands = BrandPeer::doSelect($cBrand); $this->selectedBrand = $this->series->getBrandId(); $cFieldCat = new Criteria(); $cFieldCat->addDescendingOrderByColumn(ConfigFieldCategoryPeer::WEIGHT); $this->configFieldCategories = ConfigFieldCategoryPeer::doselect($cFieldCat); $this->setTemplate('config'); }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(BrandPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(BrandPeer::DATABASE_NAME); $criteria->add(BrandPeer::ID, $pks, Criteria::IN); $objs = BrandPeer::doSelect($criteria, $con); } return $objs; }
public function executeIndex(sfWebRequest $request) { $this->brands = BrandPeer::doSelect(new Criteria()); }