public function getQuery()
 {
     $query = ExecutiveSummaryGroup::find()->asArray();
     if ($this->validate()) {
         $query->andFilterWhere(['year_invoice' => $this->year_invoice, 'gid' => $this->gid, 'group_name' => $this->group_name, 'user_id' => $this->user_id, 'name' => $this->name]);
     }
     $query->orderBy($this->default_order);
     return $query;
 }
 public function actionGetEssGroupDetail($group, $series = null, $year = null)
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $data = [];
     if (!$year) {
         $year = date('Y');
     }
     $groupObj = GroupSales::find()->where('name like :search')->addParams([':search' => strtolower($group)])->one();
     if ($groupObj) {
         $dataArr = ExecutiveSummaryGroup::find()->where('year_invoice = :year AND gid = :gid')->addParams([':year' => (int) $year, ':gid' => $groupObj->id])->orderBy('name ASC')->asArray()->all();
         $ytdSales = array_map(function ($v) {
             return ['name' => $v['name'], 'y' => floatval($v['ytd_target'])];
         }, $dataArr);
         $ytdAchievement = array_map(function ($v) {
             return ['name' => $v['name'], 'y' => floatval($v['ytd_sales_achievement'])];
         }, $dataArr);
         $series = ['name' => 'Ytd Achievement', 'data' => preg_replace('/W+/', '', strtolower($series)) == 'ytdtarget' ? $ytdTarget : $ytdAchievement];
     }
     return \yii\helpers\Json::encode($series);
 }