示例#1
0
 public function run()
 {
     //copied from HackathonProjects.pdf
     $positions = array(array('abbr' => 'P'), array('abbr' => 'C'), array('abbr' => '1B'), array('abbr' => '2B'), array('abbr' => '3B'), array('abbr' => 'SS'), array('abbr' => 'LF'), array('abbr' => 'CF'), array('abbr' => 'RF'), array('abbr' => 'DH'), array('abbr' => 'PH'));
     foreach ($positions as $p) {
         $position = Position::where('abbr', $p['abbr'])->first();
         if (!$position) {
             $position = new Position();
             $position->abbr = $p['abbr'];
         }
         $position->save();
     }
 }
示例#2
0
 /**
  * @inheritdoc
  */
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         if ($this->scenario == 'user-update') {
             // Верификация должностей и пользователей
             foreach ($this->position as $key => $positionId) {
                 if (!isset($this->user[$key])) {
                     continue;
                 }
                 if (!($position = Position::findOne($positionId))) {
                     continue;
                 }
                 if (is_numeric($this->user[$key])) {
                     $user = User::findIdentity($this->user[$key]);
                 } else {
                     $user = User::findByUsername(trim($this->user[$key]));
                 }
                 if (!$user) {
                     continue;
                 }
                 $this->_verifyPositions[] = ['positionId' => $position->id, 'userId' => $user->id];
             }
             if (empty($this->_verifyPositions)) {
                 $this->addError('position', 'Вы должны указать минимум одну должность');
             }
         }
         return true;
     }
     return false;
 }
示例#3
0
 /**
  * AJAX获取部门职位
  */
 public function actionLists()
 {
     $name = $_POST['name'];
     $countSection = Position::find()->where(['uid' => Yii::$app->user->id, 'section' => $name])->count();
     $section = Position::find()->where(['uid' => Yii::$app->user->id, 'section' => $name])->all();
     if ($countSection > 0) {
         foreach ($section as $item) {
             echo "<option value='" . $item->name . "'>" . $item->name . "</option>";
         }
     } else {
         echo "<option>无</option>";
     }
 }
示例#4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Position::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, 'sort' => $this->sort, 'uid' => Yii::$app->user->id]);
     $query->andFilterWhere(['like', 'section', $this->section])->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
示例#5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Position::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(['position_id' => $this->position_id, 'flag_active' => $this->flag_active, 'date_added' => $this->date_added, 'date_update' => $this->date_update]);
     $query->andFilterWhere(['like', 'position_name', $this->position_name])->andFilterWhere(['like', 'position_desc', $this->position_desc]);
     return $dataProvider;
 }
 /**
  * Редактировать
  * @param $id
  * @return string|\yii\web\Response
  * @throws NotFoundHttpException
  */
 public function actionUpdate($id)
 {
     $model = ProjectForm::findById($id, null);
     if (!$model) {
         throw new NotFoundHttpException("Проекта №{$id} нет в базе данных");
     }
     $model->setScenario('user-update');
     $positionsArray = Position::findAllArray();
     $positionsArray = ArrayHelper::map($positionsArray, 'id', 'name');
     if (Yii::$app->request->isPost) {
         $model->load(Yii::$app->request->post());
         if ($model->validate()) {
             if ($model->updateProject()) {
                 Yii::$app->session->setFlash('success', 'Данные успешно сохранены');
             } else {
                 Yii::$app->session->setFlash('danger', 'Возникла критическая ошибка');
             }
             return $this->refresh();
         }
     }
     return $this->render('update', ['model' => $model, 'positionsArray' => $positionsArray]);
 }
