Exemplo n.º 1
0
 /**
  * @Route("/signup", name="signup")
  */
 public function signupAction(Request $request)
 {
     if ($request->getMethod() == 'POST') {
         $account = $request->request->get('company');
         $user = $request->request->get('user');
         if ($account['name'] == '') {
             return $this->_result(['code' => '-1', 'mess' => 'empty_fields']);
         }
         if ($account['company'] == '') {
             return $this->_result(['code' => '-1', 'mess' => 'empty_fields']);
         }
         if ($account['site'] == '') {
             return $this->_result(['code' => '-1', 'mess' => 'empty_fields']);
         }
         if ($account['country'] == '') {
             return $this->_result(['code' => '-1', 'mess' => 'empty_fields']);
         }
         if ($user['name'] == '') {
             return $this->_result(['code' => '-1', 'mess' => 'empty_fields']);
         }
         if ($user['email'] == '') {
             return $this->_result(['code' => '-1', 'mess' => 'empty_fields']);
         }
         if ($user['passwd'] == '') {
             return $this->_result(['code' => '-1', 'mess' => 'empty_fields']);
         }
         //check user email
         if (!filter_var($user['email'], FILTER_VALIDATE_EMAIL)) {
             return $this->_result(['code' => '-1', 'mess' => 'wrong_email']);
         }
         //parse website
         if (strpos($account['site'], "http://") === false && strpos($account['site'], "https://") === false) {
             $account['site'] = 'http://' . $account['site'];
         }
         //check if company exists
         $companyDB = $this->getDoctrine()->getRepository('AppBundle:Company')->findOneBy(['account_name' => $account['name']]);
         if ($companyDB) {
             return $this->_result(['code' => '-1', 'mess' => 'company_exists']);
         }
         $activateCode = rand(11111111, 99999999);
         //add company
         $companyDB = new Company();
         $companyDB->setAccountName($account['name'])->setCompanyName($account['company'])->setUrl($account['site'])->setCountry($account['country'])->setTimezone($account['timezone'])->setActive('N')->setBanned('N')->setRegisteredAt(time())->setUpdatedAt(time())->setActivateCode($activateCode);
         $em = $this->getDoctrine()->getManager();
         $em->persist($companyDB);
         $em->flush();
         $companyId = $companyDB->getId();
         //add user
         $usersDB = new Users();
         $usersDB->setCompanyId($companyId)->setEmail($user['email'])->setName($user['name'])->setPasswd(md5($user['passwd']))->setTimezone($account['timezone'])->setAdmin('Y');
         $em->persist($usersDB);
         $em->flush();
         //send mail
         $message = \Swift_Message::newInstance()->setSubject('inWorkFlow registration')->setFrom(['*****@*****.**' => 'inWorkFlow'])->setTo([$user['email'] => $user['name']])->setBody($this->renderView('emails/registration.html.twig', ['user' => $user, 'company' => $account, 'activateCode' => $activateCode]), 'text/html');
         $this->get('mailer')->send($message);
         return $this->_result(['code' => '1']);
     } else {
         return $this->redirect('/', 301);
     }
 }
Exemplo n.º 2
0
 /**
  * @Given existen las siguientes compañías:
  */
 public function createCompanies(TableNode $tableNode)
 {
     $em = $this->getEntityManager();
     foreach ($tableNode->getHash() as $companyHash) {
         $company = new Company();
         $company->setName($companyHash['nombre']);
         $company->setNif($companyHash['nif']);
         $em->persist($company);
     }
     $em->flush();
 }
