示例#1
1
 public function csvImport($csvFile, $entity, $user, $fileRecord)
 {
     // Create and configure the reader
     $headers = new ParagonArray();
     $file = new \SplFileObject($csvFile);
     $csvReader = new CsvReader($file);
     $csvReader->setHeaderRowNumber(0);
     $csvReader->setStrict(false);
     $csvReader->setColumnHeaders($headers->csvReaderArray());
     $workflow = new Workflow($csvReader);
     $doctrineWriter = new DoctrineWriter($this->em, $entity);
     $doctrineWriter->disableTruncate();
     $workflow->addWriter($doctrineWriter);
     $dateConverter = new DateConventer($fileRecord->getPlanDate());
     $weekNumberConverter = new WeekNumberConventer($fileRecord->getPlanDate());
     $planNameConverter = new PlanNameConventer($fileRecord->getName());
     $routeNameConventer = new RouteNameConventer($fileRecord->getPlanDate());
     $dateTimeNow = new DateTimeNow();
     $dateToMicroConventer = new TimeToMicroConventer();
     $timeConverter = new DateTimeValueConverter('H:i');
     $uploadedBy = new UploadedBy($user);
     $planDateConvert = new PlanDateConvert($fileRecord->getPlanDate());
     //\Doctrine\Common\Util\Debug::dump($date->format('Y-m-d'));
     //die;
     $date = $fileRecord->getPlanDate();
     $workflow->setSkipItemOnFailure(true)->addValueConverter('routeNo', $routeNameConventer)->addValueConverter('startTime', $dateConverter)->addValueConverter('sourceDepotDepartureTime', $dateConverter)->addValueConverter('arrivalTime', $dateConverter)->addValueConverter('departTime', $dateConverter)->addValueConverter('endDepotArrivalTime', $dateConverter)->addValueConverter('tripStart', $dateConverter)->addValueConverter('destDepotArrivalTime', $dateConverter)->addValueConverter('destDepotDepartureTime', $dateConverter)->addValueConverter('sourceDepotArrivalTime2', $dateConverter)->addValueConverter('sourceDepotDepartureTime2', $dateConverter)->addValueConverter('startDepotDepartureTime', $dateConverter)->addValueConverter('endTime', $dateConverter)->addValueConverter('callDuration', $dateToMicroConventer)->addValueConverter('dutyTime', $dateToMicroConventer)->addValueConverter('driveTime', $dateToMicroConventer)->addValueConverter('emptyTime', $dateToMicroConventer)->addValueConverter('timeWindowStart', $dateConverter)->addValueConverter('timeWindowEnd', $dateConverter)->addValueConverter('uploadDate', $dateTimeNow)->addValueConverter('uploadedBy', $uploadedBy)->addValueConverter('planDate', $planDateConvert)->addValueConverter('planName', $planNameConverter)->addValueConverter('weekNumber', $weekNumberConverter);
     //        \Doctrine\Common\Util\Debug::dump($doctrineWriter);
     //        die;
     $result = $workflow->process();
     //update query to generate route and trip combination
     $query = $this->em->createQuery("UPDATE NTPBundle:ParagonData p SET p.routeNo = CONCAT(p.routeNo,'0', p.tripNo) " . "WHERE p.planDate=:date")->setParameter('date', $date);
     $query->execute();
     return $result;
 }
示例#2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $reader = new CsvReader(new \SplFileObject($input->getArgument("file")));
     $reader->setHeaderRowNumber(0);
     $workflow = new Workflow($reader);
     $workflow->addWriter(new IssueWriter($this->client));
     $workflow->process();
 }
示例#3
0
 /**
  * Import action
  *
  * @return Response
  *
  * @throws AccessDeniedException If access is not granted
  */
 public function importAction(Request $request)
 {
     if (false === $this->admin->isGranted('IMPORT')) {
         throw new AccessDeniedException();
     }
     $defaultData = array();
     $form = $this->createFormBuilder($defaultData)->add('file', 'file')->getForm();
     $form->handleRequest($request);
     $data = array();
     if ($form->isValid()) {
         $fs = new Filesystem();
         try {
             $fs->mkdir('/tmp/import');
         } catch (IOExceptionInterface $e) {
             echo "An error occurred while creating your directory at " . $e->getPath();
         }
         $form['file']->getData()->move('/tmp/import', 'data.csv');
         $file = new \SplFileObject('/tmp/import/data.csv');
         // this must be done to import CSVs where one of the data-field has CRs within!
         $file->setFlags(\SplFileObject::READ_CSV | \SplFileObject::SKIP_EMPTY | \SplFileObject::READ_AHEAD);
         $reader = new Reader\CsvReader($file, ';');
         $reader->setHeaderRowNumber(0);
         if ($request->request->has('btn_preview')) {
             foreach ($reader as $row) {
                 $data[] = $row;
             }
         } else {
             // Set Database into "nonchecking Foreign Keys"
             $em = $this->getDoctrine()->getManager();
             $em->getConnection()->exec("SET FOREIGN_KEY_CHECKS=0;");
             $writer = new DoctrineWriter($em, "AppBundle:Partner");
             $writer->setTruncate(false);
             $metadata = $em->getClassMetaData("AppBundle:Partner");
             $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
             $mapping = new Step\MappingStep();
             $mapping->map('[country_code]', '[country]');
             $mapping->map('[category]', '[partnerCategory]');
             $converter = new StringToObjectConverter($em->getRepository("AppBundle:PartnerCategory"), 'name');
             $valueConverterStep = new Step\ValueConverterStep();
             $valueConverterStep->add('[partnerCategory]', $converter);
             //                $converter = new CustomValueConverter();
             //                $converterStep = new Step\ConverterStep();
             //                $converterStep->add($converter);
             $workflow = new Workflow\StepAggregator($reader);
             $workflow->addStep($mapping);
             $workflow->addStep($valueConverterStep);
             //                $workflow->addStep($converterStep);
             $workflow->addWriter($writer);
             $workflow->process();
             // Resetting Database Check Status
             $em->getConnection()->exec("SET FOREIGN_KEY_CHECKS=1;");
         }
     }
     $formView = $form->createView();
     // set the theme for the current Admin Form
     $this->get('twig')->getExtension('form')->renderer->setTheme($formView, $this->admin->getFilterTheme());
     return $this->render('CRUD/import_partner.html.twig', array('action' => 'import', 'form' => $formView, 'data' => $data));
 }
示例#4
0
 public function getReader(\SplFileObject $file)
 {
     $reader = new CsvReader($file, $this->delimiter, $this->enclosure, $this->escape);
     if (null !== $this->headerRowNumber) {
         $reader->setHeaderRowNumber($this->headerRowNumber);
     }
     $reader->setStrict($this->strict);
     return $reader;
 }
示例#5
0
 /**
  *
  * @param string $path
  * @return \CsvReader
  */
 static function csv_reader($path, $setFirstRowAsHeader = true)
 {
     if (empty($path)) {
         return false;
     }
     $file = new \SplFileObject($path);
     $csvReader = new CsvReader($file, ';');
     if ($setFirstRowAsHeader) {
         $csvReader->setHeaderRowNumber(0);
     }
     return $csvReader;
 }
 public function prepare_data($file)
 {
     echo '<h3>Choose the positions to import</h3>';
     echo '<form id="CSVImport" name="CSVImport" method="post" enctype="multipart/form-data">';
     $file = new \SplFileObject($file);
     $reader = new CsvReader($file);
     $reader->setHeaderRowNumber(0);
     $this->results_table($reader);
     $this->setup_data($reader);
     echo '<br />';
     $this->button('Confirm Import', true);
     echo '</form>';
 }
 /**
  * Import action
  *
  * @return Response
  *
  * @throws AccessDeniedException If access is not granted
  */
 public function importAction(Request $request)
 {
     if (false === $this->admin->isGranted('IMPORT')) {
         throw new AccessDeniedException();
     }
     //        $workflow = new Workflow($reader);
     /*
             $result = $workflow
                 ->addWriter(new Writer\DoctrineWriter())
                 ->addFilter(new Filter\CallbackFilter())
                     ->setSkipItemOnFailure(true)
                     ->process()
                 ;
     */
     $defaultData = array();
     $form = $this->createFormBuilder($defaultData)->add('file', 'file')->getForm();
     $form->handleRequest($request);
     $data = array();
     if ($form->isValid()) {
         if ($request->request->has('btn_preview')) {
             print_r('PREVIEW');
         }
         $fs = new Filesystem();
         try {
             $fs->mkdir('/tmp/randomtest');
         } catch (IOExceptionInterface $e) {
             echo "An error occurred while creating your directory at " . $e->getPath();
         }
         $form['file']->getData()->move('/tmp/randomtest', 'data.csv');
         $file = new \SplFileObject('/tmp/randomtest/data.csv');
         //            $data = $form->getData();
         $reader = new Reader\CsvReader($file);
         $reader->setHeaderRowNumber(0);
         foreach ($reader as $row) {
             // $row will be an array containing the comma-separated elements of the line:
             // array(
             //   0 => 'James',
             //   1 => 'Bond'
             //   etc...
             // )
             $data[] = $row;
         }
     }
     $formView = $form->createView();
     // set the theme for the current Admin Form
     $this->get('twig')->getExtension('form')->renderer->setTheme($formView, $this->admin->getFilterTheme());
     return $this->render('CRUD/import.html.twig', array('action' => 'import', 'form' => $formView, 'data' => $data));
 }
