/**
  * Creates a new InventoryActsTb model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($act_id, $dev_id, $wp_id)
 {
     if ($act_id == 0) {
         $model_act = new InventoryActs();
         $model_act->workplace_id = $wp_id;
         $workplace = Workplaces::findOne($wp_id);
         //var_dump($workplace->owner); die;
         $model_act->owner_employee_id = $workplace->owner[0]->id;
         $model_act->exec_employee_id = $workplace->owner[0]->id;
         $model_act->status = 0;
         if ($model_act->save()) {
             $act_id = $model_act->id;
         } else {
             Yii::$app->session->setFlash('error', 'Ошибка при создании Акта инвентарзации');
             return $this->redirect(['inventory-acts/view', 'id' => $act_id]);
         }
     }
     $model = new InventoryActsTb();
     $model->act_id = $act_id;
     $model->device_id = $dev_id;
     $model->status = 'OK!';
     if ($model->save()) {
         return $this->redirect(['inventory-acts/view', 'id' => $act_id]);
     }
 }
 /**
  * Создаем Акт инвентаризации.
  * @param integer $id_wp идентификатор рабочего места
  * @return mixed
  */
 public function actionCreate($id_wp = null)
 {
     $model = new InventoryActs();
     if ($id_wp) {
         $model->workplace_id = $id_wp;
         $workplace = Workplaces::findOne($id_wp);
         if ($workplace->owner) {
             $model->owner_employee_id = $workplace->owner[0]->id;
             $model->owner_name = $workplace->owner[0]->snp;
         }
     }
     if ($model->load(Yii::$app->request->post())) {
         $model->act_date = Yii::$app->formatter->asDate($model->act_date, 'yyyy-MM-dd');
         $model->status = 0;
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Esempio n. 3
0
}]]]);
?>
    <?php 
if (Yii::$app->user->can('admin')) {
    ?>
        <?php 
    echo Html::a('Добавить номер', ['voipnumbers/index', 'id_wp' => $model->id], ['class' => 'btn btn-primary']);
    ?>
    <?php 
}
?>
</div>
<div style="margin: 5px">
    <h4> Сетевые интерфейсы </h4>
    <?php 
echo GridView::widget(['dataProvider' => Workplaces::getNetintsProvider($model->id), 'layout' => "{sorter}\n{pager}\n{items}", 'columns' => [['attribute' => 'title', 'header' => 'Тип устройства', 'value' => 'title'], ['attribute' => 'dev_id', 'header' => 'Устройство', 'value' => function ($arr) {
    return Html::a($arr['dev_id'], ['devices/view', 'id' => $arr['dev_id']]);
}, 'format' => 'raw'], ['attribute' => 'ip', 'header' => 'IP адрес', 'value' => 'ip']]]);
?>
</div>
<div style="margin: 5px">

    <div class="devices-index">
        <h4> Закрепленные устройства: </h4>
        <?php 
Modal::begin(['header' => '<div class="breadcrumb"><h4> Редактировать </h4></div>', 'id' => 'modal', 'size' => 'modal-lg']);
echo '<div id="modalContent"></div>';
Modal::end();
?>
        <?php 
if (Yii::$app->user->can('admin')) {
Esempio n. 4
0
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\WpOwners */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="wp-owners-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'workplace_id')->dropDownList(ArrayHelper::map(Workplaces::find()->all(), 'id', 'workplaces_title'), ['prompt' => 'Выберите рабочее место...']);
?>

    <?php 
echo $form->field($model, 'employee_id')->dropDownList(ArrayHelper::map(Employees::find()->all(), 'id', function ($model) {
    return $model->surname . ' ' . $model->name;
}), ['prompt' => 'Выберите сотрудника...']);
?>

    <?php 
echo $form->field($model, 'event')->checkbox();
?>

    <?php 
echo $form->field($model, 'date')->textInput();
?>
Esempio n. 5
0
 /**
  * Finds the Workplaces model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Workplaces the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Workplaces::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 6
0
 /**
  * @return $this
  */
 public function getWorkplace()
 {
     return $this->hasMany(Workplaces::className(), ['id' => 'workplace_id'])->viaTable('wp_owners', ['employee_id' => 'id']);
 }
Esempio n. 7
0
 /**
  * Связываем таблицу устройств с таблицей рабочих мест
  * @return \yii\db\ActiveQuery
  */
 public function getWorkplace()
 {
     return $this->hasOne(Workplaces::className(), ['id' => 'workplace_id']);
 }
Esempio n. 8
0
            devWork.html(\'<option value="0"> - </option>\');
        });']);
    ?>
    <?php 
    echo $form->field($model, 'room_id')->dropDownList(ArrayHelper::map(Rooms::find()->orderBy('room_title')->all(), 'id', 'room_title'), ['prompt' => 'Выберите отдел/кабинет...', 'onchange' => '$.post("/admin/workplaces/list?id=' . '"+$(this).val(), function(data) {
            $("select#devices-workplace_id").html(data);
        });']);
    ?>
    <?php 
}
if ($id_wp > 0) {
    $model->workplace_id = $id_wp;
}
?>
    <?php 
echo $form->field($model, 'workplace_id')->dropDownList(ArrayHelper::map(Workplaces::find()->all(), 'id', function ($model_wp) {
    $snp = '';
    if ($model_wp->owner) {
        $snp = $model_wp->owner[0]['snp'];
    }
    return '"' . $model_wp->workplaces_title . '" ' . $snp;
}), ['prompt' => 'Выберите рабочее место...']);
?>

    <?php 
echo $form->field($model, 'type_id')->dropDownList(ArrayHelper::map(DeviceType::find()->orderBy('title')->all(), 'id', 'title'), ['prompt' => 'Выберите тип устройства...']);
?>
    <?php 
echo $form->field($model, 'brand')->textInput(['maxlength' => true])->widget(AutoComplete::className(), ['clientOptions' => ['source' => $model::arrayBrands()], 'options' => ['class' => 'form-control']]);
?>
    <?php 
Esempio n. 9
0
<?php

use backend\models\Workplaces;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\StoryworkplaceSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$wp = Workplaces::findOne(['id' => $id_wp]);
$this->title = 'История рабочего места "' . $wp->workplaces_title . '"';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="story-workplace-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>

    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'employee.snp', 'date_up', 'event', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>