Exemplo n.º 3
0
 public function load(ObjectManager $manager)
 {
     $obj = new Company();
     $obj->setName("CAPella");
     $obj->setAddress("rue de l'église, 25");
     $obj->setCode("4000");
     $obj->setLocality("Boncelles");
     $obj->setTelSecretary("04225566");
     $obj->setUrlWeb("www.cap.be");
     $obj->setEmail("*****@*****.**");
     $obj->setDescription("Rien de spécial");
     $manager->persist($obj);
     $manager->flush();
 }
 /**
  * @Route("/", name="homepage")
  */
 public function indexAction(Request $request)
 {
     /** @var EntityManager $em */
     $em = $this->getDoctrine()->getManager();
     $user = new EnboxUser();
     $user->setName('Alan');
     $quotation = new Quotation();
     $quote = new Quote();
     $company = new Company();
     $company->setName('Enbox');
     $timeline = new Timeline();
     $timeline->setCompany($company);
     $qo = new QuotationOpenActivityItem();
     $qs = new QuoteSentActivityItem();
     $timeline->addActivity($qo);
     $timeline->addActivity($qs);
     $qo->setActor($user);
     $qo->setObject($quotation);
     $qo->setTarget($company);
     $qs->setActor($company);
     $qs->setObject($quote);
     $qs->setTarget($quotation);
     $em->persist($user);
     $em->persist($quotation);
     $em->persist($quote);
     $em->persist($company);
     $em->persist($qo);
     $em->persist($qs);
     $em->persist($timeline);
     $em->flush();
     //dump($company);
     $qb = new QueryBuilder($em);
     $qb->from('AppBundle:Timeline', 't')->select('t')->leftJoin('t.activities', 'ta');
     $timeline = $qb->getQuery()->execute();
     dump($timeline);
     $qb = new QueryBuilder($em);
     $qb->from('AppBundle:ActivityItem', 'a')->select('a');
     $activities = $qb->getQuery()->execute();
     dump($activities);
     return $this->render('default/result.html.twig', array("timeline" => $timeline[0], "activities" => $activities));
 }
Exemplo n.º 5
0
 /**
  * @param Company       $company
  * @param CompanyEntity $companyEntity
  *
  * @return CompanyEntity
  */
 public static function toEntity(Company $company, CompanyEntity $companyEntity)
 {
     $companyEntity->setId($company->id());
     $companyEntity->setName($company->getName());
     $companyEntity->setMainActivity($company->mainActivity()->code());
     $companyEntity->setLegalCode($company->getLegalCode());
     if ($company->users()) {
         foreach ($company->users() as $user) {
             $companyEntity->addUser($user);
         }
     }
     return $companyEntity;
 }
 protected function parseCompany($record)
 {
     $idno = $record[0];
     $title = $record[2];
     $address = $record[4];
     $director = $record[5];
     $company = new Company();
     $company->setIdno($idno);
     $company->setTitle($title);
     $company->setAddress($address);
     $company->setDirector($director);
     $this->em->persist($company);
 }
Exemplo n.º 7
0
 /**
  * @Route("/parserVera/6")
  */
 public function parserVera6Action($hot = false)
 {
     $em = $this->em;
     $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Вера Олимп');
     if ($company == null) {
         $company = new Company();
         $company->setTitle('Вера Олимп');
         $em->persist($company);
         $em->flush($company);
         $em->refresh($company);
     }
     $phpExcelObject = $this->container->get('phpexcel')->createPHPExcelObject($this->filePath);
     $num = 11;
     $city = $em->getRepository('AppBundle:City')->findOneById(2);
     while (true) {
         if ($phpExcelObject->setActiveSheetIndex(5)->getCell('A' . $num)->getValue() == '') {
             break;
         }
         $banner = new Banner();
         $banner->setCompany($company);
         $banner->setAdrs(explode("\n", $phpExcelObject->setActiveSheetIndex(5)->getCell('B' . $num)->getValue())[0]);
         $banner->setTitle(explode("\n", $phpExcelObject->setActiveSheetIndex(5)->getCell('B' . $num)->getValue())[0]);
         $banner->setBody($phpExcelObject->setActiveSheetIndex(5)->getCell('B' . $num)->getValue());
         $banner->setSide($phpExcelObject->setActiveSheetIndex(5)->getCell('R' . $num)->getValue());
         $banner->setCity($city);
         $banner->setGrp(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(5)->getCell('E' . $num)->getValue()));
         $banner->setGid($phpExcelObject->setActiveSheetIndex(5)->getCell('F' . $num)->getValue());
         $banner->setOts(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(5)->getCell('M' . $num)->getValue()));
         $banner->setPrice(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(5)->getCell('G' . $num)->getValue()));
         $banner->setPrice2(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(5)->getCell('G' . $num)->getValue() * 1.18));
         $banner->setTaxType('НДС (18%)');
         $banner->setPriceDeploy(str_replace(array(',', ' '), array('.', ''), $phpExcelObject->setActiveSheetIndex(5)->getCell('Q' . $num)->getValue()));
         $banner->setFormat('3x6');
         $banner->setType($phpExcelObject->setActiveSheetIndex(5)->getCell('O' . $num)->getValue());
         $banner->setArea(null);
         $banner->setLight($phpExcelObject->setActiveSheetIndex(5)->getCell('N' . $num)->getValue() == 'Да' || $phpExcelObject->setActiveSheetIndex(5)->getCell('N' . $num)->getValue() == 'да' ? 1 : 0);
         $banner->setImg(null);
         $banner->setLink($phpExcelObject->setActiveSheetIndex(5)->getCell('J' . $num)->getHyperlink()->getUrl());
         //            $pos = $this->getPosition($phpExcelObject->setActiveSheetIndex(5)->getCell('R'.$num)->getValue());
         //            $banner->setLongitude($pos[1]);
         //            $banner->setLatitude($pos[0]);
         //            if ($hot){
         //                $banner->setHot(true);
         //            }else{
         $banner->setHot(true);
         //            }
         $banner2 = $em->getRepository('AppBundle:Banner2')->findOneByTitle($banner->getTitle());
         if ($banner2) {
             $banner->setLatitude($banner2->getLatitude());
             $banner->setLongitude($banner2->getLongitude());
         } else {
             $banner->setLatitude(0);
             $banner->setLongitude(0);
         }
         $em->persist($banner);
         $em->flush($banner);
         $num++;
     }
     return true;
 }