示例#8
0
 /**
  * @param \SplFileObject $file
  * @param array          $data
  * @return array
  */
 public function getCsvHeader(\SplFileObject $file, &$data)
 {
     $csvReader = new CsvReader($file, $data['delimiter']);
     $csvReader->setHeaderRowNumber(0, 1);
     $csvReader->setStrict(false);
     $data['count'] = $csvReader->count();
     $data['header'] = $csvReader->getColumnHeaders();
     if ($csvReader->hasErrors() || count($csvReader->getFields()) <= 1) {
         $this->setError('error read file');
     } else {
         $row = $csvReader->getRow(1);
         foreach ($row as $key => $value) {
             $data['first'][$key] = $value;
         }
     }
     return $data;
 }
    public function setCsvReader($file)
    {
        if (isset( $this->importFolder )) {
            $path = $this->importFolder . $file;
        } else {
            $path = $file;
        }
        if (is_readable($path)) {
            $splFile      = new \SplFileObject($path);
            $this->reader = new CsvReader($splFile, ",");
            $this->reader->setHeaderRowNumber(0, CsvReader::DUPLICATE_HEADERS_MERGE);

            return $this->reader;
        } else {
            return false;
        }
    }
示例#10
0
 /**
  * Parse attachments
  *
  * @return array    Returns array with failed or success data
  *                  (See parser-common/src/Parser.php) for more info.
  */
 public function parse()
 {
     foreach ($this->parsedMail->getAttachments() as $attachment) {
         // Only use the Abusehub formatted reports, skip all others
         if (preg_match(config("{$this->configBase}.parser.report_file"), $attachment->filename)) {
             // Create temporary working environment for the parser ($this->tempPath, $this->fs)
             $this->createWorkingDir();
             file_put_contents($this->tempPath . $attachment->filename, $attachment->getContent());
             $csvReader = new Reader\CsvReader(new SplFileObject($this->tempPath . $attachment->filename));
             $csvReader->setHeaderRowNumber(0);
             // Loop through all csv reports
             foreach ($csvReader as $report) {
                 if (!empty($report['report_type'])) {
                     $this->feedName = $report['report_type'];
                     // If feed is known and enabled, validate data and save report
                     if ($this->isKnownFeed() && $this->isEnabledFeed()) {
                         // Sanity check
                         if ($this->hasRequiredFields($report) === true) {
                             // incident has all requirements met, filter and add!
                             $report = $this->applyFilters($report);
                             $incident = new Incident();
                             $incident->source = config("{$this->configBase}.parser.name");
                             $incident->source_id = false;
                             $incident->ip = $report['src_ip'];
                             $incident->domain = false;
                             $incident->class = config("{$this->configBase}.feeds.{$this->feedName}.class");
                             $incident->type = config("{$this->configBase}.feeds.{$this->feedName}.type");
                             $incident->timestamp = strtotime($report['event_date'] . ' ' . $report['event_time']);
                             $incident->information = json_encode($report);
                             $this->incidents[] = $incident;
                         }
                     }
                 } else {
                     // We cannot parse this report, since we haven't detected a report_type.
                     $this->warningCount++;
                 }
             }
             // end foreach: loop through csv lines
         }
         // end if: found report file to parse
     }
     // end foreach: loop through attachments
     return $this->success();
 }
 /**
  * @Route("/cargadatos", name="cargador_deudores")
  */
 public function indexAction()
 {
     // Inicializamos el objeto file
     try {
         $this->filepath = $this->getFilePath();
         $file = new \SplFileObject($this->filepath);
     } catch (\Exception $e) {
         echo " Se ha producido una Excepción: ", $e->getMessage(), "\n";
     }
     //Declaramos el reader
     $reader = new CsvReader($file);
     //$reader->setStrict(false);
     $reader->setHeaderRowNumber(0);
     // Necesitamos un logger
     $logger = $this->get('logger');
     //Declaramos el Flujo de Trabajo
     // Declaramos el writer
     // Conseguimos el manager de Doctrine
     $em = $this->getDoctrine()->getManager();
     // Generamos el Writter de Doctrine
     $this->writer = new DoctrineWriter($em, 'AppBundle:Deudores');
     // Generamos el converter
     $this->converter = new DateTimeValueConverter('Y-m-d H:i');
     $this->workflow = new Workflow($reader, $logger, 'Importación CSV');
     $this->resultado = $this->workflow->addWriter($this->writer)->setSkipItemOnFailure(true)->addValueConverter('fechaInclusion', $this->converter)->process();
     //  Procesamos el workflow
     //$this->workflow->process();
     $data = array();
     $data['Nombre'] = $this->resultado->getName();
     //$data['Total Datos Importados']=$this->resultado->getSuccessCount();
     $data['Fecha Inicio'] = $this->resultado->getStartTime();
     $data['Fecha Fin'] = $this->resultado->getEndTime();
     $data['Duración'] = $this->resultado->getElapsed();
     $data['Número de Errores'] = $this->resultado->getErrorCount();
     $data['Tiene Errores'] = $this->resultado->hasErrors();
     $data['Tiene Excepciones'] = $this->resultado->getExceptions();
     // Finalmente presentamos los datos
     $engine = $this->container->get('templating');
     $content = $engine->render('dataimport/index.html.twig', array('data' => $data));
     return new Response($content);
 }
示例#12
0
 public function load()
 {
     $reader = new CsvReader($this->getFile(), $this->getOption('delimiter'), $this->getOption('enclosure'), $this->getOption('escape'));
     $headers = $this->getOption('headers');
     $headerRow = $this->getOption('header_row');
     if (false !== $headerRow) {
         $duplicateHeaders = $headers == 'merge' ? CsvReader::DUPLICATE_HEADERS_MERGE : CsvReader::DUPLICATE_HEADERS_INCREMENT;
         $reader->setHeaderRowNumber($headerRow, $duplicateHeaders);
     }
     if (is_array($headers)) {
         $reader->setColumnHeaders($headers);
     } elseif ('number' == $headers) {
         $headers = [];
         for ($i = 1; $i <= count($reader->getColumnHeaders()); ++$i) {
             $headers[] = 'field' . $i;
         }
         $reader->setColumnHeaders($headers);
     }
     $reader->setStrict($this->getOption('strict'));
     return $this->setReader($reader);
 }
示例#13
0
 /**
  * @Route("/student",name="admin_sse_icss_student_import")
  */
 public function studentAction(Request $request)
 {
     $uploadedFile = $request->files->get("csvFile");
     if (!$uploadedFile) {
         return [];
     }
     $import = getcwd() . "/Import";
     $fname = "input.csv";
     $filename = $import . "/" . $fname;
     @mkdir($import);
     @unlink($filename);
     $uploadedFile->move($import, $fname);
     $file = new \SplFileObject($filename);
     $reader = new CsvReader($file);
     $reader->setHeaderRowNumber(0);
     $workflow = new Workflow($reader);
     $em = $this->getDoctrine()->getEntityManager();
     $em->getConnection()->exec("SET FOREIGN_KEY_CHECKS=0;");
     $resault = $workflow->addWriter(new DoctrineWriter($em, "SSEICSSBundle:Student"))->process();
     $em->getConnection()->exec("SET FOREIGN_KEY_CHECKS=1;");
     return [];
 }
示例#14
0
 public function importFileAction(Request $request)
 {
     // Get FileId to "import"
     $param = $request->request;
     $fileId = (int) trim($param->get("fileId"));
     $curType = trim($param->get("fileType"));
     $uploadedFile = $request->files->get("csvFile");
     // if upload was not ok, just redirect to "AdminStatWrongPArameters"
     if (!CSVTypes::existsType($curType) || $uploadedFile == null) {
         return 0;
     }
     // generate dummy dir
     $dummyImport = getcwd() . "/dummyImport";
     $fname = "directly.csv";
     $filename = $dummyImport . "/" . $fname;
     @mkdir($dummyImport);
     @unlink($filename);
     // move file to dummy filename
     $uploadedFile->move($dummyImport, $fname);
     echo "Starting to Import " . $filename . ", Type: " . CSVTypes::getNameOfType($curType) . "<br/>";
     // open file
     $source = new StreamSource($filename);
     if ($source === false) {
         die("Can't open filestream {$filename}");
     }
     $file = $source->getFile();
     if ($file === false) {
         die("Can't open file {$filename}");
     }
     // Create and configure the reader
     $csvReader = new CsvReader($file, ";");
     if ($csvReader === false) {
         die("Can't create csvReader {$filename}");
     }
     $csvReader->setHeaderRowNumber(1);
     var_dump($csvReader);
     // this must be done to import CSVs where one of the data-field has CRs within!
     $file->setFlags(\SplFileObject::READ_CSV | \SplFileObject::SKIP_EMPTY | \SplFileObject::READ_AHEAD);
     echo "etape";
     var_dump($file);
     // Set Database into "nonchecking Foreign Keys"
     $em = $this->getDoctrine()->getManager();
     $em->getConnection()->exec("SET FOREIGN_KEY_CHECKS=0;");
     // Create the workflow
     $workflow = new Workflow($csvReader);
     if ($workflow === false) {
         die("Can't create workflow {$filename}");
     }
     $curEntityClass = CSVTypes::getEntityClass($curType);
     $writer = new DoctrineWriter($em, $curEntityClass);
     $writer->setTruncate(false);
     $entityMetadata = $em->getClassMetadata($curEntityClass);
     $entityMetadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_AUTO);
     // $entityMetadata->setIdGeneratorType(Doctrine\ORM\Mapping\::GENERATOR_TYPE_NONE);
     $workflow->addWriter($writer);
     $workflow->process();
     // RESetting Database Check Status
     $em->getConnection()->exec("SET FOREIGN_KEY_CHECKS=1;");
     // After successfully import, some files need special treatment --> Reset some DB fields
     /* if ($curType==CSVTypes::STOCK) {
          $q=$em->createQuery("UPDATE AdminAdminBundle:Product s
                            SET s.description = false");
            $q->execute();
        }*/
     // var_dump($workflow);
     return $this->render('SuppliercheckAdminBundle:Default:csv_import.html.twig');
 }
 public function importResourcesAction($file)
 {
     $file = new \SplFileObject($file->getPathname());
     $reader = new CsvReader($file);
     $reader->setHeaderRowNumber(0);
     $data = ['resourcesTypes' => [], 'resources' => []];
     foreach ($reader as $row) {
         $resourceTypeName = ucfirst($row['resource_type']);
         $resourceName = ucfirst($row['name']);
         $maxTimeReservation = $row['max_time_reservation'];
         $description = ucfirst($row['description']);
         $localisation = ucfirst($row['localisation']);
         $quantity = $row['quantity'];
         $color = empty($row['color']) ? '#3a87ad' : $row['color'];
         $resourceType = $this->resourceTypeRepo->findOneBy(['name' => $resourceTypeName]);
         if (!$resourceType) {
             $resourceType = new ResourceType();
             $resourceType->setName($resourceTypeName);
             $this->em->persist($resourceType);
             $this->em->flush();
             $data['resourcesTypes'][] = ['id' => $resourceType->getId(), 'name' => $resourceType->getName()];
         }
         $resource = new Resource();
         $resource->setResourceType($resourceType)->setName($resourceName)->setMaxTimeReservation($maxTimeReservation)->setDescription($description)->setLocalisation($localisation)->setQuantity($quantity)->setColor($color);
         $this->em->persist($resource);
         $this->em->flush();
         $data['resources'][] = ['resourceTypeId' => $resourceType->getId(), 'resource' => ['id' => $resource->getId(), 'name' => $resourceName]];
     }
     return $data;
 }
