Exemplo n.º 1
0
 public function search($params)
 {
     $query = Code::find()->indexBy('id');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 20]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'poll_id' => $this->poll_id, 'member_id' => $this->member_id, 'code_status' => $this->code_status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'token', $this->token]);
     return $dataProvider;
 }
Exemplo n.º 2
0
 private function _sorted($field, $sort, $action)
 {
     $lang = Yii::$app->request->getQueryParam('language');
     $conditions = ['approved' => 1];
     if ($lang) {
         $conditions['language'] = $lang;
     }
     $query = Code::find();
     $query->where($conditions)->orderBy([$field => $sort]);
     $models = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->params['per-page']]]);
     return $this->render('index', ['models' => $models, 'languages' => Code::getLanguages(), 'action' => $action]);
 }
Exemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Code::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $query->andFilterWhere(['z_b_id' => $this->z_b_id]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     if (!$this->status) {
         $query->andFilterWhere(['status' => $this->status]);
     } else {
         $query->andFilterWhere(['>', 'status', $this->status]);
     }
     $query->andFilterWhere(['like', 'code', $this->code]);
     return $dataProvider;
 }
Exemplo n.º 4
0
 public function actionIndex()
 {
     $this->redirect('home/cqssc');
     $type = \Yii::$app->request->get('type') ? \Yii::$app->request->get('type') : 1;
     $data = Code::find()->where(['type' => $type])->orderBy('time DESC');
     $pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => '3']);
     $model = $data->offset($pages->offset)->limit($pages->limit)->all();
     if ($page = \Yii::$app->request->get('page')) {
         if (intval(ceil($data->count() / 3)) < $page) {
             return false;
         }
         return $this->renderAjax('_list', ['model' => $model]);
     }
     return $this->render('index', ['model' => $model]);
     /*
     $type = 1;
     if(\Yii::$app->request->get('type')){
         $type = \Yii::$app->request->get('type');
     }
     $model = Code::find()->where(['type'=>$type])->orderBy('time DESC')->all();
     return $this->render('index',['model'=>$model]);
     */
 }
Exemplo n.º 5
0
 public function actionSendmultiple()
 {
     $poll = $this->getPoll();
     $email = new EmailForm(['scenario' => EmailForm::SCENARIO_MULTIPLE_EMAIL]);
     if ($email->load(Yii::$app->request->post()) && $email->validate()) {
         $members = [];
         if (intval($email->sendMode) === EmailForm::EMAIL_TO_ALL) {
             $members = Member::find()->where($this->getPollSearchOptions())->with('codes')->with('contacts')->all();
         } elseif (intval($email->sendMode) === EmailForm::EMAIL_TO_UNUSED) {
             $codes = Code::find()->where($this->getPollSearchOptions())->valid()->unused()->with('member.contacts')->all();
             $members = ArrayHelper::getColumn($codes, 'member');
         } elseif (intval($email->sendMode) === EmailForm::EMAIL_TO_USED) {
             $codes = Code::find()->where($this->getPollSearchOptions())->valid()->used()->with('member.contacts')->all();
             $members = ArrayHelper::getColumn($codes, 'member');
         }
         // Count successful and failed emails.
         $success = 0;
         $failure = 0;
         foreach ($members as $member) {
             set_time_limit(6);
             // 6 seconds for each email to render
             if ($this->sendEmailToMember($email, $member)) {
                 $success++;
             } else {
                 $failure++;
             }
         }
     }
     if ($success > 0) {
         Yii::$app->getSession()->addFlash('success', Yii::t('app', 'Successfully sent {n, plural, =0{no Email} =1{one Email} other{# Emails}}!', ['n' => $success]));
     }
     if ($failure > 0) {
         Yii::$app->getSession()->addFlash('error', Yii::t('app', 'Failed to send {n, plural, =0{no Email} =1{one Email} other{# Emails}}!', ['n' => $failure]));
     }
     return $this->redirect(['poll/view', 'id' => $poll->id, 'tab' => 'members']);
 }
Exemplo n.º 6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Code::find();
     $pageSize = Yii::$app->session->get('pageSize', Yii::$app->params['defaultPageSize']);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize]]);
     $dataProvider->setSort(['attributes' => ['code', 'z_p_id', 'status', 'fillingDate' => ['asc' => ['{{%meta}}.time_start' => SORT_ASC], 'desc' => ['{{%meta}}.time_start' => SORT_DESC], 'label' => 'Filling Date'], 'duration' => ['asc' => ['{{%meta}}.time_end' => SORT_ASC], 'desc' => ['{{%meta}}.time_end' => SORT_DESC], 'label' => 'Duration']]]);
     /*$query->andFilterWhere([
     			'z_b_id' => $this->z_b_id,
     		]);*/
     if (!($this->load($params) && $this->validate())) {
         $query->joinWith(['meta']);
         return $dataProvider;
     }
     if (!$this->status) {
         $query->andFilterWhere(['status' => $this->status]);
     } else {
         $query->andFilterWhere(['>', 'status', $this->status]);
         if ($this->status == 1) {
             $query->andFilterWhere(['=', 'used', 0]);
         } else {
             $query->andFilterWhere(['=', 'used', 1]);
         }
     }
     if (isset($this->z_p_id) && !empty($this->z_p_id)) {
         $query->andFilterWhere(['z_p_id' => $this->z_p_id]);
     }
     $query->andFilterWhere(['like', 'CONCAT("' . $this->z_b_id . '", LPAD(`z_p_id`,3,"0"),`code`)', $this->code]);
     $query->joinWith(['meta' => function ($q) {
         if (isset($this->z_id) && !empty($this->z_id)) {
             $q->where('{{%meta}}.m_z_id = "' . $this->z_id . '"');
         }
     }]);
     //echo $query->createCommand()->getRawSql();
     //exit();
     return $dataProvider;
 }
