/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $random = [];
     if (Yii::$app->session->has('random')) {
         $random = Yii::$app->session->get('random');
     }
     $query = Main::find()->joinWith(['mainTrashPlaces', 'mainTrashMen', 'mainTrashRecycles', 'mainTrashRelations', 'mainRubberItems']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (isset($params['MainSearch']['region']) && $params['MainSearch']['region'] == -1) {
         unset($params['MainSearch']['region']);
     }
     $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->select('main.*');
     $query->distinct();
     $query->andFilterWhere(['region' => $this->region, 'city' => $this->city, 'type' => $this->type, 'resident' => $this->resident, 'children' => $this->children, 'employee' => $this->employee, 'retiree' => $this->retiree, 'dominant' => $this->dominant, 'trash_man' => $this->trash_man, 'trash_out' => $this->trash_out, 'trash_count' => $this->trash_count, 'trash_count_summer' => $this->trash_count_summer, 'trash_count_winter' => $this->trash_count_winter, 'paper' => $this->paper, 'trash_relation' => $this->trash_relation, 'trash_recycle' => $this->trash_recycle, 'person' => $this->person, 'id' => $this->id, 'main_trash_place.trash_place_id' => $this->getAttribute('places'), 'main_trash_man.trash_man_id' => $this->getAttribute('men'), 'main_trash_recycle.trash_recycle_id' => $this->getAttribute('recycles'), 'main_trash_relation.trash_relation_id' => $this->getAttribute('relations'), 'main_rubber_items.rubber_item_id' => $this->getAttribute('rubber_items')]);
     $query = $this->addBetween($query);
     if (!empty($random)) {
         $query->andFilterWhere(['IN', 'main.id', $random]);
     }
     $query->andFilterWhere(['like', 'answer_count', $this->answer_count])->andFilterWhere(['like', 'woman_count', $this->woman_count])->andFilterWhere(['like', 'date', $this->date])->andFilterWhere(['like', 'interrogatory', $this->interrogatory]);
     return $dataProvider;
 }
Beispiel #2
0
 public function actionIndex()
 {
     if (\Yii::$app->user->isGuest) {
         \Yii::$app->user->loginRequired();
     }
     $dataProvider = new ActiveDataProvider(['query' => Main::find()->with(['source', 'period', 'catalog'])->where(["user_id" => Yii::$app->user->identity->id]), 'pagination' => ['pageSize' => 10], 'sort' => ['defaultOrder' => ['date' => SORT_DESC], 'attributes' => []]]);
     return $this->render('index', ["dataProvider" => $dataProvider]);
 }
Beispiel #3
0
 /**
  * 获取热门
  *
  * @param 类型,1为问答,2为文章,3为笔记 $type            
  * @return Ambigous <multitype:, multitype:\yii\db\ActiveRecord , array, multitype:unknown >
  */
 public static function getHotMain($type, $name)
 {
     if (3 == $type) {
         $where = ['type' => 3, 'status' => 2];
     } else {
         $where = ['type' => $type];
     }
     return Main::find()->where($where)->andWhere(['like', 'tags', $name])->orderBy('scanNum DESC,id asc')->limit('10')->all();
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     // $sid = Session::get('session_id');
     //全局变量  导航栏信息
     $navs = Models\Main::all()->where('type', 'category');
     // $title_three=tools\ShareFun::object_to_array($rows_nav_three);
     // View::share('sid',$sid);
     View::share('nav', $navs);
 }
Beispiel #5
0
 public function __construct($query)
 {
     parent::__construct();
     $query = !empty($query) ? trim($query) : false;
     if (!empty($query)) {
         $this->searchObj = new SearchClass();
         $this->indexQuery = $this->searchObj->make_index($query);
         $this->dataSearch = $this->getDataSearch();
     }
 }
Beispiel #6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Main::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, 'status' => $this->status, 'userId' => $this->userId, 'createTime' => $this->createTime, 'scanNum' => $this->scanNum, 'cellectNum' => $this->cellectNum, 'attentionNum' => $this->attentionNum, 'type' => $this->type]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'tags', $this->tags]);
     return $dataProvider;
 }