示例#16
0
 public function importFileAction(Request $request)
 {
     /*
      * $import = new Import();
      *
      *
      * $em2 = $this->getDoctrine()->getManager();
      * $em2->persist($import);
      * $em2->flush();
      * $i = $import->getId();
      * var_dump($i);
      */
     // Get FileId to "import"
     $param = $request->request;
     $fileId = (int) trim($param->get("fileId"));
     $curType = trim($param->get("fileType"));
     $uploadedFile = $request->files->get("csvFile");
     // if upload was not ok, just redirect to "AdminStatWrongPArameters"
     if (!CSVTypes::existsType($curType) || $uploadedFile == null) {
         return 0;
     }
     // generate dummy dir
     $dummyImport = getcwd() . "/dummyImport";
     $fname = "directly.csv";
     $filename = $dummyImport . "/" . $fname;
     @mkdir($dummyImport);
     @unlink($filename);
     // move file to dummy filename
     $uploadedFile->move($dummyImport, $fname);
     // Create and configure the reader
     $file = new \SplFileObject('dummyImport/directly.csv', "r");
     // $file->setFlags(SplFileObject::READ_CSV);
     $csvReader = new CsvReader($file, ";");
     // var_dump($csvReader);
     // Tell the reader that the first row in the CSV file contains column headers
     $csvReader->setHeaderRowNumber(0);
     // 		foreach ($csvReader as $row => $value) {
     // 			$value['sku'] = '1' ;
     // 		}
     // Create the workflow from the reader
     $workflow = new Workflow($csvReader);
     // Create a writer: you need Doctrine’s EntityManager.
     $em = $this->getDoctrine()->getManager();
     $doctrineWriter = new DoctrineWriter($em, 'SuppliercheckAdminBundle:Data');
     // $doctrineWriter->writeItem(array ('import', 'test'));
     /*
      * $em = $this->getDoctrine()->getManager();
      * $query = $em->createQuery(
      * 'SELECT p
      * FROM AcmeStoreBundle:Product p
      * WHERE p.price > :price
      * ORDER BY p.price ASC'
      * )->setParameter('price', '19.99');
      *
      * $products = $query->getResult();
      */
     // $doctrineWriter->setTruncate(false);
     /*
      * $doctrineWriter
      * ->prepare()
      * ->writeItem(
      * array(
      * 'voila' => $i,
      *
      * )
      * );
      */
     // $doctrineWriter->setTruncate(false);
     $workflow->addWriter($doctrineWriter);
     // $em3=$this->getDoctrine()->getManager();
     // $doctrineR = new DoctrineReader($em3, 'AdminAdminBundle:Data');
     // $fields =$doctrineR->getFields();
     // $workflow2 = new Workflow($doctrineR);
     // $entityMetadata=$em->getClassMetadata('AdminAdminBundle:Product');
     // $entityMetadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_AUTO);
     // $converter = new StringToDateTimeValueConverter();
     $converter = new MappingItemConverter();
     $converter->addMapping('id_catalog_simple', 'idCatalogSimple')->addMapping('created_at_external', 'createdAtExternal')->addMapping('updated_at_external', 'updatedAtExternal')->addMapping('created_at', 'createdAt')->addMapping('updated_at', 'updatedAt')->addMapping('special_price', 'specialPrice')->addMapping('special_from_date', 'specialFromDate')->addMapping('special_to_date', 'specialToDate')->addMapping('tax_class', 'taxClass')->addMapping('tax_class_2', 'taxClass2')->addMapping('original_price', 'originalPrice')->addMapping('base_price', 'basePrice')->addMapping('barcode_ean', 'barcodeEan')->addMapping('sku_supplier_simple', 'skuSupplierSimple')->addMapping('supplier_simple_name', 'supplierSimpleName')->addMapping('shipment_type', 'shipmentType')->addMapping('transport_type', 'transportType')->addMapping('is_global', 'isGlobal')->addMapping('shipment_cost', 'shipmentCost')->addMapping('shipment_cost_comment', 'shipmentCostComment')->addMapping('dreamroom_show_in_image_map', 'dreamroomShowInImageMap')->addMapping('dreamroom_image_map_x', 'dreamroomImageMapX')->addMapping('dreamroom_image_map_y', 'dreamroomImageMapY')->addMapping('xcart_sku', 'xcartSku')->addMapping('delivery_date_start', 'deliveryDateStart')->addMapping('delivery_date_end', 'deliveryDateEnd')->addMapping('docdata_ean', 'docdataEan')->addMapping('docdata_description', 'docdataDescription')->addMapping('docdata_weight', 'docdataWeight')->addMapping('custom_identifier', 'customIdentifier')->addMapping('expected_delivery_date_start', 'expectedDeliveryDateStart')->addMapping('expected_delivery_date_end', 'expectedDeliveryDateEnd')->addMapping('navision_flag', 'navisionFlag')->addMapping('delivery_day_min', 'deliveryDayMin')->addMapping('delivery_day_max', 'deliveryDayMax')->addMapping('additional_inbound_info', 'additionalInboundInfo')->addMapping('expected_gm1', 'expectedGm1')->addMapping('expected_gm2', 'expectedGm2')->addMapping('expected_gm3', 'expectedGm3')->addMapping('sum_gross_weight', 'sumGrossWeight')->addMapping('number_separate_packages', 'numberSeparatePackages')->addMapping('delay_reasons', 'delayReasons')->addMapping('hide_original_price', 'hideOriginalPrice')->addMapping('producer_name', 'producerName')->addMapping('producer_address', 'producerAddress')->addMapping('additional_2mh_service', 'additional2mhService')->addMapping('additional_2mh_service_price', 'additional2mhServicePrice')->addMapping('is_bundle', 'isBundle')->addMapping('id_catalog_config_westwing', 'idCatalogConfigWestwing')->addMapping('design_scout', 'designScout')->addMapping('logistic_lead', 'logisticLead')->addMapping('id_catalog_simple_westwing', 'idCatalogSimpleWestwing')->addMapping('supplier_identifier', 'supplierIdentifier')->addMapping('config_group', 'configGroup')->addMapping('attribute_set', 'attributeSet')->addMapping('id_catalog_config', 'idCatalogConfig')->addMapping('sku_config', 'skuConfig')->addMapping('status_config', 'statusConfig')->addMapping('name_other', 'nameOther')->addMapping('editor_opinion', 'editorOpinion')->addMapping('choice_of_description', 'choiceOfDescription')->addMapping('display_as_out_of_stock', 'displayAsOutOfStock')->addMapping('pet_status', 'petStatus')->addMapping('pet_approved', 'petApproved')->addMapping('activated_at', 'activatedAt')->addMapping('sku_supplier_config', 'skuSupplierConfig')->addMapping('name_supplier', 'nameSupplier')->addMapping('delivery_period', 'deliveryPeriod')->addMapping('main_material', 'mainMaterial')->addMapping('package_height', 'packageHeight')->addMapping('package_length', 'packageLength')->addMapping('package_width', 'packageWidth')->addMapping('package_weight', 'packageWeight')->addMapping('short_description', 'shortDescription')->addMapping('care_label', 'careLabel')->addMapping('next_simple_nr', 'nextSimpleNr')->addMapping('brand_name_for_theme_campaigns', 'brandNameForThemeCampaigns')->addMapping('advent_day', 'adventDay')->addMapping('advent_url', 'adventUrl')->addMapping('advent_path', 'adventPath')->addMapping('overwrite_delivery_period', 'overwriteDeliveryPeriod')->addMapping('is_seo_relevant', 'isSeoRelevant')->addMapping('export_static', 'exportStatic')->addMapping('is_hybris_product', 'isHybrisProduct')->addMapping('has_delivery_guarantee', 'hasDeliveryGuarantee')->addMapping('net_purchase_price', 'netPurchasePrice')->addMapping('net_purchase_price_discounted', 'netPurchasePriceDiscounted')->addMapping('supplier_product_number', 'supplierProductNumber')->addMapping('supplier_product_name', 'supplierProductName')->addMapping('local_stock', 'localStock')->addMapping('global_stock', 'globalStock')->addMapping('package1_length', 'package1Length')->addMapping('package1_height', 'package1Height')->addMapping('package1_width', 'package1Width')->addMapping('package1_weight', 'package1Weight')->addMapping('package2_length', 'package2Length')->addMapping('package2_height', 'package2Height')->addMapping('package2_width', 'package2Width')->addMapping('package2_weight', 'package2Weight')->addMapping('package3_length', 'package3Length')->addMapping('package3_height', 'package3Height')->addMapping('package3_width', 'package3Width')->addMapping('package3_weight', 'package3Weight')->addMapping('color_1', 'color1')->addMapping('color_2', 'color2')->addMapping('color_3', 'color3')->addMapping('color_characteristic', 'colorCharacteristic')->addMapping('additional_campaigns', 'additionalCampaigns')->addMapping('status_simple', 'statusSimple')->addMapping('expected_logistics_cost', 'expectedLogisticsCost')->addMapping('discount_level', 'discountLevel')->addMapping('blowout_round', 'blowoutRound')->addMapping('allow_multiple_po', 'allowMultiplePo');
     // Process the workflow
     // $workflow->addValueConverter('import', $i);
     $workflow->addItemConverter($converter)->process();
     //$workflow2->process();
     /*  	
         	$doctrineWriterId = new DoctrineWriter($em3, 'AdminAdminBundle:Data');
         	$doctrineWriterId
         	->prepare()
         	->writeItem(
         			array(
         					'importId' => '$i',
         	
         			)
         	)
         	->finish();*/
     //$reader =$doctrineWriterId = new DoctrineWriter($em3, 'AdminAdminBundle:Data');
     /*	$em3=$this->getDoctrine()->getManager();
         	$doctrineWriterId = new DoctrineWriter($em3, 'AdminAdminBundle:Data');
         	$doctrineWriterId
         	->prepare()
         	->writeItem(
         			array(
         					'importId' => '$i',
         	
         			)
         	)
         	->finish();
         	$workflow2 = new Workflow($doctrineWriterId);
         	$workflow2->process();
     		//var_dump($workflow);
     		//$b = new csv() ;
     		$em2 = $this->getDoctrine()->getManager();
     		
     		$em3 = $this->getDoctrine()->getManager();
     		
     		//$em2->persist($import);
     		//$em2->flush();
     		//$i = $import->getId();
     		$A = $em2->getRepository('AdminAdminBundle:Data');
     		//$B = new csv() ;
     		$B = clone $A;
     		//$B->setId(null);
     		//$B = new csv() ;
     
     		//$B->setIdCatalogConfig('11');
     		//$em3->persist($B);
     		$em3->flush();
     		$em2->flush();
     		var_dump($B);
     		*/
     return $this->render('SuppliercheckAdminBundle:Default:csv_import.html.twig');
 }
