/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Personal::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'telno' => $this->telno, 'celno' => $this->celno, 'birthdate' => $this->birthdate, 'age' => $this->age, 'height' => $this->height, 'weight' => $this->weight]); $query->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'middlename', $this->middlename])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'house_num1', $this->house_num1])->andFilterWhere(['like', 'st_add1', $this->st_add1])->andFilterWhere(['like', 'brgy_add1', $this->brgy_add1])->andFilterWhere(['like', 'city_add1', $this->city_add1])->andFilterWhere(['like', 'house_num2', $this->house_num2])->andFilterWhere(['like', 'st_add2', $this->st_add2])->andFilterWhere(['like', 'brgy_add2', $this->brgy_add2])->andFilterWhere(['like', 'city_add2', $this->city_add2])->andFilterWhere(['like', 'email_add', $this->email_add])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'sex', $this->sex])->andFilterWhere(['like', 'birthplace', $this->birthplace])->andFilterWhere(['like', 'nationality', $this->nationality])->andFilterWhere(['like', 'religion', $this->religion]); return $dataProvider; }
/** * (string) actionDetail : 右侧区域信息 * @return string * @throws NotFoundHttpException */ public function actionDetail() { //$this->layout = 'bank'; $id = Yii::$app->request->post('id', '%'); if ($id == '0' || $id == '@') { $id = '%'; } $name = Yii::$app->request->post('name', '计生管理系统'); $unit = new Unit(); $p_num = Personal::find()->where(['unit' => $id])->count(1); if ($unit->isParent($id) && $p_num <= 0) { return $this->renderAjax('_detail', ['parent' => $id, 'parentName' => $name, 'unitcode' => Unit::getMaxunitcode($id), 'isParent' => intval($this->findModel($id)->corpflag) < 5 ? "yes" : "no"]); } else { $preferences = []; $preferences['sex'] = Preferences::getByClassmark('psex'); $preferences['marry'] = Preferences::getByClassmark('pmarry'); $preferences['flag'] = Preferences::getByClassmark('pflag'); $preferences['work1'] = Preferences::getByClassmark('pwork1'); return $this->renderAjax('/personal/_list', ['parent' => $id, 'parentName' => $name, 'code1' => Personal::getMaxCode(), 'preferences' => Json::encode($preferences)]); } }
/** * (void) actionSummary : 一个单位或部门的情况概述. * @param string $unit 单位编码 * @return string */ public function actionSummary($unit = '%') { //前三个月日期 $dateThreeMonthAgo = date('Ymd', mktime(0, 0, 0, date("m") - 3, date("d"), date("Y"))); $unitlist = Unit::getChildList($unit); //总人数 $num1 = Personal::find()->where('FIND_IN_SET (unit, :unitlist)', [':unitlist' => $unitlist])->andFilterWhere(['logout' => 0])->count(1); //流动人口 $num2 = Personal::find()->where('FIND_IN_SET (unit, :unitlist)', [':unitlist' => $unitlist])->andFilterWhere(['logout' => 0])->andFilterWhere(['<>', 'flag', '01'])->count(1); //已婚男性 $num3 = Personal::find()->where('FIND_IN_SET (unit, :unitlist)', [':unitlist' => $unitlist])->andFilterWhere(['logout' => 0, 'sex' => '01'])->andFilterWhere(['<>', 'marry', '10'])->count(1); //已婚女性 $num4 = Personal::find()->where('FIND_IN_SET (unit, :unitlist)', [':unitlist' => $unitlist])->andFilterWhere(['logout' => 0, 'sex' => '02'])->andFilterWhere(['<>', 'marry', '10'])->count(1); //未婚男性 $num5 = Personal::find()->where('FIND_IN_SET (unit, :unitlist)', [':unitlist' => $unitlist])->andFilterWhere(['logout' => 0, 'sex' => '01', 'marry' => '10'])->count(1); //未婚女性 $num6 = Personal::find()->where('FIND_IN_SET (unit, :unitlist)', [':unitlist' => $unitlist])->andFilterWhere(['logout' => 0, 'sex' => '02', 'marry' => '10'])->count(1); //已婚未育 $num7 = Personal::find()->where('FIND_IN_SET (unit, :unitlist)', [':unitlist' => $unitlist])->andFilterWhere(['logout' => 0, 'childnum' => 0])->andFilterWhere(['<>', 'marry', '10'])->count(1); //已婚育一孩 $num8 = Personal::find()->where('FIND_IN_SET (unit, :unitlist)', [':unitlist' => $unitlist])->andFilterWhere(['logout' => 0, 'childnum' => 1])->andFilterWhere(['<>', 'marry', '10'])->count(1); //已婚育二孩 $num9 = Personal::find()->where('FIND_IN_SET (unit, :unitlist)', [':unitlist' => $unitlist])->andFilterWhere(['logout' => 0, 'childnum' => 2])->andFilterWhere(['<>', 'marry', '10'])->count(1); //已婚育三孩+ $num10 = Personal::find()->where('FIND_IN_SET (unit, :unitlist)', [':unitlist' => $unitlist])->andFilterWhere(['logout' => 0])->andFilterWhere(['<>', 'marry', '10'])->andFilterWhere(['>=', 'childnum', '3'])->count(1); //近三个月内新入职 $num11 = Personal::find()->where('FIND_IN_SET (unit, :unitlist)', [':unitlist' => $unitlist])->andFilterWhere(['logout' => 0])->andFilterWhere(['>=', 'ingoingdate', $dateThreeMonthAgo])->count(1); //近三个月内离开单位 $num12 = Personal::find()->where('FIND_IN_SET (unit, :unitlist)', [':unitlist' => $unitlist])->andFilterWhere(['>', 'logout', 0])->andFilterWhere(['>=', 'e_date', $dateThreeMonthAgo])->count(1); $data = "总人数为<span data-toggle='tooltip' data-filter='无过滤条件' title='总人数' class='text-red p-extra-filter'> {$num1} </span>人," . "流动人口为<span data-toggle='tooltip' data-filter='流动人口' title='流动人口' class='text-red p-extra-filter'> {$num2} </span>人," . "已婚男性人数为<span data-toggle='tooltip' data-filter='已婚男性' title='已婚男性人数' class='text-red p-extra-filter'> {$num3} </span>人," . "已婚女性人数为<span data-toggle='tooltip' data-filter='已婚女性' title='已婚女性人数' class='text-red p-extra-filter'> {$num4} </span>人," . "未婚男性人数为<span data-toggle='tooltip' data-filter='未婚男性' title='未婚男性人数' class='text-red p-extra-filter'> {$num5} </span>人," . "未婚女性人数为<span data-toggle='tooltip' data-filter='未婚女性' title='未婚女性人数' class='text-red p-extra-filter'> {$num6} </span>人," . "已婚未育<span data-toggle='tooltip' data-filter='已婚未育' title='已婚未育' class='text-red p-extra-filter'> {$num7} </span>人," . "已婚育一孩<span data-toggle='tooltip' data-filter='已婚育一孩' title='已婚育一孩' class='text-red p-extra-filter'> {$num8} </span>人," . "已婚育二孩<span data-toggle='tooltip' data-filter='已婚育二孩' title='已婚育二孩' class='text-red p-extra-filter'> {$num9} </span>人," . "已婚育三孩及以上<span data-toggle='tooltip' data-filter='已婚育三孩及以上' title='已婚育三孩及以上' class='text-red p-extra-filter'> {$num10} </span>人," . "近三个月内新入职<span data-toggle='tooltip' data-filter='近三个月内新入职' title='近三个月内新入职' class='text-red p-extra-filter'> {$num11} </span>人," . "近三个月内离开单位<span data-toggle='tooltip' data-filter='近三个月内离开单位' title='近三个月内离开单位' class='text-red p-extra-filter'> {$num12} </span>人"; return $data; }