Exemplo n.º 7
0
 function find($qihao, $urlName, $codeArr, $code_id)
 {
     sort($codeArr);
     //数组从小到大排序 用户需求
     //数据分析
     $config = Configure::findOne(['type' => 1]);
     //系统报警配置
     //记录中奖与未中奖号码
     $model = Comparison::findOne(['type' => 1]);
     $data = $model->txt;
     $dataTxts = str_replace("\r\n", ' ', $data);
     //将回车转换为空格
     $dataArr = explode(' ', $dataTxts);
     $dataArr = array_filter($dataArr);
     $dataArr = array_chunk($dataArr, 5);
     //当前开奖号码 对比 数据库
     $lucky = array();
     //中奖号
     $regret = $dataArr;
     //未中奖号
     foreach ($dataArr as $key => $val) {
         sort($val);
         // 从小到大排序
         if ($codeArr == $val) {
             //中奖号组
             array_push($lucky, $val);
             unset($regret[$key]);
         }
     }
     //将中奖与未中奖的数组 转换为用户上传数据本的 格式 存入数据库
     $luckyStr = null;
     $regretStr = null;
     if (count($lucky) != 0) {
         //有中奖号码 记录数据库
         foreach ($lucky as $luc) {
             foreach ($luc as $l) {
                 $luckyStr .= $l . ' ';
             }
             $luckyStr .= "\r\n";
         }
     }
     if (count($regret) != 0) {
         //有未中奖号码 记录数据库
         foreach ($regret as $reg) {
             foreach ($reg as $r) {
                 $regretStr .= $r . ' ';
             }
             $regretStr .= "\r\n";
         }
     }
     //分析数据本与当前这期开奖号码 记录数据本里面 中奖号码与未中奖的号码 到数据库中
     $analysis = new Analysis();
     $analysis->codi_id = $code_id;
     $analysis->lucky_txt = $luckyStr;
     $analysis->regret_txt = $regretStr;
     $analysis->data_txt = $data;
     $analysis->time = time();
     $analysis->save();
     if ($config->state == 1) {
         //系统开启邮件 通知
         if (date('H', time()) > intval($config->start_time) && date('H', time()) < intval($config->end_time)) {
             //            if(true){
             //报警时间段内
             if ($config->forever == 1) {
                 //每一期 邮件通知打开
                 $cfg = array('type' => 1, 'qihao' => $qihao, 'codeArr' => $codeArr, 'urlName' => $urlName, 'luckyStr' => $luckyStr, 'regretStr' => $regretStr);
                 $this->send($cfg);
             }
             // 用户设置 几期都未中奖 报警通知
             $NewestCodes = Code::find()->orderBy('time DESC')->limit($config->regret_number)->all();
             if (count($NewestCodes) == $config->regret_number) {
                 //所有的最新的数据 必须 等于 用户设置的报警期数
                 $codeLucky = true;
                 foreach ($NewestCodes as $codeold) {
                     if (!empty($codeold->analysis->lucky_txt)) {
                         //N 期内有中奖 不发送报警
                         $codeLucky = false;
                         break;
                     }
                 }
                 if ($codeLucky) {
                     //发送报警通知 当前 $config->regret_number 内 都未中奖
                     $cfg = array('type' => 2, 'regret_number' => $config->regret_number, 'NewestCodes' => $NewestCodes);
                     $this->send($cfg);
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
 public static function countPending()
 {
     static $count = null;
     return $count === null ? $count = Code::find()->where(['approved' => 0])->count() : $count;
 }
Exemplo n.º 9
0
 Mehrfachauswahlfragen<br/>

<h4>Banken</h4>


<?php 
echo \app\models\Bank::find()->count();
?>
 Banken insgesamt, in<br/>
<?php 
echo \app\models\Bank::find()->distinct('klasse')->count();
?>
 verschiedenen Bankenklassen<br/>

<h4>Benutzergruppen</h4>


<?php 
echo \app\models\Group::find()->count();
?>
 Benutzergruppen insgesamt<br/>

<h4>Zugangscodes</h4>
<?php 
echo \app\models\Code::find()->count();
?>
 Verschiedene Zugangscodes, davon<br/>
<?php 
echo \app\models\Code::find()->andFilterWhere(['used' => 1])->count();
?>
 bereits verwendet<br/>
Exemplo n.º 10
0
 public function actionPending()
 {
     $query = Code::find()->where(['approved' => false]);
     $pending = new ActiveDataProvider(['query' => $query]);
     return $this->render('pending', ['pending' => $pending]);
 }
Exemplo n.º 11
0
$mip = '';
$max = 0;
foreach ($ips as $ip => $ipc) {
    if ($ipc > $max) {
        $max = $ipc;
        $mip = $ip;
    }
}
if ($count) {
    $time = $time / $count;
}
?>

	<h3>Metadaten</h3>
	Benutzer gesamt: <b><?php 
echo \app\models\Code::find()->andWhere(['used' => 1, 'z_b_id' => $model->b_id])->count();
?>
</b>
	<br/>
	Eindeutige IP- Adressen: <b><?php 
echo count($ips);
?>
</b>
	<br/>
	Am häufigsten eingetragene IP- Adresse: <b><?php 
echo $mip;
?>
</b> (<b><?php 
echo $max;
?>
</b> mal)