Esempio n. 1
0
 function GetDevloper($Type = null, $status = null, $limit = null, $UserType = null)
 {
     App::import('Model', 'Advertise');
     $objAdvertise = new Advertise();
     $objAdvertise->bindModel(array('belongsTo' => array('User' => array('foreignKey' => 0, 'conditions' => 'Advertise.user_id = User.id'))), false);
     $condition = array('Advertise.category_type in (' . $Type . ')', "Advertise.status" => $status, 'User.user_type_id in (' . $UserType . ')');
     $AdvertisearrData = $objAdvertise->find("all", array("conditions" => $condition, 'order' => array('Advertise.modified' => 'DESC'), 'limit' => $limit));
     return $AdvertisearrData;
 }
Esempio n. 2
0
 public static function get_all_advertise($connection)
 {
     $statement = $connection->prepare("SELECT * FROM advertise");
     $statement->execute();
     $result = $statement->get_result();
     $advertises = array();
     while ($row = $result->fetch_assoc()) {
         $advertise = new Advertise();
         $advertise->set_email($row["email"]);
         $advertise->set_title($row["title"]);
         $advertise->set_content($row["content"]);
         array_push($advertises, $advertise);
     }
     return $advertises;
 }
Esempio n. 3
0
 public function testMerge()
 {
     $adv = Advertise::model()->findByPk(23);
     $map = array();
     foreach ($adv->advChannels as $advChannel) {
         $map[$advChannel->tag] = $advChannel;
     }
 }
Esempio n. 4
0
 private function getAdvId($name)
 {
     $model = Advertise::model()->findByAttributes(array('name' => $name));
     if ($model) {
         return $model->id;
     }
     return 0;
 }
Esempio n. 5
0
 public function actionImport()
 {
     while ($row = fgets(STDIN)) {
         $row = trim($row);
         if (!$row) {
             continue;
         }
         $row = preg_replace('/\\s+/', "\t", $row);
         list($name, $income_price, $outcome_price) = explode("\t", $row);
         $advertise = new Advertise();
         $advertise->cp_id = 100000;
         $advertise->name = $name;
         $advertise->income_price = $income_price;
         $advertise->outcome_price = $outcome_price;
         echo $name, ":", $advertise->save(), "\n";
     }
 }
Esempio n. 6
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $user = Yii::app()->user;
     if (Yii::app()->request->isPostRequest) {
         $type = $_POST['type'];
         if ($type == 'login') {
             $identity = new UserIdentity($_POST['LoginForm']['email'], $_POST['LoginForm']['password']);
             if ($identity->authenticate()) {
                 $user->login($identity);
                 $this->redirect('/');
             } else {
             }
         }
         return;
     }
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     if ($user->isGuest) {
         $this->render('login', array('userinput' => Yii::app()->request->isPostRequest ? $_POST['LoginForm'] : array()));
     } else {
         $criteria = new CDbCriteria();
         if ($user->isChannel()) {
             if ($user->getChannelId()) {
                 $criteria->compare('channel_id', Yii::app()->user->getChannelId());
             } else {
                 echo '此账户尚未开通,请联系管理员';
                 return;
             }
         } else {
             //管理员
             $channel_id = $user->getChannelId();
             if ($user->getChannelId()) {
                 $criteria->compare('channel_id', Yii::app()->user->getChannelId());
             }
         }
         //添加搜索条件
         if ($_GET) {
             $tag = $_GET['tag'];
             $adv_name = $_GET['adv_name'];
             $adv_id = "";
             if ($adv_name) {
                 $advertise = Advertise::model();
                 $adv_id = $advertise->getAdvId($adv_name);
             }
             $startTime = $_GET['startTime'];
             $endTime = $_GET['endTime'];
             $criteria->compare('tag', $tag);
             $criteria->compare('adv_id', $adv_id);
             if ($startTime) {
                 $criteria->addBetweenCondition('date', $startTime, $endTime);
             }
         }
         $criteria->order = "date desc";
         $dataProvider = new CActiveDataProvider('AdvData', array('criteria' => $criteria, 'pagination' => array('pageSize' => 20, 'pageVar' => 'page')));
         $this->render('index', array('attributes' => array('date', 'adv.name', 'tag', 'download_number', 'price', 'total_price', 'star_level'), 'current_channel_id' => $user->getChannelId(), 'channels' => Yii::app()->user->isAdmin() ? Channel::model()->findAll() : array(), 'dataProvider' => $dataProvider));
     }
 }
 /**
  * @return string
  *
  * 返回表的名字
  */
 public function getTableName()
 {
     $filters = $this->getFilterCondition();
     if (isset($filters['adv_id'])) {
         $model = Advertise::model()->findByPk($filters['adv_id']);
         if ($model) {
             return $model->cp->name . '-' . $model->name . ' 渠道列表';
         }
     }
     return '业务-渠道列表';
 }
