diff --git a/documents/April2021_Datentabelle baueradvance.com.xlsx b/documents/April2021_Datentabelle baueradvance.com.xlsx new file mode 100644 index 0000000..84f8d15 Binary files /dev/null and b/documents/April2021_Datentabelle baueradvance.com.xlsx differ diff --git a/httpdocs/composer.json b/httpdocs/composer.json index 607e4e7..c722b75 100644 --- a/httpdocs/composer.json +++ b/httpdocs/composer.json @@ -16,7 +16,8 @@ "oveleon/contao-component-style-manager": "^2.4", "terminal42/contao-changelanguage": "^3.1", "terminal42/contao-node": "^1.3", - "terminal42/dc_multilingual": "^4.1" + "terminal42/dc_multilingual": "^4.1", + "onurb/excel-bundle": "^1.0" }, "extra": { "contao-component-dir": "assets" diff --git a/httpdocs/composer.lock b/httpdocs/composer.lock index baea335..c53eea7 100644 --- a/httpdocs/composer.lock +++ b/httpdocs/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bb8176e4b84151a2b3e04303c69ddae5", + "content-hash": "cecc1016949c9828ae57f7ec14197a87", "packages": [ { "name": "alnv/catalog-manager", @@ -4214,6 +4214,60 @@ ], "time": "2021-04-01T18:37:14+00:00" }, + { + "name": "ezyang/htmlpurifier", + "version": "v4.13.0", + "source": { + "type": "git", + "url": "https://github.com/ezyang/htmlpurifier.git", + "reference": "08e27c97e4c6ed02f37c5b2b20488046c8d90d75" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/08e27c97e4c6ed02f37c5b2b20488046c8d90d75", + "reference": "08e27c97e4c6ed02f37c5b2b20488046c8d90d75", + "shasum": "" + }, + "require": { + "php": ">=5.2" + }, + "require-dev": { + "simpletest/simpletest": "dev-master#72de02a7b80c6bb8864ef9bf66d41d2f58f826bd" + }, + "type": "library", + "autoload": { + "psr-0": { + "HTMLPurifier": "library/" + }, + "files": [ + "library/HTMLPurifier.composer.php" + ], + "exclude-from-classmap": [ + "/library/HTMLPurifier/Language/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-or-later" + ], + "authors": [ + { + "name": "Edward Z. Yang", + "email": "admin@htmlpurifier.org", + "homepage": "http://ezyang.com" + } + ], + "description": "Standards compliant HTML filter written in PHP", + "homepage": "http://htmlpurifier.org/", + "keywords": [ + "html" + ], + "support": { + "issues": "https://github.com/ezyang/htmlpurifier/issues", + "source": "https://github.com/ezyang/htmlpurifier/tree/master" + }, + "time": "2020-06-29T00:56:53+00:00" + }, { "name": "friendsofsymfony/http-cache", "version": "2.10.0", @@ -5421,6 +5475,246 @@ ], "time": "2021-03-29T14:13:42+00:00" }, + { + "name": "maennchen/zipstream-php", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/maennchen/ZipStream-PHP.git", + "reference": "c4c5803cc1f93df3d2448478ef79394a5981cc58" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/c4c5803cc1f93df3d2448478ef79394a5981cc58", + "reference": "c4c5803cc1f93df3d2448478ef79394a5981cc58", + "shasum": "" + }, + "require": { + "myclabs/php-enum": "^1.5", + "php": ">= 7.1", + "psr/http-message": "^1.0", + "symfony/polyfill-mbstring": "^1.0" + }, + "require-dev": { + "ext-zip": "*", + "guzzlehttp/guzzle": ">= 6.3", + "mikey179/vfsstream": "^1.6", + "phpunit/phpunit": ">= 7.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "ZipStream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paul Duncan", + "email": "pabs@pablotron.org" + }, + { + "name": "Jonatan Männchen", + "email": "jonatan@maennchen.ch" + }, + { + "name": "Jesse Donat", + "email": "donatj@gmail.com" + }, + { + "name": "András Kolesár", + "email": "kolesar@kolesar.hu" + } + ], + "description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.", + "keywords": [ + "stream", + "zip" + ], + "support": { + "issues": "https://github.com/maennchen/ZipStream-PHP/issues", + "source": "https://github.com/maennchen/ZipStream-PHP/tree/master" + }, + "funding": [ + { + "url": "https://opencollective.com/zipstream", + "type": "open_collective" + } + ], + "time": "2020-05-30T13:11:16+00:00" + }, + { + "name": "markbaker/complex", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPComplex.git", + "reference": "6f724d7e04606fd8adaa4e3bb381c3e9db09c946" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/6f724d7e04606fd8adaa4e3bb381c3e9db09c946", + "reference": "6f724d7e04606fd8adaa4e3bb381c3e9db09c946", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "phpcompatibility/php-compatibility": "^9.0", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.3", + "squizlabs/php_codesniffer": "^3.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Complex\\": "classes/src/" + }, + "files": [ + "classes/src/functions/abs.php", + "classes/src/functions/acos.php", + "classes/src/functions/acosh.php", + "classes/src/functions/acot.php", + "classes/src/functions/acoth.php", + "classes/src/functions/acsc.php", + "classes/src/functions/acsch.php", + "classes/src/functions/argument.php", + "classes/src/functions/asec.php", + "classes/src/functions/asech.php", + "classes/src/functions/asin.php", + "classes/src/functions/asinh.php", + "classes/src/functions/atan.php", + "classes/src/functions/atanh.php", + "classes/src/functions/conjugate.php", + "classes/src/functions/cos.php", + "classes/src/functions/cosh.php", + "classes/src/functions/cot.php", + "classes/src/functions/coth.php", + "classes/src/functions/csc.php", + "classes/src/functions/csch.php", + "classes/src/functions/exp.php", + "classes/src/functions/inverse.php", + "classes/src/functions/ln.php", + "classes/src/functions/log2.php", + "classes/src/functions/log10.php", + "classes/src/functions/negative.php", + "classes/src/functions/pow.php", + "classes/src/functions/rho.php", + "classes/src/functions/sec.php", + "classes/src/functions/sech.php", + "classes/src/functions/sin.php", + "classes/src/functions/sinh.php", + "classes/src/functions/sqrt.php", + "classes/src/functions/tan.php", + "classes/src/functions/tanh.php", + "classes/src/functions/theta.php", + "classes/src/operations/add.php", + "classes/src/operations/subtract.php", + "classes/src/operations/multiply.php", + "classes/src/operations/divideby.php", + "classes/src/operations/divideinto.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@lange.demon.co.uk" + } + ], + "description": "PHP Class for working with complex numbers", + "homepage": "https://github.com/MarkBaker/PHPComplex", + "keywords": [ + "complex", + "mathematics" + ], + "support": { + "issues": "https://github.com/MarkBaker/PHPComplex/issues", + "source": "https://github.com/MarkBaker/PHPComplex/tree/2.0.3" + }, + "time": "2021-06-02T09:44:11+00:00" + }, + { + "name": "markbaker/matrix", + "version": "2.1.3", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPMatrix.git", + "reference": "174395a901b5ba0925f1d790fa91bab531074b61" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/174395a901b5ba0925f1d790fa91bab531074b61", + "reference": "174395a901b5ba0925f1d790fa91bab531074b61", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "phpcompatibility/php-compatibility": "^9.0", + "phpdocumentor/phpdocumentor": "2.*", + "phploc/phploc": "^4.0", + "phpmd/phpmd": "2.*", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.3", + "sebastian/phpcpd": "^4.0", + "squizlabs/php_codesniffer": "^3.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Matrix\\": "classes/src/" + }, + "files": [ + "classes/src/Functions/adjoint.php", + "classes/src/Functions/antidiagonal.php", + "classes/src/Functions/cofactors.php", + "classes/src/Functions/determinant.php", + "classes/src/Functions/diagonal.php", + "classes/src/Functions/identity.php", + "classes/src/Functions/inverse.php", + "classes/src/Functions/minors.php", + "classes/src/Functions/trace.php", + "classes/src/Functions/transpose.php", + "classes/src/Operations/add.php", + "classes/src/Operations/directsum.php", + "classes/src/Operations/subtract.php", + "classes/src/Operations/multiply.php", + "classes/src/Operations/divideby.php", + "classes/src/Operations/divideinto.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@demon-angel.eu" + } + ], + "description": "PHP Class for working with matrices", + "homepage": "https://github.com/MarkBaker/PHPMatrix", + "keywords": [ + "mathematics", + "matrix", + "vector" + ], + "support": { + "issues": "https://github.com/MarkBaker/PHPMatrix/issues", + "source": "https://github.com/MarkBaker/PHPMatrix/tree/2.1.3" + }, + "time": "2021-05-25T15:42:17+00:00" + }, { "name": "matthiasmullie/minify", "version": "1.3.66", @@ -5751,6 +6045,66 @@ ], "time": "2020-12-14T12:56:38+00:00" }, + { + "name": "myclabs/php-enum", + "version": "1.8.3", + "source": { + "type": "git", + "url": "https://github.com/myclabs/php-enum.git", + "reference": "b942d263c641ddb5190929ff840c68f78713e937" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/php-enum/zipball/b942d263c641ddb5190929ff840c68f78713e937", + "reference": "b942d263c641ddb5190929ff840c68f78713e937", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.5", + "squizlabs/php_codesniffer": "1.*", + "vimeo/psalm": "^4.6.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "MyCLabs\\Enum\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP Enum contributors", + "homepage": "https://github.com/myclabs/php-enum/graphs/contributors" + } + ], + "description": "PHP Enum implementation", + "homepage": "http://github.com/myclabs/php-enum", + "keywords": [ + "enum" + ], + "support": { + "issues": "https://github.com/myclabs/php-enum/issues", + "source": "https://github.com/myclabs/php-enum/tree/1.8.3" + }, + "funding": [ + { + "url": "https://github.com/mnapoli", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/php-enum", + "type": "tidelift" + } + ], + "time": "2021-07-05T08:18:36+00:00" + }, { "name": "nelmio/cors-bundle", "version": "2.1.0", @@ -6209,6 +6563,79 @@ ], "time": "2020-07-13T19:23:57+00:00" }, + { + "name": "onurb/excel-bundle", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/Nono1971/excel-bundle.git", + "reference": "ebd4e5ebfd683d54d0b94834e514619128434f41" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Nono1971/excel-bundle/zipball/ebd4e5ebfd683d54d0b94834e514619128434f41", + "reference": "ebd4e5ebfd683d54d0b94834e514619128434f41", + "shasum": "" + }, + "require": { + "php": ">=7.1.3", + "phpoffice/phpspreadsheet": "~1.0", + "symfony/config": "~4.2", + "symfony/dependency-injection": "~3.2|~4.0", + "symfony/framework-bundle": "~3.2|~4.0", + "symfony/http-foundation": "~3.2|~4.0", + "symfony/http-kernel": "~3.2|~4.0" + }, + "require-dev": { + "php": ">=7.0", + "phpunit/phpunit": "~6.5", + "sensio/framework-extra-bundle": "~3.2|~4.0", + "squizlabs/php_codesniffer": "~2" + }, + "suggest": { + "onurb/doctrine-yuml-bundle": "Use this bundle to generate mapping graph from your entities" + }, + "type": "symfony-bundle", + "extra": { + "symfony": { + "allow-contrib": "true" + } + }, + "autoload": { + "psr-4": { + "Onurb\\Bundle\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Giulio De Donato", + "email": "liuggio@gmail.com" + }, + { + "name": "Bruno Heron", + "email": "herobrun@gmail.com" + } + ], + "description": "Symfony Bundle to read or write Excel file (including pdf, xlsx, odt), using phpoffice/phpspreadsheet library (replacement of phpoffice/phpexcel, abandonned)", + "keywords": [ + "PHPExcel", + "bundle", + "excel", + "spreadsheet", + "symfony", + "xls", + "xlsx" + ], + "support": { + "issues": "https://github.com/Nono1971/excel-bundle/issues", + "source": "https://github.com/Nono1971/excel-bundle/tree/1.0.2" + }, + "time": "2019-06-24T20:41:00+00:00" + }, { "name": "oveleon/contao-component-style-manager", "version": "2.4.4", @@ -6818,6 +7245,110 @@ ], "time": "2020-07-07T09:29:14+00:00" }, + { + "name": "phpoffice/phpspreadsheet", + "version": "1.18.0", + "source": { + "type": "git", + "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", + "reference": "418cd304e8e6b417ea79c3b29126a25dc4b1170c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/418cd304e8e6b417ea79c3b29126a25dc4b1170c", + "reference": "418cd304e8e6b417ea79c3b29126a25dc4b1170c", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-dom": "*", + "ext-fileinfo": "*", + "ext-gd": "*", + "ext-iconv": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-simplexml": "*", + "ext-xml": "*", + "ext-xmlreader": "*", + "ext-xmlwriter": "*", + "ext-zip": "*", + "ext-zlib": "*", + "ezyang/htmlpurifier": "^4.13", + "maennchen/zipstream-php": "^2.1", + "markbaker/complex": "^2.0", + "markbaker/matrix": "^2.0", + "php": "^7.2 || ^8.0", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "psr/simple-cache": "^1.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-master", + "dompdf/dompdf": "^1.0", + "friendsofphp/php-cs-fixer": "^2.18", + "jpgraph/jpgraph": "^4.0", + "mpdf/mpdf": "^8.0", + "phpcompatibility/php-compatibility": "^9.3", + "phpstan/phpstan": "^0.12.82", + "phpstan/phpstan-phpunit": "^0.12.18", + "phpunit/phpunit": "^8.5", + "squizlabs/php_codesniffer": "^3.5", + "tecnickcom/tcpdf": "^6.3" + }, + "suggest": { + "dompdf/dompdf": "Option for rendering PDF with PDF Writer (doesn't yet support PHP8)", + "jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers", + "mpdf/mpdf": "Option for rendering PDF with PDF Writer", + "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer (doesn't yet support PHP8)" + }, + "type": "library", + "autoload": { + "psr-4": { + "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maarten Balliauw", + "homepage": "https://blog.maartenballiauw.be" + }, + { + "name": "Mark Baker", + "homepage": "https://markbakeruk.net" + }, + { + "name": "Franck Lefevre", + "homepage": "https://rootslabs.net" + }, + { + "name": "Erik Tilt" + }, + { + "name": "Adrien Crivelli" + } + ], + "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", + "homepage": "https://github.com/PHPOffice/PhpSpreadsheet", + "keywords": [ + "OpenXML", + "excel", + "gnumeric", + "ods", + "php", + "spreadsheet", + "xls", + "xlsx" + ], + "support": { + "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.18.0" + }, + "time": "2021-05-31T18:21:15+00:00" + }, { "name": "phpspec/php-diff", "version": "v1.1.3", @@ -12728,5 +13259,6 @@ "prefer-stable": false, "prefer-lowest": false, "platform": [], - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "2.0.0" } diff --git a/httpdocs/config/routing.yaml b/httpdocs/config/routing.yaml new file mode 100644 index 0000000..90f06d4 --- /dev/null +++ b/httpdocs/config/routing.yaml @@ -0,0 +1,7 @@ +# config/routing.yml +app.controller: + resource: ../src/Controller + type: annotation + +#ContaoCoreBundle: +# resource: "@ContaoCoreBundle/Resources/config/routing.yml" \ No newline at end of file diff --git a/httpdocs/config/services.yaml b/httpdocs/config/services.yaml new file mode 100644 index 0000000..3a2c079 --- /dev/null +++ b/httpdocs/config/services.yaml @@ -0,0 +1,46 @@ +# This file is the entry point to configure your own services. +# Files in the packages/ subdirectory configure your dependencies. + +# Put parameters here that don't need to change on each machine where the app is deployed +# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration +parameters: + + +services: + # default configuration for services in *this* file + _defaults: + autowire: true # Automatically injects dependencies in your services. + autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. + + # makes classes in src/ available to be used as services + # this creates a service per class whose id is the fully-qualified class name + App\: + resource: '../src/' + exclude: + - '../src/DependencyInjection/' + - '../src/Entity/' + - '../src/Kernel.php' + - '../src/Tests/' + + # controllers are imported separately to make sure services can be injected + # as action arguments even if you don't extend any base controller class + App\Controller\: + resource: '../src/Controller/' + tags: ['controller.service_arguments', '%kernel.environment%'] + + App\Command\: + resource: '../src/Command/' + autowire: true + autoconfigure: true + arguments: ['@doctrine.orm.entity_manager', '@service_container'] + tags: + - { name: 'console.command' } + + # add more service definitions when explicit configuration is needed + # please note that last definitions always *replace* previous ones + App\EventListener\BackendMenuListener: + arguments: + - "@router" + - "@request_stack" + tags: + - { name: kernel.event_listener, event: contao.backend_menu_build, method: onContaoBackendMenuBuild, priority: -255 } \ No newline at end of file diff --git a/httpdocs/src/Controller/BackendController.php b/httpdocs/src/Controller/BackendController.php new file mode 100644 index 0000000..72b09b6 --- /dev/null +++ b/httpdocs/src/Controller/BackendController.php @@ -0,0 +1,164 @@ +twig = $twig; + $this->kernel = $kernel; + } + + /** + * @Route("/", name="data_menu") + * + * @param Request $request + * @return Response + * @throws \Twig\Error\LoaderError + * @throws \Twig\Error\RuntimeError + * @throws \Twig\Error\SyntaxError + */ + public function dataMenu(Request $request): Response + { + $res = $this->twig->render( + 'backend/data_menu.html.twig', + [ + 'token' => $this->getToken($request) + ] + ); + return new Response($res); + } + + /** + * @Route("/import-xls", name="import_xls") + * + * @param Request $request + * @return JsonResponse + */ + public function importXls(Request $request) + { + /** @var UploadedFile $xlsFile */ + $xlsFile = $request->files->get('xls'); + + + if ($xlsFile === null || + !($xlsFile->getClientMimeType() === 'application/vnd.ms-excel' || + $xlsFile->getClientMimeType() === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || + $xlsFile->getClientMimeType() === 'application/octet-stream')) { + return new JsonResponse(null, JsonResponse::HTTP_BAD_REQUEST); + } + + + // Save file temporarily + $filename = time().'.xls'; + $path = __DIR__.'/../../xls-imports/'; + + if (!file_exists($path)) { + mkdir($path, 0777, true); + } + + $xlsFile->move( + $path, + $filename + ); + + $excelFactory = new ExcelFactory(); + $spreadsheet = $excelFactory->createSpreadsheet($path . $filename); + $spreadsheet->setActiveSheetIndex(0); + $activesheet = $spreadsheet->getActiveSheet(); + $highestRow = $activesheet->getHighestRow(); + $startRow = 5; + /** @var Connection $connection */ + $connection = $this->getDoctrine()->getConnection(); + + $resultSet = $connection->executeQuery('SELECT * FROM `ctlg_brands`'); + $data = $resultSet->fetchAllAssociative(); + $entriesById = []; + foreach ($data as $entry) { + $entriesById[$entry['id']] = $entry; + } + + $connection->beginTransaction(); + try { + + for ($row = $startRow; $row <= $highestRow; $row++) { + $id = $activesheet->getCell('A'.$row)->getValue(); + if ($id !== null) { + + if (!array_key_exists($id, $entriesById)) { + return new JsonResponse("id $id existiert nicht im System", JsonResponse::HTTP_BAD_REQUEST); + } + $range = (int)$activesheet->getCell('E'.$row)->getCalculatedValue(); + $edition = (int)$activesheet->getCell('G'.$row)->getCalculatedValue(); + $brand_reach = (int)$activesheet->getCell('K'.$row)->getCalculatedValue(); + $social_contacts = (int)$activesheet->getCell('M'.$row)->getCalculatedValue(); + $unique_users = (int)$activesheet->getCell('N'.$row)->getCalculatedValue(); + $page_impressions = (int)$activesheet->getCell('P'.$row)->getCalculatedValue(); + $visits = (int)$activesheet->getCell('R'.$row)->getCalculatedValue(); + + $range = $range !== 0 ? $range : ""; + $edition = $edition !== 0 ? $edition : ""; + $brand_reach = $brand_reach !== 0 ? $brand_reach : ""; + $social_contacts = $social_contacts !== 0 ? $social_contacts : ""; + $unique_users = $unique_users !== 0 ? $unique_users : ""; + $page_impressions = $page_impressions !== 0 ? $page_impressions : ""; + $visits = $visits !== 0 ? $visits : ""; + + $connection->executeStatement( + "UPDATE `ctlg_brands` SET ". + "`range`='$range',". + "`edition`='$edition',". + "`brand_reach`='$brand_reach',". + "`social_contacts`='$social_contacts',". + "`unique_user`='$unique_users',". + "`page_impressions`='$page_impressions',". + "`visits`='$visits'". + " WHERE `id` = $id" + ); + } + } + + } catch (\Exception $e) { + $connection->rollBack(); + unlink($path . $filename); + return new JsonResponse("Es ist ein Fehler aufgetreten: ".$e->getMessage(), JsonResponse::HTTP_BAD_REQUEST); + } + $connection->commit(); + unlink($path . $filename); + return new JsonResponse('done'); + } + + private function getToken(Request $request) + { + return $request->cookies->get($this->kernel->getEnvironment() === 'dev' ? 'csrf_contao_csrf_token' : 'csrf_https-contao_csrf_token'); + } +} \ No newline at end of file diff --git a/httpdocs/src/EventListener/BackendMenuListener.php b/httpdocs/src/EventListener/BackendMenuListener.php new file mode 100644 index 0000000..3adb5a5 --- /dev/null +++ b/httpdocs/src/EventListener/BackendMenuListener.php @@ -0,0 +1,50 @@ +router = $router; + $this->requestStack = $requestStack; + } + + public function onContaoBackendMenuBuild(MenuEvent $event): void + { + $factory = $event->getFactory(); + $tree = $event->getTree(); + + if ('mainMenu' !== $tree->getName()) { + return; + } + + $contentNode = $tree->getChild('content'); + + $node = $factory + ->createItem('Brands Data Import') + ->setUri($this->router->generate('data_menu')) + ->setLabel('Brands Data Import') + ->setLinkAttribute('title', 'Brands Data Import') + ->setLinkAttribute('class', 'brands-import-data') + ->setCurrent($this->requestStack->getCurrentRequest()->get('_controller') === BackendController::class) + ; + + $contentNode->addChild($node); + } +} diff --git a/httpdocs/templates/backend/data_menu.html.twig b/httpdocs/templates/backend/data_menu.html.twig new file mode 100644 index 0000000..9e5c501 --- /dev/null +++ b/httpdocs/templates/backend/data_menu.html.twig @@ -0,0 +1,65 @@ +{% extends "@ContaoCore/Backend/be_page.html.twig" %} + +{% block headline %} + Datenverwaltung +{% endblock %} + +{% block error %} +{% endblock %} + +{% block main %} + + +
+
+
+ + + + + + + + + + + + +
Excel Import
+ + + + + +
+
+
+ + + + +{% endblock %}