Пример #1
0
 public static function getLinkfile($key)
 {
     $img = Images::find()->where(['owner' => $key])->one();
     //var_dump($img);
     //die;
     return $img['linkfile'];
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Images::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, 'advertise_id' => $this->advertise_id]);
     $query->andFilterWhere(['like', 'image', $this->image]);
     return $dataProvider;
 }
Пример #3
0
 public function run()
 {
     $postData = Yii::$app->request->post('filename');
     $model = Images::find()->where('name=:name', [':name' => $postData])->one();
     if ($model) {
         $model->delete();
     }
     if (\Yii::$app->session['upload'] !== null) {
         $array = \Yii::$app->session['upload'];
         $key = array_search(StringHelper::basename(Yii::$app->request->post('filename')), \Yii::$app->session['upload']);
         array_splice($array, $key);
         unset(\Yii::$app->session['upload']);
         \Yii::$app->session['upload'] = $array;
     }
     return (int) unlink(Yii::getAlias($this->uploadUrl) . $postData);
 }
Пример #4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Images::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]);
     $query->andFilterWhere(['like', 'linkfile', $this->linkfile])->andFilterWhere(['like', 'owner', $this->owner]);
     return $dataProvider;
 }
Пример #5
0
                    <br>
                    <?php 
    echo Html::a('Добавить пользователя', ['employees/index', 'mode' => 'select', 'id_wp' => $model->id], ['class' => 'btn btn-primary']);
    ?>
                <?php 
}
?>

            </div>
        </div>
        <div class="col-xs-12 col-md-3 col-md-pull-9">

            <div class="img-thumbnail" style="margin-top: 20px">
                <?php 
$key = md5('workplace' . $model->id);
echo Html::img('/admin/' . Images::getLinkfile($key), ['width' => '200px', 'alt' => 'Отсутствует изображение']) . '<br>';
if (Yii::$app->user->can('admin')) {
    echo Html::a('Изменить', ['images/index', 'owner' => $key, 'owner_id' => $model->id, 'target' => 'workplaces/view']);
}
?>
            </div>
        </div>
    </div>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', ['attribute' => 'branch_id', 'value' => $model->branch ? $model->branch->branch_title : '-', 'format' => 'raw'], ['attribute' => 'room_id', 'value' => $model->room ? $model->room->room_title : '-', 'format' => 'raw'], 'workplaces_title', ['label' => 'Многопользовательское рабочее место', 'value' => $model->mu ? 'Да' : 'Нет']]]);
?>

</div>
<div style="margin: 5px">
    <h4> Внутренние номера </h4>
Пример #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getImages()
 {
     return $this->hasMany(Images::className(), ['obj_reservation_id' => 'id']);
 }
 /**
  * Finds the Images model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Images the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Images::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }