public function searchCodstr($params, $code) { $query = Bureau::find()->where(['codestructure' => $code]); $dataProvider = new ActiveDataProvider(['query' => $query]); $modelsbur = $dataProvider->getModels(); foreach ($modelsbur as $rowbur) { echo $rowbur->codestructure; } $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(['like', 'codestructure', $this->codestructure])->andFilterWhere(['like', 'codestructure', $this->codestructure])->andFilterWhere(['like', 'designationbureau', $this->designationbureau]); return $dataProvider; }
<?php echo $form->field($bureau, 'codestructure', ['horizontalCssClasses' => ['wrapper' => 'col-sm-3']])->dropDownList($dataStruct, ['prompt' => '----------Choisir la structure----------', 'onchange' => ' $.post( "index.php?r=bien/lists&id=' . '"+$(this).val(), function( data ) { $( "select#bureau-codebureau").html( data ); });'])->label(false); ?> </div> <div > <label class="col-lg-2 control-label">Nouveau Bureau:</label> <?php echo $form->field($bureau, 'codebureau', ['horizontalCssClasses' => ['wrapper' => 'col-sm-3']])->dropDownList(ArrayHelper::map(Bureau::find()->asArray()->all(), 'codebureau', 'codebureau'), ['prompt' => '----------Choisir le bureau----------'])->label(false); ?> </div> <div> <label for="DateTrans" class="col-lg-2 control-label">Date de transfert:</label> <?php echo $form->field($trans, 'dt')->widget(DatePicker::className(), ['template' => '{addon}{input}', 'clientOptions' => ['autoclose' => true, 'format' => 'dd/mm/yyyy']])->label(false); ?> </div>
<?php //use yii\widgets\ActiveForm; use yii\helpers\Html; use yii\bootstrap\ActiveForm; use yii\helpers\ArrayHelper; use yii\grid\GridView; use yii\widjets\Pjax; use yii\bootstrap\Modal; use yii\helpers\Url; use app\models\Bureau; use dosamigos\datepicker\DatePicker; use yii\widgets\Breadcrumbs; $dataStruct = ArrayHelper::map(Bureau::find()->asArray()->all(), 'codestructure', 'codestructure'); echo $this->render('men'); ?> <?php echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]); ?> <?php echo Html::beginForm([''], 'post', ['data-pjax' => '']); Pjax::begin(); ?> <div class="col-lg-12"> <label class="col-lg-2 control-label">code bien:</label> <div class= "col-lg-8"> <?php
public function actionLists($id) { $countBureau = Bureau::find()->where(['codestructure' => $id])->count(); $bureaux = Bureau::find()->where(['codestructure' => $id])->all(); if ($countBureau > 0) { foreach ($bureaux as $bureau) { echo "<option value='" . $bureau->codebureau . "'>" . $bureau->codebureau . "</option>"; } } else { echo "<option> - </option>"; } }