Exemplo n.º 8
0
 public function parserGellary3Action($hot = false)
 {
     //        $this->filePath = $this->filePath.'G2.XLSX';
     $em = $this->em;
     $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Gallery  roller');
     if ($company == null) {
         $company = new Company();
         $company->setTitle('Gallery roller');
         $em->persist($company);
         $em->flush($company);
         $em->refresh($company);
     }
     $phpExcelObject = $this->container->get('phpexcel')->createPHPExcelObject($this->filePath);
     $num = 2;
     while (true) {
         if ($phpExcelObject->setActiveSheetIndex(0)->getCell('B' . $num)->getValue() == '') {
             break;
         }
         $banner = new Banner();
         $banner->setCompany($company);
         $banner->setAdrs($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setTitle($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setBody($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setSide($this->getSide($phpExcelObject->setActiveSheetIndex(0)->getCell('D' . $num)->getValue()));
         $city = $this->em->getRepository('AppBundle:City')->findOneByTitle($phpExcelObject->setActiveSheetIndex(0)->getCell('A' . $num)->getValue());
         if ($city == null) {
             $city = new City();
             $city->setTitle($phpExcelObject->setActiveSheetIndex(0)->getCell('A' . $num)->getValue());
             $em->persist($city);
             $em->flush($city);
             $em->refresh($city);
         }
         $banner->setCity($city);
         $banner->setGid($phpExcelObject->setActiveSheetIndex(0)->getCell('N' . $num)->getValue());
         $banner->setGrp(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('L' . $num)->getValue()));
         $banner->setOts(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('M' . $num)->getValue()));
         $banner->setPrice(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('J' . $num)->getValue()));
         $banner->setPrice2(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('I' . $num)->getValue()));
         $banner->setPriceDeploy(0);
         $banner->setTaxType('НДС (18%)');
         $banner->setFormat('small');
         $banner->setType($phpExcelObject->setActiveSheetIndex(0)->getCell('B' . $num)->getValue());
         $banner->setArea($phpExcelObject->setActiveSheetIndex(0)->getCell('W' . $num)->getValue());
         $banner->setLight($phpExcelObject->setActiveSheetIndex(0)->getCell('C' . $num)->getValue() == 'Да' || $phpExcelObject->setActiveSheetIndex(0)->getCell('C' . $num)->getValue() == 'да' ? 1 : 0);
         $banner->setImg($this->getImage($phpExcelObject->setActiveSheetIndex(0)->getCell('G' . $num)->getHyperlink()->getUrl()));
         $banner->setLink($phpExcelObject->setActiveSheetIndex(0)->getCell('G' . $num)->getHyperlink()->getUrl());
         if ($hot) {
             $banner->setHot(true);
         } else {
             $banner->setHot(false);
         }
         $url = 'http://geocode-maps.yandex.ru/1.x/?geocode=' . urlencode($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $content = file_get_contents($url);
         $XmlObj = simplexml_load_string($content);
         if (isset($XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)) {
             $pos['x'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[1];
             $pos['y'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[0];
         } else {
             $pos['x'] = 0;
             $pos['y'] = 0;
         }
         $banner->setLongitude($pos['y']);
         $banner->setLatitude($pos['x']);
         $banner = $this->setBanner($banner);
         $month = array('2015-06-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('O' . $num)->getFill()->getStartColor()->getRGB()), '2015-07-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('P' . $num)->getFill()->getStartColor()->getRGB()), '2015-08-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('Q' . $num)->getFill()->getStartColor()->getRGB()), '2015-09-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('R' . $num)->getFill()->getStartColor()->getRGB()), '2015-10-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('S' . $num)->getFill()->getStartColor()->getRGB()), '2015-11-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('T' . $num)->getFill()->getStartColor()->getRGB()), '2015-12-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('U' . $num)->getFill()->getStartColor()->getRGB()));
         $this->refreshStatus($banner, $month, array('date' => '2015-06-01', 'sale' => $hot));
         $num++;
         if ($num % 50 == 0) {
             sleep(rand(1, 5));
         }
     }
     return true;
 }
