From: Vladimir Fomichev Date: Fri, 8 Aug 2025 14:57:42 +0000 (+0300) Subject: Декодирование писем и просмотр X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=36e93f0af878c4bb5ba33e82a52760539b6f1f07;p=erp24_rep%2Fyii-erp24%2F.git Декодирование писем и просмотр --- diff --git a/erp24/controllers/MarketplaceFlowwowEmailsController.php b/erp24/controllers/MarketplaceFlowwowEmailsController.php index c40d9c8b..c30c9fbb 100644 --- a/erp24/controllers/MarketplaceFlowwowEmailsController.php +++ b/erp24/controllers/MarketplaceFlowwowEmailsController.php @@ -2,6 +2,8 @@ namespace app\controllers; +use Yii; +use yii\data\ActiveDataProvider; use yii_app\records\MarketplaceFlowwowEmails; use yii_app\records\MarketplaceFlowwowEmailsSearch; use yii\web\Controller; @@ -60,6 +62,47 @@ class MarketplaceFlowwowEmailsController extends Controller ]); } + public function actionDecodeBodies() + { + if (Yii::$app->request->isPost) { + $emails = MarketplaceFlowwowEmails::find()->all(); + foreach ($emails as $email) { + $decoded = quoted_printable_decode($email->body); + if ($email->body !== $decoded) { + $email->body = $decoded; + $email->save(false, ['body']); + } + } + Yii::$app->session->setFlash('success', 'Декодирование завершено'); + return $this->refresh(); + } + + $dataProvider = new ActiveDataProvider([ + 'query' => MarketplaceFlowwowEmails::find()->orderBy(['id' => SORT_DESC]), + 'pagination' => ['pageSize' => 20], + ]); + + return $this->render('decode-bodies', [ + 'dataProvider' => $dataProvider, + ]); + } + + + public function actionViewBody($id) + { + $model = MarketplaceFlowwowEmails::findOne($id); + if (!$model) { + throw new NotFoundHttpException('Письмо не найдено'); + } + + $decodedBody = quoted_printable_decode($model->body); + + return $this->render('view-body', [ + 'model' => $model, + 'body' => $decodedBody, + ]); + } + /** * Creates a new MarketplaceFlowwowEmails model. * If creation is successful, the browser will be redirected to the 'view' page. diff --git a/erp24/services/MarketplaceService.php b/erp24/services/MarketplaceService.php index f10ae786..2a3e4d1b 100644 --- a/erp24/services/MarketplaceService.php +++ b/erp24/services/MarketplaceService.php @@ -1639,7 +1639,7 @@ class MarketplaceService 'from' => $from, 'to' => $to, 'date' => $date, - 'body' => $htmlMessage, + 'body' => quoted_printable_decode($htmlMessage), ]; $output = MarketplaceService::processMessage($message); diff --git a/erp24/views/marketplace-flowwow-emails/decode-bodies.php b/erp24/views/marketplace-flowwow-emails/decode-bodies.php new file mode 100644 index 00000000..79b68d33 --- /dev/null +++ b/erp24/views/marketplace-flowwow-emails/decode-bodies.php @@ -0,0 +1,43 @@ +title = 'Декодирование писем Flowwow'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+

title) ?>

+ + session->hasFlash('success')): ?> +
session->getFlash('success') ?>
+ + +

+ 'btn btn-primary my-4']) ?> + + 'btn btn-primary', 'data-confirm' => 'Вы уверены? Будет перезаписано тело писем!']) ?> + +

+ +

Последние письма:

+ $dataProvider, + 'columns' => [ + 'id', + 'subject', + 'from', + 'to', + 'date', + [ + 'label' => 'Действия', + 'format' => 'raw', + 'value' => function($model) { + return Html::a('Просмотр', ['view-body', 'id' => $model->id], ['target' => '_blank', 'class' => 'btn btn-xs btn-success']); + } + ], + ], + ]) ?> +
diff --git a/erp24/views/marketplace-flowwow-emails/index.php b/erp24/views/marketplace-flowwow-emails/index.php index c7c69c74..f5687ac8 100644 --- a/erp24/views/marketplace-flowwow-emails/index.php +++ b/erp24/views/marketplace-flowwow-emails/index.php @@ -16,7 +16,8 @@ $this->params['breadcrumbs'][] = $this->title;
'btn btn-primary my-4']) ?> -

title) ?>

+ 'btn btn-primary my-4']) ?> +

title) ?>

@@ -51,7 +52,13 @@ $this->params['breadcrumbs'][] = $this->title; 'from', 'to', 'date', - //'body:ntext', + [ + 'label' => 'Просмотр письма', + 'format' => 'raw', + 'value' => function($model) { + return Html::a('Просмотр', ['view-body', 'id' => $model->id], ['target' => '_blank', 'class' => 'btn btn-xs btn-success']); + } + ], 'created_at', [ 'template' => '{view}', diff --git a/erp24/views/marketplace-flowwow-emails/view-body.php b/erp24/views/marketplace-flowwow-emails/view-body.php new file mode 100644 index 00000000..7354cc43 --- /dev/null +++ b/erp24/views/marketplace-flowwow-emails/view-body.php @@ -0,0 +1,21 @@ +title = 'Просмотр тела письма: ' . $model->subject; +$this->params['breadcrumbs'][] = ['label' => 'Декодирование писем', 'url' => ['decode-bodies']]; +$this->params['breadcrumbs'][] = $this->title; + +?> +
+

title) ?>

+
+ 'btn btn-primary']) ?> +
+
+ + +