Esempio n. 8
0
 public function postUpdate()
 {
     $id = substr(Input::get('id'), 2);
     $advertise = Advertise::find($id);
     $advertise->caption = Input::get('caption');
     $advertise->language_id = Input::get('language_id');
     $advertise->client_id = Input::get('client_id');
     $advertise->duration = Input::get('duration');
     $advertise->brand_id = Input::get('brand_id');
     $advertise->save();
     return Response::json($advertise);
 }
Esempio n. 9
0
 public function actionUpload()
 {
     $filter = $this->getFilterCondition();
     if (isset($filter['adv_channel_id'])) {
         $advertiseChannel = AdvertiseChannel::model()->findByPk($filter['adv_channel_id']);
         $advertise = $advertiseChannel->advertise;
     } else {
         if (isset($filter['adv_id'])) {
             $advertise = Advertise::model()->findByPk($filter['adv_id']);
         }
     }
     //$historyList = $adv_data->getDayDataForIn('',$startTime, $endTime, false);
     $this->render('upload', array('filters' => $this->getFilterCondition(), 'advertise' => $advertise, 'adv_channel_id' => $filter['adv_channel_id']));
 }
Esempio n. 10
0
 public static function getAdvertise($position, $modelName = null, $modelId = null)
 {
     // Header & Footer
     if ($modelName == null && $modelId == null) {
         if (Cache::has('ad' . $position)) {
             $ad = Cache::get('ad' . $position);
         } else {
             $ad = Advertise::where(array('position' => $position, 'status' => ENABLED))->first();
             Cache::put('ad' . $position, $ad, CACHETIME);
         }
         return $ad;
     } else {
         //check Common models
         if (Cache::has('common_model' . $modelName . $modelId)) {
             $common_model = Cache::get('common_model' . $modelName . $modelId);
         } else {
             $common_model = CommonModel::where(array('model_name' => $modelName, 'model_id' => $modelId))->first();
             Cache::put('common_model' . $modelName . $modelId, $common_model, CACHETIME);
         }
         if ($common_model) {
             $common_model_id = $common_model->id;
             if (Cache::has('advertisement_id' . $common_model_id)) {
                 $advertisement_id = Cache::get('advertisement_id' . $common_model_id);
             } else {
                 $advertisement_id = AdvertisePosition::where(array('common_model_id' => $common_model_id, 'status' => ENABLED))->first();
                 Cache::put('advertisement_id' . $common_model_id, $advertisement_id, CACHETIME);
             }
             if ($advertisement_id) {
                 if (Cache::has('ad' . $advertisement_id)) {
                     $ad = Cache::get('ad' . $advertisement_id);
                 } else {
                     $advertisement_id = AdvertisePosition::where(array('common_model_id' => $common_model_id, 'status' => ENABLED))->first()->advertisement_id;
                     $ad = Advertise::find($advertisement_id);
                     Cache::put('ad' . $advertisement_id, $advertisement_id, CACHETIME);
                 }
                 return $ad;
             }
             return null;
         } else {
             return null;
         }
     }
 }