Exemplo n.º 9
0
 /**
  * @Route("/parserVera/6")
  */
 public function parserVera6Action()
 {
     $em = $this->getDoctrine()->getManager();
     $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Вера Олимп');
     if ($company == null) {
         $company = new Company();
         $company->setTitle('Вера Олимп');
         $em->persist($company);
         $em->flush($company);
         $em->refresh($company);
     }
     $phpExcelObject = $this->get('phpexcel')->createPHPExcelObject($this->filePath);
     $num = 11;
     while (true) {
         if ($phpExcelObject->setActiveSheetIndex(4)->getCell('A' . $num)->getValue() == '') {
             break;
         }
         $banner = new Banner();
         $banner->setCompany($company);
         $banner->setAdrs(explode("\n", $phpExcelObject->setActiveSheetIndex(4)->getCell('B' . $num)->getValue())[0]);
         $banner->setTitle(explode("\n", $phpExcelObject->setActiveSheetIndex(4)->getCell('B' . $num)->getValue())[0]);
         $banner->setBody($phpExcelObject->setActiveSheetIndex(4)->getCell('B' . $num)->getValue());
         $banner->setSide($phpExcelObject->setActiveSheetIndex(4)->getCell('C' . $num)->getValue());
         $banner->setCity('Московская область');
         $banner->setGrp(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(4)->getCell('E' . $num)->getValue()));
         $banner->setGid($phpExcelObject->setActiveSheetIndex(4)->getCell('F' . $num)->getValue());
         $banner->setPrice(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(4)->getCell('G' . $num)->getValue()));
         $banner->setPrice2(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(4)->getCell('G' . $num)->getValue()) * 1.18);
         $banner->setTaxType('НДС (18%)');
         $banner->setOts(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(4)->getCell('M' . $num)->getValue()));
         $banner->setFormat('3x6');
         $banner->setType($phpExcelObject->setActiveSheetIndex(4)->getCell('N' . $num)->getValue());
         $banner->setArea(null);
         $banner->setLight($phpExcelObject->setActiveSheetIndex(4)->getCell('Q' . $num)->getValue() == 'Да' || $phpExcelObject->setActiveSheetIndex(4)->getCell('Q' . $num)->getValue() == 'да' ? 1 : 0);
         $banner->setImg(null);
         $banner->setLink($phpExcelObject->setActiveSheetIndex(0)->getCell('J' . $num)->getHyperlink()->getUrl());
         $pos = $this->getPosition($phpExcelObject->setActiveSheetIndex(4)->getCell('R' . $num)->getValue());
         $banner->setLongitude($pos[1]);
         $banner->setLatitude($pos[0]);
         $em->persist($banner);
         $em->flush($banner);
         $num++;
     }
     return new Response('открылось');
 }
