src/Controller/AppController.php line 153

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Component\Filesystem\Filesystem;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Component\HttpFoundation\JsonResponse;
  10. class AppController extends AbstractController
  11. {
  12.     /**
  13.      * @Route("/mdm/map")
  14.      */
  15.     public function map(Request $requestString $ldbUrlString $nappUrl)
  16.     {
  17.         $curl curl_init();
  18.         curl_setopt_array($curl, array(
  19.             CURLOPT_URL => $ldbUrl.'/api/ci_notecategory',
  20.             CURLOPT_RETURNTRANSFER => true,
  21.             CURLOPT_ENCODING       => '',
  22.             CURLOPT_MAXREDIRS      => 10,
  23.             CURLOPT_TIMEOUT        => 0,
  24.             CURLOPT_FOLLOWLOCATION => true,
  25.             CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  26.             CURLOPT_SSL_VERIFYPEER => 0,
  27.             CURLOPT_CUSTOMREQUEST  => 'POST',
  28.             CURLOPT_POSTFIELDS     =>'{
  29.                     "data": {
  30.                         "language": "de"
  31.                     }
  32.                 }',
  33.             CURLOPT_HTTPHEADER => array(
  34.                 'Content-Type: application/json',
  35.                 'X-i42AccountToken: 42'
  36.             )
  37.         ));
  38.         $response   curl_exec($curl);
  39.         curl_close($curl);
  40.         $resp       json_decode($responsetrue);
  41.         $categories = [];
  42.         if (is_array($resp) && isset($resp['data']) && isset($resp['data']['notecategory']) && count($resp['data']['notecategory']))
  43.         {
  44.             foreach ($resp['data']['notecategory'] as $key => $noteCategory)
  45.             {
  46.                 $categories[$noteCategory['id']] = $noteCategory['name'];
  47.             }
  48.         }
  49.         $curl curl_init();
  50.         curl_setopt_array($curl, array(
  51.             CURLOPT_URL => $nappUrl.'/extapi/customer.json',
  52.             CURLOPT_RETURNTRANSFER => true,
  53.             CURLOPT_ENCODING       => '',
  54.             CURLOPT_MAXREDIRS      => 10,
  55.             CURLOPT_TIMEOUT        => 0,
  56.             CURLOPT_FOLLOWLOCATION => true,
  57.             CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  58.             CURLOPT_SSL_VERIFYPEER => 0,
  59.             CURLOPT_CUSTOMREQUEST  => 'POST',
  60.             CURLOPT_POSTFIELDS     =>'{"data" : {}}',
  61.             CURLOPT_HTTPHEADER     => array(
  62.                 'Content-Type: application/json',
  63.                 'X-i42AccountToken: 42'
  64.             )
  65.         ));
  66.         $response  curl_exec($curl);
  67.         curl_close($curl);
  68.         $resp      json_decode($responsetrue);
  69.         $customers = [];
  70.         $officeids = [];
  71.         if (is_array($resp) && isset($resp['results']) && count($resp['results']))
  72.         {
  73.             $roles $this->getUser()->getRoles();
  74.             foreach ($resp['results'] as $identifier => $customer)
  75.             {
  76.                 if (in_array('ROLE_ADMIN'$roles))
  77.                 {
  78.                     $customers[$identifier] = $customer['name'];
  79.                     $officeids[$identifier] = $customer['officeId'];
  80.                 }
  81.                 else
  82.                 {
  83.                     if (in_array('ROLE_DEMOVERSION'$roles))
  84.                     {
  85.                         if ($identifier == 'asdfasdrwgdrasdasdfawesrsdafawersdvaswerlrujawemvrfcawse')
  86.                         {
  87.                             $customers[$identifier] = $customer['name'];
  88.                             $officeids[$identifier] = $customer['officeId'];
  89.                         }
  90.                     }
  91.                     else
  92.                     {
  93.                         if ($identifier == 'dsfasdfasdfsdfasdfasdf709asdfasdf70706asdfasdf09707asdfas0df97sd')
  94.                         {
  95.                             $customers[$identifier] = $customer['name'];
  96.                             $officeids[$identifier] = $customer['officeId'];
  97.                         }
  98.                     }
  99.                 }
  100.             }
  101.         }
  102.         return $this->render('here/nicemap.html.twig', ['notecategories' => $categories'customers' => $customers'officeids' => $officeids]);
  103.     }
  104.     /**
  105.      * @Route("/adm/expmdmrdblog", name="exp_mdmrdblog")
  106.      */
  107.     public function exportMdmrdblog(Request $request): Response
  108.     {
  109.         $em   $this->getDoctrine()->getManager();
  110.         $logs $em->getRepository('App:Mdmrdblog')->findAll();
  111.         if ($logs)
  112.         {
  113.             $csv 'ID~PLZ~Entfernung~Fachrichtung~Limit~Nur Ärzte~Nur Ärztinnen~Legal~Privat~Erstellt am'."\r\n";
  114.             foreach ($logs as $log)
  115.             {
  116.                 $csv .= $log->getId().'~';
  117.                 $csv .= $log->getZipcode().'~';
  118.                 $csv .= $log->getDistance().'~';
  119.                 $csv .= $log->getSpecialization().'~';
  120.                 $csv .= $log->getCountlimit().'~';
  121.                 $csv .= $log->getOnlymaledoctor().'~';
  122.                 $csv .= $log->getOnlyfemaledoctor().'~';
  123.                 $csv .= $log->getLegal().'~';
  124.                 $csv .= $log->getPrivate().'~';
  125.                 $csv .= $log->getCreatedAt()->format('d.m.Y H:i:s')."\r\n";
  126.             }
  127.             $fileSys  = new Filesystem();
  128.             $rootDir  $this->getParameter('kernel.project_dir');
  129.             $expDir   $rootDir.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR;
  130.             $fileName 'MdmrdblogExport.csv';
  131.             file_put_contents($expDir.$fileName$csv);
  132.             header('Pragma: public');
  133.             header('Expires: 0');
  134.             header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  135.             header('Last-Modified: '.gmdate ('D, d M Y H:i:s'filemtime($expDir.$fileName)).' GMT');
  136.             header('Cache-Control: private'false);
  137.             header('Content-Type: application/pdf');
  138.             header('Content-Disposition: attachment; filename="'.basename($expDir.$fileName).'"');
  139.             header('Content-Transfer-Encoding: binary');
  140.             header('Content-Length: '.filesize($expDir.$fileName));
  141.             header('Connection: close');
  142.             readfile($expDir.$fileName);
  143.         }
  144.         exit;
  145.     }
  146.     public function welcome(Request $request)
  147.     {
  148.         return $this->render('app/welcome.html.twig');
  149.     }
  150. }