Пример #1
0
 /**
  * 活动列表*
  */
 public function actionActivity_list()
 {
     $this->setauth();
     // 检查有无权限
     if ($_POST) {
         $ids = implode('\',\'', $_POST['ids']);
         $count = VcosActivity::model()->deleteAll("activity_id in('{$ids}')");
         // $count1 = VcosActivityCategory::model()->deleteAll("activity_id in('$ids')");
         $count2 = VcosActivityProduct::model()->deleteAll("activity_id in('{$ids}')");
         $sql = "DELETE FROM `vcos_activity_product` WHERE product_id in ('{$ids}') AND product_type=4";
         Yii::app()->p_db->createCommand($sql)->execute();
         if ($count > 0) {
             Helper::show_message(yii::t('vcos', '删除成功。'), Yii::app()->createUrl("Activity/activity_list"));
         } else {
             Helper::show_message(yii::t('vcos', '删除失败。'));
         }
     }
     if (isset($_GET['id'])) {
         $did = $_GET['id'];
         $count = VcosActivity::model()->deleteByPk($did);
         // $count1 = VcosActivityCategory::model()->deleteAll("activity_id in($did)");
         $count2 = VcosActivityProduct::model()->deleteAll("activity_id in({$did})");
         $sql = "DELETE FROM `vcos_activity_product` WHERE product_id ='{$did}' AND product_type=4";
         Yii::app()->p_db->createCommand($sql)->execute();
         if ($count > 0) {
             Helper::show_message(yii::t('vcos', '删除成功。'), Yii::app()->createUrl("Activity/activity_list"));
         } else {
             Helper::show_message(yii::t('vcos', '删除失败。'));
         }
     }
     $count_sql = "SELECT count(*) count FROM `vcos_activity`  WHERE is_nav=0";
     $count = Yii::app()->p_db->createCommand($count_sql)->queryRow();
     $criteria = new CDbCriteria();
     $count = $count['count'];
     $pager = new CPagination($count);
     $pager->pageSize = 10;
     $pager->applyLimit($criteria);
     $sql = "SELECT * FROM `vcos_activity`  WHERE is_nav=0\r\n\t\tLIMIT {$criteria->offset}, 10";
     $activity = Yii::app()->p_db->createCommand($sql)->queryAll();
     $this->render('activity_list', array('pages' => $pager, 'auth' => $this->auth, 'activity' => $activity));
 }
Пример #2
0
 public function actionActivity_product_edit()
 {
     $this->setauth();
     //检查有无权限
     $p_db = Yii::app()->p_db;
     $id = $_GET['id'];
     $layer_cat = '';
     $layer_cat2 = '';
     $layer_1 = '';
     $layer_2 = '';
     $layer_3 = '';
     $product_sel = '';
     $category_code = '';
     $activity_product = VcosActivityProduct::model()->findByPk($id);
     if ($_POST) {
         $activicty = isset($_POST['activity']) ? $_POST['activity'] : 0;
         $product = isset($_POST['product']) ? $_POST['product'] : 0;
         $shop = isset($_POST['shop']) ? $_POST['shop'] : 0;
         $activity_child = isset($_POST['activity_child']) ? $_POST['activity_child'] : 0;
         $activity_category = isset($_POST['activity_category']) ? $_POST['activity_category'] : 0;
         $sort = isset($_POST['sort']) ? $_POST['sort'] : '';
         $product_type = isset($_POST['product_type']) ? $_POST['product_type'] : 0;
         $time = explode(" - ", $_POST['time']);
         $s_time = $time[0] . ' ' . $_POST['stime'];
         $e_time = $time[1] . ' ' . $_POST['etime'];
         $stime = date('Y/m/d H:i:s', strtotime($s_time));
         $etime = date('Y/m/d H:i:s', strtotime($e_time));
         if ($product_type == 3) {
             $product_shop = $shop;
             $activity_category = '';
         } elseif ($product_type == 6) {
             $product_shop = $product;
             $activity_category = $activity_category;
         } elseif ($product_type == 4) {
             $product_shop = $activity_child;
             $activity_category = '';
         }
         //事务处理
         $transaction = $p_db->beginTransaction();
         try {
             $activity_product->activity_id = $activicty;
             $activity_product->product_id = $product_shop;
             $activity_product->activity_cid = $activity_category;
             $activity_product->sort_order = $sort;
             $activity_product->start_show_time = $stime;
             $activity_product->end_show_time = $etime;
             $activity_product->product_type = $product_type;
             $activity_product->save();
             $transaction->commit();
             Helper::show_message(yii::t('vcos', '修改成功。'), Yii::app()->createUrl("Activity/activity_product_list"));
         } catch (Exception $e) {
             $transaction->rollBack();
             Helper::show_message(yii::t('vcos', '修改失败。'));
         }
     }
     $sql = "SELECT activity_id,activity_name FROM `vcos_activity` WHERE status=1";
     $activity = Yii::app()->p_db->createCommand($sql)->queryAll();
     //$sql = "SELECT product_id,product_name FROM `vcos_product` WHERE status=1";
     //$product = Yii::app()->p_db->createCommand($sql)->queryAll();
     $sql = "SELECT activity_cid,activity_category_name FROM `vcos_activity_category` WHERE status=1 AND activity_id = " . $activity_product['activity_id'];
     $activity_category = Yii::app()->p_db->createCommand($sql)->queryAll();
     $sql = "SELECT shop_id,shop_title FROM `vcos_shop` ";
     $shop = Yii::app()->p_db->createCommand($sql)->queryAll();
     $sql = "SELECT activity_id,activity_name FROM `vcos_activity` WHERE activity_id !=" . $activity[0]['activity_id'];
     $activity_child = Yii::app()->p_db->createCommand($sql)->queryAll();
     if ($activity_product['product_type'] == 6) {
         $sql = "SELECT category_code FROM `vcos_product` WHERE product_id=" . $activity_product['product_id'];
         $category_code = Yii::app()->p_db->createCommand($sql)->queryRow();
         $category_code = $category_code['category_code'];
         $sql = "SELECT parent_cid FROM `vcos_category` WHERE category_code =" . $category_code;
         $layer_cat_2 = $p_db->createCommand($sql)->queryRow();
         $sql = "SELECT parent_cid FROM `vcos_category` WHERE category_code =" . $layer_cat_2['parent_cid'];
         $layer_cat_1 = $p_db->createCommand($sql)->queryRow();
         $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=0";
         $layer_1 = $p_db->createCommand($sql)->queryAll();
         $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=" . $layer_cat_1['parent_cid'];
         $layer_2 = $p_db->createCommand($sql)->queryAll();
         $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=" . $layer_cat_2['parent_cid'];
         $layer_3 = $p_db->createCommand($sql)->queryAll();
         $sql = "SELECT product_id,product_name FROM `vcos_product` WHERE category_code=" . $category_code;
         $product = $p_db->createCommand($sql)->queryAll();
         $layer_cat = $layer_cat_1['parent_cid'];
         $layer_cat2 = $layer_cat_2['parent_cid'];
     } else {
         $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=0";
         $layer_1 = $p_db->createCommand($sql)->queryAll();
         $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=" . $layer_1[0]['category_code'];
         $layer_2 = $p_db->createCommand($sql)->queryAll();
         $sql = "SELECT category_code,name,parent_cid FROM `vcos_category` WHERE parent_cid=" . $layer_2[0]['category_code'];
         $layer_3 = $p_db->createCommand($sql)->queryAll();
         $sql = "SELECT product_id,product_name,category_code FROM `vcos_product` WHERE status=1 AND category_code=" . $layer_3[0]['category_code'];
         $product = Yii::app()->p_db->createCommand($sql)->queryAll();
     }
     $this->render('activity_product_edit', array('activity_child' => $activity_child, 'shop' => $shop, 'activity' => $activity, 'product' => $product, 'activity_category' => $activity_category, 'activity_product' => $activity_product, 'layer_cat' => $layer_cat, 'layer_cat2' => $layer_cat2, 'layer_1' => $layer_1, 'layer_2' => $layer_2, 'layer_3' => $layer_3, 'category_code' => $category_code));
 }
