/**
  * Добавление строки в табличную часть документа Акт списания.
  *
  * @param integer $id идентификатор устройсва
  * @param string $param параметры УРЛ
  * @return mixed
  */
 public function actionCreate($id, $param)
 {
     parse_str($param, $arr);
     $model = new DtDefsheetDevices();
     $device = Devices::findOne($id);
     if ($device->workplace_id != 1) {
         Yii::$app->session->setFlash('error', 'Устройство должно находится на Складе ОИ');
         return $this->redirect(['dt-defsheets/view', 'id' => $arr['target_id']]);
     }
     //var_dump($arr);
     $model->dt_defsheets_id = $arr['target_id'];
     $model->devices_id = $id;
     //if ($model->load(Yii::$app->request->post()) && $model->save()) {
     if ($model->save()) {
         return $this->redirect(['dt-defsheets/view', 'id' => $arr['target_id']]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * @param $id
  * @param $param
  * @return string|\yii\web\Response
  */
 public function actionCreate2($id, $param)
 {
     /* @var $device Devices */
     parse_str($param, $arr);
     $id_doc = $arr['id_doc'];
     $model = new DtEnquiryDevices();
     $device = Devices::findOne($id);
     $model->dt_enquiries_id = $id_doc;
     $model->type_id = $device->type_id;
     if ($device->parent_device_id) {
         $model->parent_device_id = $device->parent_device_id;
     }
     if ($model->save()) {
     } else {
         Yii::$app->session->setFlash('error', 'Ошибка при добавлении устройства');
     }
     if ($id_doc > 0) {
         return $this->redirect(['dt-enquiries/view', 'id' => $id_doc]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Finds the Devices model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Devices the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Devices::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#4
0
文件: index.php 项目: Griff19/it_base
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use backend\models\Devices;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\StorydeviceSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$moddev = Devices::findOne($id_dev);
$this->title = 'История изменений';
$this->params['breadcrumbs'][] = ['label' => 'Устройства', 'url' => Url::to(['devices/index'])];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="story-device-index">
    <h4> История изменений </h4>
    <h1><?php 
echo (isset($moddev->deviceType) ? $moddev->deviceType->title : '') . ' ' . $moddev->device_note;
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>



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

</div>
示例#5
0
 /**
  * Finds the Devices model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Devices the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Devices::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('Запрашиваемой страницы не существует.');
     }
 }