public function actionUpload()
{
Yii::$app->response->format = Response::FORMAT_HTML;
- $guid = Yii::$app->request->get('guid') ?? Yii::$app->request->post('guid');
- //var_dump($guid); die();
+ $guid = Yii::$app->request->get('guid');
+
if (!$guid) {
- return $this->redirect(['/']);
+ return $this->render('upload.php', [
+ 'guid' => null,
+ ]);
}
+
$entity = MarketplaceOrders::PHOTO_ORDER;
$type = MarketplaceOrders::PHOTO_TYPE;
$order = MarketplaceOrders::find()->where(['guid' => $guid])->one();
- // var_dump($order); die();
+
if (!$order) {
throw new \yii\web\NotFoundHttpException("Заказ не найден.");
}
<?php
+
use yii\widgets\ActiveForm;
use yii\helpers\Html;
/** @var $this yii\web\View */
/** @var string $guid */
-
-$this->title = 'Загрузка фотографий заказа (GUID: ' . $guid . ')';
+$order = \yii_app\records\MarketplaceOrders::find()->where(['guid' => $guid])->one();
+$this->title = $guid ? 'Загрузка фотографий заказа c ' . $order->marketplace_name . ' (Заказ: ' . $order->marketplace_order_id . ')' :
+ 'Загрузка недоступна';
?>
<div class="upload-wrapper">
<div class="upload-form">
- <h1><?= Html::encode($this->title) ?></h1>
+ <?php if (!$guid): ?>
+ <h1><?= Html::encode($this->title) ?></h1>
+ <p style="text-align: center; margin-top: 20px;">
+ Пожалуйста, перейдите по QR-коду для загрузки фотографий.
+ </p>
+ <?php else: ?>
+ <h1><?= Html::encode($this->title) ?></h1>
- <?php if (Yii::$app->session->hasFlash('success')): ?>
- <div class="alert alert-success">
- <?= Yii::$app->session->getFlash('success') ?>
- </div>
- <?php endif; ?>
+ <?php if (Yii::$app->session->hasFlash('success')): ?>
+ <div class="alert alert-success">
+ <?= Yii::$app->session->getFlash('success') ?>
+ </div>
+ <?php endif; ?>
- <form action="/marketplace/upload" method="post" enctype="multipart/form-data">
- <input type="hidden" name="guid" value="<?= $guid ?>">
+ <form action="/marketplace/upload" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="guid" value="<?= $guid ?>">
- <div class="form-group">
- <label for="files">Выберите файлы</label>
- <input type="file" name="files[]" id="files" multiple>
- </div>
+ <div class="form-group">
+ <label for="files">Выберите файлы</label>
+ <input type="file" name="files[]" id="files" multiple>
+ </div>
- <button type="submit">Загрузить</button>
- </form>
+ <button type="submit">Загрузить</button>
+ </form>
+ <?php endif; ?>
</div>
</div>
margin-bottom: 16px;
text-align: center;
}
-CSS);
+CSS
+);
?>
\ No newline at end of file