throw new \yii\web\NotFoundHttpException("Заказ не найден.");
}
if (Yii::$app->request->isPost) {
- $files = UploadedFile::getInstancesByName('files');
+ $file = UploadedFile::getInstanceByName('file');
+ //var_dump($file);
Files::deleteAll(['entity_id' => $order->id, 'entity' => $entity]);
$uploads = Yii::getAlias("@uploads");
$target_dir = '/' . $order->id . '/' . date("Y") . "/" . date("m") . "/" . date("d") . "/";
- foreach ($files as $file) {
- $filePath = $uploads . $target_dir;
- if (!is_dir($filePath)) {
- Yii::error('Создание папки' );
- mkdir($filePath, 0777, true);
- }
- $targetFile = $filePath . $file->baseName . '.' . $file->extension;
- $file->saveAs($targetFile);
+ $filePath = $uploads . $target_dir;
+ if (!is_dir($filePath)) {
+ Yii::error('Создание папки');
+ mkdir($filePath, 0777, true);
+ }
+ $targetFile = $filePath . $file->baseName . '.' . $file->extension;
+ $file->saveAs($targetFile);
- $fileRecord = new Files();
- $fileRecord->created_at = date("Y-m-d H:i:s");
- $fileRecord->entity_id = $order->id;
- $fileRecord->entity = $entity;
- $fileRecord->file_type = $file->type;
- $fileRecord->url = '/uploads' . $target_dir . $file->baseName . '.' . $file->extension;
- if (!$fileRecord->save()) {
- Yii::error('Ошибка сохранения файла: ' . json_encode($fileRecord->getErrors(), JSON_UNESCAPED_UNICODE));
- }
+ $fileRecord = new Files();
+ $fileRecord->created_at = date("Y-m-d H:i:s");
+ $fileRecord->entity_id = $order->id;
+ $fileRecord->entity = $entity;
+ $fileRecord->file_type = $file->type;
+ $fileRecord->url = '/uploads' . $target_dir . $file->baseName . '.' . $file->extension;
+ if (!$fileRecord->save()) {
+ Yii::error('Ошибка сохранения файла: ' . json_encode($fileRecord->getErrors(), JSON_UNESCAPED_UNICODE));
}
+
$photos = $order->getFiles();
if (count($photos) > 0 && isset($photos[0]->url)) {
$order->order_photo = $photos[0]->url;
/** @var $this yii\web\View */
/** @var string $guid */
$order = \yii_app\records\MarketplaceOrders::find()->where(['guid' => $guid])->one();
-$this->title = $guid ? 'Загрузка фотографий заказа c ' . $order->marketplace_name . ' (Заказ: ' . $order->marketplace_order_id . ')' :
+$this->title = $guid ? 'Загрузка фото заказа c ' . $order->marketplace_name . ' (Заказ: ' . $order->marketplace_order_id . ')' :
'Загрузка недоступна';
?>
<input type="hidden" name="guid" value="<?= $guid ?>">
<div class="form-group">
- <label for="files">Выберите файлы</label>
- <input type="file" name="files[]" id="files" multiple>
+ <label for="file">Выберите файл</label>
+ <input type="file" name="file" id="file">
</div>
<button type="submit">Загрузить</button>
use yii_app\records\MarketplaceOrderItems;
use yii_app\records\MarketplaceOrders;
use yii_app\records\WriteOffsErp;
+use yii\web\View;
/** @var yii\web\View $this */
/** @var yii_app\records\MarketplaceOrders $model */
-
+$this->registerCssFile('@web/css/fancybox.css');
+$this->registerJsFile('@web/js/fancybox.umd.js', ['position' => View::POS_END]);
+$this->registerJsFile('/js/bouquet/bouquet.js', ['position' => View::POS_END]);
$this->title = 'Заказ магазина ' . $model->store->name . ' от ' . $model->creation_date;
$this->params['breadcrumbs'][] = ['label' => 'Marketplace Orders', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
'format' => 'raw',
'value' => function ($model) {
- return Html::img($model->order_photo, ['width' => '100px']);
+ return Html::a(
+ Html::img($model->order_photo, ['width' => '100px']),
+ $model->order_photo,
+ ['data-fancybox' => 'gallery']
+ );
}
],
[