/* @var $this yii\web\View */
/* @var $searchModel app\models\ElectionSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Добавяне на кандидати';
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = $this->title;
$this->params['electionId'] = $model->id;
?>
<div class="election-index">	

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'first_name', 'last_name', 'email:email', ['attribute' => 'position0.title', 'value' => 'position0.title', 'filter' => Html::activeDropDownList($searchModel, 'position', ArrayHelper::map(Position::find()->asArray()->all(), 'id', 'title'), ['class' => 'form-control', 'prompt' => 'Select Position'])], ['attribute' => 'group0.title', 'value' => 'group0.title', 'filter' => Html::activeDropDownList($searchModel, 'group', ArrayHelper::map(Group::find()->asArray()->all(), 'id', 'title'), ['class' => 'form-control', 'prompt' => 'Select Group	'])], 'unique_id', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{add}', 'buttons' => ['add' => function ($url, $model, $id) {
    return Html::a('<span class="glyphicon glyphicon-plus"></span>', $url, ['title' => Yii::t('app', 'Add Candidate')]);
}], 'urlCreator' => function ($action, $model, $key, $index) {
    if ($action === 'add') {
        $url = Url::to(['/admin/election/add-candidate', 'userId' => $model->id, 'electionId' => $this->params['electionId']]);
        return $url;
    }
}]]]);
?>

</div>
示例#8
0
<?php

use yii\helpers\Html;
//use yii\widgets\ActiveForm;
use kartik\widgets\ActiveForm;
use app\models\Position;
use yii\helpers\ArrayHelper;
use app\models\Department;
/* @var $this yii\web\View */
/* @var $model app\models\Staff */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="staff-form">
	<?php 
$Position = Position::find()->all();
$arraypos = ArrayHelper::map($Position, 'positio_id', 'position_name');
$Department = Department::find()->all();
$arraydep = ArrayHelper::map($Department, 'department_id', 'department_name');
// echo '<pre>';
// 	print_r($arraypos);
// echo '<pre>';
?>

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

     <?php 
echo $form->field($model, 'position_id')->dropDownList($arraypos, ['prompt' => '--Select--']);
?>
 /**
  * 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;
 }
示例#10
0
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use app\models\Group;
use app\models\Position;
/* @var $this yii\web\View */
/* @var $model app\models\User */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="user-form">

    <?php 
$groups = Group::find()->asArray()->all();
$groupMap = ArrayHelper::map($groups, 'id', 'title');
$positions = Position::find()->asArray()->all();
$positionMap = ArrayHelper::map($positions, 'id', 'title');
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'first_name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'last_name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'email')->textInput(['maxlength' => true]);
?>
示例#11
0
 /**
  * Создает экземпляр ActiveDataProvider с поисковым запросом
  *
  * @return ActiveDataProvider
  */
 public function search()
 {
     $query = Position::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_ASC]], 'pagination' => false]);
     return $dataProvider;
 }
示例#12
0
 public function getPositionId($pos)
 {
     $p = Position::where('descriptor', $pos)->first();
     if (!is_null($p)) {
         return $p->id;
     }
     switch (trim($pos)) {
         case "Dining Supv.":
             return 'B3622DDF666611E596ECDA40B3C0AA12';
             break;
         case "Dining Super":
             return 'B3622DDF666611E596ECDA40B3C0AA12';
             break;
         case "Cashier Seni":
             return '69427592A5E111E385D3C0188508F93C';
             break;
         case "Cashier Sr.":
             return '69427592A5E111E385D3C0188508F93C';
             break;
         case "Dining Asst.":
             return '8EF16963673A11E596ECDA40B3C0AA12';
             break;
         case "Kitchen Supe":
             return 'A7006EB7A3D411E592E000FF59FBB323';
             break;
         case "Kitchen Asst":
             return 'D02091AB673A11E596ECDA40B3C0AA12';
             break;
         case "OIC Kitchen":
             return '81BCB53BA3D711E592E000FF59FBB323';
             break;
         case "Kitchen Supv":
             return 'A7006EB7A3D411E592E000FF59FBB323';
             break;
         case "Manager - Op":
             return '55FC33F0A30211E592E000FF59FBB323';
             break;
         case "Mngr Branch":
             return '55FC33F0A30211E592E000FF59FBB323';
             break;
         case "Management T":
             return 'EC5ED785673A11E596ECDA40B3C0AA12';
             break;
         case "Mgmt Trainee":
             return 'EC5ED785673A11E596ECDA40B3C0AA12';
             break;
         case "Utility Staf":
             return '67B0F27F673B11E596ECDA40B3C0AA12';
             break;
         case "Tech'n":
             return 'F55DA154A47B11E592E000FF59FBB323';
             break;
         case "Tech'n Sr.":
             return '553820C0A47C11E592E000FF59FBB323';
             break;
         default:
             return '';
             break;
     }
 }
