示例#1
0
文件: Start.php 项目: robky/tb
 public function getUsd($id)
 {
     try {
         //Получаем весь массив данных из таблицы
         $q = Usd::find()->select(['id', 'dns_name', 'login', 'pass'])->where($id === NULL ? ['work_usd' => '1'] : ['id' => $id, 'work_usd' => '1'])->createCommand()->queryAll();
     } catch (\Exception $e) {
         echo "Something went wrong of get Device\n";
         throw $e;
         return FALSE;
     }
     return $q;
 }
示例#2
0
文件: UsdSearch.php 项目: robky/tb
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Usd::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'work_usd' => $this->work_usd]);
     $query->andFilterWhere(['like', 'name_usd', $this->name_usd])->andFilterWhere(['like', 'dns_name', $this->dns_name])->andFilterWhere(['like', 'login', $this->login])->andFilterWhere(['like', 'pass', $this->pass]);
     return $dataProvider;
 }
示例#3
0
文件: Device.php 项目: robky/tb
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdUsd()
 {
     return $this->hasOne(Usd::className(), ['id' => 'id_usd']);
 }
示例#4
0
文件: _form.php 项目: robky/tb
//Получаем все типы
$typed = TypeDevice::find()->orderBy('name_type')->all();
//Формируем массив с ключем равным полю 'id' и значением равным полю 'name'
$items1 = ArrayHelper::map($typed, 'id', 'name_type');
$params1 = ['prompt' => 'Выберите тип'];
echo $form->field($model, 'id_type_device')->dropDownList($items1, $params1);
?>
    

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

   <?php 
//Получаем все усд
$usd = Usd::find()->orderBy('name_usd')->all();
//Формируем массив с ключем равным полю 'id' и значением равным полю 'name'
$items2 = ArrayHelper::map($usd, 'id', 'name_usd');
$params2 = ['prompt' => 'Выберите сборщик'];
echo $form->field($model, 'id_usd')->dropDownList($items2, $params2);
?>

   <?php 
$items3 = array("1" => "Работает", "0" => "Отключено");
echo $form->field($model, 'work_device')->dropDownList($items3);
?>

   <div class="form-group">
      <?php 
echo Html::submitButton($model->isNewRecord ? 'Сохранить' : 'Изменить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
示例#5
0
 /**
  * Finds the Usd model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Usd the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Usd::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }