diff --git a/mirzaev/skillparts/system/assets/.gitignore b/mirzaev/skillparts/system/assets/.gitignore index 685f372..0e75838 100644 --- a/mirzaev/skillparts/system/assets/.gitignore +++ b/mirzaev/skillparts/system/assets/.gitignore @@ -1 +1,2 @@ -/import \ No newline at end of file +/import +/invoices diff --git a/mirzaev/skillparts/system/commands/TestController.php b/mirzaev/skillparts/system/commands/TestController.php new file mode 100644 index 0000000..2822d39 --- /dev/null +++ b/mirzaev/skillparts/system/commands/TestController.php @@ -0,0 +1,78 @@ +renderPartial('/invoice/order/pattern', [ + 'buyer' => [ + 'id' => $buyer, + 'info' => 'Неизвестно' + ], + 'order' => [ + 'id' => $order, + 'date' => time(), + 'entries' => [ + [ + 'title' => 'Тестовое вхождение', + 'amount' => [ + 'value' => 1, + 'unit' => 'шт' + ], + 'cost' => [ + 'value' => 1000, + 'unit' => 'руб' + ], + 'type' => 'supply' + ], + [ + 'title' => 'Тестовое вхождение', + 'amount' => [ + 'value' => 1, + 'unit' => 'шт' + ], + 'cost' => [ + 'value' => 1000, + 'unit' => 'руб' + ], + 'type' => 'supply' + ], + [ + 'title' => 'Тестовое вхождение', + 'amount' => [ + 'value' => 1, + 'unit' => 'шт' + ], + 'cost' => [ + 'value' => 1000, + 'unit' => 'руб' + ], + 'type' => 'supply' + ], + [ + 'title' => 'Тестовое вхождение', + 'amount' => [ + 'value' => 5, + 'unit' => 'шт' + ], + 'cost' => [ + 'value' => 1000, + 'unit' => 'руб' + ], + 'type' => 'supply' + ] + ] + ] + ])); + + return ExitCode::OK; + } +} diff --git a/mirzaev/skillparts/system/config/params.php.example b/mirzaev/skillparts/system/config/params.php.example index 36fbf5d..ee5ef0e 100644 --- a/mirzaev/skillparts/system/config/params.php.example +++ b/mirzaev/skillparts/system/config/params.php.example @@ -1,9 +1,24 @@ [ + 'suppliers' => [ + 'public' => '', + 'secret' => '' + ] + ], + 'mail' => [ + 'system' => '', + 'info' => '' + ], 'dellin' => [ 'nickname' => '', 'password' => '', 'key' => '' ], + 'cdek' => [ + 'nickname' => '', + 'password' => '', + 'key' => '' + ], ]; diff --git a/mirzaev/skillparts/system/config/web.php.example b/mirzaev/skillparts/system/config/web.php.example index 9dc2a0e..651255b 100644 --- a/mirzaev/skillparts/system/config/web.php.example +++ b/mirzaev/skillparts/system/config/web.php.example @@ -53,10 +53,15 @@ $config = [ ], 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', - // send all mails to a file by default. You have to set - // 'useFileTransport' to false and configure a transport - // for the mailer to send real emails. - 'useFileTransport' => true, + 'useFileTransport' => false, + 'transport' => [ + 'class' => 'Swift_SmtpTransport', + 'host' => 'ssl://smtp.yandex.com', + 'username' => 'info@skillparts.ru', + 'password' => 'SkillParts_1337', + 'port' => '587', + 'encryption' => 'ssl', + ], ], 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, diff --git a/mirzaev/skillparts/system/controllers/SuppliersController.php b/mirzaev/skillparts/system/controllers/SuppliersController.php index 297431f..3a1a501 100644 --- a/mirzaev/skillparts/system/controllers/SuppliersController.php +++ b/mirzaev/skillparts/system/controllers/SuppliersController.php @@ -4,7 +4,9 @@ declare(strict_types=1); namespace app\controllers; +use yii; use yii\web\Controller; +use yii\web\UploadedFile; use app\models\Request; @@ -15,7 +17,26 @@ class SuppliersController extends Controller return $this->renderPartial('/suppliers/index'); } - public function actionRequest() { + public function actionRequest() + { return $this->renderPartial('/suppliers/request'); } + + /** + * @todo Сделать отправку только назначенным модераторам + */ + public function actionRequestSend() + { + $request = yii::$app->request->post('Request') ?? yii::$app->request->get('Request'); + + yii::$app->mailer->compose() + ->setFrom(yii::$app->params['mail']['system']) + ->setTo(yii::$app->params['mail']['info']) + ->setSubject('Регистрация поставщика') + ->setHtmlBody($this->renderPartial('/mails/supplier', $request)) + ->attach(($file = UploadedFile::getInstance(new Request($request), 'file'))->tempName, ['fileName' => $file->name]) + ->send(); + + return $this->renderPartial('/suppliers/requested'); + } } diff --git a/mirzaev/skillparts/system/models/Request.php b/mirzaev/skillparts/system/models/Request.php index 20dd3ee..05d2d51 100644 --- a/mirzaev/skillparts/system/models/Request.php +++ b/mirzaev/skillparts/system/models/Request.php @@ -20,6 +20,11 @@ use Exception; */ class Request extends Document { + /** + * Файл с данными ("Карточка предприятия") + */ + public string|array|null $file = null; + /** * Имя коллекции */ @@ -36,7 +41,7 @@ class Request extends Document return array_merge( parent::attributes(), [ - 'text', + 'name', 'phon', 'mail', 'file' @@ -52,7 +57,7 @@ class Request extends Document return array_merge( parent::attributeLabels(), [ - 'text' => 'ФИО', + 'name' => 'ФИО', 'phon' => 'Номер', 'mail' => 'Почта', 'file' => 'Карточка предприятия' diff --git a/mirzaev/skillparts/system/views/invoice/order/pattern.php b/mirzaev/skillparts/system/views/invoice/order/pattern.php index fd60925..9a8dea0 100644 --- a/mirzaev/skillparts/system/views/invoice/order/pattern.php +++ b/mirzaev/skillparts/system/views/invoice/order/pattern.php @@ -9,7 +9,7 @@
ВНИМАНИЕ! Уважаемые покупатели, просим вас указывать в назначении платежа: Аванс за запчасти по договору №= $account ?> | +ВНИМАНИЕ! Уважаемые покупатели, просим вас указывать в назначении платежа: Аванс за запчасти по договору №= $buyer['id'] ?> | ||||||||||||||||||||||||
Покупатель | -+ | = $buyer['info'] ?> | |||||||||||||||||||||||
Тест | -Тест | -Тест | -Тест | -Тест | ++ | ||||||||||||||||||||
№ | +Товары (работы, услуги) | +Количество | +Цена | +Сумма | +|||||||||||||||||||||
+ | |||||||||||||||||||||||||
= $row++ ?> | += $entry['title'] ?> | += $entry['amount']['value'] ?> | += $entry['cost']['value'] ?> | += $entry['cost']['unit'] ?> | += $cost += $entry['cost']['value'] * $entry['amount']['value'] ?> | +||||||||||||||||||||
+ | |||||||||||||||||||||||||
+ | Итого: | += $cost - $tax = $cost * 0.2 ?> | +|||||||||||||||||||||||
+ | В т.ч. НДС (20%): | += $tax ?> | +|||||||||||||||||||||||
+ | Итого с НДС: | += $cost ?> | +|||||||||||||||||||||||
Всего наименований = $row - 1 ?>, на сумму = $cost ?> руб. | +|||||||||||||||||||||||||
= mb_strtoupper(mb_substr($text = mb_strtolower($text = (new NumberFormatter("ru", NumberFormatter::SPELLOUT))->format($cost), 'UTF-8'), 0, 1, 'UTF-8'), 'UTF-8') . mb_substr($text, 1, null, 'UTF-8') ?> рублей | +|||||||||||||||||||||||||
ФИО: = $name ?>
+Номер: = $phon ?>
+Почта: = $mail ?>
+ + + diff --git a/mirzaev/skillparts/system/views/suppliers/request.php b/mirzaev/skillparts/system/views/suppliers/request.php index c0c52fe..9405711 100644 --- a/mirzaev/skillparts/system/views/suppliers/request.php +++ b/mirzaev/skillparts/system/views/suppliers/request.php @@ -77,7 +77,7 @@ AppAsset::register($this);