/** * 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>"; } }
/** * 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; }
/** * 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; }
/** * Создает экземпляр ActiveDataProvider с поисковым запросом * * @return ActiveDataProvider */ public function search() { $query = Position::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_ASC]], 'pagination' => false]); return $dataProvider; }
/* @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>
<?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; }
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]); ?>
<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>
/** * Lists all Position models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Position::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }
<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">