From: fomichev Date: Mon, 3 Feb 2025 06:58:16 +0000 (+0300) Subject: Таблица просмотра X-Git-Tag: 1.7~22^2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=0c50e31bbccb88cad30f9f13eeef8a98d40f6dfd;p=erp24_rep%2Fyii-erp24%2F.git Таблица просмотра --- diff --git a/erp24/controllers/Products1cNomenclatureController.php b/erp24/controllers/Products1cNomenclatureController.php new file mode 100644 index 00000000..abfff6d6 --- /dev/null +++ b/erp24/controllers/Products1cNomenclatureController.php @@ -0,0 +1,144 @@ + [ + 'class' => VerbFilter::class, + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ] + ); + } + + /** + * Lists all Products1cNomenclature models. + * + * @return string + */ + public function actionIndex() + { + $dataProvider = new ActiveDataProvider([ + 'query' => Products1cNomenclature::find(), + /* + 'pagination' => [ + 'pageSize' => 50 + ], + 'sort' => [ + 'defaultOrder' => [ + 'id' => SORT_DESC, + ] + ], + */ + ]); + + return $this->render('index', [ + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Products1cNomenclature model. + * @param string $id GUID - уникальный номер номенклатуры в 1С + * @return string + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Products1cNomenclature model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return string|\yii\web\Response + */ + public function actionCreate() + { + $model = new Products1cNomenclature(); + + if ($this->request->isPost) { + if ($model->load($this->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + } else { + $model->loadDefaultValues(); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing Products1cNomenclature model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param string $id GUID - уникальный номер номенклатуры в 1С + * @return string|\yii\web\Response + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + + /** + * Deletes an existing Products1cNomenclature model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param string $id GUID - уникальный номер номенклатуры в 1С + * @return \yii\web\Response + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the Products1cNomenclature model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param string $id GUID - уникальный номер номенклатуры в 1С + * @return Products1cNomenclature the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Products1cNomenclature::findOne(['id' => $id])) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } +} diff --git a/erp24/records/Products1cNomenclature.php b/erp24/records/Products1cNomenclature.php index 0549cc9b..2e60e155 100644 --- a/erp24/records/Products1cNomenclature.php +++ b/erp24/records/Products1cNomenclature.php @@ -49,10 +49,10 @@ class Products1cNomenclature extends \yii\db\ActiveRecord public function attributeLabels() { return [ - 'id' => 'GUID - уникальный номер номенклатуры в 1С', - 'location' => 'расположение номенклатуры в системе 1С, т.е. путь до папки где храниться номенклатура', - 'name' => 'имя номенклатуры', - 'type_num' => 'Название вида номенклатуры из логического условия, без квадратных скобок.', + 'id' => 'GUID', + 'location' => 'Расположение номенклатуры в системе 1С', + 'name' => 'Имя', + 'type_num' => 'Название вида номенклатуры', 'category' => 'Категория', 'subcategory' => 'Подкатегория', 'species' => 'Вид', diff --git a/erp24/views/products1c-nomenclature/index.php b/erp24/views/products1c-nomenclature/index.php new file mode 100644 index 00000000..1c535929 --- /dev/null +++ b/erp24/views/products1c-nomenclature/index.php @@ -0,0 +1,47 @@ +title = 'Товары с категориями'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + + $dataProvider, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + 'location', + 'name', + 'type_num', + 'category', + 'subcategory', + 'species', + 'sort', + 'size', + 'measure', + 'color', + [ + 'class' => ActionColumn::class, + 'template' => '{view}', + 'urlCreator' => function ($action, Products1cNomenclature $model, $key, $index, $column) { + return Url::toRoute([$action, 'id' => $model->id]); + } + ], + ], + ]); ?> + + +
diff --git a/erp24/views/products1c-nomenclature/view.php b/erp24/views/products1c-nomenclature/view.php new file mode 100644 index 00000000..e2717e40 --- /dev/null +++ b/erp24/views/products1c-nomenclature/view.php @@ -0,0 +1,35 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Products1c Nomenclatures', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +\yii\web\YiiAsset::register($this); +?> +
+ 'btn btn-primary mb-3']) ?> +

title) ?>

+ + $model, + 'attributes' => [ + 'id', + 'location', + 'name', + 'type_num', + 'category', + 'subcategory', + 'species', + 'sort', + 'size', + 'measure', + 'color', + ], + ]) ?> + +