Beispiel #7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Main::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, 'catalog_id' => $this->catalog_id, 'date' => $this->date, 'enddate' => $this->enddate, 'period_id' => $this->period_id, 'source_id' => $this->source_id]);
     $query->andFilterWhere(['like', 'amount', $this->amount]);
     return $dataProvider;
 }
Beispiel #8
0
 /**
  * Creates a new Answer model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * 
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Answer();
     $post = Yii::$app->request->post();
     if (isset($post['Answer']['content']) && isset($post['Answer']['askId'])) {
         $model->load($post);
         $model->userId = Yii::$app->user->identity->getId();
         $model->createTime = date('Y-m-d H:i:s', time());
         $model->status = 1;
         $model->helpNum = 0;
         if ($model->save()) {
             $main = Main::findOne($post['Answer']['askId']);
             $main->status = 2;
             $main->save();
         }
     }
     return $this->redirect(['/main/view', 'id' => $post['Answer']['askId']]);
 }
Beispiel #9
0
 public function actionFind()
 {
     $searchForm = new FindForm();
     $view['districtList'] = ArrayHelper::map(District::find()->where("district != ''")->orderBy('district')->all(), 'id_district', 'district');
     $params = ArrayHelper::merge(Yii::$app->request->getQueryParams(), Yii::$app->request->post());
     $searchForm->load($params);
     if (implode('', $searchForm->toArray())) {
         //$view['list'] = $searchForm->search();
     } else {
         $amount = (int) ArrayHelper::getValue(Main::findBySql("select count(id_person) as amount from main")->asArray()->one(), 'amount');
     }
     $view['pagination'] = new Pagination(['pageSize' => 10]);
     //dd($amount);
     $dataProvider = new ActiveDataProvider(['query' => $searchForm->getSearchQuery(), 'totalCount' => $amount ? $amount : null, 'pagination' => $view['pagination']]);
     //dd($dataProvider);
     $view['dataProvider'] = $dataProvider;
     $view['searchForm'] = $searchForm;
     return $this->render('find', $view);
 }
Beispiel #10
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMains()
 {
     return $this->hasMany(Main::className(), ['period_id' => 'id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMains()
 {
     return $this->hasMany(Main::className(), ['trash_recycle' => 'id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMain()
 {
     return $this->hasOne(Main::className(), ['id' => 'main_id']);
 }
Beispiel #13
0
 /**
  * 发布的笔记页面
  *
  * @return mixed
  */
 public function actionMynote($id)
 {
     $private = Yii::$app->user->identity->getId() == $id ? false : true;
     $result = Main::getMyUserDataByQuery(Yii::$app->request->post('page'), $id, 3, $private);
     if (Yii::$app->request->post('page')) {
         echo Main::getUserData($result, Yii::$app->request->post('page'));
     } else {
         return $this->render('index', ['message' => Main::getUserData($result, Yii::$app->request->post('page')), 'title' => '发布的笔记']);
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMains()
 {
     return $this->hasMany(Main::className(), ['trash_count_winter' => 'id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMains()
 {
     return $this->hasMany(Main::className(), ['dominant' => 'id']);
 }
            $sheets[$i]->setCellValue($startColumn . '2', $value);
            $sheets[$i]->setCellValue($startColumn . '4', $trashRecycleEng[$key]);
            $startColumn++;
        }
        $data = $pilots;
    }
    $sheets[$i] = ExcelHelper::printData($data, $cities, $types, $sheets[$i]);
    for ($columnItem = 'A'; $columnItem <= $endColumn; $columnItem++) {
        $sheets[$i]->getColumnDimension($columnItem)->setWidth(15);
    }
    $sheets[$i]->getStyle('A1:' . $endColumn . '4')->getAlignment()->setWrapText(true);
    $i++;
}
$sheets[$i] = new PHPExcel_Worksheet($objPHPExcel, 'total');
$objPHPExcel->addSheet($sheets[$i]);
$main = new Main();
$searchModel = new MainSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$dataProvider->setPagination(['pageSize' => $dataProvider->getTotalCount()]);
$dataArray = [[$main->getAttributeLabel('city'), $main->getAttributeLabel('type'), $main->getAttributeLabel('resident'), $main->getAttributeLabel('children'), $main->getAttributeLabel('employee'), $main->getAttributeLabel('retiree'), $main->getAttributeLabel('dominant'), $main->getAttributeLabel('mainTrashPlaces.trash_place_id'), $main->getAttributeLabel('mainTrashMen.trash_man_id'), $main->getAttributeLabel('filter_trash_out'), $main->getAttributeLabel('filter_trash_count'), $main->getAttributeLabel('filter_summer_1'), $main->getAttributeLabel('filter_summer_2'), $main->getAttributeLabel('filter_summer_3'), $main->getAttributeLabel('filter_summer_4'), $main->getAttributeLabel('filter_winter_1'), $main->getAttributeLabel('filter_winter_2'), $main->getAttributeLabel('filter_winter_3'), $main->getAttributeLabel('filter_winter_4'), $main->getAttributeLabel('paper'), $main->getAttributeLabel('mainTrashRelations.trash_relation_id'), $main->getAttributeLabel('mainTrashRecycles.trash_recycle_id'), $main->getAttributeLabel('mainRubberItems.rubber_item_id'), $main->getAttributeLabel('answer_count'), $main->getAttributeLabel('woman_count'), $main->getAttributeLabel('person'), $main->getAttributeLabel('date'), $main->getAttributeLabel('interrogatory')]];
foreach ($dataProvider->getModels() as $value) {
    $dataArray[] = [isset($value->city0) ? $value->city0->nameBothShort : '', isset($value->type0) ? $value->type0->nameBothShort : '', $value->resident, $value->children, $value->employee, $value->retiree, isset($value->dominant0) ? $value->dominant0->nameBothShort : '', $value->trashPlaceMulti, $value->trashManMulti, $value->trash_out, $value->trash_count, $value->summer_count_1, $value->summer_count_2, $value->summer_count_3, $value->summer_count_4, $value->winter_count_1, $value->winter_count_2, $value->winter_count_3, $value->winter_count_4, isset($value->paper0) ? $value->paper0->nameBothShort : '', $value->trashRelationMulti, $value->trashRecycleMulti, $value->rubberItemsMulti, $value->answer_count, $value->woman_count, isset($value->person0) ? $value->person0->nameBothShort : '', $value->date, $value->interrogatory];
}
$sheets[$i]->fromArray($dataArray, '', 'A1');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
// Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
// always modified
header('Cache-Control: cache, must-revalidate');
// HTTP/1.1
header('Pragma: public');
Beispiel #17
0
echo $form->field($searchForm, 'midname')->widget(AutoComplete::className(), ['clientOptions' => ['source' => '/index.php?r=site/ajax-search&t=midname'], 'options' => ['class' => 'form-control']]);
?>
            <div class="uk-grid uk-grid-small">
                <div class="uk-width-1-3">
                    <?php 
echo $form->field($searchForm, 'byear');
?>
                </div>
                <div class="uk-width-1-3">
                    <?php 
echo $form->field($searchForm, 'bmonth')->dropDownList(Main::getMonthList());
?>
                </div>
                <div class="uk-width-1-3">
                    <?php 
echo $form->field($searchForm, 'bdate')->dropDownList(Main::getDateList());
?>
                </div>
            </div>
            <?php 
echo $form->field($searchForm, 'district')->dropDownList($districtList, ['prompt' => '']);
?>
            <?php 
echo $form->field($searchForm, 'city')->widget(AutoComplete::className(), ['clientOptions' => ['source' => '/index.php?r=site/ajax-search&t=city'], 'options' => ['class' => 'form-control']]);
?>
            <div class="uk-grid uk-grid-small">
                <div class="uk-width-3-5">
                    <?php 
echo $form->field($searchForm, 'street')->widget(AutoComplete::className(), ['clientOptions' => ['source' => '/index.php?r=site/ajax-search&t=street'], 'options' => ['class' => 'form-control']]);
?>
                </div>
Beispiel #18
0
 /**
  * Finds the Main model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  *
  * @param integer $id            
  * @return Main the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Main::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function getContact()
 {
     $dataMenu = new Main();
     $dataMenu = Main::all();
     return View('main.contact', compact('dataMenu'));
 }
 public static function getMainData($region)
 {
     $random = [];
     if (Yii::$app->session->has('random')) {
         $random = Yii::$app->session->get('random');
     }
     $query = Main::find();
     if (!empty($random)) {
         $query->andFilterWhere(['IN', 'main.id', $random]);
     }
     if ($region != -1) {
         $query->andFilterWhere(['region' => $region]);
     }
     return $query->all();
 }
Beispiel #21
0
 public function actionDetail($id)
 {
     $detail = $this->findModel($id);
     return $this->render('detail', ['tag' => $detail, 'hotAsk' => Main::getHotMain(1, $detail->name), 'hotArt' => Main::getHotMain(2, $detail->name), 'hotNote' => Main::getHotMain(3, $detail->name)]);
 }
 public function actionTables()
 {
     $params = Yii::$app->request->queryParams;
     $region = 1;
     if (!empty($params['MainSearch']['region'])) {
         $region = $params['MainSearch']['region'];
     }
     if (empty($params['excel'])) {
         $params['excel'] = false;
     }
     $data = Main::getMainData($region);
     if ($region == -1) {
         $regionWhere = [];
     } else {
         $regionWhere = ['region' => $region];
     }
     $cityIds = ArrayHelper::map($data, 'city', 'city');
     $regionWhere['id'] = array_values($cityIds);
     $cities = ArrayHelper::map(City::find()->where($regionWhere)->orderBy('id')->all(), 'id', 'nameBoth');
     $types = ArrayHelper::map(Type::find()->orderBy('id')->all(), 'id', 'nameBoth');
     $trashPlaceArm = ArrayHelper::map(TrashPlace::find()->orderBy('id')->all(), 'id', 'name');
     $trashPlaceEng = ArrayHelper::map(TrashPlace::find()->orderBy('id')->all(), 'id', 'name_eng');
     $trashManArm = ArrayHelper::map(TrashMan::find()->orderBy('id')->all(), 'id', 'name');
     $trashManEng = ArrayHelper::map(TrashMan::find()->orderBy('id')->all(), 'id', 'name_eng');
     $trashRelationArm = ArrayHelper::map(TrashRelation::find()->orderBy('id')->all(), 'id', 'name');
     $trashRelationEng = ArrayHelper::map(TrashRelation::find()->orderBy('id')->all(), 'id', 'name_eng');
     $trashRecycleArm = ArrayHelper::map(TrashRecycle::find()->orderBy('id')->all(), 'id', 'name');
     $trashRecycleEng = ArrayHelper::map(TrashRecycle::find()->orderBy('id')->all(), 'id', 'name_eng');
     $trashCountSummerArm = ArrayHelper::map(TrashCountSummer::find()->orderBy('id')->all(), 'id', 'name');
     $trashCountSummerEng = ArrayHelper::map(TrashCountSummer::find()->orderBy('id')->all(), 'id', 'name_eng');
     $trashCountWinterArm = ArrayHelper::map(TrashCountWinter::find()->orderBy('id')->all(), 'id', 'name');
     $trashCountWinterEng = ArrayHelper::map(TrashCountWinter::find()->orderBy('id')->all(), 'id', 'name_eng');
     return $this->render('tables', ['data' => $data, 'region' => $region, 'cities' => $cities, 'types' => $types, 'trashPlaceArm' => $trashPlaceArm, 'trashPlaceEng' => $trashPlaceEng, 'trashManArm' => $trashManArm, 'trashManEng' => $trashManEng, 'trashRelationArm' => $trashRelationArm, 'trashRelationEng' => $trashRelationEng, 'trashRecycleArm' => $trashRecycleArm, 'trashRecycleEng' => $trashRecycleEng, 'trashCountSummerArm' => $trashCountSummerArm, 'trashCountSummerEng' => $trashCountSummerEng, 'trashCountWinterArm' => $trashCountWinterArm, 'trashCountWinterEng' => $trashCountWinterEng, 'excel' => $params['excel']]);
 }