Przeglądaj źródła

import done

master
Daniel 4 lat temu
rodzic
commit
afcb68723c
8 zmienionych plików z 868 dodań i 3 usunięć
  1. BIN
      ueradvance.com.xlsx
  2. +2
    -1
      httpdocs/composer.json
  3. +534
    -2
      httpdocs/composer.lock
  4. +7
    -0
      httpdocs/config/routing.yaml
  5. +46
    -0
      httpdocs/config/services.yaml
  6. +164
    -0
      httpdocs/src/Controller/BackendController.php
  7. +50
    -0
      httpdocs/src/EventListener/BackendMenuListener.php
  8. +65
    -0
      httpdocs/templates/backend/data_menu.html.twig

BIN
documents/April2021_Datentabelle → ueradvance.com.xlsx Wyświetl plik


+ 2
- 1
httpdocs/composer.json Wyświetl plik

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


+ 534
- 2
httpdocs/composer.lock Wyświetl plik

@@ -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"
}

+ 7
- 0
httpdocs/config/routing.yaml Wyświetl plik

@@ -0,0 +1,7 @@
# config/routing.yml
app.controller:
resource: ../src/Controller
type: annotation

#ContaoCoreBundle:
# resource: "@ContaoCoreBundle/Resources/config/routing.yml"

+ 46
- 0
httpdocs/config/services.yaml Wyświetl plik

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

+ 164
- 0
httpdocs/src/Controller/BackendController.php Wyświetl plik

@@ -0,0 +1,164 @@
<?php
namespace App\Controller;


use Doctrine\DBAL\Connection;
use Onurb\Bundle\ExcelBundle\Factory\ExcelFactory;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Annotation\Route;
use Twig\Environment as TwigEnvironment;
use Terminal42\ServiceAnnotationBundle\Annotation\ServiceTag;
use function Ramsey\Uuid\v1;

/**
* @Route("/contao/key-data",
* defaults={
* "_scope" = "backend",
* "_backend_module" = "my-module",
* "_token_check" = true
* }
* )
* @ServiceTag("controller.service_arguments")
*/
class BackendController extends AbstractController
{

private $twig;
private $kernel;

public function __construct(TwigEnvironment $twig, KernelInterface $kernel)
{
$GLOBALS['TL_JAVASCRIPT'][] = 'assets/jquery/js/jquery.js';
$this->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');
}
}

+ 50
- 0
httpdocs/src/EventListener/BackendMenuListener.php Wyświetl plik

@@ -0,0 +1,50 @@
<?php


namespace App\EventListener;

use App\Controller\BackendController;
use Contao\CoreBundle\Event\MenuEvent;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\RouterInterface;
use Terminal42\ServiceAnnotationBundle\Annotation\ServiceTag;

/**
* Class to register backend modules
*
* @ServiceTag("kernel.event_listener", event="contao.backend_menu_build", priority=-255)
*/
class BackendMenuListener
{
protected $router;
protected $requestStack;

public function __construct(RouterInterface $router, RequestStack $requestStack)
{
$this->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);
}
}

+ 65
- 0
httpdocs/templates/backend/data_menu.html.twig Wyświetl plik

@@ -0,0 +1,65 @@
{% extends "@ContaoCore/Backend/be_page.html.twig" %}

{% block headline %}
Datenverwaltung
{% endblock %}

{% block error %}
{% endblock %}

{% block main %}
<script>
jQuery.noConflict();
</script>

<div class="tl_listing_container list_view">
<div id="xls-message"></div>
<form id="xls-import" method="post" action="{{ path('import_xls') }}" enctype="multipart/form-data">
<input type="hidden" name="REQUEST_TOKEN" value="{{ token }}"/>
<table class="tl_listing">
<tbody>
<tr>
<td colspan="4" class="tl_folder_tlist">Excel Import</td>
</tr>
<tr>
<td class="tl_file_list">
<label for="result-xls">Excel-Datei:</label>
</td>
<td class="tl_file_list">
<input id="xls" type="file" name="xls" accept=".xls,.xlsx,.XLS,.XLSX" class="tl_submit" required>
</td>
<td class="tl_file_list" colspan="2">
<input type="submit" value="Datei importieren" class="tl_submit">
</td>
</tr>
</tbody>
</table>
</form>
</div>

<script src="{{ asset('files/e-formel/assets/backend/js/backend-data-menu.js') }}" type="text/javascript" charset="utf-8"></script>
<script>
jQuery("#xls-import").on("submit", function(e) {
e.preventDefault();
let form = jQuery(this)[0]; // You need to use standard javascript object here
let formData = new FormData(form);
jQuery("#xls-message").html("");
jQuery.ajax({
url: "{{ path('import_xls') }}",
method: "post",
data: formData,
processData: false,
contentType: false,
success: function(data) {
jQuery("#xls-message").html("Excel-Datei wurde erfolgreich importiert!");
},
error: function(requestObject, error, errorThrown) {
jQuery("#xls-message").html('Fehler:' + requestObject.responseText);
},
dataType: "html"
});
});

</script>

{% endblock %}

Ładowanie…
Anuluj
Zapisz