示例#17
0
 /**
  * @Secure(roles={"ROLE_RCA"})
  */
 public function importAction()
 {
     $form = $this->createForm('enigmatic_crm_account_import');
     $form->handleRequest($this->get('request'));
     if ($form->isSubmitted() && $form->isValid()) {
         $account_manager = $this->get('enigmatic_crm.manager.account');
         $data = $form->getData();
         $file = new \SplFileObject($data['file']);
         $reader = new CsvReader($file, ';');
         $reader->setHeaderRowNumber(0);
         foreach ($reader as $row) {
             $row = array_map(function ($str) {
                 return iconv("Windows-1252", "UTF-8", $str);
             }, $row);
             $account = $account_manager->create();
             $account->setName($row['Nom']);
             $account->setSiret($row['Siret']);
             $account->setAddress($row['Adresse']);
             $account->setAddressCpl($row['Adresse Cpl']);
             $account->setPhone($row['Telephone']);
             $account->setFax($row['Fax']);
             $account->setActivity($row['Activite']);
             $account->setCity($this->get('enigmatic_city.manager.city')->getByZipcode($row['Code postal']));
             $errors = $this->get('validator')->validate($account);
             if (count($errors)) {
                 $error_as_string = '';
                 foreach ($errors as $error) {
                     $error_as_string .= '<br/>&nbsp;&nbsp;&nbsp;' . $this->get('translator')->trans('enigmatic.crm.account.field.' . $error->getPropertyPath() . '.name') . ' : ' . $error->getMessage();
                 }
                 $this->get('session')->getFlashBag()->add('error', $this->get('translator')->trans('enigmatic.crm.account_import.messages.error.%account%.%errors%', array('%account%' => $account->getName(), '%errors%' => $error_as_string)));
             } else {
                 $account_manager->save($account);
                 if ($this->get('security.authorization_checker')->isGranted('ROLE_RS')) {
                     if (count($data['agencies'])) {
                         foreach ($data['agencies'] as $agency) {
                             $this->get('enigmatic_crm.manager.agency_account')->save($this->get('enigmatic_crm.manager.agency_account')->create($account, $agency));
                         }
                     }
                 }
                 if (count($data['owners'])) {
                     foreach ($data['owners'] as $user) {
                         $this->get('enigmatic_crm.manager.account_owner')->save($this->get('enigmatic_crm.manager.account_owner')->create($account, $user));
                     }
                 }
                 $this->get('session')->getFlashBag()->add('success', $this->get('translator')->trans('enigmatic.crm.account_import.messages.success.%account%', array('%account%' => $account->getName())));
             }
         }
         $this->get('session')->getFlashBag()->add('success', $this->get('translator')->trans('enigmatic.crm.account_import.messages.success.import'));
         return $this->redirect($this->generateUrl('enigmatic_crm_account_import'));
     }
     return $this->get('enigmatic.render')->render($this->renderView('EnigmaticCRMBundle:Account:import.html.twig', array('form' => $form->createView())));
 }
