예제 #1
0
 /**
  * 管理图片
  */
 public function ActionAdminPicture()
 {
     //搜索条件处理 [E]
     $searchType = Yii::app()->request->getParam('searchType');
     if ($searchType === 'page') {
         //判断是分页提交还是搜索列表提交的查询条件
         $search = Yii::app()->request->getParam('search');
         $search = unserialize(base64_decode($search));
         //对分布传来的数据进行还原
     } else {
         $search = Yii::app()->request->getParam('search');
     }
     $search_continentid = '';
     //搜索的大洲ID
     $search_countryid = '';
     //搜索的国家ID
     $search_cityids = '';
     //要搜索的所有城市id
     $search_picture_category_id = '';
     //要搜索的图片类型
     $search_pic_name = '';
     //要搜索的图片名称或标题
     $continent = array();
     $country = array();
     $city = array();
     //得到国家名下对应的所有城市ID信息字符串
     if (isset($search) && !empty($search['continent'])) {
         //大洲
         $search_continentid = intval($search['continent']);
         if ($search['country']) {
             //大洲+国家
             $search_countryid = intval($search['country']);
             if (empty($search['city'])) {
                 //大洲+国家+城市
                 $search_cityids = AreaManage::getCityIdStrByCountryId($search_countryid);
             } else {
                 //大洲+国家
                 $search_cityids = intval($search['city']);
             }
         } else {
             //只选择大洲
             $search_countryid = AreaManage::getCountryStrByContinentId($search_continentid);
             if (empty($search['city'])) {
                 $search_cityids = AreaManage::getCityIdStrByCountryId($search_countryid);
             } else {
                 $search_cityids = trim($search['city']);
             }
         }
     }
     //得到图片类型
     if (is_numeric(trim($search['picture_category_id']))) {
         $search_picture_category_id = trim($search['picture_category_id']);
     }
     //图片标题
     if (trim($search['pic_name'])) {
         $search_pic_name = trim($search['pic_name']);
     }
     //所有图片类型
     $picture_category = PictureCategory::model()->findAll();
     $picture_category_list = array();
     if (!empty($picture_category)) {
         foreach ($picture_category as $v) {
             $picture_category_list[$v['ID']] = $v;
         }
     }
     $continent = Continent::model()->findAll();
     //获取所有的大洲信息
     if (!empty($search_continentid)) {
         //返回搜索大洲的下级国家信息
         $country = AreaManage::getCountryByContinentId($search_continentid);
     }
     if (!empty($search_countryid)) {
         //返回搜索国家的下级城市信息
         $city = AreaManage::getCityByCountryId($search_countryid);
     }
     $picture_category = PictureCategory::model()->findAllByAttributes(array('ParentId' => 0));
     // 图片二级类别列表
     if (!empty($search['picture_parent_id'])) {
         // 如果选择了一级图片类别则根据一级类别ID 查询二级类别
         $picture_children_category = PictureCategory::model()->findAllByAttributes(array('ParentId' => $search['picture_parent_id']));
     } else {
         $picture_children_category = array();
     }
     //搜索条件处理 [E]
     $criteria = new CDbCriteria();
     $criteria->order = 'ID DESC';
     // 增加搜索条件 [S]
     $cityIdArr = !empty($search_cityids) ? explode(',', $search_cityids) : array();
     $criteria->compare('Valid', '0');
     //对打上删除标记的数据进行过滤
     if (count($cityIdArr) > 0) {
         $criteria->addInCondition('CityId', $cityIdArr);
     }
     if (!empty($search_picture_category_id)) {
         $criteria->compare('CategoryId', $search_picture_category_id);
     }
     if (!empty($search_pic_name)) {
         //$criteria->compare('Title',$search_pic_name,true);
         $criteria->addSearchCondition('Title', $search_pic_name);
     }
     //增加搜索条件 [E]
     $count = Picture::model()->count($criteria);
     $pager = new CPagination($count);
     if (!empty($search)) {
         //判断是否存在搜索条件,并对搜索条件进行数据处理(便于url传输)
         $pager->params = array('search' => base64_encode(serialize($search)), 'searchType' => 'page');
     }
     $pager->pageSize = 20;
     $pager->applyLimit($criteria);
     $picture_list = Picture::model()->findAll($criteria);
     $picIdStr = '';
     //图片ID字符串
     $cityIDStr = '';
     //城市ID字符串
     if (!empty($picture_list)) {
         foreach ($picture_list as $val) {
             $picIdStr .= $val['ID'] . ',';
             $cityIDStr .= $val['CityId'] . ',';
         }
     }
     //得到图片地址信息列表
     $picture_source = PictureSourceManage::getPicSourceArrByPicIdStr($picIdStr);
     //得到每张图片所在的名称:(城市-国家-大洲)
     $area = AreaManage::getAreaByCityid($cityIDStr);
     $this->render('list_picture', array('picture_list' => $picture_list, 'picture_category_list' => $picture_category_list, 'picture_source' => $picture_source, 'pages' => $pager, 'area' => $area, 'continent' => $continent, 'picture_category' => $picture_category, 'picture_children_category' => $picture_children_category, 'search' => $search, 'country' => $country, 'city' => $city));
 }
 /**
  * 修改购物中心
  * @param $shopping_mall_id 购物中心ID
  * @return bool
  */
 public function ActionModifyShoppingMall($shopping_mall_id)
 {
     $shopping_mall_model = ShoppingMall::model();
     $shopping_mall_info = $shopping_mall_model->findByPk($shopping_mall_id);
     // 根据ID查询出对应的购物中心数据
     $old_shopping_mall_info = $shopping_mall_info;
     // 保存购物中心的旧数据,作为日志的新旧数据对比用
     // 获取全部品牌
     $brand_criteria = new CDbCriteria();
     $brand_criteria->select = array('Id', 'BrandName');
     $brand = IconvEncode::ObjArrChangeArray(Brand::model()->findAll($brand_criteria), 'BrandName');
     // 获取全部餐厅
     $restaurant_criteria = new CDbCriteria();
     $restaurant_criteria->select = array('Id', 'RestaurantName');
     $restaurant = IconvEncode::ObjArrChangeArray(Restaurant::model()->findAll($restaurant_criteria), 'RestaurantName');
     // 获取全部优惠卡/券
     $discount_criteria = new CDbCriteria();
     $discount_criteria->select = array('Id', 'DiscountCardName');
     $discount_card = IconvEncode::ObjArrChangeArray(DiscountCard::model()->findAll($discount_criteria), 'DiscountCardName');
     // 获取所有 大洲/国家/城市
     $continent = Continent::model()->findAll();
     $country = AreaManage::getCountryByContinentId($shopping_mall_info['ContinentId']);
     $city = AreaManage::getCityByCountryId($shopping_mall_info['CountryId']);
     // 将 品牌/餐厅/优惠卡 ID串转为ID数组
     $card_ids = explode(',', $shopping_mall_info['CardIds']);
     $brand_ids = explode(',', $shopping_mall_info['BrandIds']);
     $restaurant_ids = explode(',', $shopping_mall_info['RestaurantIds']);
     // 有表单提交则更新
     if (isset($_POST['ShoppingMall']) && !empty($shopping_mall_id)) {
         $is_modify = false;
         // 保存时判断是否做过任意修改
         $log = Yii::app()->user->name . '于 ' . date('Y-m-d H:i:s', time()) . ' 修改了 【' . $old_shopping_mall_info['Name_Cn'] . '】 购物中心,';
         // 日志描述
         // 替换表单数据中的值
         $_POST['ShoppingMall']['BusinessTime'] = trim($_POST['ShoppingMall']['StartTime']) . '~' . trim($_POST['ShoppingMall']['EndTime']);
         // 整合起始与结束时间
         unset($_POST['ShoppingMall']['StartTime']);
         // 移除StartTime
         unset($_POST['ShoppingMall']['EndTime']);
         // 移除EndTime
         $_POST['ShoppingMall']['CardIds'] = !empty($_POST['ShoppingMall']['CardIds']) ? implode(',', $_POST['ShoppingMall']['CardIds']) : '';
         // 将优惠卡ID数组转成ID字符串
         $_POST['ShoppingMall']['BrandIds'] = !empty($_POST['ShoppingMall']['BrandIds']) ? implode(',', $_POST['ShoppingMall']['BrandIds']) : '';
         // 将品牌ID数组转成ID字符串
         $_POST['ShoppingMall']['RestaurantIds'] = !empty($_POST['ShoppingMall']['RestaurantIds']) ? implode(',', $_POST['ShoppingMall']['RestaurantIds']) : '';
         // 将餐厅ID数组转成ID字符串
         // 生成日志记录
         $attribute = ShoppingMall::model()->attributeLabels();
         foreach ($_POST['ShoppingMall'] as $_k => $_v) {
             // 新旧数据不一致 则生成日志
             if ($old_shopping_mall_info[$_k] != $_v) {
                 $is_modify = true;
                 // 赋为true 表示有数据被修改
                 $old_shopping_mall_info[$_k] = empty($old_shopping_mall_info[$_k]) ? '未填写' : $old_shopping_mall_info[$_k];
                 // 判断被修改的数据原值是否为空
                 $log .= '将【' . $attribute[$_k] . '】 由 【' . $old_shopping_mall_info[$_k] . '】 修改为 【' . $_v . '】,';
                 // 拼接日志描述
             }
         }
         // 填充模型
         $shopping_mall_info->attributes = $_POST['ShoppingMall'];
         // 执行更新
         if ($shopping_mall_info->save()) {
             $is_modify ? OperationLogManage::AddOperationLog(trim($log, ',')) : '';
             // 添加日志
             Yii::app()->user->setFlash('save_sign', '修改成功');
             $this->redirect(Yii::app()->createUrl('ShoppingMall/ListShoppingMall'));
         } else {
             Yii::app()->user->setFlash('save_sign', '修改失败');
             // 替换 品牌/餐厅/优惠卡 ID
             $shopping_mall_info['CardIds'] = $card_ids;
             $shopping_mall_info['BrandIds'] = $brand_ids;
             $shopping_mall_info['RestaurantIds'] = $restaurant_ids;
             // 跳转至购物中心修改页
             $this->render('modify_shopping_mall', array('shopping_mall_info' => $shopping_mall_info, 'continent' => $continent, 'country' => $country, 'city' => $city, 'brand' => $brand, 'restaurant' => $restaurant, 'discount_card' => $discount_card));
         }
     } else {
         // 替换 品牌/餐厅/优惠卡 ID
         $shopping_mall_info['CardIds'] = $card_ids;
         $shopping_mall_info['BrandIds'] = $brand_ids;
         $shopping_mall_info['RestaurantIds'] = $restaurant_ids;
         // 跳转至购物中心修改页
         $this->render('modify_shopping_mall', array('shopping_mall_info' => $shopping_mall_info, 'continent' => $continent, 'country' => $country, 'city' => $city, 'brand' => $brand, 'restaurant' => $restaurant, 'discount_card' => $discount_card));
     }
 }
