/**
  * @param Schema $schema
  */
 public function up(Schema $schema)
 {
     // this up() migration is auto-generated, please modify it to your needs
     $em = $this->container->get('doctrine')->getManager();
     $dataSet = ['MAGELLAN MARITIME SERVICES GMBH', 'UES INTERNATIONAL (HK) HOLDINGS LIMITED', 'SEACO SRL', 'FLORENS CONTAINER SERVICES CO LTD', 'SEACUBE CONTAINER LEASING', 'TOUAX', 'GRAND VIEW CONTAINER TRADING (HK) CO LTD'];
     foreach ($dataSet as $k => $v) {
         $organization = new Organization();
         $organization->setName($v);
         $em->persist($organization);
     }
     $em->flush();
     $em->clear();
 }
 /**
  * @param Schema $schema
  */
 public function up(Schema $schema)
 {
     // this up() migration is auto-generated, please modify it to your needs
     $em = $this->container->get('doctrine')->getManager();
     $dataSet = ['Sogeco', 'CAI (Container Applications International)', 'Textainer', 'TAL International Container Corporation', 'Beacon Intermodal', 'Triton Container International Limited '];
     foreach ($dataSet as $k => $v) {
         $organization = new Organization();
         $organization->setName($v);
         $em->persist($organization);
     }
     $em->flush();
     $em->clear();
 }
 /**
  * @param Schema $schema
  */
 public function up(Schema $schema)
 {
     // this up() migration is auto-generated, please modify it to your needs
     $em = $this->container->get('doctrine')->getManager();
     $dataSet = ['A.P. Moller–Maersk Group', 'CMA CGM S.A.'];
     foreach ($dataSet as $k => $v) {
         $organization = new Organization();
         $organization->setName($v);
         $em->persist($organization);
     }
     $em->flush();
     $em->clear();
 }
 /**
  * @param Schema $schema
  */
 public function up(Schema $schema)
 {
     $em = $this->container->get('doctrine')->getManager();
     $dataSet = ['APL' => ['APL' => 'American President Lines']];
     foreach ($dataSet as $k => $v) {
         $organization = new Organization();
         $organization->setName($k);
         $em->persist($organization);
         foreach ($v as $i => $j) {
             $subcontractor = new Subcontractor();
             $subcontractor->setOrganization($organization);
             $subcontractor->setCode($i);
             $subcontractor->setName($j);
             $em->persist($subcontractor);
         }
     }
     $em->flush();
     $em->clear();
 }
 /**
  * Parse sheet
  * @param \PHPExcel_Worksheet $sheet
  * @param bool $isEem
  */
 private function parseSheet(\PHPExcel_Worksheet $sheet, $isEem = false)
 {
     $this->setActiveWorksheet($sheet);
     $map = $this->getSheetMap($this->_objExcel->getIndex($sheet));
     $this->getMessageService()->addMessage("Start import sheet <i>{$sheet->getTitle()}</i>:", Message::TEXT);
     for ($startRow = 2; ($orgId = $this->getValueByColAndRow($map['OrganizationID'], $startRow)) == true; $startRow++) {
         $data = array_map(function ($col) use($startRow, $map) {
             return $this->getValueByColAndRow($col, $startRow);
         }, $map);
         if (isset($data['Action']) && strtoupper($data['Action']) == 'DELETED') {
             continue;
         }
         if (!is_numeric($data['LocationID'])) {
             $this->getMessageService()->addMessage('Location is not a number at line ' . $startRow, Message::WARNING);
             continue;
         }
         if (!$data['Organization']) {
             $this->getMessageService()->addMessage('Empty organization name at line ' . $startRow, Message::WARNING);
             continue;
         }
         if (!$data['LocationID']) {
             $this->getMessageService()->addMessage('Empty location id at line ' . $startRow, Message::WARNING);
             continue;
         }
         if (!isset($this->processedOrganizations[$orgId])) {
             $this->_em->getFilters()->disable('softdeleteable');
             $organization = $this->_em->getRepository('CoreBundle:Organization')->findOneBy(['customerCode' => $orgId, 'customer' => $this->customer->getId()]);
             $this->_em->getFilters()->enable('softdeleteable');
             if (!$organization) {
                 $organization = new Entity\Organization();
                 $this->counters['createdOrg']++;
             }
             $organization->setName($data['Organization'])->setCustomer($this->customer)->setCustomerCode($data['OrganizationID'])->setCustomNumber1(intval($isEem))->setDeletedAt(null);
             $this->processedOrganizations[$orgId] = $organization;
         } else {
             $organization = $this->processedOrganizations[$orgId];
             if ($organization->getName() && $this->stripValue($organization->getName()) != $this->stripValue($data['Organization'])) {
                 $this->getMessageService()->addMessage("Different organization name for orgId = {$orgId} at line " . $startRow, Message::ERROR);
                 continue;
             }
         }
         if (isset($data['Sign'])) {
             $organization->setSign($data['Sign']);
         }
         $this->_em->persist($organization);
         $this->_em->getFilters()->disable('softdeleteable');
         $location = $this->_em->getRepository('CoreBundle:OrganizationLocation')->findOneBy(['organization' => $organization->getId(), 'customerCode' => $data['LocationID']]);
         $this->_em->getFilters()->enable('softdeleteable');
         if (!$location) {
             $location = new Entity\OrganizationLocation();
             $this->counters['createdLoc']++;
         } else {
             $this->counters['updatedLoc']++;
         }
         if (!isset($this->locationsNames[$data['LocationID']])) {
             $this->locationsNames[$data['LocationID']] = $this->stripValue($data['LocationName']);
         } else {
             if ($this->locationsNames[$data['LocationID']] != $this->stripValue($data['LocationName'])) {
                 $this->getMessageService()->addMessage("Different location name for LocationId = {$data['LocationID']} at line " . $startRow, Message::ERROR);
                 continue;
             }
         }
         $location->setAlias($data['LocationName'])->setOrganization($organization)->setCustomer($this->customer)->setCustomerCode((int) $data['LocationID'])->setDeletedAt(null);
         if (isset($data['LocationDesc'])) {
             $location->setCustomText1($data['LocationDesc']);
         }
         if (isset($data['AgentID'])) {
             $location->setCustomNumber1((int) $data['AgentID'])->setCustomText2($data['AgentName']);
         }
         if (isset($data['TimeBuffer'])) {
             $location->setCustomNumber2((int) $data['TimeBuffer'])->setCustomNumber3((int) $data['ADP']);
         }
         $this->_em->persist($location);
         //remaining locations will be soft deleted
         if (isset($this->vendors[$orgId]['locs'][$data['LocationID']])) {
             unset($this->vendors[$orgId]['locs'][$data['LocationID']]);
         }
     }
 }
 private function addOrganization($name)
 {
     $org = new Entity\Organization();
     $org->setName($name);
     $org->setCustomer($this->_customer);
     $org->setCustomerCode(self::CUSTOMER_CODE);
     $this->_em->persist($org);
     return $org;
 }