Отправка на почту

This commit is contained in:
Arsen Mirzaev Tatyano-Muradovich 2021-06-21 04:21:28 +10:00
parent cb315a9fcf
commit 8c4ca42d3c
11 changed files with 300 additions and 17 deletions

View File

@ -1 +1,2 @@
/import
/import
/invoices

View File

@ -0,0 +1,78 @@
<?php
namespace app\commands;
use yii\console\Controller;
use yii\console\ExitCode;
use app\models\Invoice;
class TestController extends Controller
{
public function actionInvoice($buyer = 123123, $order = 0)
{
// Генерация счета
Invoice::generate($order, $this->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;
}
}

View File

@ -1,9 +1,24 @@
<?php
return [
'captcha' => [
'suppliers' => [
'public' => '',
'secret' => ''
]
],
'mail' => [
'system' => '',
'info' => ''
],
'dellin' => [
'nickname' => '',
'password' => '',
'key' => ''
],
'cdek' => [
'nickname' => '',
'password' => '',
'key' => ''
],
];

View File

@ -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,

View File

@ -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');
}
}

View File

@ -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' => 'Карточка предприятия'

View File

@ -9,7 +9,7 @@
<body>
<table style="height: 100vh;" cols="13" rows="50">
<tr>
<td style="text-align: center; outline: 2px solid;" colspan="13" rowspan="3" valign="center"><b>ВНИМАНИЕ! Уважаемые покупатели, просим вас указывать в назначении платежа: Аванс за запчасти по договору <?= $account ?></b></td>
<td style="text-align: center; outline: 2px solid;" colspan="13" rowspan="3" valign="center"><b>ВНИМАНИЕ! Уважаемые покупатели, просим вас указывать в назначении платежа: Аванс за запчасти по договору <?= $buyer['id'] ?></b></td>
</tr>
<tr>
@ -109,7 +109,7 @@
<tr>
<td colspan="2" rowspan="2" valign="center">Покупатель</td>
<td style="word-wrap: break-word;" colspan="11" rowspan="2" valign="left"><b></b></td>
<td style="word-wrap: break-word;" colspan="11" rowspan="2" valign="top"><b><?= $buyer['info'] ?></b></td>
</tr>
<tr>
@ -117,11 +117,72 @@
</tr>
<tr>
<td>Тест</td>
<td>Тест</td>
<td>Тест</td>
<td>Тест</td>
<td>Тест</td>
<td colspan="13"></td>
</tr>
<tr>
<td style="text-align: center; border: solid; border-top: thick; border-left: thick;" colspan="1" rowspan="2" valign="center"><b></b></td>
<td style="text-align: center; border: solid; border-top: thick;" colspan="6" rowspan="2" valign="center"><b>Товары (работы, услуги)</b></td>
<td style="text-align: center; border: solid; border-top: thick;" colspan="2" rowspan="2" valign="center"><b>Количество</b></td>
<td style="text-align: center; border: solid; border-top: thick;" colspan="2" rowspan="2" valign="center"><b>Цена</b></td>
<td style="text-align: center; border: solid; border-top: thick; border-right: thick;" colspan="2" rowspan="2" valign="center"><b>Сумма</b></td>
</tr>
<tr>
<td colspan="13"></td>
</tr>
<?php
// Инициализация счётчика строк
$row = 1;
// Инициализация итоговой цены
$cost = 0;
?>
<?php foreach ($order['entries'] as $entry) : ?>
<tr>
<td style="text-align: center; border: solid; border-left: thick;" colspan="1" valign="center"><?= $row++ ?></td>
<td style="text-align: left; border: solid;" colspan="6" valign="center"><?= $entry['title'] ?></td>
<td style="text-align: center; border: solid;" colspan="2" valign="center"><?= $entry['amount']['value'] ?></td>
<td style="text-align: center; border: solid;" valign="center"><?= $entry['cost']['value'] ?></td>
<td style="text-align: center; border: solid;" valign="center"><?= $entry['cost']['unit'] ?></td>
<td style="text-align: center; border: solid; border-right: thick;" colspan="2" valign="center"><?= $cost += $entry['cost']['value'] * $entry['amount']['value'] ?></td>
</tr>
<?php endforeach ?>
<tr>
<td style="border-top: thick;" colspan="13"></td>
</tr>
<tr>
<td colspan="9"></td>
<td style="text-align: right;" colspan="2" valign="center"><b>Итого:</b></td>
<td colspan="2" valign="center"><b><?= $cost - $tax = $cost * 0.2 ?></b></td>
</tr>
<tr>
<td colspan="9"></td>
<td style="text-align: right;" colspan="2" valign="center"><b>В т.ч. НДС (20%):</b></td>
<td colspan="2" valign="center"><b><?= $tax ?></b></td>
</tr>
<tr>
<td colspan="9"></td>
<td style="text-align: right;" colspan="2" valign="center"><b>Итого с НДС:</b></td>
<td colspan="2" valign="center"><b><?= $cost ?></b></td>
</tr>
<tr>
<td colspan="13" valign="center">Всего наименований <?= $row - 1 ?>, на сумму <?= $cost ?> руб.</td>
</tr>
<tr>
<td colspan="13" valign="center"><b><?= 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') ?> рублей</b></td>
</tr>
<tr>
<td style="width: 8pt;" colspan="13"><img src="<?= YII_PATH_PUBLIC . '/img/invoices/signature.png'?>" /></td>
</tr>
</table>
</body>

