/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = MMarketingRegion::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
public static function getScoreRanking($is_selfOperated = 0, $date = null) { $ranking = array(); $mrs = MMarketingRegion::find()->all(); foreach ($mrs as $mr) { foreach ($mr->mscs as $msc) { foreach ($msc->offices as $office) { if ($office->is_selfOperated != $is_selfOperated) { continue; } $score = self::getScore($office->office_id, $date); if ($score !== false) { $ranking[] = ['office_id' => $office->office_id, 'score' => $score]; } } } } if (count($ranking) == 0) { return $ranking; } $scores = []; foreach ($ranking as $key => $row) { $scores[$key] = $row['score']; } array_multisort($scores, SORT_DESC, $ranking); //return arsort($ranking); return $ranking; }
public function actionQdxcjspb1($backwards = true, $pop = false) { $this->layout = false; $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); Yii::$app->wx->setGhId($gh_id); if (!$backwards) { \app\models\utils\BrowserHistory::delete($gh_id, $openid); \app\models\utils\BrowserHistory::push($gh_id, $openid); } else { if ($pop) { \app\models\utils\BrowserHistory::pop($gh_id, $openid); } else { \app\models\utils\BrowserHistory::push($gh_id, $openid); } } //$models_mr = new MMarketingRegion(); $models_mr = MMarketingRegion::find()->all(); $wx_user = \app\models\MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); return $this->render('qdxcjspb1', ['wx_user' => $wx_user, 'gh_id' => $gh_id, 'openid' => $openid, 'models_mr' => $models_mr, 'backwards' => $backwards]); }