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 @@ - + @@ -109,7 +109,7 @@ - + @@ -117,11 +117,72 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ВНИМАНИЕ! Уважаемые покупатели, просим вас указывать в назначении платежа: Аванс за запчасти по договору №ВНИМАНИЕ! Уважаемые покупатели, просим вас указывать в назначении платежа: Аванс за запчасти по договору №
Покупатель
ТестТестТестТестТест
Товары (работы, услуги)КоличествоЦенаСумма
Итого:
В т.ч. НДС (20%):
Итого с НДС:
Всего наименований , на сумму руб.
format($cost), 'UTF-8'), 0, 1, 'UTF-8'), 'UTF-8') . mb_substr($text, 1, null, 'UTF-8') ?> рублей
diff --git a/mirzaev/skillparts/system/views/mails/supplier.php b/mirzaev/skillparts/system/views/mails/supplier.php new file mode 100644 index 0000000..11d4ae0 --- /dev/null +++ b/mirzaev/skillparts/system/views/mails/supplier.php @@ -0,0 +1,9 @@ + + + +

ФИО:

+

Номер:

+

Почта:

+ + + 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);

Заявка на подключение

'form_suppliers_request', - 'action' => false, + 'action' => '/suppliers/request-send', 'fieldConfig' => [ 'template' => '{label}{input}', ], @@ -93,7 +93,7 @@ AppAsset::register($this);
- field($model_request, 'text', ['options' => ['class' => "mb-3"]])->input('text', ['placeholder' => 'Иванов Иван Иванович']) ?> + field($model_request, 'name', ['options' => ['class' => "mb-3"]])->input('text', ['placeholder' => 'Иванов Иван Иванович']) ?> field($model_request, 'phon', ['options' => ['class' => "mb-3"]])->input('tel', ['aria-invalid' => false, 'aria-required' => true, 'pattern' => '7[0-9]{3}[0-9]{3}[0-9]{2}[0-9]{2}', 'placeholder' => '79091112233', 'title' => '79091112233']); ?> field($model_request, 'mail', ['options' => ['class' => "mb-3"]])->input('email', ['placeholder' => 'company@mail.ru']); ?> field($model_request, 'file', ['options' => ['class' => "mb-3 d-flex flex-column justify-content-center"]])->fileInput(['multiple' => true, 'class' => 'my-auto px-0']) ?> diff --git a/mirzaev/skillparts/system/views/suppliers/requested.php b/mirzaev/skillparts/system/views/suppliers/requested.php new file mode 100644 index 0000000..571f9f6 --- /dev/null +++ b/mirzaev/skillparts/system/views/suppliers/requested.php @@ -0,0 +1,88 @@ + + +beginPage() ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + registerCsrfMetaTags() ?> + + <?= Html::encode($this->title ?? 'Поставщикам | SkillParts') ?> + + head() ?> + + + + beginBody() ?> + +
+
+ +
+
+ +
+
+

Заявка на подключение

+ отсоси +
+
+ + endBody() ?> + + + + + +endPage() ?> diff --git a/mirzaev/skillparts/system/web/img/invoices/signature.png b/mirzaev/skillparts/system/web/img/invoices/signature.png new file mode 100644 index 0000000..da0b9e7 Binary files /dev/null and b/mirzaev/skillparts/system/web/img/invoices/signature.png differ