<?php
namespace Mm\Beton\Planungsatlas\AtlasBundle\Controller;
use Knp\Bundle\SnappyBundle\KnpSnappyBundle;
use Knp\Snappy\Pdf;
use Mm\Beton\Planungsatlas\AtlasBundle\Entity\Main\DownloadFileModel;
use Mm\Beton\Planungsatlas\AtlasBundle\Entity\Main\UserCart;
use Mm\Beton\Planungsatlas\AtlasBundle\Repository\UserCartRepository;
use Mm\Beton\Planungsatlas\AtlasBundle\Service\AtlasDaoDbImpl;
use Mm\Beton\Planungsatlas\AtlasBundle\Service\AtlasDownloadService;
use Mm\Beton\Planungsatlas\AtlasBundle\Service\HeatProtectionService;
use Mm\Beton\Planungsatlas\AtlasBundle\Service\UserCartService;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Annotation\Route;
class DefaultController extends AbstractAuthenticatedController implements AuthenticatedControllerInterface
{
private $atlasSession;
/**
* @var UserCartService
*/
private $userCartService;
/**
* @var SessionInterface
*/
private $session;
/**
* @var KnpSnappyBundle
*/
private $knpSnappyPdf;
/**
* @var AtlasDownloadService
*/
private $downloadService;
/**
* @var HeatProtectionService
*/
private $heatProtectionService;
/**
* @var KernelInterface
*/
private $kernel;
public function __construct(
UserCartService $userCartService,
SessionInterface $session,
Pdf $knpSnappyPdf,
AtlasDownloadService $downloadService,
HeatProtectionService $heatProtectionService,
KernelInterface $kernel
)
{
$this->atlasSession = $this->loadAtlasSession();
$this->userCartService = $userCartService;
$this->session = $session;
$this->knpSnappyPdf = $knpSnappyPdf;
$this->downloadService = $downloadService;
$this->heatProtectionService = $heatProtectionService;
$this->kernel = $kernel;
}
/**
* @Route(
* "/",
* name="home"
* )
*
* @return Response
*/
public function homeAction()
{
$data['loggedIn'] = $this->isUserLoggedIn();
$data['userData'] = $this->atlasSession->getUser();
return $this->heatProtectionAction(null, null, null, new Request());
}
/**
* @Route(
* "/parse-elements",
* name="parseElements"
* )
*
* @return Response
*/
public function parseElementsAction()
{
$data['loggedIn'] = $this->isUserLoggedIn();
$data['userData'] = $this->atlasSession->getUser();
return $this->render('index.html.twig', $data);
}
/**
* @Route(
* "/logout",
* name="logout"
* )
*
* @param Request $request
* @return Response
*/
public function logoutAction(Request $request)
{
unset($_SESSION['userinfo']);
session_destroy();
return $this->redirectToRoute('home');
}
public function toAscii($str, $replace = array(), $delimiter = '-')
{
$clean = str_replace(array('ä', 'ü', 'ö', 'ß', '°'), array('ae', 'ue', 'oe', 'ss', '-grad'), $str);
if (!empty($replace)) {
$clean = str_replace((array)$replace, ' ', $clean);
}
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $clean);
$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean);
$clean = strtolower(trim($clean, '-'));
$clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean);
return $clean;
}
public function toSearchKeyword($str, $replace = array(), $delimiter = '-')
{
if (!empty($replace)) {
$str = str_replace((array)$replace, ' ', $str);
}
$clean = str_replace(array('ae', 'ue', 'oe', 'ss', '-', 'grad'), array('ä', 'ü', 'ö', '%%', '%', '%'), $str);
return $clean;
}
/**
* @Route(
* "/waermeschutz/{constructionIdOrTypeName}/{constructionTypeIdOrTypeName}/{searchTermOrElementId}",
* defaults={"constructionIdOrTypeName" = false, "constructionTypeIdOrTypeName" = false, "searchTermOrElementId" = false},
* name="heatProtection"
* )
* @return Response
*/
public function heatProtectionAction(
$constructionIdOrTypeName,
$constructionTypeIdOrTypeName,
$searchTermOrElementId,
Request $request
)
{
$this->getCartFromSession();
$search = array();
$searchTypes = array();
$constructionId = false;
$constructionTypeId = false;
if ($constructionIdOrTypeName) {
if (preg_match('/^\d\d-\d\d?-?\d?\d?-?\d?\d?$/', $constructionIdOrTypeName, $constructionElementCode)) {
$search[] = $constructionElementCode[0];
}
if (empty($search)) {
preg_match('/\d+/', $constructionIdOrTypeName, $constructionId);
if (empty($constructionId)) {
$constructionId = false;
$search[] = $this->toSearchKeyword($this->toAscii($constructionIdOrTypeName));
$searchTypes['constructionIdOrTypeName'] = $constructionIdOrTypeName;
} else {
$constructionId = (int)$constructionId[0];
}
}
}
if ($constructionTypeIdOrTypeName) {
preg_match('/\d+/', $constructionTypeIdOrTypeName, $constructionTypeId);
if (empty($constructionTypeId)) {
$searchTypes['constructionTypeIdOrTypeName'] = $constructionTypeIdOrTypeName;
$constructionTypeId = false;
$search[] = $this->toSearchKeyword($this->toAscii($constructionTypeIdOrTypeName));
} else {
$constructionTypeId = (int)$constructionTypeId[0];
}
}
if ($searchTermOrElementId) {
// show detail view if search term lools like link on detail page
if (preg_match('/^\d{1,3}-[a-z\-]{10,}/', $searchTermOrElementId, $constructionElementId)) {
$constructionElementId = (int)$constructionElementId[0];
return $this->constructionsDetailAction($constructionElementId, $request);
}
$search[] = $this->toSearchKeyword($this->toAscii($searchTermOrElementId));
}
$heatProtectionService = $this->getHeatProtectionService();
$data = $heatProtectionService->getHeatProtectionData($constructionTypeId, $constructionId, $search);
if (!empty($data['results'])) {
foreach ($data['results'] as $constructionName => $elements) {
foreach ($elements as $elementId => $elementValues) {
if ($constructionId) {
$data['construction_link'] = $elementValues['construction_id'] . '-' . $this->toAscii($elementValues['construction_name']);
$data['construction_name'] = $constructionName;
}
if ($constructionTypeId and $constructionId) {
$data['type_link'] = $data['construction_link'] . '/' . $elementValues['type_id'] . '-' . $this->toAscii($elementValues['type_name']);
$data['type_name'] = $elementValues['type_name'];
}
$data['results'][$constructionName][$elementId]['link'] =
$this->toAscii($elementValues['construction_name']) . '/'
. $this->toAscii($elementValues['type_name']) . '/'
. $elementId . '-' . $this->toAscii($elementValues['element_name']);
}
}
}
if (!empty($searchTypes)) {
$data['origin_search'] = $searchTypes;
} else {
unset($data['type_names']);
}
$data['search'] = ((!empty($search) or $constructionId or $constructionTypeId) ? true : false);
$data['loggedIn'] = $this->isUserLoggedIn();
$data['userData'] = $this->atlasSession->getUser();
$response = $this->render('heatProtection.html.twig', $data);
if (!empty($data['element_string'])) {
$response->headers->setCookie(new Cookie('elements', $data['element_string']));
}
return $response;
}
private function getCartFromSession()
{
if ($this->isUserLoggedIn()) {
$this->userCartService->setSavedCartToSession($this->loadAtlasSession());
}
}
/**
* @Route(
* "konstruktions-detail/{productId}",
* name="constructionsDetail",
* requirements={"productId" = ".+"},
* )
*
* @param $productId
* @return Response
*/
public function constructionsDetailAction($productId, Request $request)
{
preg_match('/\d+/', $productId, $elementId);
$heatProtectionService = $this->getHeatProtectionService();
$thermalData = $heatProtectionService->getThermalDataByElement($productId);
$viewParameters = $this->prepareFilterResponse($request);
$data = $heatProtectionService->getConstructionsDetailData($productId);
if (isset($data['element'])) {
if (isset($data['element']['thermals'])) {
foreach ($data['element']['thermals'] as $id => $thermal) {
$digit = null;
if (preg_match('/\d$/', $thermal->getVariable(), $digit)) {
$thermal->setVariable(preg_replace('/\d$/', '<sub>' . (int)$digit[0] . '</sub>',
$thermal->getVariable()));
}
}
}
$pagination = $heatProtectionService->getElementPagination((int)$elementId[0],
$request->cookies->get('elements'));
$pagination['previous_link'] =
$this->toAscii($pagination['previous_construction_name']) . '/' .
$this->toAscii($pagination['previous_type_name']) . '/' .
$pagination['previous'] . '-' . $this->toAscii($pagination['previous_name']);
$pagination['next_link'] =
$this->toAscii($pagination['next_construction_name']) . '/' .
$this->toAscii($pagination['next_type_name']) . '/' .
$pagination['next'] . '-' . $this->toAscii($pagination['next_name']);
$data = array_merge($viewParameters, $data);
$data = array_merge($data, $pagination);
$data['cart_elements'] = $this->atlasSession->getCartElements();
$data['thermalDataJson'] = $thermalData->getJson();
$data['availableTpcKeys'] = $thermalData->getTpcKeys();
$data['regulationComponents'] = $data['element']['element']->getRegulationComponents();
foreach ($data['regulationComponents'] as $index => $component) {
$currentArrValue = current($data['availableTpcKeys']);
if(false === $currentArrValue){
continue;
}
$data['regulationComponents'][$currentArrValue] = $component;
unset($data['regulationComponents'][$index]);
next($data['availableTpcKeys']);
}
$data['construction_link'] = $data['element']['construction_id'] . '-' . $this->toAscii($data['element']['construction_name']);
$data['construction_name'] = $data['element']['construction_name'];
$data['type_link'] = $data['construction_link'] . '/' . $data['element']['type_id'] . '-' . $this->toAscii($data['element']['type_name']);
$data['type_name'] = $data['element']['type_name'];
$data['element_link'] = $this->toAscii($data['element']['construction_name']) . '/' .
$this->toAscii($data['element']['type_name']) . '/' .
$data['element']['element']->getId() . '-' . $this->toAscii($data['element']['element']->getName());
}
$data['loggedIn'] = $this->isUserLoggedIn();
$data['userData'] = $this->atlasSession->getUser();
if (!isset($data['element'])) {
return $this->render('catchall.html.twig', $data);
} else {
return $this->render('constructionsDetail.html.twig', $data);
}
}
/**
* @Route(
* "konstruktions-details-pdf-download/{productId}/{tpcKeyCode}",
* name="constructionsDetailPdfDownload",
* requirements={"productId" = ".+", "tpcKeyCode" = ".+"},
* )
*
* @param $productId
* @param $tpcKeyCode
* @return Response
*/
public function constructionsDetailPdfDownloadAction(ParameterBagInterface $parameterBag, $productId, $tpcKeyCode)
{
$heatProtectionService = $this->getHeatProtectionService();
$dataDirectory = $this->getDataDirectory($parameterBag);
$thermalData = $heatProtectionService->getThermalDataByElement($productId);
$data = $heatProtectionService->getConstructionsDetailData($productId);
$thermalData->loadData($dataDirectory);
$data['tpcData'] = $thermalData->getTpc()[$tpcKeyCode] ?? null;
$data['selectedValues'] = explode('-', $tpcKeyCode);
$data['availableTpcKeys'] = $thermalData->getTpcKeys();
$data['regulationComponents'] = $data['element']['element']->getRegulationComponents();
foreach ($data['regulationComponents'] as $index => $component) {
$currentArrValue = current($data['availableTpcKeys']);
if (false === $currentArrValue) {
continue;
}
$data['regulationComponents'][$currentArrValue] = $component;
unset($data['regulationComponents'][$index]);
next($data['availableTpcKeys']);
}
$data['loggedIn'] = $this->isUserLoggedIn();
$data['userData'] = $this->atlasSession->getUser();
if ($data['element'] == null) {
return $this->render('catchall.html.twig');
} else {
$html = $this->render('constructionsDetailPdf.html.twig', $data);
$this->session->save();
session_write_close();
return new Response(
$this->knpSnappyPdf->getOutputFromHtml(
$html->getContent(),
array(
'username' => $this->getParameter('atlas.authentication')['uname']
,
'password' => $this->getParameter('atlas.authentication')['pass'],
)
),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="' . $data['element']['element']->getCode() . '.pdf"',
)
);
}
}
/**
* @Route(
* "waermeberechnung-pdf-download",
* name="heatProtectionPdfDownload",
* )
*
* @return Response
*/
public function heatCalculationPdfDownloadAction(ParameterBagInterface $parameterBag)
{
$heatProtectionService = $this->getHeatProtectionService();
$data['cart_elements'] = $this->atlasSession->getCartElements();
$data['cart_elements_sum'] = $this->atlasSession->getCartElementsSum();
$data['cart_ages'] = $this->atlasSession->getAges();
$data['cart_uwb'] = $this->atlasSession->getUwb();
$data['loggedIn'] = $this->isUserLoggedIn();
$data['userData'] = $this->atlasSession->getUser();
if ($data['cart_elements'] == null) {
return $this->render('catchall.html.twig', $data);
} else {
$html = $this->render('heatCalculationPdf.html.twig', $data);
$this->session->save();
session_write_close();
$cdPdf = '';
foreach ($data['cart_elements'] as $cartElement) {
if ($cartElement->getConstructionElement()->getId() != null) {
$idConstElement = $cartElement->getConstructionElement()->getId();
} else {
$idConstElement = "";
}
$thermalData = $heatProtectionService->getThermalDataByElement($idConstElement);
$data = $heatProtectionService->getConstructionsDetailData($idConstElement);
$data['tpcData'] = $idConstElement === "" ? '' : ($thermalData->getTpc()[$cartElement->getTpcKeyCode()] ?? "");
$data['selectedValues'] = $idConstElement == "" ? '' : explode('-', $cartElement->getTpcKeyCode());
$htmlCd = $this->render('constructionsDetailPdf.html.twig', $data);
$cdPdf .= $htmlCd->getContent();
}
return new Response(
$this->knpSnappyPdf->getOutputFromHtml(
$html->getContent() . $cdPdf,
[
'username' => $this->getParameter('atlas.authentication')['uname'],
'password' => $this->getParameter('atlas.authentication')['pass']
]
),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="Wärmebrückenberechnung.pdf"',
)
);
}
}
/**
* @Route(
* "/waermeberechnung",
* name="heatCalculation"
* )
*
* @return Response
*/
public function heatCalculationAction()
{
$data['cart_elements'] = $this->atlasSession->getCartElements();
$data['cart_elements_sum'] = $this->atlasSession->getCartElementsSum();
$data['cart_ages'] = $this->atlasSession->getAges();
$data['cart_uwb'] = $this->atlasSession->getUwb();
$data['loggedIn'] = $this->isUserLoggedIn();
$data['userData'] = $this->atlasSession->getUser();
return $this->render('heatCalculation.html.twig', $data);
}
/**
* @Route(
* "/oekobilanzierung",
* name="ecobalancing"
* )
*
* @return Response
*/
public function ecobalancingAction()
{
$data['loggedIn'] = $this->isUserLoggedIn();
$data['userData'] = $this->atlasSession->getUser();
return $this->render('ecobalancing.html.twig', $data);
}
/**
* @Route(
* "/zertifizierung",
* name="certification"
* )
*
* @return Response
*/
public function certificationAction()
{
$data['loggedIn'] = $this->isUserLoggedIn();
$data['userData'] = $this->atlasSession->getUser();
return $this->render('certification.html.twig', $data);
}
/**
* @Route(
* "/schallschutz",
* name="noiseProtection"
* )
*
* @return Response
*/
public function noiseProtectionAction()
{
$data['loggedIn'] = $this->isUserLoggedIn();
$data['userData'] = $this->atlasSession->getUser();
return $this->render('noiseProtection.html.twig', $data);
}
/**
* @Route(
* "/info",
* name="info"
* )
*
* @return Response
*/
public function infoAction()
{
$data['loggedIn'] = $this->isUserLoggedIn();
$data['userData'] = $this->atlasSession->getUser();
return $this->render('info.html.twig', $data);
}
/**
* @Route(
* "/impressum",
* name="imprint"
* )
*
* @return Response
*/
public function imprintAction()
{
$data['loggedIn'] = $this->isUserLoggedIn();
$data['userData'] = $this->atlasSession->getUser();
return $this->render('imprint.html.twig', $data);
}
/**
* @Route("/datenschutz", name="privacy")
*
* @return Response
*/
public function privacyAction()
{
$data['loggedIn'] = $this->isUserLoggedIn();
$data['userData'] = $this->atlasSession->getUser();
return $this->render('privacy.html.twig', $data);
}
/**
* @Route(
* "/download/{fileType}/{fileId}",
* name="atlasDownload",
* requirements={"fileType" = ".+", "fileId" = ".+"},
* )
*
* @param string $fileType
* @param int $fileId
* @return Response
*/
public function downloadAction($fileType, $fileId)
{
$downloadFile = $this->downloadService->prepareDownloadFile($fileType, $fileId, $this->getParameter('kernel.project_dir'));
return $this->doDownload($downloadFile);
}
/**
* @Route(
* "/ajax/{action}",
* name="atlas_ajax",
* requirements={"action" = ".+"},
* )
*
* @param $action
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function ajaxAction($action)
{
return $this->{$action . 'AjaxAction'}();
}
public function addElementToCartAjaxAction()
{
$heatProtectionService = $this->getHeatProtectionService();
$request = new Request();
$data = $request->createFromGlobals()->get('atlas');
$elementId = intval($data['elementId']);
$tpcKeyCode = $data['tpcKeyCode'];
$psiValue = $data['psiValue'];
$return = $heatProtectionService->addElementToCart($elementId, $tpcKeyCode, $psiValue, $this->atlasSession);
$response = array(
'state' => $return->state,
'msg' => $return->msg,
);
return new JsonResponse($response);
}
public function addEmptyElementToCartAjaxAction()
{
$heatProtectionService = $this->getHeatProtectionService();
$request = new Request();
$data = $request->createFromGlobals()->get('atlas');
$tpcKeyCode = $data['tpcKeyCode'];
$psiValue = $data['psiValue'];
$return = $heatProtectionService->addEmpytElementToCart(null, $tpcKeyCode, $psiValue, $this->loadAtlasSession());
$response = array(
'state' => $return->state,
'msg' => $return->msg,
);
return new JsonResponse($response);
}
public function removeElementFromCartAjaxAction()
{
$heatProtectionService = $this->getHeatProtectionService();
$request = new Request();
$data = $request->createFromGlobals()->get('atlas');
$elementId = intval($data['elementId']);
$return = $heatProtectionService->removeElementFromCart($elementId, $this->atlasSession);
$response = array(
'state' => $return->state,
'msg' => $return->msg,
);
return new JsonResponse($response);
}
public function setElementLengthAjaxAction()
{
$heatProtectionService = $this->getHeatProtectionService();
$request = new Request();
$data = $request->createFromGlobals()->get('atlas');
$elementId = intval($data['elementId']);
$elementLength = $data['elementLength'];
$elementPsiValue = $data['elementPsiValue'];
$return = $heatProtectionService->setElementLengthById($elementId, $elementLength, $this->atlasSession, $elementPsiValue);
$response = array(
'state' => $return->state,
'msg' => $return->msg,
);
return new JsonResponse($response);
}
public function setCartElementNameByIdAjaxAction()
{
$heatProtectionService = $this->getHeatProtectionService();
$request = new Request();
$data = $request->createFromGlobals()->get('atlas');
$cartElementId = $data['cartElementId'];
$cartElementName = $data['cartElementName'];
$return = $heatProtectionService->setCartElementNameById($cartElementId, $cartElementName, $this->atlasSession);
$response = array(
'state' => $return->state,
'msg' => $return->msg,
);
return new JsonResponse($response);
}
public function setAgesAjaxAction()
{
$heatProtectionService = $this->getHeatProtectionService();
$request = new Request();
$data = $request->createFromGlobals()->get('atlas');
$aGes = $data['aGes'];
$return = $heatProtectionService->setAges($aGes, $this->atlasSession);
$response = array(
'state' => $return->state,
'msg' => $return->msg,
);
return new JsonResponse($response);
}
/**
* @param DownloadFileModel $downloadFile
* @return Response
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
public function doDownload(DownloadFileModel $downloadFile)
{
if ($downloadFile->isValid() && $downloadFile->getContent() != null) {
$response = new Response();
$response->setStatusCode(200);
$response->headers->set('Cache-Control', 'private');
$response->headers->set('Content-type', $downloadFile->getFiletype());
$response->headers->set('Content-Disposition',
'attachment; filename="' . $downloadFile->getFilename() . '.' . $downloadFile->getFileExt() . '";');
$response->headers->set('Content-length', filesize($downloadFile->getFilepath()));
$response->setContent($downloadFile->getContent());
return $response;
} else {
throw new NotFoundHttpException("File not found");
}
}
/**
* @param $request
* @return array
*/
private function prepareFilterResponse($request)
{
$viewParameters = array();
$viewParameters['wbName'] = ($request->query->get("wbName") == '0' ? null : $request->query->get("wbName"));
$wbId = intval($request->query->get("wbId"));
$viewParameters['wbId'] = ($wbId == 0 ? null : $wbId);
$viewParameters['constructionTypeParam'] = ($viewParameters['wbName'] != null ? $viewParameters['wbName'] : $viewParameters['wbId']);
$selectedConstruction = intval($request->query->get("konst"));
$viewParameters['konst'] = ($selectedConstruction == 0 ? null : $selectedConstruction);
$searchTerm = $request->query->get("searchTerm");
$viewParameters['searchTerms'] = $this->clearUpSearchTerm($searchTerm);
$buildingType = $request->query->get("buildingType");
$viewParameters['buildingType'] = ($buildingType == null ? 'select_wo_ge' : $buildingType);
$buildingView = $request->query->get("buildingView");
$viewParameters['buildingView'] = ($buildingView == null ? 'woge_front_svg' : $buildingView);
return $viewParameters;
}
/**
* @param $searchTerm
* @return array
*/
private function clearUpSearchTerm($searchTerm)
{
$searchTerms = explode('|', $searchTerm);
foreach ($searchTerms as $key => $searchTerm) {
$searchTerms[$key] = trim($searchTerm);
}
return $searchTerms;
}
/**
* @Route(
* "/{path}",
* name="catchall",
* requirements={"path" = ".+"}
* )
*
* @return Response
*/
public function catchAllAction($path)
{
$data['loggedIn'] = $this->isUserLoggedIn();
$data['userData'] = $this->atlasSession->getUser();
return $this->render('catchall.html.twig', $data);
}
private function getDataDirectory(ParameterBagInterface $parameterBag)
{
return $parameterBag->get('thermal_data_dir');
}
private function getHeatProtectionService()
{
return $this->heatProtectionService;
}
public function saveUserCartAjaxAction()
{
$dao = new AtlasDaoDbImpl($this->getDoctrine()->getManager());
if ($this->isUserLoggedIn()) {
$userId = $this->loadAtlasSession()->getUser()['uid'];
$aGes = ($this->loadAtlasSession()->getAges() == null) ? 0 : $this->loadAtlasSession()->getAges();
/** @var UserCartRepository $userCartRepo */
$userCartRepo = $this->getDoctrine()->getRepository(UserCart::class);
/** @var UserCart $savedCart */
$savedCart = $userCartRepo->findOneBy(array('userId' => $userId));
if (empty($savedCart)) {
$savedCart = new UserCart();
$savedCart->setUserId($userId);
}
$savedCart->clearCart();
$cartElements = $this->loadAtlasSession()->getCartElements();
foreach ($cartElements as $cartElement) {
$savedCart->addCartelement($cartElement);
}
$savedCart->setAGes($aGes);
$dao->saveModelTree($savedCart);
}
$response = array(
'state' => '0',
'msg' => 'ok',
);
return new JsonResponse($response);
}
}