Inheritance: extends yii\db\ActiveRecord
Esempio n. 1
0
 public function search($params)
 {
     $query = Rank::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'value' => $this->value]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'traditional_name', $this->traditional_name]);
     return $dataProvider;
 }
 public function rules()
 {
     return [[['team', 'is_me'], 'required'], [['team'], 'in', 'range' => ['my', 'his']], [['is_me'], 'boolean', 'trueValue' => 'yes', 'falseValue' => 'no'], [['weapon'], 'exist', 'targetClass' => Weapon::className(), 'targetAttribute' => 'key'], [['rank'], 'exist', 'targetClass' => Rank::className(), 'targetAttribute' => 'key'], [['level'], 'integer', 'min' => 1, 'max' => 50], [['rank_in_team'], 'integer', 'min' => 1, 'max' => 4], [['kill', 'death'], 'integer', 'min' => 0], [['point'], 'integer', 'min' => 0]];
 }
Esempio n. 3
0
 * @var yii\widgets\ActiveForm $form
 */
?>

<div class="promotion-form">

   <?php 
$form = ActiveForm::begin();
?>

   <?php 
echo Html::activeHiddenInput($model, 'student_id', ['value' => $student->id]);
?>

   <?php 
echo $form->field($model, 'rank_id')->dropDownList(Rank::getMap());
?>

   <?php 
echo $form->field($model, 'testing_session_id')->textInput();
?>

   <?php 
echo $form->field($model, 'date')->widget(DateControl::classname(), ['widgetClass' => '\\yii\\widgets\\MaskedInput', 'options' => ['mask' => '99/99/9999']]);
?>

   <div class="form-group">
   <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
   </div>
Esempio n. 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRankAfter()
 {
     return $this->hasOne(Rank::className(), ['id' => 'rank_after_id']);
 }
Esempio n. 5
0
 public function toPlayers(Battle $battle)
 {
     if (is_array($this->players) && !empty($this->players)) {
         foreach ($this->players as $form) {
             if (!$form instanceof PostBattlePlayerForm) {
                 throw new \Exception('Logic error: assert: instanceof PostBattlePlayerForm');
             }
             $weapon = $form->weapon == '' ? null : Weapon::findOne(['key' => $form->weapon]);
             $rank = $form->rank == '' ? null : Rank::findOne(['key' => $form->rank]);
             $player = new BattlePlayer();
             $player->attributes = ['battle_id' => $battle->id, 'is_my_team' => $form->team === 'my', 'is_me' => $form->is_me === 'yes', 'weapon_id' => $weapon ? $weapon->id : null, 'rank_id' => $rank ? $rank->id : null, 'level' => (string) $form->level === '' ? null : (int) $form->level, 'rank_in_team' => (string) $form->rank_in_team === '' ? null : (int) $form->rank_in_team, 'kill' => (string) $form->kill === '' ? null : (int) $form->kill, 'death' => (string) $form->death === '' ? null : (int) $form->death, 'point' => (string) $form->point === '' ? null : (int) $form->point];
             (yield $player);
         }
     }
 }