示例#13
0
 public function run()
 {
     $there_is_more = RawDatum::select('id')->whereNull('processed_utc')->first();
     if ($there_is_more) {
         $raw_data = RawDatum::whereNull('processed_utc')->take(4000)->get();
         foreach ($raw_data as $raw_datum) {
             $batter = Player::where('mlb_id', $raw_datum->batter_id)->first();
             if (!$batter) {
                 $batter = new Player();
                 $batter->mlb_id = $raw_datum->batter_id;
                 $batter->name = $raw_datum->batter;
             }
             $batter->batter_hand = $raw_datum->batter_hand;
             $batter->timestamp_utc = time();
             $batter->save();
             $pitcher = Player::where('mlb_id', $raw_datum->pitcher_id)->first();
             if (!$pitcher) {
                 $pitcher = new Player();
                 $pitcher->mlb_id = $raw_datum->pitcher_id;
                 $pitcher->name = $raw_datum->pitcher;
             }
             $pitcher->pitcher_hand = $raw_datum->pitcher_hand;
             $pitcher->timestamp_utc = time();
             $pitcher->save();
             $catcher = Player::where('mlb_id', $raw_datum->catcher_id)->first();
             if (!$catcher) {
                 $catcher = new Player();
                 $catcher->mlb_id = $raw_datum->catcher_id;
                 $catcher->name = $raw_datum->catcher;
             }
             $catcher->timestamp_utc = time();
             $catcher->save();
             $pitch_result = PitchResult::where('slug', $raw_datum->pitch_result)->first();
             if (!$pitch_result) {
                 $pitch_result = new PitchResult();
                 $pitch_result->slug = $raw_datum->pitch_result;
                 $pitch_result->timestamp_utc = time();
                 $pitch_result->save();
             }
             $pitch_type = PitchType::where('slug', $raw_datum->pitch_type)->first();
             if (!$pitch_type) {
                 $pitch_type = new PitchType();
                 $pitch_type->slug = $raw_datum->pitch_type;
                 $pitch_type->timestamp_utc = time();
                 $pitch_type->save();
             }
             $plate_appearance_result = PlateAppearanceResult::where('slug', $raw_datum->pa_result)->first();
             if (!$plate_appearance_result) {
                 $plate_appearance_result = new PlateAppearanceResult();
                 $plate_appearance_result->slug = $raw_datum->pa_result;
                 $plate_appearance_result->timestamp_utc = time();
                 $plate_appearance_result->save();
             }
             $batted_ball_type = BattedBallType::where('slug', $raw_datum->batted_ball_type)->first();
             if (!$batted_ball_type) {
                 $batted_ball_type = new BattedBallType();
                 $batted_ball_type->slug = $raw_datum->batted_ball_type;
                 $batted_ball_type->timestamp_utc = time();
                 $batted_ball_type->save();
             }
             $pitch = Pitch::where('raw_data_id', $raw_datum->id)->first();
             if (!$pitch) {
                 $pitch = new Pitch();
                 $pitch->raw_data_id = $raw_datum->id;
             }
             $pitch->season_year = $raw_datum->season_year;
             $pitch->game_string = $raw_datum->game_string;
             $pitch->game_date = $raw_datum->game_date;
             $pitch->game_type = $raw_datum->game_type;
             $pitch->visitor = $raw_datum->visitor;
             $pitch->home = $raw_datum->home;
             $pitch->visiting_team_final_runs = $raw_datum->visiting_team_final_runs;
             $pitch->home_team_final_runs = $raw_datum->home_team_final_runs;
             $pitch->inning = $raw_datum->inning;
             $pitch->side = $raw_datum->side;
             if ($batter->id == 0 || $pitcher->id == 0) {
                 dd(array('raw_data' => $raw_datum, 'batter' => $batter, 'pitcher' => $pitcher));
             }
             $pitch->batter_id = $batter->id;
             $pitch->pitcher_id = $pitcher->id;
             $pitch->inning = $raw_datum->inning;
             $pitch->catcher_id = $catcher->id;
             $pitch->times_faced = $raw_datum->times_faced;
             $pitch->batter_pos = $raw_datum->batter_pos;
             $position = Position::where('abbr', $raw_datum->batter_pos)->first();
             if ($position) {
                 $player_position = PlayerPosition::where('player_id', $batter->id)->where('position_id', $position->id)->first();
                 if (!$player_position) {
                     $player_position = new PlayerPosition();
                     $player_position->player_id = $batter->id;
                     $player_position->position_id = $position->id;
                     $player_position->save();
                 }
             }
             $pitch->balls = $raw_datum->balls;
             $pitch->strikes = $raw_datum->strikes;
             $pitch->outs = $raw_datum->outs;
             $pitch->man_on_first = $raw_datum->man_on_first == "TRUE";
             $pitch->man_on_second = $raw_datum->man_on_second == "TRUE";
             $pitch->man_on_third = $raw_datum->man_on_third == "TRUE";
             $pitch->end_man_on_first = $raw_datum->end_man_on_first == "TRUE";
             $pitch->end_man_on_second = $raw_datum->end_man_on_second == "TRUE";
             $pitch->end_man_on_third = $raw_datum->end_man_on_third == "TRUE";
             $pitch->visiting_team_current_runs = $raw_datum->visiting_team_current_runs;
             $pitch->home_team_current_runs = $raw_datum->home_team_current_runs;
             $pitch->pitch_result_id = $pitch_result->id;
             $pitch->pitch_type_id = $pitch_type->id;
             $pitch->release_velocity = $raw_datum->release_velocity;
             $pitch->spin_rate = $raw_datum->spin_rate;
             $pitch->spin_direction = $raw_datum->spin_direction;
             $pitch->px = $raw_datum->px;
             $pitch->pz = $raw_datum->pz;
             $pitch->szt = $raw_datum->szt;
             $pitch->szb = $raw_datum->szb;
             $pitch->x0 = $raw_datum->x0;
             $pitch->y0 = $raw_datum->y0;
             $pitch->z0 = $raw_datum->z0;
             $pitch->vx0 = $raw_datum->vx0;
             $pitch->vy0 = $raw_datum->vy0;
             $pitch->vz0 = $raw_datum->vz0;
             $pitch->ax = $raw_datum->ax;
             $pitch->ay = $raw_datum->ay;
             $pitch->az = $raw_datum->az;
             $pitch->pa_result_id = $plate_appearance_result->id;
             $pitch->runs_home = $raw_datum->runsHome;
             $pitch->batted_ball_type_id = $batted_ball_type->id;
             $pitch->batted_ball_angle = $raw_datum->batted_ball_angle;
             $pitch->batted_ball_distance = $raw_datum->batted_ball_distance;
             $pitch->atbat_desc = $raw_datum->atbat_desc;
             $pitch->timestamp_utc = time();
             if (!$pitch->save()) {
                 dd($raw_datum);
             }
             if ($raw_datum->id % 1000 == 0) {
                 echo "Processed record number " . $raw_datum->id . "\n\r";
             }
             $raw_datum->processed_utc = time();
             $raw_datum->save();
         }
     }
 }
