/** * 首页 * */ public function actionIndex() { parent::_acl(); $model = new District('district_index'); $criteria = new CDbCriteria(); $count = $model->count($criteria); $pages = new CPagination($count); $pages->pageSize = 10; $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $result = $model->findAll($criteria); $this->city_list = parent::_groupList('city'); $this->render('index', array('datalist' => $result, 'pagebar' => $pages)); }
/** * 管理员编辑 * * @param $id */ public function actionUpdate($id) { parent::_acl('admin_update'); $model = parent::_dataLoad(new Admin(), $id); if (isset($_POST['Admin'])) { $password = $_POST['Admin']['password']; if (empty($password)) { $_POST['Admin']['password'] = $model->password; } else { $_POST['Admin']['password'] = md5($password); } $model->attributes = $_POST['Admin']; if ($model->save()) { AdminLogger::_create(array('catalog' => 'update', 'intro' => '更新管理员资料:' . $model->username)); $this->redirect(array('index')); } } $this->group_list = parent::_groupList('user'); $this->render('admin_update', array('model' => $model)); }
/** * 首页 * */ public function actionIndex($id = 0) { parent::_acl('layout_index'); $model = new Layout(); $criteria = new CDbCriteria(); $condition = '1'; $house_id = $this->_gets->getParam('house_id'); $house_id && ($condition .= ' AND house_id= ' . $house_id); $criteria->condition = $condition; $criteria->order = 't.id DESC'; $count = $model->count($criteria); $pages = new CPagination($count); $pages->pageSize = 10; $pageParams = XUtils::buildCondition($_GET, array('house_id')); $pages->params = is_array($pageParams) ? $pageParams : array(); $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $result = $model->findAll($criteria); $this->house_list = parent::_groupList('house'); $this->render('index', array('datalist' => $result, 'pagebar' => $pages, 'house_id' => $id)); }
/** * 更新 * * @param $id */ public function actionUpdate($id) { parent::_acl('subject_update'); $model = parent::_dataLoad(new Subject(), $id); $imageList = $this->_gets->getParam('imageList'); $layoutList = $this->_gets->getParam('layoutList'); $imageListSerialize = XUtils::imageListSerialize($imageList); $layoutListSerialize = XUtils::imageListSerialize($layoutList); if (isset($_POST['Subject'])) { $model->attributes = $_POST['Subject']; $model->date = strtotime($_POST['Subject']['date']); $file = XUpload::upload($_FILES['attach']); if (is_array($file)) { $model->room_type_image = $file['pathname']; @unlink($_POST['oAttach']); } $model->image_list = $imageListSerialize['dataSerialize']; $model->layout_list = $layoutListSerialize['dataSerialize']; if ($model->save()) { AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑项目,ID:' . $id)); $this->redirect(array('index')); } } if ($imageList) { $imageList = $imageListSerialize['data']; } elseif ($model->image_list) { $imageList = unserialize($model->image_list); } if ($layoutList) { $layoutList = $layoutListSerialize['data']; } elseif ($model->layout_list) { $layoutList = unserialize($model->layout_list); } $this->city_list = parent::_groupList('city'); $this->render('update', array('model' => $model, 'imageList' => $imageList, 'layoutList' => $layoutList)); }
/** * 更新 * * @param $id */ public function actionUpdate($id) { parent::_acl('house_update'); $original = Yii::app()->request->getQuery('original'); $model = parent::_dataLoad(new House(), $id); $imageList = $this->_gets->getParam('imageList'); $imageListSerialize = XUtils::imageListSerialize($imageList); if (isset($_POST['House'])) { $model->attributes = $_POST['House']; $model->accessDate = strtotime($_POST['House']['accessDate']); $model->match = implode(',', $_POST['House']['match']); $file = XUpload::upload($_FILES['house_image']); if (is_array($file)) { $model->house_image = $file['pathname']; @unlink($_POST['oAttach']); } $model->image_list = $imageListSerialize['dataSerialize']; if ($model->save()) { AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑房源信息,ID:' . $id)); if (!empty($original)) { $this->redirect($original); } else { $this->redirect(array('index')); } } } if ($imageList) { $imageList = $imageListSerialize['data']; } elseif ($model->image_list) { $imageList = unserialize($model->image_list); } $this->subject_list = parent::_groupList('subject'); $this->city_list = parent::_groupList('city'); $this->district_list = parent::_groupList('district'); $this->investType_list = parent::_groupList('investType'); $this->propertyType_list = parent::_groupList('propertyType'); $this->match_list = parent::_groupList('match'); $this->render('update', array('model' => $model, 'imageList' => $imageList, 'original' => $original)); }