示例#18
0
 /**
  * ImportProcess action
  *
  * @param $request
  * @return Response
  *
  * @throws AccessDeniedException If access is not granted
  */
 public function importProcessAction(Request $request)
 {
     if (false === $this->admin->isGranted('IMPORT')) {
         throw new AccessDeniedException();
     }
     $file = new \SplFileObject('/tmp/import/product_import.csv');
     // this must be done to import CSVs where one of the data-field has CRs within!
     $file->setFlags(\SplFileObject::READ_CSV | \SplFileObject::SKIP_EMPTY | \SplFileObject::READ_AHEAD);
     $reader = new Reader\CsvReader($file, ';');
     $reader->setHeaderRowNumber(0);
     $choices = array(null => 'Nicht importieren', 'id' => 'Id', 'productNumber' => 'Artikelnummer', 'productCategory' => 'Artikelkategorie', 'translations.name' => 'Name', 'translations.description' => 'Beschreibung', 'memo' => 'Memo', 'enabled' => 'Aktiv', 'basePrice' => 'Basispreis', 'unitOfQuantity' => 'Mengeneinheit');
     $defaultData = array();
     $builder = $this->createFormBuilder($defaultData);
     $builder->add('language', ChoiceType::class, array('choices' => array('de' => 'Deutsch', 'en' => 'Englisch', 'fr' => 'Franzoesisch', 'it' => 'Italienisch')));
     $builder->add('onlyUpdate', CheckboxType::class, array('label' => 'Nur Update, keine neuen Saetze importieren', 'required' => false));
     $headers = array();
     foreach ($reader->getColumnHeaders() as $header) {
         preg_match_all('/\\((.*?)\\)/', $header, $out);
         $header = $out[1] ? $out[1][0] : $header;
         $headers[] = $header;
         $builder->add($header, 'choice', array('required' => false, 'label' => false, 'choices' => $choices));
     }
     $form = $builder->getForm();
     $form->handleRequest($request);
     $data = array();
     foreach ($reader as $row) {
         $data[] = $row;
     }
     $mapping = null;
     if ($form->isValid()) {
         if ($request->request->has('btn_confirm')) {
             $formData = $form->getData();
             // Set Database into "nonchecking Foreign Keys"
             $em = $this->getDoctrine()->getManager();
             $em->getConnection()->exec("SET FOREIGN_KEY_CHECKS=0;");
             $writer = new DoctrineWriter($em, "AppBundle:Product", array('productNumber'), $formData['language']);
             $writer->setTruncate(false);
             $metadata = $em->getClassMetaData("AppBundle:Product");
             $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
             //                **************************************
             //                Excel Verwurschtelt die Artikelnummer.
             //                **************************************
             $filter = new Step\ConverterStep();
             $filter->add(function ($v) {
                 unset($v['--NONE--']);
                 if (array_key_exists('id', $v)) {
                     $v['id'] = intval($v['id']);
                 }
                 return $v;
             });
             $filter->add(function ($v) {
                 if (array_key_exists('basePrice', $v)) {
                     $v['basePrice'] = intval($v['basePrice']);
                 }
                 return $v;
             });
             $filter->add(function ($v) {
                 if (!array_key_exists('enabled', $v)) {
                     $v['enabled'] = true;
                 }
                 return $v;
             });
             $mapping = new Step\MappingStep();
             foreach ($headers as $header) {
                 $newMap = $formData[$header] ? $formData[$header] : '--NONE--';
                 $mapping->map('[' . $header . ']', '[' . $newMap . ']');
             }
             $converter = new Step\ValueConverterStep();
             $converter->add('[productCategory]', function ($id) {
                 $repository = $this->getDoctrine()->getRepository('AppBundle:ProductCategory');
                 $category = $repository->findOneById($id);
                 return $category;
             });
             $converter->add('[unitOfQuantity]', function ($id) {
                 $repository = $this->getDoctrine()->getRepository('AppBundle:UnitOfQuantity');
                 $uoq = $repository->findOneById($id);
                 return $uoq;
             });
             $workflow = new Workflow\StepAggregator($reader);
             $workflow->addStep($mapping);
             $workflow->addStep($filter);
             $workflow->addStep($converter);
             $workflow->addWriter($writer);
             $workflow->process();
             // Resetting Database Check Status
             $em->getConnection()->exec("SET FOREIGN_KEY_CHECKS=1;");
             return $this->render('CRUD/import_product_category_finish.html.twig', array('action' => 'import'));
         }
     }
     $formView = $form->createView();
     // set the theme for the current Admin Form
     $this->get('twig')->getExtension('form')->renderer->setTheme($formView, $this->admin->getFilterTheme());
     return $this->render('CRUD/import_product_category_process.html.twig', array('action' => 'import', 'form' => $formView, 'data' => $data, 'headers' => $headers));
 }
 public function updateEntityAction($object)
 {
     //override createAction in line 66;
     //get path and set the file
     $path = '../web/media/' . $object->getPath();
     $file = new \SplFileObject($path);
     //check extension to read
     if ($object->getExtension() == 'csv') {
         $reader = new CsvReader($file, ',');
         $reader->setHeaderRowNumber(0);
     } else {
         if ($object->getExtension() == 'xls' || $object->getExtension() == 'xlsx') {
             $reader = new ExcelReader($file, 0);
         }
     }
     //find Key :applicationKey
     $readerAllHeader = $reader->getColumnHeaders();
     foreach ($readerAllHeader as $readerHeader) {
         if (preg_match("/applicationKey/i", $readerHeader)) {
             $key = $readerHeader;
         }
     }
     $em = $this->getDoctrine()->getManager();
     $em->getConnection()->beginTransaction();
     // suspend auto-commit
     //$doctrineWriter = new DoctrineWriter($em, 'LmcAdmissionBundle:Test','appPrefix');
     $doctrineWriter = new DoctrineWriter($em, 'LmcAdmissionBundle\\Entity\\Application', $key);
     $doctrineWriter->disableTruncate();
     $doctrineWriter->prepare();
     $line = 1;
     $fail = 0;
     $error_line = array();
     $dateField = array('createdAt', 'deletedAt', 'updatedAt', 'birthDate');
     try {
         foreach ($reader as $row) {
             foreach ($dateField as $field) {
                 if (!$row[$field]) {
                     unset($row[$field]);
                 } else {
                     $dateConverter = strtotime($row[$field]);
                     $new_dateConverter = date_create(date('Y-m-d H:i:s', $dateConverter));
                     $row[$field] = $new_dateConverter;
                 }
             }
             //                if(is_float($row['interviewDate'])){
             //                    $temp = date('Y-m-d H:i:s', $row['interviewDate']);
             //                    $row['interviewDate'] = $temp;
             //                }
             $line++;
             $doctrineWriter->writeItem($row);
             if ($doctrineWriter->getFail() != $fail) {
                 $error_line[] = $line;
                 $fail = $doctrineWriter->getFail();
             }
         }
         $success = $doctrineWriter->getSuccess();
         $doctrineWriter->finish();
         $em->getConnection()->commit();
         if ($fail != 0) {
             $log = 'sccess:' . $success . ' fail:' . $fail . ' line (' . implode(",", $error_line) . ')';
         } else {
             $log = 'sccess:' . $success . ' fail:' . $fail;
         }
         $object->setLog($log);
         $em->persist($object);
         $em->flush();
     } catch (Exception $e) {
         $em->getConnection()->rollback();
         throw $e;
     }
 }
示例#20
0
 /**
  * Import  from csv
  * using https://github.com/ddeboer/data-import
  *
  * @Route("/import/{filetype}/{entity}/{id}", name="import_upload")
  */
 public function importAction($id, $filetype, $entity)
 {
     $em = $this->getDoctrine()->getManager();
     // Create and configure the reader
     $upload = $em->getRepository('AppBundle:Upload')->find($id);
     $path = $this->get('kernel')->getRootDir() . '/../uploads/' . $upload->getName();
     $entity_namespace = 'AppBundle:' . $entity;
     $entity_redirect = $entity;
     $file = new \SplFileObject($path);
     $csvReader = new CsvReader($file);
     // Tell the reader that the first row in the CSV file contains column headers
     $csvReader->setHeaderRowNumber(0);
     $csvReader->setStrict(FALSE);
     // Create the workflow from the reader
     $workflow = new Workflow($csvReader);
     // Create a writer: you need Doctrine’s EntityManager.
     $doctrineWriter = new DoctrineWriter($em, $entity_namespace);
     $doctrineWriter->disableTruncate();
     $workflow->addWriter($doctrineWriter);
     // Process the workflow
     $workflow->process();
     return $this->redirect($this->generateUrl(strtolower($entity_redirect)));
 }
