public function searchVirtual($params)
 {
     $query = Subsgroup::find()->where(['virtual_id' => $_GET['id']]);
     $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, 'virtual_id' => $this->virtual_id, 'area_code' => $this->area_code, 'office_code' => $this->office_code, 'rating_id' => $this->rating_id, 'first_update' => $this->first_update, 'last_update' => $this->last_update]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'desc', $this->desc])->andFilterWhere(['like', 'wallet', $this->wallet])->andFilterWhere(['like', 'first_user', $this->first_user])->andFilterWhere(['like', 'last_user', $this->last_user])->andFilterWhere(['like', 'first_ip', $this->first_ip])->andFilterWhere(['like', 'last_ip', $this->last_ip]);
     return $dataProvider;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSubsgroup()
 {
     return $this->hasOne(Subsgroup::className(), ['id' => 'subsgroup_id']);
 }
Example #3
0
use yii\helpers\ArrayHelper;
use yii\widgets\ActiveForm;
use backend\models\Subsgroup;
/* @var $this yii\web\View */
/* @var $model backend\models\OutSubsgroupPrefix */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="out-subsgroup-prefix-form">

    <?php 
$form = ActiveForm::begin(['id' => $model->formName(), 'enableAjaxValidation' => true, 'validationUrl' => Url::toRoute('out-subsgroup-prefix/validation')]);
?>

    <?php 
echo $form->field($model, 'subsgroup_id')->dropDownList(ArrayHelper::map(Subsgroup::find()->all(), 'id', 'name'), ['prompt' => 'Select Subsgroup']);
?>
    <div class="hide">
        <?php 
echo $form->field($model, 'prefix_id')->textInput(['value' => $model->isNewRecord ? $_GET['id'] : $model->prefix_id]);
?>
    </div>   

    <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();
 /**
  * Finds the Subsgroup model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Subsgroup the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Subsgroup::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }