From: fomichev Date: Tue, 10 Dec 2024 15:16:14 +0000 (+0300) Subject: Вывод таблицы просмотра документа с товарами X-Git-Tag: 1.7~179^2~1 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=e3fddf673dcb8d8c46bc27198f92985e51502a99;p=erp24_rep%2Fyii-erp24%2F.git Вывод таблицы просмотра документа с товарами --- diff --git a/erp24/controllers/WaybillWriteOffsController.php b/erp24/controllers/WaybillWriteOffsController.php index 3ce886d8..5245a888 100644 --- a/erp24/controllers/WaybillWriteOffsController.php +++ b/erp24/controllers/WaybillWriteOffsController.php @@ -4,6 +4,7 @@ namespace app\controllers; use yii\data\ActiveDataProvider; use yii_app\records\WaybillWriteOffs; +use yii_app\records\WaybillWriteOffsProducts; class WaybillWriteOffsController extends \yii\web\Controller { @@ -21,9 +22,23 @@ class WaybillWriteOffsController extends \yii\web\Controller ]); } - public function actionView() + public function actionView($id) { - return $this->render('view'); - } + $model = WaybillWriteOffs::findOne($id); + if (!$model) { + throw new \yii\web\NotFoundHttpException("Документ с ID {$id} не найден."); + } + $productsDataProvider = new \yii\data\ActiveDataProvider([ + 'query' => WaybillWriteOffsProducts::find()->where(['waybill_write_offs_id' => $model->id]), + 'pagination' => [ + 'pageSize' => 10, // Количество записей на странице + ], + ]); + + return $this->render('view', [ + 'model' => $model, + 'productsDataProvider' => $productsDataProvider, + ]); + } } diff --git a/erp24/views/waybill-write-offs/index.php b/erp24/views/waybill-write-offs/index.php index 6252b1a1..845ed78d 100644 --- a/erp24/views/waybill-write-offs/index.php +++ b/erp24/views/waybill-write-offs/index.php @@ -4,6 +4,7 @@ use yii\grid\GridView; use yii\helpers\Html; use yii_app\records\Admin; use yii_app\records\CityStore; +use yii_app\records\ExportImportTable; /** @var yii\data\ActiveDataProvider $dataProvider */ @@ -36,7 +37,8 @@ $this->params['breadcrumbs'][] = $this->title; 'label' => 'Магазин', 'attribute' => 'store_id', 'value' => function ($model) { - return CityStore::findOne(\yii_app\records\ExportImportTable::findOne(['export_val' => $model->store_guid])->entity_id)->name; + return CityStore::findOne(ExportImportTable::findOne(['export_val' => $model->store_guid]) + ->entity_id)->name; } ], 'quantity', @@ -49,7 +51,7 @@ $this->params['breadcrumbs'][] = $this->title; 'label' => 'Создан пользователем', 'attribute' => 'created_admin_id', 'value' => function ($model) { - return Admin::findOne( [$model->created_admin_id])->name; + return Admin::findOne([$model->created_admin_id])->name; } ], [ diff --git a/erp24/views/waybill-write-offs/view.php b/erp24/views/waybill-write-offs/view.php new file mode 100644 index 00000000..d665244a --- /dev/null +++ b/erp24/views/waybill-write-offs/view.php @@ -0,0 +1,71 @@ +title = "Детали документа: {$model->number}"; +$this->params['breadcrumbs'][] = ['label' => 'Список документов', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + + $model, + 'attributes' => [ + 'id', + 'guid', + 'number', + 'date', + [ + 'label' => 'Магазин', + 'attribute' => 'store_id', + 'value' => function ($model) { + return CityStore::findOne(ExportImportTable::findOne(['export_val' => $model->store_guid]) + ->entity_id)->name; + } + ], + 'quantity', + 'summ', + 'status', + [ + 'label' => 'Создан пользователем', + 'attribute' => 'created_admin_id', + 'value' => function ($model) { + return Admin::findOne([$model->created_admin_id])->name; + } + ], + 'created_at', + 'updated_at', + 'deleted_at', + ], + ]) ?> + +

Списываемые товары

+ + + $productsDataProvider, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + 'name', + 'product_id', + 'product_count', + 'product_price', + 'product_self_cost', + 'summ', + 'summ_self_cost', + 'created_at', + ], + ]) ?> + +