示例#21
0
 /**
  * Creates a new Campaign entity.
  *
  */
 public function createAction(Request $request)
 {
     $entity = new Campaign();
     //         $product = new \Suppliercheck\SupplierBundle\Entity\Product();
     //         $product->setName('tag1');
     //         $product->setCampaignId(1);
     //         $entity->getProducts()->add($product);
     //         $em1 = $this->getDoctrine()->getManager();
     //         $em1->persist($product);
     //         $em1->flush();
     // Original create form
     // $form = $this->createCreateForm($entity);
     $request = $this->getRequest();
     $form = $this->createCreateForm($entity);
     //        	 $form->handleRequest($request);
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             //         	$form['file']->getData()->move($dir, $someNewFilename);
             $dummyImport = getcwd() . "/dummyImport";
             $fname = "directly.csv";
             $filename = $dummyImport . "/" . $fname;
             @mkdir($dummyImport);
             @unlink($filename);
             // move file to dummy filename
             $form['file']->getData()->move($dummyImport, $fname);
             // Create and configure the reader
             $file = new \SplFileObject('dummyImport/directly.csv', "r");
             // $file->setFlags(SplFileObject::READ_CSV);
             $csvReader = new CsvReader($file, ";");
             $csvReader->setHeaderRowNumber(0);
             // Create the workflow from the reader
             $workflow = new Workflow($csvReader);
             // Create a writer: you need Doctrine’s EntityManager.
             $em = $this->getDoctrine()->getManager();
             $doctrineWriter = new DoctrineWriter($em, 'SuppliercheckSupplierBundle:Import');
             $workflow->addWriter($doctrineWriter);
             $converter = new MappingItemConverter();
             $converter->addMapping('id_catalog_simple', 'idCatalogSimple')->addMapping('created_at_external', 'createdAtExternal')->addMapping('updated_at_external', 'updatedAtExternal')->addMapping('created_at', 'createdAt')->addMapping('updated_at', 'updatedAt')->addMapping('special_price', 'specialPrice')->addMapping('special_from_date', 'specialFromDate')->addMapping('special_to_date', 'specialToDate')->addMapping('tax_class', 'taxClass')->addMapping('tax_class_2', 'taxClass2')->addMapping('original_price', 'originalPrice')->addMapping('base_price', 'basePrice')->addMapping('barcode_ean', 'barcodeEan')->addMapping('sku_supplier_simple', 'skuSupplierSimple')->addMapping('supplier_simple_name', 'supplierSimpleName')->addMapping('shipment_type', 'shipmentType')->addMapping('transport_type', 'transportType')->addMapping('is_global', 'isGlobal')->addMapping('shipment_cost', 'shipmentCost')->addMapping('shipment_cost_comment', 'shipmentCostComment')->addMapping('dreamroom_show_in_image_map', 'dreamroomShowInImageMap')->addMapping('dreamroom_image_map_x', 'dreamroomImageMapX')->addMapping('dreamroom_image_map_y', 'dreamroomImageMapY')->addMapping('xcart_sku', 'xcartSku')->addMapping('delivery_date_start', 'deliveryDateStart')->addMapping('delivery_date_end', 'deliveryDateEnd')->addMapping('docdata_ean', 'docdataEan')->addMapping('docdata_description', 'docdataDescription')->addMapping('docdata_weight', 'docdataWeight')->addMapping('custom_identifier', 'customIdentifier')->addMapping('expected_delivery_date_start', 'expectedDeliveryDateStart')->addMapping('expected_delivery_date_end', 'expectedDeliveryDateEnd')->addMapping('navision_flag', 'navisionFlag')->addMapping('delivery_day_min', 'deliveryDayMin')->addMapping('delivery_day_max', 'deliveryDayMax')->addMapping('additional_inbound_info', 'additionalInboundInfo')->addMapping('expected_gm1', 'expectedGm1')->addMapping('expected_gm2', 'expectedGm2')->addMapping('expected_gm3', 'expectedGm3')->addMapping('sum_gross_weight', 'sumGrossWeight')->addMapping('number_separate_packages', 'numberSeparatePackages')->addMapping('delay_reasons', 'delayReasons')->addMapping('hide_original_price', 'hideOriginalPrice')->addMapping('producer_name', 'producerName')->addMapping('producer_address', 'producerAddress')->addMapping('additional_2mh_service', 'additional2mhService')->addMapping('additional_2mh_service_price', 'additional2mhServicePrice')->addMapping('is_bundle', 'isBundle')->addMapping('id_catalog_config_westwing', 'idCatalogConfigWestwing')->addMapping('design_scout', 'designScout')->addMapping('logistic_lead', 'logisticLead')->addMapping('id_catalog_simple_westwing', 'idCatalogSimpleWestwing')->addMapping('supplier_identifier', 'supplierIdentifier')->addMapping('config_group', 'configGroup')->addMapping('attribute_set', 'attributeSet')->addMapping('id_catalog_config', 'idCatalogConfig')->addMapping('sku_config', 'skuConfig')->addMapping('status_config', 'statusConfig')->addMapping('name_other', 'nameOther')->addMapping('editor_opinion', 'editorOpinion')->addMapping('choice_of_description', 'choiceOfDescription')->addMapping('display_as_out_of_stock', 'displayAsOutOfStock')->addMapping('pet_status', 'petStatus')->addMapping('pet_approved', 'petApproved')->addMapping('activated_at', 'activatedAt')->addMapping('sku_supplier_config', 'skuSupplierConfig')->addMapping('name_supplier', 'nameSupplier')->addMapping('delivery_period', 'deliveryPeriod')->addMapping('main_material', 'mainMaterial')->addMapping('package_height', 'packageHeight')->addMapping('package_length', 'packageLength')->addMapping('package_width', 'packageWidth')->addMapping('package_weight', 'packageWeight')->addMapping('short_description', 'shortDescription')->addMapping('care_label', 'careLabel')->addMapping('next_simple_nr', 'nextSimpleNr')->addMapping('brand_name_for_theme_campaigns', 'brandNameForThemeCampaigns')->addMapping('advent_day', 'adventDay')->addMapping('advent_url', 'adventUrl')->addMapping('advent_path', 'adventPath')->addMapping('overwrite_delivery_period', 'overwriteDeliveryPeriod')->addMapping('is_seo_relevant', 'isSeoRelevant')->addMapping('export_static', 'exportStatic')->addMapping('is_hybris_product', 'isHybrisProduct')->addMapping('has_delivery_guarantee', 'hasDeliveryGuarantee')->addMapping('net_purchase_price', 'netPurchasePrice')->addMapping('net_purchase_price_discounted', 'netPurchasePriceDiscounted')->addMapping('supplier_product_number', 'supplierProductNumber')->addMapping('supplier_product_name', 'supplierProductName')->addMapping('local_stock', 'localStock')->addMapping('global_stock', 'globalStock')->addMapping('package1_length', 'package1Length')->addMapping('package1_height', 'package1Height')->addMapping('package1_width', 'package1Width')->addMapping('package1_weight', 'package1Weight')->addMapping('package2_length', 'package2Length')->addMapping('package2_height', 'package2Height')->addMapping('package2_width', 'package2Width')->addMapping('package2_weight', 'package2Weight')->addMapping('package3_length', 'package3Length')->addMapping('package3_height', 'package3Height')->addMapping('package3_width', 'package3Width')->addMapping('package3_weight', 'package3Weight')->addMapping('color_1', 'color1')->addMapping('color_2', 'color2')->addMapping('color_3', 'color3')->addMapping('color_characteristic', 'colorCharacteristic')->addMapping('additional_campaigns', 'additionalCampaigns')->addMapping('status_simple', 'statusSimple')->addMapping('expected_logistics_cost', 'expectedLogisticsCost')->addMapping('discount_level', 'discountLevel')->addMapping('blowout_round', 'blowoutRound')->addMapping('allow_multiple_po', 'allowMultiplePo');
             $workflow->addItemConverter($converter)->process();
             //fin de l'import dans la table virtuelle IMPORT
             //copie des données avec mise en place des relations One TO Many
             $em1 = $this->getDoctrine()->getManager();
             $getData = new ArrayCollection();
             $getData = $em1->getRepository('SuppliercheckSupplierBundle:Import');
             $listData = $getData->findAll();
             foreach ($listData as $value) {
                 $newProduct = new Product();
                 $newProduct->setCampaign($entity);
                 $newProduct->createFromImport($value);
                 $sku = $newProduct->getSku();
                 $newProduct->setLink($sku);
                 $entity->getProducts()->add($newProduct);
                 $newProduct = $value;
             }
             //         	$entity->addProducts($value);
             //var_dump($entity);
             //         	$user->getAuthoredComments()->add($newComment);
             //         	$newComment->setAuthor($user);
             $em = $this->getDoctrine()->getManager();
             $em->persist($entity);
             $em->flush();
             return $this->redirect($this->generateUrl('supplier_campaign_show', array('id' => $entity->getId())));
         }
     }
     //         if ($form->isValid()) {
     //             $em = $this->getDoctrine()->getManager();
     //             $em->persist($entity);
     //             $em->flush();
     //             return $this->redirect($this->generateUrl('supplier_campaign_show', array('id' => $entity->getId())));
     //         }
     return $this->render('SuppliercheckSupplierBundle:Campaign:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }
示例#22
0
 public function testInvalidCsv()
 {
     $file = new \SplFileObject(__DIR__ . '/../Fixtures/data_column_headers_varying_element_count.csv');
     $reader = new CsvReader($file);
     $reader->setHeaderRowNumber(0);
     $this->assertTrue($reader->hasErrors());
     $this->assertCount(2, $reader->getErrors());
     $errors = $reader->getErrors();
     $this->assertEquals(2, key($errors));
     $this->assertEquals(array('123', 'test'), current($errors));
     next($errors);
     $this->assertEquals(3, key($errors));
     $this->assertEquals(array('7', '7890', 'Some more info', 'too many columns'), current($errors));
 }
 private function formatToReader(Format $format, \SplFileInfo $file)
 {
     if ($format instanceof CsvFormat) {
         $reader = new CsvReader($file->openFile(), $format->getDelimiter(), $format->getEnclosure(), $format->getEscape());
         $reader->setStrict(false);
         if ($format->isHeaderInFirstRow()) {
             $reader->setHeaderRowNumber(0, CsvReader::DUPLICATE_HEADERS_MERGE);
             $reader->setColumnHeaders(array_map('trim', $reader->getColumnHeaders()));
             //TODO some header-collaborator?
         }
     } elseif ($format instanceof ExcelFormat) {
         $headerRowNumber = $format->isHeaderInFirstRow() ? 0 : null;
         $reader = new ExcelReader($file->openFile(), $headerRowNumber, $format->getActivesheet());
         if ($format->isHeaderInFirstRow()) {
             $reader->setColumnHeaders(array_map('trim', $reader->getColumnHeaders()));
             //TODO some header-collaborator?
         }
     } elseif ($format instanceof JsonFormat) {
         $array = json_decode(file_get_contents($file), true);
         $reader = new ArrayReader($array);
     } elseif ($format instanceof XmlFormat) {
         $reader = new XmlReader($file->openFile(), $format->getXpath());
     } elseif ($format instanceof CompressedFormat && $format->getSubFormat()) {
         $reader = $this->formatToReader($format->getSubFormat(), $format->getInsideStream($file));
     } else {
         throw new InvalidConfigurationException('Cannot build reader. Unknown format: ' . $format);
     }
     return $reader;
 }
示例#24
0
 public function createAction(Request $request = null)
 {
     // the key used to lookup the template
     $templateKey = 'edit';
     if (false === $this->admin->isGranted('CREATE')) {
         throw new AccessDeniedException();
     }
     $object = $this->admin->getNewInstance();
     $this->admin->setSubject($object);
     /** @var $form \Symfony\Component\Form\Form */
     $form = $this->admin->getForm();
     $form->setData($object);
     if ($this->getRestMethod() == 'POST') {
         $form->submit($this->get('request'));
         $isFormValid = $form->isValid();
         // persist if the form was valid and if in preview mode the preview was approved
         if ($isFormValid && (!$this->isInPreviewMode() || $this->isPreviewApproved())) {
             if (false === $this->admin->isGranted('CREATE', $object)) {
                 throw new AccessDeniedException();
             }
             try {
                 $dummyImport = getcwd() . "/dummyImport";
                 $fname = "directly.csv";
                 $filename = $dummyImport . "/" . $fname;
                 @mkdir($dummyImport);
                 @unlink($filename);
                 // move file to dummy filename
                 $form['file']->getData()->move($dummyImport, $fname);
                 // Create and configure the reader
                 $file = new \SplFileObject('dummyImport/directly.csv', "r");
                 // $file->setFlags(SplFileObject::READ_CSV);
                 $csvReader = new CsvReader($file, ";");
                 $csvReader->setHeaderRowNumber(0);
                 // Create the workflow from the reader
                 $workflow = new Workflow($csvReader);
                 // Create a writer: you need Doctrine’s EntityManager.
                 $em = $this->getDoctrine()->getManager();
                 $doctrineWriter = new DoctrineWriter($em, 'SuppliercheckAdminBundle:Import');
                 $workflow->addWriter($doctrineWriter);
                 $converter = new MappingItemConverter();
                 $converter->addMapping('id_catalog_simple', 'idCatalogSimple')->addMapping('created_at_external', 'createdAtExternal')->addMapping('updated_at_external', 'updatedAtExternal')->addMapping('created_at', 'createdAt')->addMapping('updated_at', 'updatedAt')->addMapping('special_price', 'specialPrice')->addMapping('special_from_date', 'specialFromDate')->addMapping('special_to_date', 'specialToDate')->addMapping('tax_class', 'taxClass')->addMapping('tax_class_2', 'taxClass2')->addMapping('original_price', 'originalPrice')->addMapping('base_price', 'basePrice')->addMapping('barcode_ean', 'barcodeEan')->addMapping('sku_supplier_simple', 'skuSupplierSimple')->addMapping('supplier_simple_name', 'supplierSimpleName')->addMapping('shipment_type', 'shipmentType')->addMapping('transport_type', 'transportType')->addMapping('is_global', 'isGlobal')->addMapping('shipment_cost', 'shipmentCost')->addMapping('shipment_cost_comment', 'shipmentCostComment')->addMapping('dreamroom_show_in_image_map', 'dreamroomShowInImageMap')->addMapping('dreamroom_image_map_x', 'dreamroomImageMapX')->addMapping('dreamroom_image_map_y', 'dreamroomImageMapY')->addMapping('xcart_sku', 'xcartSku')->addMapping('delivery_date_start', 'deliveryDateStart')->addMapping('delivery_date_end', 'deliveryDateEnd')->addMapping('docdata_ean', 'docdataEan')->addMapping('docdata_description', 'docdataDescription')->addMapping('docdata_weight', 'docdataWeight')->addMapping('custom_identifier', 'customIdentifier')->addMapping('expected_delivery_date_start', 'expectedDeliveryDateStart')->addMapping('expected_delivery_date_end', 'expectedDeliveryDateEnd')->addMapping('navision_flag', 'navisionFlag')->addMapping('delivery_day_min', 'deliveryDayMin')->addMapping('delivery_day_max', 'deliveryDayMax')->addMapping('additional_inbound_info', 'additionalInboundInfo')->addMapping('expected_gm1', 'expectedGm1')->addMapping('expected_gm2', 'expectedGm2')->addMapping('expected_gm3', 'expectedGm3')->addMapping('sum_gross_weight', 'sumGrossWeight')->addMapping('number_separate_packages', 'numberSeparatePackages')->addMapping('delay_reasons', 'delayReasons')->addMapping('hide_original_price', 'hideOriginalPrice')->addMapping('producer_name', 'producerName')->addMapping('producer_address', 'producerAddress')->addMapping('additional_2mh_service', 'additional2mhService')->addMapping('additional_2mh_service_price', 'additional2mhServicePrice')->addMapping('is_bundle', 'isBundle')->addMapping('id_catalog_config_westwing', 'idCatalogConfigWestwing')->addMapping('design_scout', 'designScout')->addMapping('logistic_lead', 'logisticLead')->addMapping('id_catalog_simple_westwing', 'idCatalogSimpleWestwing')->addMapping('supplier_identifier', 'supplierIdentifier')->addMapping('config_group', 'configGroup')->addMapping('attribute_set', 'attributeSet')->addMapping('id_catalog_config', 'idCatalogConfig')->addMapping('sku_config', 'skuConfig')->addMapping('status_config', 'statusConfig')->addMapping('name_other', 'nameOther')->addMapping('editor_opinion', 'editorOpinion')->addMapping('choice_of_description', 'choiceOfDescription')->addMapping('display_as_out_of_stock', 'displayAsOutOfStock')->addMapping('pet_status', 'petStatus')->addMapping('pet_approved', 'petApproved')->addMapping('activated_at', 'activatedAt')->addMapping('sku_supplier_config', 'skuSupplierConfig')->addMapping('name_supplier', 'nameSupplier')->addMapping('delivery_period', 'deliveryPeriod')->addMapping('main_material', 'mainMaterial')->addMapping('package_height', 'packageHeight')->addMapping('package_length', 'packageLength')->addMapping('package_width', 'packageWidth')->addMapping('package_weight', 'packageWeight')->addMapping('short_description', 'shortDescription')->addMapping('care_label', 'careLabel')->addMapping('next_simple_nr', 'nextSimpleNr')->addMapping('brand_name_for_theme_campaigns', 'brandNameForThemeCampaigns')->addMapping('advent_day', 'adventDay')->addMapping('advent_url', 'adventUrl')->addMapping('advent_path', 'adventPath')->addMapping('overwrite_delivery_period', 'overwriteDeliveryPeriod')->addMapping('is_seo_relevant', 'isSeoRelevant')->addMapping('export_static', 'exportStatic')->addMapping('is_hybris_product', 'isHybrisProduct')->addMapping('has_delivery_guarantee', 'hasDeliveryGuarantee')->addMapping('net_purchase_price', 'netPurchasePrice')->addMapping('net_purchase_price_discounted', 'netPurchasePriceDiscounted')->addMapping('supplier_product_number', 'supplierProductNumber')->addMapping('supplier_product_name', 'supplierProductName')->addMapping('local_stock', 'localStock')->addMapping('global_stock', 'globalStock')->addMapping('package1_length', 'package1Length')->addMapping('package1_height', 'package1Height')->addMapping('package1_width', 'package1Width')->addMapping('package1_weight', 'package1Weight')->addMapping('package2_length', 'package2Length')->addMapping('package2_height', 'package2Height')->addMapping('package2_width', 'package2Width')->addMapping('package2_weight', 'package2Weight')->addMapping('package3_length', 'package3Length')->addMapping('package3_height', 'package3Height')->addMapping('package3_width', 'package3Width')->addMapping('package3_weight', 'package3Weight')->addMapping('color_1', 'color1')->addMapping('color_2', 'color2')->addMapping('color_3', 'color3')->addMapping('color_characteristic', 'colorCharacteristic')->addMapping('additional_campaigns', 'additionalCampaigns')->addMapping('status_simple', 'statusSimple')->addMapping('expected_logistics_cost', 'expectedLogisticsCost')->addMapping('discount_level', 'discountLevel')->addMapping('blowout_round', 'blowoutRound')->addMapping('allow_multiple_po', 'allowMultiplePo');
                 $workflow->addItemConverter($converter)->process();
                 //fin de l'import dans la table virtuelle IMPORT
                 //copie des données avec mise en place des relations One TO Many
                 $em1 = $this->getDoctrine()->getManager();
                 $getData = new ArrayCollection();
                 $getData = $em1->getRepository('SuppliercheckAdminBundle:Import');
                 $listData = $getData->findAll();
                 foreach ($listData as $value) {
                     $newProduct = new Product();
                     $newProduct->setCampaign($object);
                     $newProduct->createFromImport($value);
                     $sku = $newProduct->getSku();
                     $newProduct->setLink($sku);
                     $newProduct->setValidated(false);
                     $newProduct->setComments(null);
                     $object->getProducts()->add($newProduct);
                     $newProduct = $value;
                 }
                 //                    $object1 = $this->admin->create($object);
                 //                    $id = $this->admin->getNormalizedIdentifier($object);
                 //                    $o = $object1->getId();
                 //                    $idencode = md5($o);
                 //                    $object1->setUrlencode($idencode);
                 //                    $this->admin->create($object);
                 $object = $this->admin->create($object);
                 $id = $object->getId();
                 $idencode = md5($id);
                 $object->setUrlencode($idencode);
                 $this->admin->create($object);
                 if ($this->isXmlHttpRequest()) {
                     return $this->renderJson(array('result' => 'ok', 'objectId' => $this->admin->getNormalizedIdentifier($object)));
                 }
                 $this->addFlash('sonata_flash_success', $this->admin->trans('flash_create_success', array('%name%' => $this->escapeHtml($this->admin->toString($object))), 'SonataAdminBundle'));
                 // redirect to edit mode
                 return $this->redirectTo($object);
             } catch (ModelManagerException $e) {
                 $this->logModelManagerException($e);
                 $isFormValid = false;
             }
         }
         // show an error message if the form failed validation
         if (!$isFormValid) {
             if (!$this->isXmlHttpRequest()) {
                 $this->addFlash('sonata_flash_error', $this->admin->trans('flash_create_error', array('%name%' => $this->escapeHtml($this->admin->toString($object))), 'SonataAdminBundle'));
             }
         } elseif ($this->isPreviewRequested()) {
             // pick the preview template if the form was valid and preview was requested
             $templateKey = 'preview';
             $this->admin->getShow();
         }
     }
     $view = $form->createView();
     // set the theme for the current Admin Form
     $this->get('twig')->getExtension('form')->renderer->setTheme($view, $this->admin->getFormTheme());
     return $this->render($this->admin->getTemplate($templateKey), array('action' => 'create', 'form' => $view, 'object' => $object));
 }
 protected function readArquivoExtrato($endereco = '')
 {
     $file = new \SplFileObject($endereco);
     $reader = new CsvReader($file);
     $reader->setHeaderRowNumber(0);
     return $reader;
 }
 public function validate($file, Constraint $constraint)
 {
     if ($file) {
         $file = new \SplFileObject($file->getPathname());
         $reader = new CsvReader($file);
         $reader->setHeaderRowNumber(0);
         foreach ($reader as $lineNb => $row) {
             $lineNb = $lineNb + 1;
             if (count($row) !== 7) {
                 $this->context->addViolation('invalid_number_of_column', ['%lineNb%' => $lineNb]);
                 return;
             }
             $columnHeaders = ['resource_type', 'name', 'max_time_reservation', 'description', 'localisation', 'quantity', 'color'];
             foreach ($columnHeaders as $name) {
                 if (!array_key_exists($name, $row)) {
                     $this->context->addViolation('invalid_column_headers', ['%columnName%' => $name]);
                     return;
                 }
             }
             if (strlen($row['resource_type']) < 2 || strlen($row['resource_type']) > 50) {
                 $this->context->addViolation('invalid_number_characters_resource_type', ['%lineNb%' => $lineNb]);
                 return;
             }
             if (strlen($row['name']) < 2 || strlen($row['name']) > 50) {
                 $this->context->addViolation('invalid_number_characters_name', ['%lineNb%' => $lineNb]);
                 return;
             }
             $file2 = new \SplFileObject($file->getPathname());
             $reader2 = new CsvReader($file2);
             $reader2->setHeaderRowNumber(0);
             foreach ($reader2 as $lineNb2 => $row2) {
                 $lineNb2 = $lineNb2 + 1;
                 if ($lineNb !== $lineNb2 && strtolower($row['resource_type']) === strtolower($row2['resource_type']) && strtolower($row['name']) === strtolower($row2['name'])) {
                     $this->context->addViolation('double_resource_for_one_resource_type', ['%lineNb1%' => $lineNb, '%lineNb2%' => $lineNb2]);
                     return;
                 }
             }
             if (!empty($row['max_time_reservation']) && !preg_match('#^[0-9]+:[0-9]{2}(:[0-9]{2})?$#', $row['max_time_reservation'])) {
                 $this->context->addViolation('invalid_type_for_max_time_reservation', ['%lineNb%' => $lineNb]);
                 return;
             }
             if (strlen($row['localisation']) > 255) {
                 $this->context->addViolation('invalid_number_characters_localisation', ['%lineNb%' => $lineNb]);
                 return;
             }
             if (intval($row['quantity']) < 1) {
                 $this->context->addViolation('invalid_number_quantity', ['%lineNb%' => $lineNb]);
                 return;
             }
             if (!preg_match('/#[a-zA-Z0-9]{6}/', $row['color']) && !empty($row['color'])) {
                 $this->context->addViolation('invalid_color_format', ['%lineNb%' => $lineNb]);
                 return;
             }
             $resourceType = $this->em->getRepository('FormaLibreReservationBundle:ResourceType')->findOneBy(['name' => $row['resource_type']]);
             if ($resourceType) {
                 $resource = $this->em->getRepository('FormaLibreReservationBundle:Resource')->findBy(['resourceType' => $resourceType->getId(), 'name' => $row['name']]);
                 if ($resource) {
                     $this->context->addViolation('resource_already_exists_for_resource_type', ['%lineNb%' => $lineNb]);
                     return;
                 }
             }
         }
     }
 }
示例#27
0
 public function importCsv($daysAgo, $analyzeCache)
 {
     if (!$analyzeCache) {
         $this->downloadReports($daysAgo);
     }
     $files = glob($this->download_directory . '*');
     // get all file names
     $shadow_server_csv_rows = array();
     foreach ($files as $file) {
         // iterate files
         if (is_file($file)) {
             $csv_file = new \SplFileObject($file);
             $reader = new CsvReader($csv_file);
             $reader->setHeaderRowNumber(0);
             foreach ($reader as $row) {
                 $header = array_keys($row);
                 $array_reader = new ArrayReader(array($row));
                 $workflow = new Workflow($array_reader);
                 $writer = new CsvWriter();
                 $shadow_server_report_evidence = '/tmp/' . uniqid('shadow_server_report_evidence') . ".csv";
                 touch($shadow_server_report_evidence);
                 chmod($shadow_server_report_evidence, 0777);
                 $writer->setStream(fopen($shadow_server_report_evidence, 'w'));
                 $writer->writeItem($header);
                 $workflow->addWriter($writer);
                 $workflow->process();
                 $reportType = $this->shadow_server_report_type_factory->getReportTypeFromCsvRow($row, $file, $shadow_server_report_evidence);
                 if ($reportType) {
                     $shadow_server_csv_rows[] = $reportType;
                 }
             }
         }
     }
     return $shadow_server_csv_rows;
 }
 /**
  * Parse attachments
  * @return array    Returns array with failed or success data
  *                  (See parser-common/src/Parser.php) for more info.
  */
 public function parse()
 {
     // Validate user based regex
     try {
         preg_match(config("{$this->configBase}.parser.file_regex"), '', $matches);
     } catch (\Exception $e) {
         $this->warningCount++;
         return $this->failed('Configuration error in the regular expression');
     }
     foreach ($this->parsedMail->getAttachments() as $attachment) {
         if (strpos($attachment->filename, '.zip') !== false && $attachment->contentType == 'application/octet-stream') {
             $zip = new Zipper();
             if (!$this->createWorkingDir()) {
                 return $this->failed("Unable to create working directory");
             }
             file_put_contents($this->tempPath . $attachment->filename, $attachment->getContent());
             $zip->zip($this->tempPath . $attachment->filename);
             $zip->extractTo($this->tempPath);
             foreach ($zip->listFiles() as $index => $compressedFile) {
                 if (strpos($compressedFile, '.csv') !== false) {
                     // For each CSV file we find, we are going to do magic (however they usually only send 1 zip)
                     if (preg_match(config("{$this->configBase}.parser.file_regex"), $compressedFile, $matches)) {
                         $this->feedName = $matches[1];
                         // If feed is known and enabled, validate data and save report
                         if ($this->isKnownFeed() && $this->isEnabledFeed()) {
                             $csvReports = new Reader\CsvReader(new SplFileObject($this->tempPath . $compressedFile));
                             $csvReports->setHeaderRowNumber(0);
                             foreach ($csvReports as $report) {
                                 // Handle field mappings first
                                 $aliasses = config("{$this->configBase}.feeds.{$this->feedName}.aliasses");
                                 if (is_array($aliasses)) {
                                     foreach ($aliasses as $alias => $real) {
                                         if (array_key_exists($alias, $report)) {
                                             $report[$real] = $report[$alias];
                                             unset($report[$alias]);
                                         }
                                     }
                                 }
                                 /*
                                  * Legacy 3.x fix for migrations.
                                  *
                                  * This resolves shadowserver errors where the CSV was send in duplicate resulting
                                  * in the header fields being used as data. If the header is detected the row can
                                  * be skipped safely
                                  */
                                 if ($report['ip'] === 'ip') {
                                     continue;
                                 }
                                 // Sanity check
                                 if ($this->hasRequiredFields($report) === true) {
                                     // incident has all requirements met, filter and add!
                                     $report = $this->applyFilters($report);
                                     $incident = new Incident();
                                     $incident->source = config("{$this->configBase}.parser.name");
                                     $incident->source_id = false;
                                     $incident->ip = $report['ip'];
                                     $incident->domain = false;
                                     $incident->class = config("{$this->configBase}.feeds.{$this->feedName}.class");
                                     $incident->type = config("{$this->configBase}.feeds.{$this->feedName}.type");
                                     $incident->timestamp = strtotime($report['timestamp']);
                                     $incident->information = json_encode($report);
                                     // some rows have a domain, which is an optional column we want to register
                                     switch ($this->feedName) {
                                         case "spam_url":
                                             if (isset($report['url'])) {
                                                 $incident->domain = getDomain($report['url']);
                                             }
                                             break;
                                         case "ssl_scan":
                                             if (isset($report['subject_common_name'])) {
                                                 /*
                                                  * Common name does not add http://, but that is required for
                                                  * the domain helper check so lets add it manually
                                                  */
                                                 $testurl = "http://{$report['subject_common_name']}";
                                                 $incident->domain = getDomain($testurl);
                                             }
                                             break;
                                         case "compromised_website":
                                             if (isset($report['http_host'])) {
                                                 $incident->domain = getDomain($report['http_host']);
                                             }
                                             break;
                                     }
                                     $this->incidents[] = $incident;
                                 }
                                 //End hasRequired fields
                             }
                             // End foreach report loop
                         }
                         // End isKnown & isEnabled
                     } else {
                         // Pregmatch failed to get feedName from attachment
                         $this->warningCount++;
                     }
                 } else {
                     // Attached file is not a CSV within a ZIP file
                     $this->warningCount++;
                 }
             }
             // End each file in ZIP attachment loop
         }
         // End if not a ZIP attachment
     }
     // End foreach attachment loop
     return $this->success();
 }
} else {
    $GLOBALS["newline"] = "\n";
    $_POST["user"] = $options['u'];
    $_POST["password"] = $options['p'];
    if (isset($options['t'])) {
        $_POST['test'] = true;
    }
    if (strpos('/', $options['f']) == false) {
        $csv = new SplFileObject(__DIR__ . '/../uploads/' . $options['f']);
    } else {
        $csv = new SplFileObject($options['f']);
    }
}
$newLine = $GLOBALS["newline"];
$reader = new CsvReader($csv);
$reader->setHeaderRowNumber(0);
$mappings = ['Project' => 'project', 'AssigneeGroup' => 'assigneeGroup', 'Summary' => 'summary'];
$mappingConverter = new MappingItemConverter($mappings);
echo $newLine . $newLine . "------------------------------" . $newLine . "    Youtrack csv importer     " . $newLine . "------------------------------" . $newLine;
if (null !== $authenticationAndSecurity->getPost("newline")) {
    echo "-- Testing progress --" . $newLine;
} else {
    echo "-- Progress --" . $newLine;
}
$workflow = new Workflow($reader);
$workflow->addItemConverter($mappingConverter)->addWriter(new ApiWriter())->process();
if (null !== $authenticationAndSecurity->getPost("newline")) {
    echo $newLine . "---- Test Finished -----" . $newLine;
} else {
    echo $newLine . "---- Upload Finished -----" . $newLine;
}