} elseif ($action === 'rejection') {
$model->updateAttributes(['status_id' => ShiftTransfer::STATUS_ID_TRANSFER_ACTIONS]);
}
+
+ $this->redirect(Yii::$app->request->referrer);
}
$shiftTransfer = ShiftTransfer::findOne($id);
'created_admin_id' => $shiftTransfer->end_shift_admin_id,
'updated_admin_id' => $shiftTransfer->start_shift_admin_id,
'confirm_admin_id' => $shiftTransfer->start_shift_admin_id,
- 'number' => $guid,
'store_id' => $storeId,
'store_guid' => $shiftTransfer->store_guid,
'date' => $shiftTransfer->date,
if ($model->validate()) {
$model->save();
+ $model->update([
+ 'number' => 'ЕРП_ПС_' . date("Y-m-d_H-i") . $model->id,
+ ]);
ReplacementInvoiceProducts::setData($model, $shiftTransfer);
} else {
var_dump($model->getErrors());
{
return [
'id' => 'ID',
- 'replacement_invoice_id' => 'Replacement Invoice ID',
- 'name' => 'Name',
- 'product_id' => 'Product ID',
- 'direction_id' => 'Direction ID',
- 'quantity' => 'Quantity',
- 'price' => 'Price',
- 'price_retail' => 'Price Retail',
- 'price_self_cost' => 'Price Self Cost',
- 'summ' => 'Summ',
- 'summ_retail' => 'Summ Retail',
- 'summ_self_cost' => 'Summ Self Cost',
- 'active_product' => 'Active Product',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- 'deleted_at' => 'Deleted At',
- 'created_admin_id' => 'Created Admin ID',
- 'updated_admin_id' => 'Updated Admin ID',
- 'deleted_admin_id' => 'Deleted Admin ID',
+ 'replacement_invoice_id' => 'ID заменяющего счета',
+ 'name' => 'Название товара',
+ 'product_id' => 'GUID товара',
+ 'direction_id' => 'Направление передачи товара',
+ 'quantity' => 'Количество',
+ 'price' => 'Цена',
+ 'price_retail' => 'Розничная цена',
+ 'price_self_cost' => 'Себестоимость',
+ 'summ' => 'Сумма',
+ 'summ_retail' => 'Сумма по розничной цене',
+ 'summ_self_cost' => 'Сумма себестоимости',
+ 'active_product' => 'Активность товара',
+ 'created_at' => 'Дата создания',
+ 'updated_at' => 'Дата обновления',
+ 'deleted_at' => 'Дата удаления',
+ 'created_admin_id' => 'Создан пользователем',
+ 'updated_admin_id' => 'Изменен пользователем',
+ 'deleted_admin_id' => 'Удален пользователем',
];
}
public static function setData($shiftTransfer)
{
-
$equalizationData = EqualizationRemains::find()
->where(['shift_id' => $shiftTransfer->id])
+ ->leftJoin('products_1c AS product', 'product.id = equalization_remains.product_id')
+ ->leftJoin('products_1c AS product_replacement', 'product_replacement.id = equalization_remains.product_replacement_id')
->select([
- 'product_id',
- 'product_count',
- 'product_price',
- 'product_self_cost',
- 'product_replacement_id',
- 'product_replacement_count',
- 'product_replacement_price',
- 'product_replacement_self_cost',
- 'balance',
- 'balance_self_cost'
+ 'equalization_remains.product_id',
+ 'product.name AS product_name',
+ 'equalization_remains.product_count',
+ 'equalization_remains.product_price',
+ 'equalization_remains.product_self_cost',
+ 'equalization_remains.product_replacement_id',
+ 'product_replacement.name AS product_replacement_name',
+ 'equalization_remains.product_replacement_count',
+ 'equalization_remains.product_replacement_price',
+ 'equalization_remains.product_replacement_self_cost',
+ 'equalization_remains.balance',
+ 'equalization_remains.balance_self_cost'
])
->asArray()
- ->all() ?? '';
+ ->all();
$articule = implode(';', array_map(fn($equalizationRemain) =>
$equalizationRemain->product->articule . '=>' . $equalizationRemain->productReplacement->articule,
->scalar() ?? '',
'status_id' => self::STATUS_NEW,
'comment' => $shiftTransfer->comment,
- 'json' => json_encode($equalizationData),
+ 'json' => json_encode($equalizationData, JSON_UNESCAPED_UNICODE),
'replace_articule' => $articule,
'type_id' => self::REPLACEMENT_ACTIONS,
]);
return $model->summ_self_cost ?? 'N/A';
},
],
- 'active_product:boolean',
'updated_at:datetime',
[
'attribute' => 'updated_admin_id',
return $model->updatedAdmin->name_full;
},
],
- ['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>
'layout' => '{items}',
]);
- if (in_array(Yii::$app->user->id, $usersOnStoreArray) && $shiftTransfer->status_id == ShiftTransfer::STATUS_ID_READY_TO_ACCEPT) {
+ if (
+ in_array(Yii::$app->user->id, $usersOnStoreArray)
+ && $shiftTransfer->status_id == ShiftTransfer::STATUS_ID_READY_TO_ACCEPT
+ && Yii::$app->user->id != $shiftTransfer->end_shift_admin_id
+ ) {
echo Html::submitButton('Принять', [
'class' => 'btn btn-primary float-right',
'name' => 'action',
use yii\helpers\Html;
use yii\grid\GridView;
+use yii_app\records\CityStore;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
- ['class' => 'yii\grid\SerialColumn'],
'id',
- 'store_id',
- 'shift_id',
+ [
+ 'attribute' => 'store_id',
+ 'value' => function ($model) {
+ return CityStore::findOne(\yii_app\records\ExportImportTable::findOne(['export_val' => $model->store_id])->entity_id)->name;
+ }
+ ],
+ [
+ 'attribute' => 'shift_id',
+ 'format' => 'raw',
+ 'value' => function ($model) {
+ return \yii\helpers\Html::a("Передача смены #$model->shift_id", ['shift-transfer/view', 'id' => $model->shift_id]);
+ }
+ ],
'date',
'amount',
- 'status_id',
- 'type_id',
+ [
+ 'attribute' => 'status_id',
+ 'value' => function ($model) {
+ return $model->status_id == \yii_app\records\StoreBalance::STATUS_NEW ? 'Новая' : $model->status_id;
+ }
+ ],
+ [
+ 'attribute' => 'type_id',
+ 'value' => function ($model) {
+ return $model->type_id == \yii_app\records\StoreBalance::REPLACEMENT_ACTIONS ? 'Действия по замене' : $model->type_id;
+ }
+ ],
'comment_controler',
[
'class' => 'yii\grid\ActionColumn',
<?php
use yii\helpers\Html;
+use yii\widgets\DetailView;
+use yii_app\records\CityStore;
/* @var $this yii\web\View */
/* @var $model app\models\StoreBalance */
-$this->title = 'Детали баланса магазина: ' . $model->id;
+$this->title = 'Детали баланса магазина # ' . $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Баланс магазинов', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<?= Html::a('Вернуться к списку', ['index'], ['class' => 'btn btn-primary']) ?>
</p>
- <table class="table table-striped">
- <tr>
- <th>ID</th>
- <td><?= Html::encode($model->id) ?></td>
- </tr>
- <tr>
- <th>Магазин</th>
- <td><?= Html::encode($model->store_id) ?></td>
- </tr>
- <tr>
- <th>Смена</th>
- <td><?= Html::encode($model->shift_id) ?></td>
- </tr>
- <tr>
- <th>Дата</th>
- <td><?= Html::encode($model->date) ?></td>
- </tr>
- <tr>
- <th>Сумма</th>
- <td><?= Html::encode($model->amount) ?></td>
- </tr>
- <tr>
- <th>Статус</th>
- <td><?= Html::encode($model->status_id) ?></td>
- </tr>
- <tr>
- <th>Комментарий</th>
- <td><?= Html::encode($model->comment) ?></td>
- </tr>
- <tr>
- <th>JSON</th>
- <td><?= Html::encode($model->json) ?></td>
- </tr>
- <tr>
- <th>Заменить товары</th>
- <td><?= Html::encode($model->replace_articule) ?></td>
- </tr>
- <tr>
- <th>Комментарий контролера</th>
- <td><?= Html::encode($model->comment_controler) ?></td>
- </tr>
- <tr>
- <th>ID контролера</th>
- <td><?= Html::encode($model->controler_id) ?></td>
- </tr>
- <tr>
- <th>Тип</th>
- <td><?= Html::encode($model->type_id) ?></td>
- </tr>
- </table>
+ <?= DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ [
+ 'attribute' => 'store_id',
+ 'value' => function ($model) {
+ // Для отображения магазина с учетом связанной таблицы
+ return CityStore::findOne(\yii_app\records\ExportImportTable::findOne(['export_val' => $model->store_id])->entity_id)->name;
+ }
+ ],
+ [
+ 'attribute' => 'shift_id',
+ 'value' => function ($model) {
+ // Если требуется вывести ссылку на смену
+ return Html::a("Передача смены #$model->shift_id", ['shift-transfer/view', 'id' => $model->shift_id]);
+ },
+ 'format' => 'raw', // Позволяет выводить HTML, то есть ссылку
+ ],
+ 'date',
+ 'amount',
+ [
+ 'attribute' => 'status_id',
+ 'value' => function ($model) {
+ return $model->status_id == \yii_app\records\StoreBalance::STATUS_NEW ? 'Новая' : $model->status_id;
+ }
+ ],
+ [
+ 'attribute' => 'type_id',
+ 'value' => function ($model) {
+ return $model->type_id == \yii_app\records\StoreBalance::REPLACEMENT_ACTIONS ? 'Действия по замене' : $model->type_id;
+ }
+ ],
+ 'comment',
+ [
+ 'attribute' => 'json',
+ 'value' => function ($model) {
+ $jsonArray = json_decode($model->json, true);
+ return Html::tag('pre', json_encode($jsonArray, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
+ },
+ 'format' => 'raw',
+ ],
+ 'replace_articule',
+ 'comment_controler',
+ 'controler_id',
+ ],
+ ]) ?>
+
</div>