Exemplo n.º 10
0
 /**
  * @Route("/parserRus/{type}", name="parserRus")
  */
 public function parserRusAction($type)
 {
     set_time_limit(0);
     ini_set("memory_limit", "-1");
     //        if ($type == 1){
     //            $filename = '3x6/'.$filename.'.json';
     //        }elseif($type == 2){
     //            $filename = 'big/'.$filename;
     //        }
     if ($type == 1) {
         $folder = '3x6';
     } elseif ($type == 2) {
         $folder = 'big';
     }
     $em = $this->getDoctrine()->getManager();
     $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Russoutdoor');
     if ($company == null) {
         $company = new Company();
         $company->setTitle('Russoutdoor');
         $em->persist($company);
         $em->flush($company);
         $em->refresh($company);
     }
     $files = scandir($this->get('kernel')->getRootDir() . '/../web/' . $folder);
     unset($files[1]);
     unset($files[0]);
     foreach ($files as $f) {
         $filename = $this->get('kernel')->getRootDir() . '/../web/' . $folder . '/' . $f;
         $file = file_get_contents($filename);
         $array = json_decode($file, true);
         $i = 0;
         foreach ($array['billboards'] as $val) {
             if (isset($val['longtitude']) && isset($val['latitude']) && isset($val['address'])) {
                 $i++;
                 $banner = new Banner();
                 $city = $this->getDoctrine()->getRepository('AppBundle:City')->findOneByTitle($val['cityName']);
                 if ($city == null) {
                     $city = new City();
                     $city->setTitle($val['cityName']);
                     $em->persist($city);
                     $em->flush($city);
                     $em->refresh($city);
                 }
                 $banner->setCity($city);
                 $banner->setCompany($company);
                 $banner->setAdrs($val['address']);
                 $banner->setTitle($val['address']);
                 $banner->setGid($val['gid']);
                 $banner->setGrp($val['grp']);
                 $banner->setOts($val['ots']);
                 $banner->setPrice((isset($val['price']) ? $val['price'] : 0) * 0.82);
                 $banner->setPrice2(isset($val['price']) ? $val['price'] : 0);
                 $banner->setLight($val['light']);
                 $banner->setSide($val['side']);
                 $desc = (isset($val['top']) ? $val['top'] : '') . '<br />' . (isset($val['distance']) ? $val['distance'] : '');
                 $banner->setBody($desc);
                 if ($type == 1) {
                     $banner->setFormat('3x6');
                 } elseif ($type == 2) {
                     $banner->setFormat('big');
                 }
                 $banner->setLongitude($val['longtitude']);
                 $banner->setLatitude($val['latitude']);
                 $banner->setImg(str_replace('//', 'http://', $val['imageURL']));
                 $em->persist($banner);
                 $em->flush();
             } else {
                 echo $val['address'] . '<br />';
                 echo '<br />';
                 print_r($val);
                 echo '<br />';
                 echo '<br />';
             }
         }
     }
     exit;
 }
