From e83bcda39a9923e3db687889fa46427a2ee153ea Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 30 Jan 2017 16:35:26 +0200 Subject: [PATCH] -Replace line breaks --- controllers/StatisticsController.php | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/controllers/StatisticsController.php b/controllers/StatisticsController.php index 64cc6d7..5ea8159 100755 --- a/controllers/StatisticsController.php +++ b/controllers/StatisticsController.php @@ -8,7 +8,6 @@ use yii\data\ActiveDataProvider; use yii\helpers\ArrayHelper; use yii\helpers\Html; - use yii\helpers\VarDumper; use yii\web\Controller; use yii\web\Response; @@ -246,7 +245,7 @@ $i = 0; $products = ''; foreach ($order->products as $product) { - $i ++; + $i++; $products .= $product->sku; if (count($order->products) != $i) { $products .= ' ,'; @@ -259,7 +258,15 @@ $line[] = (string) $order->total; $line[] = empty($order->reason) ? '' : $formatter->asText(Order::REASONS[ $order->reason ]); $line[] = empty($order->manager) ? '' : $formatter->asText($order->manager->username); - $line[] = (string) $order->body; + $line[] = str_replace( + [ + "\r\n", + "\n", + "\r", + ], + ' ', + $order->body + ); fputcsv($file, $line, ";"); } @@ -267,12 +274,19 @@ return [ 'message' => 'Файл успешно сгенерирован', - 'button' => Html::a( - Html::tag('i', '', [ - 'class' => 'glyphicon glyphicon-download-alt' - ]) . ' Скачать', '/storage/statistics_export.csv', [ - 'class' => 'btn bg-olive', - ]) + 'button' => Html::a( + Html::tag( + 'i', + '', + [ + 'class' => 'glyphicon glyphicon-download-alt', + ] + ) . ' Скачать', + '/storage/statistics_export.csv', + [ + 'class' => 'btn bg-olive', + ] + ), ]; } } -- libgit2 0.21.4