Пример #3
0
 public function actionNavigation_content()
 {
     $this->setauth();
     //检查有无权限
     if ($_POST) {
         $ids = implode('\',\'', $_POST['ids']);
         $count = VcosActivityProduct::model()->deleteAll("id in('{$ids}')");
         if ($count > 0) {
             Helper::show_message(yii::t('vcos', '删除成功。'), Yii::app()->createUrl("Navigation/navigation_content"));
         } else {
             Helper::show_message(yii::t('vcos', '删除失败。'));
         }
     }
     if (isset($_GET['id'])) {
         $did = $_GET['id'];
         $count = VcosActivityProduct::model()->deleteByPk($did);
         if ($count > 0) {
             Helper::show_message(yii::t('vcos', '删除成功。'), Yii::app()->createUrl("Navigation/navigation_content"));
         } else {
             Helper::show_message(yii::t('vcos', '删除失败。'));
         }
     }
     /*
     if(isset($_GET['naviagtion'])){
     	$sql = "SELECT activity_id,activity_name FROM `vcos_activity` WHERE  activity_id=".$_GET['activity'];
     	$activity_first = Yii::app()->p_db->createCommand($sql)->queryRow();
     }else{
     	$sql = "SELECT activity_id,activity_name FROM `vcos_activity` LIMIT 1";
     	$activity_first = Yii::app()->p_db->createCommand($sql)->queryRow();
     }
     $navigation_but = $activity_first['activity_id'];
     $type_but = 0;
     
     $activity_id = isset($_GET['activity'])?$_GET['activity']:$activity_first['activity_id'];
     
     $navigation_but =$activity_id;
     $type_but = $type_id;
     */
     $type_id = isset($_GET['type']) ? $_GET['type'] : 0;
     $type_but = $type_id;
     $sql = "SELECT a.navigation_id,a.navigation_name,a.activity_id,b.activity_name FROM `vcos_navigation` a LEFT JOIN `vcos_activity` b ON a.activity_id=b.activity_id WHERE a.status=1";
     $navigation_sel = Yii::app()->p_db->createCommand($sql)->queryAll();
     $navigation_but = $navigation_sel[0]['navigation_id'];
     $activity_id = $navigation_sel[0]['activity_id'];
     $sql = "call fun_activity_product_t1({$activity_id},{$type_id})";
     $activity_product = Yii::app()->p_db->createCommand($sql)->queryAll();
     $criteria = new CDbCriteria();
     $count = count($activity_product);
     $pager = new CPagination($count);
     $pager->pageSize = 10;
     $pager->applyLimit($criteria);
     $this->render('navigation_content', array('navigation_but' => $navigation_but, 'type_but' => $type_but, 'navigation_sel' => $navigation_sel, 'pages' => $pager, 'auth' => $this->auth, 'activity_product' => $activity_product));
 }