예제 #3
0
 /**
  * 修改酒店
  */
 public function ActionModifyHotel()
 {
     $hotel_id = trim(Yii::app()->request->getParam('hotel_id'));
     // 获取酒店ID
     if (!empty($hotel_id) && intval($hotel_id) > 0) {
         // 根据酒店ID 获取要修改的酒店数据
         $hotel_obj = Hotel::model()->findByPk($hotel_id);
         // 获取所有 大洲/国家/城市 数据
         $continent = Continent::model()->findAll();
         $country = AreaManage::getCountryByContinentId($hotel_obj['ContinentId']);
         $city = AreaManage::getCityByCountryId($hotel_obj['CountryId']);
         // 判断是执行修改 还是跳转至修改页
         if (Yii::app()->request->isPostRequest) {
             // 获取提交的表单数据
             $hotel_obj->attributes = Yii::app()->request->getParam('Hotel');
             $hotel_obj->HotelIntroduction = $_POST['Hotel']['HotelIntroduction'];
             $hotel_obj->DecorationTime = $_POST['Hotel']['DecorationTime'];
             // 执行修改操作
             if ($hotel_obj->save()) {
                 Yii::app()->user->setFlash('message', '修改成功');
                 $this->redirect(array('Hotel/HotelList'));
             } else {
                 Yii::app()->user->setFlash('message', '修改失败');
                 $this->render('modify_hotel', array('hotel_obj' => $hotel_obj, 'continent' => $continent, 'country' => $country, 'city' => $city));
             }
         } else {
             // 跳转至修改酒店页
             $this->render('modify_hotel', array('hotel_obj' => $hotel_obj, 'continent' => $continent, 'country' => $country, 'city' => $city));
         }
     }
 }
