/** * Пулечение всех юо.лиц в регионе плательщиков взносов * @param null $regional_id * @param $region_id * @return array */ public static function getUr_l_in_region($regional_id, $region_id) { $regional_id = (int) $regional_id; $region_id = (int) $region_id; $db = new Query(); $db->from(Ur::tableName()); $db->select(['ur_l.name', 'ur_l.id']); $db->innerJoin('region_ur_l', "region_ur_l.id_ur = ur_l.id"); $db->Where(['=', 'region_ur_l.id_reg', $region_id]); $db->andWhere(['=', 'ur_l.plat', '1']); $db->andwhere(['=', 'ur_l.regional_id', $regional_id]); $db->orderBy('ur_l.name ASC'); $return = $db->all(); return $return; }
public function actionTable() { if (\Yii::$app->user->identity->status == 1) { $users = Users::find()->where(['status' => 2])->orderBy('username')->all(); } else { $users = Users::find()->where(['id' => \Yii::$app->user->identity->id])->orderBy('username')->all(); } foreach ($users as $user) { $id = $user['id']; $db = new Query(); $db->from(Ur::tableName()); $db->select(['COUNT(*) AS count', 'id_reg', 'region.name']); $db->where(['=', 'ur_l.regional_id', $id]); $db->andWhere(['=', 'ur_l.plat', '1']); $db->innerJoin('region_ur_l', "region_ur_l.id_ur = ur_l.id"); $db->innerJoin('region', "region.id = region_ur_l.id_reg"); $db->groupBy('region_ur_l.id_reg'); $db->orderBy('region.name ASC'); $ur_region_array[$id] = $db->all(); $db = new Query(); $db->from(Apteki::tableName()); $db->select(['COUNT(*) AS count', 'region.id', 'region.name']); $db->where(['=', 'apteki.regional_id', $id]); $db->innerJoin('region', "region.id = apteki.region_id"); $db->groupBy('region.id'); $db->orderBy('region.name ASC'); $apteki_region_array[$id] = $db->all(); } return $this->render('table', compact(['ur_region_array', 'apteki_region_array', 'users'])); }