示例#14
0
    
    <div class="form-group">
      <label class="col-sm-3 control-label">Mobile Phone</label>
      <div class="col-sm-6">
        <?php 
echo $form->field($model, 'mobile_phone')->label(false)->textInput(['maxlength' => 15, 'placeholder' => 'Enter number only.', 'class' => 'form-control', 'parsley-type' => 'number']);
?>
  
      </div>
    </div><!--/form-group--> 
    
    <div class="form-group">
      <label class="col-sm-3 control-label">Position</label>
      <div class="col-sm-6">
        <?php 
echo $form->field($model, 'position_id')->label(false)->dropDownList(ArrayHelper::map(Position::find()->all(), 'position_id', 'position_name'), ['prompt' => 'Select Position Name', 'class' => 'form-control']);
?>
      </div>
    </div><!--/form-group--> 

    <div class="form-group">
      <label class="col-sm-3 control-label">Note</label>
      <div class="col-sm-6">
        <?php 
echo $form->field($model, 'note')->label(false)->textArea(['maxlength' => 500, 'class' => 'form-control ckeditor', 'placeholder' => 'Input address 1.', 'rows' => '3']);
?>
 
      </div>
    </div><!--/form-group--> 
    
    <div class="form-group">
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPositions()
 {
     return $this->hasMany(Position::className(), ['type_id' => 'id']);
 }
示例#16
0
 /**
  * Finds the Position model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Position the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Position::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#17
0
<div class="employee-form">

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

    <?php 
echo $form->field($model, 'first_name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'last_name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'position_id')->dropDownList(ArrayHelper::map(Position::find()->all(), 'id', 'name'));
?>


    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
示例#18
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPosition()
 {
     return $this->hasOne(Position::className(), ['position_id' => 'position_id']);
 }
示例#19
0
 public function getBranchManager()
 {
     $postions = Position::all();
     $branches = Branch::all();
     return view('branch.manager')->with('postions', $postions)->with('branches', $branches);
 }