Esempio n. 11
0
 public function getDailyToTalData($date)
 {
     /*
         $db = Yii::app()->db;
         $sql = "select advertise.name as adv_name,sum(total_price) as prices,sum(download_number) as downloads from adv_data join advertise on advertise.id = adv_id where date = :date group by adv_id";
         $command = $db->createCommand($sql);
         $command->bindParam(':date', $date);
         return $command->queryAll();
     */
     $criteria = new CDbCriteria();
     $criteria->compare('ctime', ">= {$date}");
     $criteria->order = 'date desc';
     $data = array();
     $advId2NameMap = array();
     foreach (Advertise::model()->findAll() as $adv) {
         $advId2NameMap[$adv->id] = $adv->name;
     }
     foreach ($this->findAll($criteria) as $model) {
         if (!isset($data[$model->date])) {
             $data[$model->date] = array();
         }
         if (!isset($data[$model->date][$model->adv_id])) {
             $data[$model->date][$model->adv_id] = array('adv_name' => $advId2NameMap[$model->adv_id], 'download_number' => 0, 'total_price' => 0);
         }
         $data[$model->date][$model->adv_id]['download_number'] += sprintf("%01.2f", floatval($model->download_number));
         $data[$model->date][$model->adv_id]['total_price'] += sprintf("%01.2f", floatval($model->total_price));
     }
     return $data;
 }
Esempio n. 12
0
 public function getTableName()
 {
     $filters = $this->getFilterCondition();
     $conditions = array();
     if (isset($filters['cp_id'])) {
         $model = CP::model()->findByPk($filters['cp_id']);
         if ($model) {
             $conditions[] = "CP:{$model->name}";
         }
     }
     if (isset($filters['adv_id'])) {
         $model = Advertise::model()->findByPk($filters['adv_id']);
         if ($model) {
             $conditions[] = "业务:{$model->name}";
         }
     }
     if (isset($filters['channel_id'])) {
         $model = Channel::model()->findByPk($filters['channel_id']);
         if ($model) {
             $conditions[] = "渠道:{$model->name}";
         }
     }
     /*2014-11-17包名*/
     if (isset($filters['adv_channel_id'])) {
         $model = AdvertiseChannel::model()->findByPk($filters['adv_channel_id']);
         if ($model) {
             $conditions[] = "包名:{$model->tag}";
         }
     }
     /*end*/
     if (isset($filters['begin_date']) && isset($filters['end_date'])) {
         $conditions[] = "从{$filters['begin_date']}到{$filters['end_date']}";
     }
     if (isset($filters['date'])) {
         $conditions[] = "日期:{$filters['date']}";
     }
     if (count($conditions)) {
         return $this->getTableBaseName() . '-(' . join('-', $conditions) . ')';
     } else {
         return $this->getTableBaseName() . '-全部';
     }
 }
 public static function getAdvertise()
 {
     $data = Advertise::where('position', '=', 1)->where('status', '=', 1)->limit(5)->get();
     return $data;
 }
Esempio n. 14
0
 /**
  * Returns the static model of the specified AR class.
  * @param string $className active record class name.
  * @return Advertise the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
 public function index()
 {
     if (CNF_FRONT == 'false' && Session::get('uid') != 1) {
         if (!Auth::check()) {
             return Redirect::to('user/login');
         }
     }
     $data['sp_banchay'] = Post::getPostNew(4);
     $data['sp_muanhieu'] = Post::getPostBuy(4);
     $data['adver_1'] = Advertise::getAdvertiseHome(1);
     $data['adver_2'] = Advertise::getAdvertiseHome(2);
     $this->data['pageTitle'] = 'Trang chu';
     $this->data['pageNote'] = 'Welcome To Our Site';
     //$this->data['breadcrumb'] = 'inactive';
     $page = 'pages.template.home';
     $page = SiteHelpers::renderHtml($page);
     $this->layout->nest('content', $page, $data)->with('menu', 'index');
 }