Esempio n. 6
0
 /**
  * Finds the Rank model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Rank the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Rank::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(InsertPoliceRequest $request, $id)
 {
     $user = PoliceImmigration::find($id);
     $user->fill(Input::except(['password']));
     if (Input::get('password')) {
         // return Input::get('password');
         $user->password = Hash::make(Input::get('password'));
     }
     if (Input::has('position.id')) {
         $position = Position::find(Input::get('position.id'));
         $user->position()->associate($position);
     }
     if (Input::has('rank.id')) {
         $rank = Rank::find(Input::get('rank.id'));
         $user->rank()->associate($rank);
     }
     if (Input::has('role.id')) {
         $role = Role::find(Input::get('role.id'));
         $user->role()->associate($role);
     }
     $user->save();
     return $user;
 }
Esempio n. 8
0
 /**
  * Updates an existing Confronto model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post())) {
         if ($model->empate == 1) {
             $model->vencedor = null;
         }
         $modelAposta = Aposta::find()->where(['=', 'id_confronto', $model->id])->all();
         foreach ($modelAposta as $item) {
             if ($item->placar_casa == $model->placar_casa && $item->placar_visitante == $model->placar_visitante) {
                 $modelRank = new Rank();
                 $modelRank->id_user = $item->id_user;
                 $modelRank->data = date('Y-m-d H:i:s');
                 $modelRank->id_aposta = $item->id;
                 $modelRank->id_ponto = 1;
                 $modelRank->save();
             } else {
                 if ($model->vencedor != null) {
                     if ($item->placar_casa > $item->placar_visitante && $model->vencedor == $model->id_time_casa) {
                         $modelRank = new Rank();
                         $modelRank->id_user = $item->id_user;
                         $modelRank->data = date('Y-m-d H:i:s');
                         $modelRank->id_aposta = $item->id;
                         $modelRank->id_ponto = 2;
                         $modelRank->save();
                     } else {
                         if ($item->placar_casa < $item->placar_visitante && $model->vencedor == $model->id_time_visitante) {
                             $modelRank = new Rank();
                             $modelRank->id_user = $item->id_user;
                             $modelRank->data = date('Y-m-d H:i:s');
                             $modelRank->id_aposta = $item->id;
                             $modelRank->id_ponto = 2;
                             $modelRank->save();
                         }
                     }
                 } else {
                     if ($item->placar_casa == $item->placar_visitante && $model->placar_casa == $model->placar_visitante) {
                         $modelRank = new Rank();
                         $modelRank->id_user = $item->id_user;
                         $modelRank->data = date('Y-m-d H:i:s');
                         $modelRank->id_aposta = $item->id;
                         $modelRank->id_ponto = 2;
                         $modelRank->save();
                     }
                 }
             }
         }
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
 }
Esempio n. 9
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRank()
 {
     $lastPromotion = Promotion::find()->where(['student_id' => $this->id, 'active' => 1])->orderBy(['promotion.date' => SORT_DESC])->one();
     return Rank::findOne($lastPromotion->rank_id);
 }
Esempio n. 10
0
                        <span class="h3 block m-t-xs"><strong><?php 
echo Rank::actionGetTotal($modelUsers->id);
?>
</strong></span>
                        <small class="text-muted text-uc">Pontos</small>
                    </a>
                </div>
                <div class="col-sm-6 col-md-3 padder-v b-r b-light lt">
                    <span class="fa-stack fa-2x pull-left m-r-sm">
                        <i class="fa fa-circle fa-stack-2x text-warning"></i>
                        <i class="fa fa-trophy fa-stack-1x text-white"></i>

                    </span>
                    <a class="clear" href="#">
                        <span class="h3 block m-t-xs"><strong id="bugs"><?php 
echo Rank::GetPosicao($modelUsers->id);
?>
ª</strong></span>
                        <small class="text-muted text-uc">Posição</small>
                    </a>
                </div>
                <div class="col-sm-6 col-md-3 padder-v b-r b-light">                     
                    <span class="fa-stack fa-2x pull-left m-r-sm">
                        <i class="fa fa-circle fa-stack-2x text-danger"></i>
                        <i class="fa fa-fire-extinguisher fa-stack-1x text-white"></i>
                        <span class="easypiechart pos-abt" data-percent="100" data-line-width="4" data-track-Color="#f5f5f5" data-scale-Color="false" data-size="50" data-line-cap='butt' data-animate="3000" data-target="#firers" data-update="5000"></span>
                    </span>
                    <a class="clear" href="#">
                        <span class="h3 block m-t-xs"><strong id="firers">359</strong></span>
                        <small class="text-muted text-uc">Extinguishers ready</small>
                    </a>
Esempio n. 11
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRanks()
 {
     return $this->hasMany(Rank::className(), ['id_aposta' => 'id']);
 }
Esempio n. 12
0
 public static function getMap()
 {
     return ArrayHelper::map(Rank::find()->where(['active' => 1])->orderBy('ord')->all(), 'id', 'name');
 }
Esempio n. 13
0
 public function toBattle()
 {
     $o = new Battle();
     $o->user_id = $this->getUser()->id;
     $o->lobby_id = $this->lobby ? Lobby::findOne(['key' => $this->lobby])->id : null;
     $o->rule_id = $this->rule ? Rule::findOne(['key' => $this->rule])->id : null;
     $o->map_id = $this->map ? Map::findOne(['key' => $this->map])->id : null;
     $o->weapon_id = $this->weapon ? Weapon::findOne(['key' => $this->weapon])->id : null;
     $o->level = $this->level ? (int) $this->level : null;
     $o->level_after = $this->level_after ? (int) $this->level_after : null;
     $o->rank_id = $this->rank ? Rank::findOne(['key' => $this->rank])->id : null;
     $o->rank_after_id = $this->rank_after ? Rank::findOne(['key' => $this->rank_after])->id : null;
     $o->rank_exp = (string) $this->rank_exp != '' ? (int) $this->rank_exp : null;
     $o->rank_exp_after = (string) $this->rank_exp_after != '' ? (int) $this->rank_exp_after : null;
     $o->cash = (string) $this->cash != '' ? (int) $this->cash : null;
     $o->cash_after = (string) $this->cash_after != '' ? (int) $this->cash_after : null;
     $o->is_win = $this->result === 'win' ? true : ($this->result === 'lose' ? false : null);
     $o->rank_in_team = $this->rank_in_team ? (int) $this->rank_in_team : null;
     $o->kill = (string) $this->kill != '' ? (int) $this->kill : null;
     $o->death = (string) $this->death != '' ? (int) $this->death : null;
     $o->gender_id = $this->fest_gender === 'boy' ? 1 : ($this->fest_gender === 'girl' ? 2 : null);
     $o->fest_title_id = $this->fest_rank ? FestTitle::findOne(['key' => $this->fest_rank])->id : null;
     $o->my_team_color_hue = $this->my_team_color ? $this->my_team_color['hue'] : null;
     $o->my_team_color_rgb = $this->my_team_color ? vsprintf('%02x%02x%02x', $this->my_team_color['rgb']) : null;
     $o->his_team_color_hue = $this->his_team_color ? $this->his_team_color['hue'] : null;
     $o->his_team_color_rgb = $this->his_team_color ? vsprintf('%02x%02x%02x', $this->his_team_color['rgb']) : null;
     $o->start_at = $this->start_at != '' ? gmdate('Y-m-d H:i:sP', (int) $this->start_at) : null;
     $o->end_at = $this->end_at != '' ? gmdate('Y-m-d H:i:sP', (int) $this->end_at) : new Now();
     $o->agent_id = null;
     $o->at = new Now();
     return $o;
 }
Esempio n. 14
0
 public static function GetPosicao($id)
 {
     $rankLista = array();
     $rankUser = array();
     $modelAposta = User::find()->orderby('id')->all();
     $total = 0;
     $id_user = 0;
     foreach ($modelAposta as $item) {
         $perfil = Perfil::find()->where(['=', 'id', $item->id])->one();
         if ($perfil != null) {
             $rankUser = array("acertos" => Rank::GetAcertos($item->id), "nome" => $perfil->nome, "id" => $item->id, "pontos" => Rank::actionGetTotal($item->id), "foto" => $perfil->foto, "resultados" => Rank::GetResultados($item->id));
             array_push($rankLista, $rankUser);
         }
     }
     $rankLista = Rank::ordenarRank($rankLista, 'pontos', 'acertos');
     $key = array_search($id, array_column($rankLista, 'id'));
     return $key + 1;
 }
Esempio n. 15
0
,<?php 
echo Rank::GetErros($modelUsers->id);
?>
</div>
                                                </div>
                                                <ul class="list-group no-radius">
                                                    <li class="list-group-item"><span class="pull-right"><?php 
echo Rank::GetAcertos($modelUsers->id);
?>
</span> <span class="label bg-primary">1</span>Placar Exatos</li>
                                                    <li class="list-group-item"><span class="pull-right"><?php 
echo Rank::GetResultados($modelUsers->id);
?>
</span> <span class="label bg-dark">2</span> Acerto de Resultado </li>
                                                    <li class="list-group-item"><span class="pull-right"><?php 
echo Rank::GetErros($modelUsers->id);
?>
</span> <span class="label bg-light">3</span> Não Pontuadas </li>
                                                </ul>
                                            </section>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <section class="panel panel-default">
                                        <div class="panel-body">
                                            <div class="clearfix text-center m-t">
                                                <div class="inline">
                                                    <div class="easypiechart" data-percent="75" data-line-width="5" data-bar-color="#4cc0c1" data-track-color="#f5f5f5" data-scale-color="false" data-size="130" data-line-cap='butt' data-animate="1000">
                                                        <div class="thumb-lg">
                                                            <img src="/images/<?php