/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Areas::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $query->joinWith('idResponsable'); $dataProvider->sort->attributes['responsable_name'] = ['asc' => ['users.first_name' => SORT_ASC], 'desc' => ['users.first_name' => SORT_DESC]]; $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, 'area_id' => $this->area_id, 'id_responsable' => $this->id_responsable]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'idResponsable.first_name', $this->responsable_name]); return $dataProvider; }
$nameValue = ""; $emailValue = ""; }else{ $user = User::findOne(\Yii::$app->user->identity->id); $nameValue = $user->first_name . " " . $user->lastname; $emailValue = $user->email; } ?> <?= $form->field($request, 'name')->textInput(['value'=>$nameValue,'maxlength' => true]) ?> <?= $form->field($request, 'email')->textInput(['value'=> $emailValue,'maxlength' => true]) ?> <?= $form->field($request, 'area_id')->dropDownList( ArrayHelper::map( Areas::find()->all(), 'id', 'name' ), array('prompt'=> "")) ?> <?= $form->field($request, 'category_id')->dropDownList( ArrayHelper::map( Categories::find()->all(), 'id', 'name' ), array('prompt'=> "")) ?> <?= $form->field($request, 'subject')->textInput(['maxlength' => true]) ?> <?= $form->field($request, 'description')->textarea(['rows' => 6]) ?>
public static function areasFilter($id = "") { $data = \App\Models\Areas::all(); $selecttop = '<select name="area_id" id="area_id" class="form-control select2">'; $option = '<option value="">- Pilih Area -</option>'; foreach ($data as $key => $value) { $option = $option . "<option value='{$value->id}'>{$value->id} - {$value->name_area}</option>"; } $selectbottom = '</select>'; $list = $selecttop . $option . $selectbottom; return $list; }
/** * @return \yii\db\ActiveQuery */ public function getArea() { return $this->hasOne(Areas::className(), ['id' => 'area_id']); }
?> <div class="site-signup"> <h1><?php echo Html::encode($this->title); ?> </h1> <p>Por favor llene los campos para poder darse de alta:</p> <div class="row"> <div class="col-lg-5"> <?php $form = ActiveForm::begin(['id' => 'form-signup']); ?> <?php $areas = Areas::find()->all(); $areaslista = ArrayHelper::map($areas, 'id_area', 'nombre_area'); ?> <?php echo $form->field($model, 'nombre'); ?> <?php echo $form->field($model, 'username')->label('Nombre de usuario'); ?> <?php echo $form->field($model, 'email'); ?> <?php
/** * @return \yii\db\ActiveQuery */ public function getIdArea() { return $this->hasOne(Areas::className(), ['id' => 'id_area']); }
/** * Finds the Areas model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Areas the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Areas::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
'checked'=>'Checked', //Verificado 'denied'=>'Denaied', //Rechazado 'completed'=>'Completed', //Finalizado ] ) ?> <?= $form->field($request, 'scheduled_start_date')->widget(\yii\jui\DatePicker::classname(), [ 'dateFormat' => 'yyyy-MM-dd', ]) ?> <?= $form->field($request, 'scheduled_end_date')->widget(\yii\jui\DatePicker::classname(), [ 'dateFormat' => 'yyyy-MM-dd', ]) ?> <?php $arrayAreas=ArrayHelper::map(Areas::find()->all(),'id','name'); $areasRequests = (new \yii\db\Query()) ->select(['area_id']) ->from('areas_request') ->where(['request_id' => $request->id]) ->all(); if(!empty($areasRequests)){ foreach ($areasRequests as $areaRequest){ unset($arrayAreas[$areaRequest["area_id"]]); } } ?> <?= $form->field($request, 'listAreas')->checkboxList($arrayAreas) ?> <?php
use app\models\Categories; use app\models\Areas; /* @var $this yii\web\View */ /* @var $model app\models\Categories */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="categories-form"> <?php $form = ActiveForm::begin(); ?> <?= $form->field($model, 'category_id')->dropDownList( ArrayHelper::map(Categories::find()->all(),'id','name'), array('prompt'=>''))?> <?= $form->field($model, 'id_area')->dropDownList(ArrayHelper::map(Areas::find()->all(),'id','name')) ?> <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'service_level_agreement_asignment')->textInput() ?> <?= $form->field($model, 'service_level_agreement_completion')->textInput() ?> <div class="form-group"> <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> </div> <?php ActiveForm::end(); ?>
public function buildForm() { $this->add('bank_id', 'select', ['attr' => ['class' => 'frm-e form-control'], 'choices' => \App\Models\Banks::lists("name", "id")->toArray(), 'empty_value' => '- Select Banks -', 'label' => 'Bank'])->add('area_id', 'select', ['attr' => ['class' => 'frm-e form-control'], 'choices' => \App\Models\Areas::lists("name_area", "id")->toArray(), 'empty_value' => '- Select Area-', 'label' => 'Area'])->add('location_id', 'select', ['attr' => ['class' => 'frm-e form-control'], 'choices' => \App\Models\Locations::lists("name", "id")->toArray(), 'empty_value' => '- Select Lokasi-', 'label' => 'Lokasi'])->add('machine_id', 'select', ['attr' => ['class' => 'frm-e form-control'], 'choices' => \App\Models\Machines::lists("name_machine", "id")->toArray(), 'empty_value' => '- Pilih Mesin -', 'label' => 'Mesin'])->add('from', 'text', ['attr' => ['class' => 'form-control datepicker1', 'required' => 'true']])->add('to', 'text', ['attr' => ['class' => 'form-control datepicker2', 'required' => 'true']])->add('format', 'choice', ['choices' => ['pdf' => 'PDF', 'csv' => 'CSV', 'xls' => 'XLS'], 'attr' => ['required' => 'true'], 'label' => "Format", 'choice_options' => ['wrapper' => ['class' => 'choice-wrapper']]]); }