Ejemplo n.º 1
0
 public function toErp()
 {
     if ($this->getProduct() > 0) {
         return;
     }
     global $kernel;
     if ('AppCache' == get_class($kernel)) {
         $kernel = $kernel->getKernel();
     }
     $em = $kernel->getContainer()->get('doctrine.orm.entity_manager');
     $dt = new \DateTime("now");
     $product = new \SoftoneBundle\Entity\Product();
     $product->setSupplierCode($this->factorypartno);
     $product->setTitle($this->description);
     $product->setTecdocCode($this->tecdocpartno);
     $product->setTecdocSupplierId($this->tecdocsupplierno);
     $product->setErpSupplier($this->supplierdescr);
     $product->setErpCode($this->partno);
     $product->setEdi($this->repository);
     $product->setEdiId($this->id);
     $product->setItemV5($dt);
     $product->setTs($dt);
     $product->setItemInsdate($dt);
     $product->setItemUpddate($dt);
     $product->setCreated($dt);
     $product->setModified($dt);
     $em->persist($product);
     $em->flush();
     $product->updatetecdoc();
     $this->setProduct($product->getId());
     $em->persist($this);
     $em->flush();
     return;
 }
Ejemplo n.º 2
0
 public function toErp()
 {
     global $kernel;
     if ('AppCache' == get_class($kernel)) {
         $kernel = $kernel->getKernel();
     }
     $em = $kernel->getContainer()->get('doctrine.orm.entity_manager');
     $this->updatetecdoc();
     //$TecdocSupplier = new \SoftoneBundle\Entity\TecdocSupplier;
     //$TecdocSupplier->updateToSoftone();
     $this->brand = $this->fixsuppliers($this->brand);
     $SoftoneSupplier = $em->getRepository("SoftoneBundle:SoftoneSupplier")->findOneBy(array('title' => $this->brand));
     //echo $SoftoneSupplier->id;
     //exit;
     if (@$SoftoneSupplier->id == 0) {
         $TecdocSupplier = $em->getRepository("SoftoneBundle:TecdocSupplier")->findOneBy(array('supplier' => $this->brand));
         if (@$TecdocSupplier->id == 0) {
             $SoftoneSupplier = new \SoftoneBundle\Entity\SoftoneSupplier();
             $SoftoneSupplier->setTitle($this->brand);
             $SoftoneSupplier->setCode(' ');
             $em->persist($SoftoneSupplier);
             $em->flush();
             $SoftoneSupplier->setCode("S" . $SoftoneSupplier->getId());
             $em->persist($SoftoneSupplier);
             $em->flush();
             $SoftoneSupplier->toSoftone();
         } else {
             $SoftoneSupplier = new \SoftoneBundle\Entity\SoftoneSupplier();
             $SoftoneSupplier->setTitle($TecdocSupplier->getSupplier());
             $SoftoneSupplier->setCode("T" . $TecdocSupplier->id);
             $em->persist($SoftoneSupplier);
             $em->flush();
             $SoftoneSupplier->toSoftone();
         }
     } else {
         $SoftoneSupplier->toSoftone();
     }
     /*
     $TecdocSuppliers = $em->getRepository("SoftoneBundle:TecdocSupplier")->findAll();
     foreach($TecdocSuppliers as $TecdocSupplier) {
         $TecdocSupplier->toSoftone();
     }
     */
     $TecdocSupplier = $em->getRepository("SoftoneBundle:TecdocSupplier")->find($this->dlnr);
     $TecdocSupplier->toSoftone();
     $erpCode = $this->clearCode($this->partno) . "-" . $SoftoneSupplier->getCode();
     $product = $em->getRepository("SoftoneBundle:Product")->findOneBy(array("erpCode" => $erpCode));
     if (@$product->id > 0) {
         //$product = $em->getRepository("SoftoneBundle:Product")->find($this->getProduct());
         //if ($product->getReference() == 0) {
         $product->setItemMtrmanfctr($SoftoneSupplier->getId());
         $product->setErpCode($this->clearCode($this->partno) . "-" . $SoftoneSupplier->getCode());
         $product->setItemCode($product->getErpCode());
         $product->setCars($this->getCars());
         $product->setCats($this->getCats());
         $em->persist($product);
         $em->flush();
         if ($TecdocSupplier) {
             $product->setTecdocSupplierId($TecdocSupplier);
         }
         $product->toSoftone();
         echo $this->clearCode($this->partno) . "-" . $SoftoneSupplier->getCode();
         return;
     }
     /*
             if ($this->getProduct() > 0) {
        if (!$product->getEdiId()) {
            $product->setEdi($this->getEdi()->getId());
            $product->setEdiId($this->id);
            $em->persist($product);
            $em->flush();
            $product->toSoftone();
            return;
        } else {
            if (!$product->getEdis()) {
                $edis = array();
            } else {
                $edis = unserialize($product->getEdis());
            }
            $edis[] = $this->id;
            $edis[] = $product->getEdiId();
            $edis = array_filter(array_unique($edis));
            $product->setEdis(serialize($edis));
            $em->persist($product);
            $em->flush();
            $product->toSoftone();
            return;
        }
        return;
             }
     * 
     */
     $dt = new \DateTime("now");
     $product = new \SoftoneBundle\Entity\Product();
     $product->setSupplierCode($this->partno);
     $product->setTitle($this->description);
     $product->setTecdocCode($this->artNr);
     $product->setItemMtrmark($this->dlnr);
     $product->setTecdocSupplierId($TecdocSupplier);
     $product->setSupplierId($SoftoneSupplier);
     $product->setTecdocCode($this->artNr);
     $product->setItemName($this->description);
     $product->setTecdocArticleId($this->tecdocArticleId);
     //$product->setItemCode($this->partno);
     $product->setItemApvcode($this->artNr);
     $product->setErpSupplier($this->brand);
     $product->setItemMtrmanfctr($SoftoneSupplier->getId());
     $product->setErpCode($erpCode);
     $product->setItemCode($product->getErpCode());
     $product->setEdi($this->getEdi()->getId());
     $product->setEdiId($this->id);
     $product->setCars($this->getCars());
     $product->setCats($this->getCats());
     $product->setItemV5($dt);
     $product->setTs($dt);
     $product->setItemInsdate($dt);
     $product->setItemUpddate($dt);
     $product->setCreated($dt);
     $product->setModified($dt);
     $em->persist($product);
     $em->flush();
     $product->updatetecdoc();
     $product->toSoftone();
     $this->updatetecdoc();
     $this->setProduct($product->getId());
     $em->persist($this);
     $em->flush();
     return;
 }