public static function copyEstimationById($em, $id)
 {
     $estimation = $em->getRepository("RenovateMainBundle:Estimation")->find($id);
     $estimationCopy = new Estimation();
     $estimationCopy->setEstimationNumber($estimation->getEstimationNumber());
     $estimationCopy->setContractNumber($estimation->getContractNumber());
     $estimationCopy->setCustomer($estimation->getCustomer());
     $estimationCopy->setPerformer($estimation->getPerformer());
     $estimationCopy->setMaterialsAmount($estimation->getMaterialsAmount());
     $estimationCopy->setWorksAmount($estimation->getWorksAmount());
     $estimationCopy->setDiscount($estimation->getDiscount());
     $estimationCopy->setTotalAmount($estimation->getTotalAmount());
     $estimationCopy->setCreated(new \DateTime());
     $estimationCopy->setUpdated(new \DateTime());
     $em->persist($estimationCopy);
     $em->flush();
     foreach ($estimation->getEstimationCosts() as $estimationCost) {
         $estimationCostCopy = new EstimationCost();
         $estimationCostCopy->setEstimationid($estimationCopy->getId());
         $estimationCostCopy->setEstimation($estimationCopy);
         $estimationCostCopy->setCategoryType($estimationCost->getCategoryType());
         $estimationCostCopy->setName($estimationCost->getName());
         $estimationCostCopy->setUnits($estimationCost->getUnits());
         $estimationCostCopy->setPrice($estimationCost->getPrice());
         $estimationCostCopy->setCount($estimationCost->getCount());
         $estimationCostCopy->setTotal($estimationCost->getTotal());
         $em->persist($estimationCostCopy);
         $em->flush();
     }
     return $estimationCopy->getId();
 }