From 29c4fe5461c1507e9dba3894305a93c33466478a Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Fri, 26 Jul 2024 19:11:06 +0300 Subject: [PATCH] =?utf8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?utf8?q?=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/services/MotivationService.php | 10 ++++++++-- erp24/web/js/motivation/index.js | 11 ++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index 85375e48..66d724f6 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -13,7 +13,11 @@ class MotivationService { public static function uploadTemplatePlan($path) { $motivationCostsItems = MotivationCostsItem::find()->indexBy('code')->all(); - $spreadsheets = IOFactory::load($path); + try { + $spreadsheets = IOFactory::load($path); + } catch (\Exception $ex) { + return ['errors' => ['Некорректный файл. Загрузите файл, заполненный по шаблону.']]; + } $errors = []; foreach ($spreadsheets->getAllSheets() as $indSS => $spreadSheet) { $rows = []; @@ -137,7 +141,9 @@ class MotivationService } } } - $errors []= empty($error) ? '' : $indSS . ":" . $error; + if (!empty($error)) { + $errors []= ($indSS + 1) . ":" . $error; + } } return compact('errors'); diff --git a/erp24/web/js/motivation/index.js b/erp24/web/js/motivation/index.js index 568d8827..79801cd5 100644 --- a/erp24/web/js/motivation/index.js +++ b/erp24/web/js/motivation/index.js @@ -12,12 +12,21 @@ function openUploadDictionary() { $mainModal.find('.close').on('click', () => { $mainModal.modal('hide'); }); $mainModal.find('.modal-title').html('Загрузка плановых значений'); $modalFooter.html(''); - $modalBody.html('
Скачать шаблон
'); + $modalBody.html('
' + + '
' + + '
' + + '
' + + '
' + + '
Скачать шаблон
' + + '
'); const browse = $modalBody.find('input[type=file]').get(0); const btn = $modalBody.find('input[type=submit]').get(0); const info = $modalBody.find('#infoModal').get(0); const form = $modalBody.find('form').get(0); async function UploadDict() { + info.innerHTML = 'загрузка...'; if (browse.files[0].size > 200000) { info.innerHTML = 'Некорректный файл. Загрузите файл, заполненный по шаблону.'; return; -- 2.39.5