View File

@ -0,0 +1,9 @@
<html>
<body>
<p>ФИО: <span style="margin-left: auto;"><?= $name ?></span></p>
<p>Номер: <span style="margin-left: auto;"><?= $phon ?></span></p>
<p>Почта: <span style="margin-left: auto;"><?= $mail ?></span></p>
</body>
</html>

View File

@ -77,7 +77,7 @@ AppAsset::register($this);
<h3 class="py-3 mt-2 mb-4 text-center"><b>Заявка на подключение</b></h3>
<?php $form = ActiveForm::begin([
'id' => 'form_suppliers_request',
'action' => false,
'action' => '/suppliers/request-send',
'fieldConfig' => [
'template' => '{label}{input}',
],
@ -93,7 +93,7 @@ AppAsset::register($this);
<div class="row mb-4">
<div class="col-4 mx-auto">
<?= $form->field($model_request, 'text', ['options' => ['class' => "mb-3"]])->input('text', ['placeholder' => 'Иванов Иван Иванович']) ?>
<?= $form->field($model_request, 'name', ['options' => ['class' => "mb-3"]])->input('text', ['placeholder' => 'Иванов Иван Иванович']) ?>
<?= $form->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']); ?>
<?= $form->field($model_request, 'mail', ['options' => ['class' => "mb-3"]])->input('email', ['placeholder' => 'company@mail.ru']); ?>
<?= $form->field($model_request, 'file', ['options' => ['class' => "mb-3 d-flex flex-column justify-content-center"]])->fileInput(['multiple' => true, 'class' => 'my-auto px-0']) ?>

View File

@ -0,0 +1,88 @@
<?php
declare(strict_types=1);
use yii\helpers\Html;
use yii;
use yii\bootstrap\ActiveForm;
use app\assets\AppAsset;
use app\models\Request;
AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= yii::$app->language ?>">
<head>
<meta charset="<?= yii::$app->charset ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/css/pages/suppliers.css" rel="stylesheet">
<link rel="apple-touch-icon" sizes="57x57" href="/favicons/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/favicons/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/favicons/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/favicons/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/favicons/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/favicons/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/favicons/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/favicons/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/favicons/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/favicons/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/favicons/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicons/favicon-16x16.png">
<link rel="manifest" href="/favicons/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/favicons/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<script type="text/javascript">
var onloadCallback = function() {
grecaptcha.render('form_suppliers_request_recaptcha', {
'sitekey': '6LcTDSsbAAAAAF-KOY6azKzaIj6rOqyegJqNKRcc'
});
};
</script>
<?php $this->registerCsrfMetaTags() ?>
<title><?= Html::encode($this->title ?? 'Поставщикам | SkillParts') ?></title>
<?php $this->head() ?>
</head>
<body class="d-flex flex-column">
<?php $this->beginBody() ?>
<header class="container pt-2 mt-1 mb-2 mb-sm-4">
<div class="row row h-100">
<div id="logo" class="col-3 col-md-4 h-100">
<a class="py-2 h-100 d-inline-flex" title="SkillParts" href="/">
<img class="img-fluid" src="/img/logos/skillparts.svg" alt="SkillParts">
</a>
</div>
</div>
</header>
<main id="page_suppliers" class="container pb-5 flex-grow-1 d-flex justify-content-center">
<article class="col my-auto p-3 px-5 rounded overflow-hidden">
<h3 class="py-3 mt-2 mb-4 text-center"><b>Заявка на подключение</b></h3>
отсоси
</article>
</main>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB