diff --git a/composer.json b/composer.json index 0d81e34..843e9ed 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "mirzaev/yii2-arangodb": ">=2.1.x-dev", "mirzaev/yii2-arangodb-sessions": ">=1.1.x-dev", "guzzlehttp/guzzle": "^7.3", - "mnvx/lowrapper": "^1.0" + "phpoffice/phpspreadsheet": "^1.18" }, "require-dev": { "codeception/codeception": ">=4.1", diff --git a/composer.lock b/composer.lock index a9b3d82..0e71101 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "128ca2ce9581ee88384d5c0eb626732b", + "content-hash": "2d649fe15bca353de389fb356d2d7d48", "packages": [ { "name": "bower-asset/bootstrap", @@ -1104,56 +1104,6 @@ ], "time": "2021-03-29T00:19:31+00:00" }, - { - "name": "mnvx/lowrapper", - "version": "1.0.8", - "source": { - "type": "git", - "url": "https://github.com/mnvx/lowrapper.git", - "reference": "aaba5349bbfd69d46e63df95beefbd877047a9e8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mnvx/lowrapper/zipball/aaba5349bbfd69d46e63df95beefbd877047a9e8", - "reference": "aaba5349bbfd69d46e63df95beefbd877047a9e8", - "shasum": "" - }, - "require": { - "php": "^7.2|^8.0", - "psr/log": "^1.0", - "symfony/process": "^3.1|^4.1|^5.0" - }, - "require-dev": { - "phpunit/phpunit": "^8.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Mnvx\\Lowrapper\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHP wrapper over LibreOffice converter", - "homepage": "https://github.com/mnvx/lowrapper", - "keywords": [ - "LibreOffice", - "converter", - "docx", - "excel", - "pdf", - "word", - "xls", - "xlsx" - ], - "support": { - "issues": "https://github.com/mnvx/lowrapper/issues", - "source": "https://github.com/mnvx/lowrapper/tree/1.0.8" - }, - "time": "2021-04-26T16:12:14+00:00" - }, { "name": "moonlandsoft/yii2-phpexcel", "version": "2.0.0", @@ -1277,16 +1227,16 @@ }, { "name": "phpoffice/phpspreadsheet", - "version": "1.17.1", + "version": "1.18.0", "source": { "type": "git", "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", - "reference": "c55269cb06911575a126dc225a05c0e4626e5fb4" + "reference": "418cd304e8e6b417ea79c3b29126a25dc4b1170c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/c55269cb06911575a126dc225a05c0e4626e5fb4", - "reference": "c55269cb06911575a126dc225a05c0e4626e5fb4", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/418cd304e8e6b417ea79c3b29126a25dc4b1170c", + "reference": "418cd304e8e6b417ea79c3b29126a25dc4b1170c", "shasum": "" }, "require": { @@ -1305,20 +1255,23 @@ "ext-zlib": "*", "ezyang/htmlpurifier": "^4.13", "maennchen/zipstream-php": "^2.1", - "markbaker/complex": "^1.5||^2.0", - "markbaker/matrix": "^1.2||^2.0", - "php": "^7.2||^8.0", + "markbaker/complex": "^2.0", + "markbaker/matrix": "^2.0", + "php": "^7.2 || ^8.0", "psr/http-client": "^1.0", "psr/http-factory": "^1.0", "psr/simple-cache": "^1.0" }, "require-dev": { - "dompdf/dompdf": "^0.8.5", + "dealerdirect/phpcodesniffer-composer-installer": "dev-master", + "dompdf/dompdf": "^1.0", "friendsofphp/php-cs-fixer": "^2.18", "jpgraph/jpgraph": "^4.0", "mpdf/mpdf": "^8.0", "phpcompatibility/php-compatibility": "^9.3", - "phpunit/phpunit": "^8.5||^9.3", + "phpstan/phpstan": "^0.12.82", + "phpstan/phpstan-phpunit": "^0.12.18", + "phpunit/phpunit": "^8.5", "squizlabs/php_codesniffer": "^3.5", "tecnickcom/tcpdf": "^6.3" }, @@ -1372,9 +1325,9 @@ ], "support": { "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", - "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.17.1" + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.18.0" }, - "time": "2021-03-02T17:54:11+00:00" + "time": "2021-05-31T18:21:15+00:00" }, { "name": "psr/http-client", @@ -1536,56 +1489,6 @@ }, "time": "2016-08-06T14:39:51+00:00" }, - { - "name": "psr/log", - "version": "1.1.4", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" - }, - "time": "2021-05-03T11:20:27+00:00" - }, { "name": "psr/simple-cache", "version": "1.0.1", @@ -2163,151 +2066,6 @@ ], "time": "2021-01-07T16:49:33+00:00" }, - { - "name": "symfony/polyfill-php80", - "version": "v1.22.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/dc3063ba22c2a1fd2f45ed856374d79114998f91", - "reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.22-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.22.1" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-01-07T16:49:33+00:00" - }, - { - "name": "symfony/process", - "version": "v5.2.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "313a38f09c77fbcdc1d223e57d368cea76a2fd2f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/313a38f09c77fbcdc1d223e57d368cea76a2fd2f", - "reference": "313a38f09c77fbcdc1d223e57d368cea76a2fd2f", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-php80": "^1.15" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Process\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Executes commands in sub-processes", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/process/tree/v5.2.4" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-01-27T10:15:41+00:00" - }, { "name": "triagens/arangodb", "version": "v3.6.0", @@ -6589,6 +6347,151 @@ ], "time": "2021-01-07T16:49:33+00:00" }, + { + "name": "symfony/polyfill-php80", + "version": "v1.22.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/dc3063ba22c2a1fd2f45ed856374d79114998f91", + "reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.22-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.22.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-01-07T16:49:33+00:00" + }, + { + "name": "symfony/process", + "version": "v5.2.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "313a38f09c77fbcdc1d223e57d368cea76a2fd2f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/313a38f09c77fbcdc1d223e57d368cea76a2fd2f", + "reference": "313a38f09c77fbcdc1d223e57d368cea76a2fd2f", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.15" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Executes commands in sub-processes", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/process/tree/v5.2.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-01-27T10:15:41+00:00" + }, { "name": "symfony/service-contracts", "version": "v2.2.0", diff --git a/mirzaev/skillparts/system/controllers/OrderController.php b/mirzaev/skillparts/system/controllers/OrderController.php index 3ac3a57..c773cb3 100644 --- a/mirzaev/skillparts/system/controllers/OrderController.php +++ b/mirzaev/skillparts/system/controllers/OrderController.php @@ -16,6 +16,7 @@ use app\models\Product; use app\models\OrderEdgeSupply; use app\models\AccountEdgeOrder; use app\models\connection\Dellin; +use app\models\Invoice; use app\models\Notification; use app\models\SupplyEdgeProduct; @@ -92,7 +93,7 @@ class OrderController extends Controller public function actionIndex() { // Инициализация - $orders = Order::search(type: 'all', limit: 10, page: 1, select: '{account_edge_order, order}'); + $orders = Order::search(type: 'all', limit: 10, page: 1, select: '{account_edge_order, order}', supplies: true); $moderator_orders = self::genOrdersForModeration(); if (yii::$app->request->isPost) { @@ -377,6 +378,15 @@ class OrderController extends Controller if ($edge->update()) { // Удалось сохранить изменения + // Генерация счета + Invoice::generate($this->renderPartial('/invoice/order/pattern', [ + 'account' => yii::$app->user->identity->_key, + 'order' => [ + 'id' => $edge->_key, + 'date' => $edge->date ?? time() // @todo доделать + ] + ])); + // Запись в журнал $model->journal('requested'); @@ -410,6 +420,8 @@ class OrderController extends Controller * Включает поиск запрошенных заказов и связанных с ними поставках * * @return array ['order' => array, 'order_edge_account' => array, 'supplies' => array] + * + * @todo Уничтожить заменив на Order::search(supplies: true) */ protected static function genOrdersForModeration(int $page = 1): array { diff --git a/mirzaev/skillparts/system/models/Invoice.php b/mirzaev/skillparts/system/models/Invoice.php index df0acf8..6e03ebf 100644 --- a/mirzaev/skillparts/system/models/Invoice.php +++ b/mirzaev/skillparts/system/models/Invoice.php @@ -7,27 +7,25 @@ namespace app\models; use yii; use yii\base\Model; -use Mnvx\Lowrapper\Converter; -use Mnvx\Lowrapper\LowrapperParameters; -use Mnvx\Lowrapper\Format; - +use PhpOffice\PhpSpreadsheet\Writer\Xlsx; +// use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader; +// use PhpOffice\PhpSpreadsheet\Writer\Html; +use PhpOffice\PhpSpreadsheet\Reader\Html as HtmlReader; class Invoice extends Model { - public function generate(): array + public static function generate(string $html): void { - // Создаем объект конвертера - $converter = new Converter(); + $reader = new HtmlReader(); + $spreadsheet = $reader->loadFromString($html); - // Описываем параметры для конвертера - $parameters = (new LowrapperParameters()) - // На вход подаем строку с HTML - ->setInputData('My html file') - // В каком формате нужен результат - ->setOutputFormat(Format::TEXT_DOCX) - // Файл для сохранения результата - ->setOutputFile('path-to-result-docx.docx'); + $writer = new Xlsx($spreadsheet); + $writer->save('hello world228.xlsx'); - // Запускаем конвертацию - $converter->convert($parameters); + // $reader = new XlsxReader(); + // $reader->setReadDataOnly(true); + // $spreadsheet = $reader->load('../views/invoice/order/original.xlsx'); + + // $writer = new Html($spreadsheet); + // $writer->save('hello world.html'); } } diff --git a/mirzaev/skillparts/system/models/Order.php b/mirzaev/skillparts/system/models/Order.php index a9a46a8..c160407 100644 --- a/mirzaev/skillparts/system/models/Order.php +++ b/mirzaev/skillparts/system/models/Order.php @@ -234,8 +234,10 @@ class Order extends Document implements DocumentInterface /** * Поиск заказа + * + * @todo Привести в порядок */ - public static function search(Account|string $account = null, string $type = 'current', int $limit = 1, int $page = 1, string $select = null): self|array|null + public static function search(Account|string $account = null, string $type = 'current', int $limit = 1, int $page = 1, string $select = null, bool $supplies = false): self|array|null { // Инициализация аккаунта if (empty($account) && isset(yii::$app->user->identity)) { @@ -271,7 +273,6 @@ class Order extends Document implements DocumentInterface ]; } - // Инициализация сдвига по запрашиваемым данным (пагинация) $offset = $limit * ($page - 1); @@ -289,6 +290,25 @@ class Order extends Document implements DocumentInterface direction: 'INBOUND' ); + if ($supplies) { + // Запрошен поиск поставок + + foreach ($return as &$container) { + // Перебор заказов + + // Инициализация настроек + $config = $container['order']; + unset($config['_id'], $config['_rev'], $config['_id']); + + if ($buffer = new Order($config)) { + // Удалось инициализировать буфер заказа + + // Чтение полного содержания + $container['supplies'] = $buffer->content(100); + } + } + } + return $limit === 1 ? $return[0] ?? null : $return; } @@ -458,7 +478,7 @@ class Order extends Document implements DocumentInterface // var_dump($e->getTrace()); // var_dump($e->getFile()); die; - var_dump(json_decode($e->getMessage(), true)['errors']); die; + // var_dump(json_decode($e->getMessage(), true)['errors']); die; } // Запись цены (цена поставки + цена доставки + наша наценка) diff --git a/mirzaev/skillparts/system/views/invoice/order/pattern.php b/mirzaev/skillparts/system/views/invoice/order/pattern.php index e69de29..4217a86 100644 --- a/mirzaev/skillparts/system/views/invoice/order/pattern.php +++ b/mirzaev/skillparts/system/views/invoice/order/pattern.php @@ -0,0 +1,129 @@ + + + +
+ +ВНИМАНИЕ! Уважаемые покупатели, просим вас указывать в назначении платежа: Аванс за запчасти по договору №= $account ?> | +||||||||||||
+ | ||||||||||||
+ | ||||||||||||
+ | ||||||||||||
Образец заполнения платежного поручения | +||||||||||||
АО "ТИНЬКОФФ БАНК" г. Москва | +БИК | +044525974 | +||||||||||
Сч. № | +30101810145250000974 | +|||||||||||
Банк получателя | +||||||||||||
ИНН | +2724241607 | +КПП | +272401001 | +Сч. № | +40702810610000696279 | +|||||||
ООО "СтандартМашинери" | +Вид оп. | +01 | +Срок плат. | ++ | ||||||||
Наз. пл. | ++ | Очер. плат. | +5 | +|||||||||
Код | ++ | Рез. поле | ++ | |||||||||
+ | ||||||||||||
+ Счет на оплату №= $order['id'] ?> от = date('d.m.Y', $order['date']) ?> + | +||||||||||||
+ | ||||||||||||
+ | ||||||||||||
+ | ||||||||||||
Поставщик | +ООО "СтандартМашинери", ИНН 2724241607, КПП 272401001, 680014, Хабаровский край, Хабаровск г, Промышленная ул, дом 3, офис 105, тел.: 89242128879 | +|||||||||||
+ | ||||||||||||
+ | ||||||||||||
Покупатель | ++ | |||||||||||
+ | ||||||||||||
Тест | +Тест | +Тест | +Тест | +Тест | +
= $supply['product']['catn'] ?> - +
@@ -173,9 +173,9 @@ if (