Exemplo n.º 11
0
 /**
  * @Route("/parserGellary/2")
  */
 public function parserGellary2Action()
 {
     $this->filePath = $this->filePath . 'G2.XLSX';
     $em = $this->getDoctrine()->getManager();
     $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Gallery');
     if ($company == null) {
         $company = new Company();
         $company->setTitle('Gallery');
         $em->persist($company);
         $em->flush($company);
         $em->refresh($company);
     }
     $phpExcelObject = $this->get('phpexcel')->createPHPExcelObject($this->filePath);
     $num = 11;
     while (true) {
         if ($phpExcelObject->setActiveSheetIndex(0)->getCell('B' . $num)->getValue() == '') {
             break;
         }
         $banner = new Banner();
         $banner->setCompany($company);
         $banner->setAdrs($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setTitle($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setBody($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setSide($this->getSide($phpExcelObject->setActiveSheetIndex(0)->getCell('D' . $num)->getValue()));
         $banner->setCity($phpExcelObject->setActiveSheetIndex(0)->getCell('A' . $num)->getValue() == 'Москва' ? 'Москва' : 'Московская область');
         $banner->setGid($phpExcelObject->setActiveSheetIndex(0)->getCell('F' . $num)->getValue());
         $banner->setGrp(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('K' . $num)->getValue()));
         $banner->setOts(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('L' . $num)->getValue()));
         $banner->setPrice(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('J' . $num)->getValue()));
         $banner->setPrice2(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('I' . $num)->getValue()));
         $banner->setPriceDeploy(0);
         $banner->setTaxType('НДС (18%)');
         $banner->setFormat('small');
         $banner->setType($phpExcelObject->setActiveSheetIndex(0)->getCell('B' . $num)->getValue());
         $banner->setArea($phpExcelObject->setActiveSheetIndex(0)->getCell('X' . $num)->getValue());
         $banner->setLight($phpExcelObject->setActiveSheetIndex(0)->getCell('C' . $num)->getValue() == 'Да' || $phpExcelObject->setActiveSheetIndex(0)->getCell('C' . $num)->getValue() == 'да' ? 1 : 0);
         $banner->setImg($this->getImage($phpExcelObject->setActiveSheetIndex(0)->getCell('G' . $num)->getHyperlink()->getUrl()));
         $banner->setLink($phpExcelObject->setActiveSheetIndex(0)->getCell('G' . $num)->getHyperlink()->getUrl());
         $url = 'http://geocode-maps.yandex.ru/1.x/?geocode=' . urlencode($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $content = file_get_contents($url);
         $XmlObj = simplexml_load_string($content);
         if (isset($XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)) {
             $pos['x'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[1];
             $pos['y'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[0];
         } else {
             $pos['x'] = 0;
             $pos['y'] = 0;
         }
         $banner->setLongitude($pos['y']);
         $banner->setLatitude($pos['x']);
         $em->persist($banner);
         $em->flush($banner);
         $num++;
         if ($num % 50 == 0) {
             sleep(rand(1, 5));
         }
     }
     return new Response('открылось');
 }
Exemplo n.º 12
0
 /**
  * @Route("/parserRasvero/1")
  */
 public function parserRasvero1Action($hot = false)
 {
     $em = $this->em;
     $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Расверо');
     if ($company == null) {
         $company = new Company();
         $company->setTitle('Расверо');
         $em->persist($company);
         $em->flush($company);
         $em->refresh($company);
     }
     $phpExcelObject = $this->container->get('phpexcel')->createPHPExcelObject($this->filePath);
     $num = 7;
     $city = $em->getRepository('AppBundle:City')->findOneById(1);
     while (true) {
         if ($phpExcelObject->setActiveSheetIndex(0)->getCell('B' . $num)->getValue() == '') {
             break;
         }
         $banner = new Banner();
         $banner->setCompany($company);
         $banner->setAdrs(explode("\n", $phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue())[0]);
         $banner->setTitle(explode("\n", $phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue())[0]);
         $banner->setBody($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setSide($phpExcelObject->setActiveSheetIndex(0)->getCell('H' . $num)->getValue());
         $banner->setCity($city);
         $banner->setGrp(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('L' . $num)->getValue()));
         $banner->setOts(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('M' . $num)->getValue()));
         $banner->setGid($phpExcelObject->setActiveSheetIndex(0)->getCell('K' . $num)->getValue());
         $banner->setPrice(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('R' . $num)->getValue() * 0.82));
         $banner->setPrice2(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('R' . $num)->getValue()));
         $banner->setTaxType('НДС (18%)');
         $banner->setFormat('small');
         $banner->setType($phpExcelObject->setActiveSheetIndex(0)->getCell('I' . $num)->getValue() . ' ' . $phpExcelObject->setActiveSheetIndex(0)->getCell('J' . $num)->getValue() . ' ' . ' ( ' . $phpExcelObject->setActiveSheetIndex(0)->getCell('G' . $num)->getValue() . ' ) ');
         $banner->setArea($phpExcelObject->setActiveSheetIndex(0)->getCell('F' . $num)->getValue());
         $banner->setLight(0);
         $banner->setImg($this->getPhoto($phpExcelObject->setActiveSheetIndex(0)->getCell('O' . $num)->getValue()));
         $banner->setLink(0);
         $url = $phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue();
         $url = 'http://geocode-maps.yandex.ru/1.x/?geocode=' . urlencode($url);
         $content = file_get_contents($url);
         $XmlObj = simplexml_load_string($content);
         if (isset($XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)) {
             $pos['x'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[1];
             $pos['y'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[0];
         } else {
             $pos['x'] = 0;
             $pos['y'] = 0;
         }
         $banner->setLongitude($pos['y']);
         $banner->setLatitude($pos['x']);
         //            $banner = $this->setBanner($banner);
         //            $month = array(
         //                '2015-08-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getCell('S'.$num)->getValue()),
         //                '2015-09-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getCell('T'.$num)->getValue()),
         //                '2015-10-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getCell('U'.$num)->getValue()),
         //                '2015-11-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getCell('V'.$num)->getValue()),
         //                '2015-12-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getCell('W'.$num)->getValue()),
         ////                '2015-12-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getCell('X'.$num)->getValue()),
         ////                '2015-12-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getCell('Y'.$num)->getValue()),
         //            );
         //            $this->refreshStatus($banner,$month, array('date' => '2015-06-01' , 'sale' => $hot));
         //            if ($hot){
         //                $banner->setHot(true);
         //            }else{
         $banner->setHot(false);
         //            }
         //            if (strripos($phpExcelObject->setActiveSheetIndex(0)->getCell('S' . $num)->getValue(),'Свободно') !== false){
         //                $banner->setHot(true);
         //            }
         $this->em->persist($banner);
         $this->em->flush($banner);
         $num++;
         if ($num % 50 == 0) {
             sleep(rand(1, 5));
         }
     }
     return true;
 }
Exemplo n.º 13
0
 /**
  * Creates a form to delete a Company entity.
  *
  * @param Company $company The Company entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Company $company)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('company_delete', array('id' => $company->getId())))->setMethod('DELETE')->getForm();
 }
Exemplo n.º 14
0
 /**
  * @Route("/parserRasvero/1")
  */
 public function parserVera1Action()
 {
     $em = $this->getDoctrine()->getManager();
     $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Расверо');
     if ($company == null) {
         $company = new Company();
         $company->setTitle('Расверо');
         $em->persist($company);
         $em->flush($company);
         $em->refresh($company);
     }
     $phpExcelObject = $this->get('phpexcel')->createPHPExcelObject($this->filePath);
     $num = 7;
     $city = $this->getDoctrine()->getRepository('AppBundle:City')->findOneById(1);
     while (true) {
         if ($phpExcelObject->setActiveSheetIndex(0)->getCell('B' . $num)->getValue() == '') {
             break;
         }
         $banner = new Banner();
         $banner->setCompany($company);
         $banner->setAdrs(explode("\n", $phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue())[0]);
         $banner->setTitle(explode("\n", $phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue())[0]);
         $banner->setBody($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setSide($this->getSide($phpExcelObject->setActiveSheetIndex(0)->getCell('I' . $num)->getValue()));
         $banner->setCity($city);
         $banner->setGrp(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('M' . $num)->getValue()));
         $banner->setOts(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('N' . $num)->getValue()));
         $banner->setGid($phpExcelObject->setActiveSheetIndex(0)->getCell('C' . $num)->getValue());
         $banner->setPrice(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('R' . $num)->getValue()));
         $banner->setPrice2(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('T' . $num)->getValue()));
         $banner->setTaxType('НДС (18%)');
         $banner->setFormat('small');
         $banner->setType($phpExcelObject->setActiveSheetIndex(0)->getCell('J' . $num)->getValue() . ' ' . $phpExcelObject->setActiveSheetIndex(0)->getCell('K' . $num)->getValue() . ' ' . ' ( ' . $phpExcelObject->setActiveSheetIndex(0)->getCell('H' . $num)->getValue() . ' ) ');
         $banner->setArea($phpExcelObject->setActiveSheetIndex(0)->getCell('G' . $num)->getValue());
         $banner->setLight(0);
         $banner->setImg($this->getPhoto($phpExcelObject->setActiveSheetIndex(0)->getCell('P' . $num)->getValue()));
         $banner->setLink(0);
         if ($phpExcelObject->setActiveSheetIndex(0)->getCell('S' . $num)->getValue() == 'Свободно') {
             $banner->setHot(true);
         }
         //            $url = substr ($phpExcelObject->setActiveSheetIndex(0)->getCell('E'.$num)->getValue(), 0, strrpos($phpExcelObject->setActiveSheetIndex(0)->getCell('E'.$num)->getValue(), '.'));
         $url = $phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue();
         //            if ($url == ''){
         //                echo '<br /><br />'.$num;
         //                break;
         //            }
         $url = 'http://geocode-maps.yandex.ru/1.x/?geocode=' . urlencode($url);
         $content = @file_get_contents($url);
         $XmlObj = simplexml_load_string($content);
         if (isset($XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)) {
             $pos['x'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[1];
             $pos['y'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[0];
         } else {
             $pos['x'] = 0;
             $pos['y'] = 0;
         }
         $banner->setLongitude($pos['y']);
         $banner->setLatitude($pos['x']);
         $em->persist($banner);
         $em->flush($banner);
         $num++;
         if ($num % 30 == 0) {
             sleep(rand(1, 5));
         }
     }
     return new Response('открылось');
 }