Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Usersection::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(['usec_id' => $this->usec_id, 'usec_user_id' => $this->usec_user_id, 'usec_section_id' => $this->usec_section_id]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find()->with(['sections', 'sections.section']);
     $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(['us_id' => $this->us_id, 'us_active' => $this->us_active, 'us_created' => $this->us_created]);
     if (!empty($this->sectionids) || !empty($this->us_mainmoderator)) {
         $ansQuery = (new Query())->select('usec_user_id')->from(Usersection::tableName())->andFilterWhere(['usec_section_id' => $this->sectionids, 'usec_section_primary' => $this->us_mainmoderator])->distinct();
         $query->andFilterWhere(['us_id' => $ansQuery]);
     }
     $query->andFilterWhere(['like', 'us_group', $this->us_group])->andFilterWhere(['or', ['like', 'us_email', $this->us_email], ['like', 'us_name', $this->us_email]])->andFilterWhere(['like', 'us_pass', $this->us_pass])->andFilterWhere(['like', 'us_confirmkey', $this->us_confirmkey])->andFilterWhere(['like', 'us_key', $this->us_key]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
 /**
  * Finds the Usersection model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Usersection the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Usersection::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 4
0
 /**
  * Export data without division to section
  * @return mixed
  */
 public function actionExportall()
 {
     $searchModel = new DocladSearch();
     $searchModel->conferenceid = Yii::$app->db->createCommand('Select s.sec_cnf_id' . ' From ' . Usersection::tableName() . ' us, ' . Section::tableName() . ' s' . ' Where s.sec_id = us.usec_section_id And us.usec_section_primary = 1 And us.usec_user_id = :uid', [':uid' => Yii::$app->user->getId()])->queryColumn();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     //        echo nl2br(print_r($searchModel->conferenceid, true));
     //        return;
     $sDir = Yii::getAlias('@webroot/assets');
     $sFileName = $sDir . DIRECTORY_SEPARATOR . 'doclad-all-' . date('Y-m-d-H-i-s') . '.xls';
     $this->clearDestinationDir($sDir, 'xls', time() - 300);
     $this->exportToFile($dataProvider, $sFileName);
     Yii::$app->response->sendFile($sFileName);
     //        return $this->renderContent(
     //            Html::a(
     //                'Загрузить',
     //                substr($sFileName, str_replace(DIRECTORY_SEPARATOR, '/', strlen($_SERVER['DOCUMENT_ROOT'])))
     //            )
     //        );
 }
Ejemplo n.º 5
0
 /**
  *  Сохраняем секции
  * @param array $aData
  */
 public function saveSectionsWithPrimary($aData = [])
 {
     $nCou = Usersection::updateAll(['usec_user_id' => 0, 'usec_section_id' => 0, 'usec_section_primary' => 0], ['usec_user_id' => $this->us_id]);
     if (count($aData) > 0) {
         foreach ($aData as $el) {
             /** @var UsersectionForm $el */
             Yii::info('saveAllSections(): ' . print_r($el, true));
             $nUpd = Yii::$app->db->createCommand('Update ' . Usersection::tableName() . ' Set usec_user_id = :us_id, usec_section_id = :section_id, usec_section_primary = :prime Where usec_user_id = 0 Limit 1', [':section_id' => $el['sectid'], ':us_id' => $this->us_id, ':prime' => $el['isprime']])->execute();
             if ($nUpd == 0) {
                 Yii::$app->db->createCommand('Insert Into ' . Usersection::tableName() . ' (usec_user_id, usec_section_id, usec_section_primary) Values (:us_id, :section_id, :prime)', [':section_id' => $el['sectid'], ':us_id' => $this->us_id, ':prime' => $el['isprime']])->execute();
                 //                    Yii::info('Insert relate records : ['.$this->msg_id.', '.$id.']');
             }
         }
     }
 }