예제 #4
0
 /**
  * 景点管理
  */
 public function actionListViewSpot()
 {
     //搜索条件处理 [E]
     $searchType = Yii::app()->request->getParam('searchType');
     if ($searchType === 'page') {
         //判断是分页提交还是搜索列表提交的查询条件
         $search = Yii::app()->request->getParam('search');
         $search = unserialize(base64_decode($search));
         //对分布传来的数据进行还原
     } else {
         $search = Yii::app()->request->getParam('search');
     }
     $search_continentid = '';
     //搜索的大洲ID
     $search_countryid = '';
     //搜索的国家ID
     $search_cityids = '';
     //要搜索的所有城市id
     $search_name = '';
     //要搜索的图片名称或标题
     $continent = array();
     $country = array();
     $city = array();
     //得到国家名下对应的所有城市ID信息字符串
     if (isset($search) && !empty($search['continent'])) {
         //大洲
         $search_continentid = intval($search['continent']);
         if ($search['country']) {
             //大洲+国家
             $search_countryid = intval($search['country']);
             if (empty($search['city'])) {
                 //大洲+国家+城市
                 $search_cityids = AreaManage::getCityIdStrByCountryId($search_countryid);
             } else {
                 //大洲+国家
                 $search_cityids = intval($search['city']);
             }
         } else {
             //只选择大洲
             $search_countryid = AreaManage::getCountryStrByContinentId($search_continentid);
             if (empty($search['city'])) {
                 $search_cityids = AreaManage::getCityIdStrByCountryId($search_countryid);
             } else {
                 $search_cityids = trim($search['city']);
             }
         }
     }
     //图片标题
     if (trim($search['name'])) {
         $search_name = trim($search['name']);
     }
     //所有图片类型
     $picture_category = PictureCategory::model()->findAll();
     $picture_category_list = array();
     if (!empty($picture_category)) {
         foreach ($picture_category as $v) {
             $picture_category_list[$v['ID']] = $v;
         }
     }
     $continent = Continent::model()->findAll();
     //获取所有的大洲信息
     if (!empty($search_continentid)) {
         //返回搜索大洲的下级国家信息
         $country = AreaManage::getCountryByContinentId($search_continentid);
     }
     if (!empty($search_countryid)) {
         //返回搜索国家的下级城市信息
         $city = AreaManage::getCityByCountryId($search_countryid);
     }
     //搜索条件处理 [E]
     $criteria = new CDbCriteria();
     $criteria->order = 'ID desc';
     $criteria->compare('Valid', '0', true);
     //增加搜索条件 [S]
     $cityIdArr = !empty($search_cityids) ? explode(',', $search_cityids) : array();
     if (count($cityIdArr) > 0) {
         $criteria->addInCondition('CityID', $cityIdArr);
     }
     if (!empty($search_name)) {
         $criteria->addSearchCondition('NameCn', $search_name);
         //$criteria->addSearchCondition('NameCnShort',$search_name,true,'or');
     }
     //增加搜索条件 [E]
     $view_spot_count = ViewSpot::model()->count($criteria);
     $pager = new CPagination($view_spot_count);
     if (!empty($search)) {
         //判断是否存在搜索条件,并对搜索条件进行数据处理(便于url传输)
         $pager->params = array('search' => base64_encode(serialize($search)), 'searchType' => 'page');
     }
     $pager->pageSize = 20;
     $pager->applyLimit($criteria);
     $view_spot_models = ViewSpot::model()->findAll($criteria);
     $cityIDStr = '';
     //城市ID字符串
     if (!empty($view_spot_models)) {
         foreach ($view_spot_models as $val) {
             $cityIDStr .= $val['CityID'] . ',';
         }
     }
     //得到每张图片所在的名称:(城市-国家-大洲)
     $area = AreaManage::getAreaByCityid($cityIDStr);
     $this->render('list_view_spot', array('view_spot_models' => $view_spot_models, 'pager' => $pager, 'country' => $country, 'continent' => $continent, 'city' => $city, 'search' => $search, 'area' => $area));
 }