protected function traceEntity(Docgroupbank $cloneDocgroupbank, Docgroupbank $docgroupbank)
 {
     $curUser = $this->getSecurityTokenStorage()->getToken()->getUser();
     $trace = new Trace();
     $trace->setActionId($docgroupbank->getId());
     $trace->setActionType(Trace::AT_UPDATE);
     $trace->setUserId($curUser->getId());
     $trace->setCompanyId($docgroupbank->getCompany()->getId());
     $trace->setUserFullname($curUser->getFullName());
     if (!$this->hasRole('ROLE_SUPERADMIN')) {
         if (!$this->hasRole('ROLE_ADMIN')) {
             $trace->setUserType(Trace::UT_CLIENT);
         } else {
             $trace->setUserType(Trace::UT_ADMIN);
         }
     } else {
         $trace->setUserType(Trace::UT_SUPERADMIN);
     }
     $tableBegin = ': <br><table class="table table-bordered table-condensed table-hover table-striped">';
     $tableBegin .= '<thead><tr><th class="text-left">' . $this->translate('Entity.field') . '</th>';
     $tableBegin .= '<th class="text-left">' . $this->translate('Entity.oldVal') . '</th>';
     $tableBegin .= '<th class="text-left">' . $this->translate('Entity.newVal') . '</th></tr></thead><tbody>';
     $tableEnd = '</tbody></table>';
     $trace->setActionEntity(Trace::AE_DOCGROUPBANK);
     $trace->setActionId2($docgroupbank->getCompany()->getId());
     $trace->setActionEntity2(Trace::AE_COMPANY);
     $msg = '';
     if ($cloneDocgroupbank->getLabel() != $docgroupbank->getLabel()) {
         $msg .= '<tr><td>' . $this->translate('Docgroupbank.label.label') . '</td><td>';
         if ($cloneDocgroupbank->getLabel() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneDocgroupbank->getLabel();
         }
         $msg .= '</td><td>';
         if ($docgroupbank->getLabel() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $docgroupbank->getLabel();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneDocgroupbank->getParent() != $docgroupbank->getParent() && ($cloneDocgroupbank->getParent() == null && $docgroupbank->getParent() != null || $cloneDocgroupbank->getParent() != null && $docgroupbank->getParent() == null || $docgroupbank->getParent() != null && $cloneDocgroupbank->getParent() != null && $cloneDocgroupbank->getParent()->getPageUrlFull() != $docgroupbank->getParent()->getPageUrlFull())) {
         $msg .= '<tr><td>' . $this->translate('Docgroupbank.parent.label') . '</td><td>';
         if ($cloneDocgroupbank->getParent() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneDocgroupbank->getParent()->getLabel();
         }
         $msg .= '</td><td>';
         if ($docgroupbank->getParent() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $docgroupbank->getParent()->getLabel();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneDocgroupbank->getOtherInfos() != $docgroupbank->getOtherInfos()) {
         $msg .= '<tr><td>' . $this->translate('Docgroupbank.otherInfos.label') . '</td><td>';
         if ($cloneDocgroupbank->getOtherInfos() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneDocgroupbank->getOtherInfos();
         }
         $msg .= '</td><td>';
         if ($docgroupbank->getOtherInfos() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $docgroupbank->getOtherInfos();
         }
         $msg .= '</td></tr>';
     }
     if (\count(\array_diff($docgroupbank->getDocs()->toArray(), $cloneDocgroupbank->getDocs()->toArray())) != 0 || \count(\array_diff($cloneDocgroupbank->getDocs()->toArray(), $docgroupbank->getDocs()->toArray())) != 0) {
         $msg .= '<tr><td>' . $this->translate('Docgroupbank.docs.label') . '</td><td>';
         if (\count($cloneDocgroupbank->getDocs()) == 0) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= '<ul>';
             foreach ($cloneDocgroupbank->getDocs() as $doc) {
                 $msg .= '<li><a href="' . $this->generateUrl('_admin_doc_editGet', array('uid' => $doc->getId())) . '">' . $doc->getOriginalName() . '</a></li>';
             }
             $msg .= '<ul>';
         }
         $msg .= '</td><td>';
         if (\count($docgroupbank->getDocs()) == 0) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= '<ul>';
             foreach ($docgroupbank->getDocs() as $doc) {
                 $msg .= '<li><a href="' . $this->generateUrl('_admin_doc_editGet', array('uid' => $doc->getId())) . '">' . $doc->getOriginalName() . '</a></li>';
             }
             $msg .= '<ul>';
         }
         $msg .= '</td></tr>';
     }
     if ($msg != '') {
         $msg = $tableBegin . $msg . $tableEnd;
         $trace->setMsg($this->translate('Docgroupbank.traceEdit', array('%docgroupbank%' => $docgroupbank->getLabel(), '%company%' => $docgroupbank->getCompany()->getCorporateName())) . $msg);
         $trace->setDtCrea(new \DateTime('now'));
         $em = $this->getEntityManager();
         $em->persist($trace);
         $em->flush();
     }
 }
 /**
  * Get Query for All Entities
  *
  * @param Docgroupbank $dg
  *
  * @return \Doctrine\ORM\Query
  */
 public function getAllChildsQuery(Docgroupbank $dg)
 {
     $c = $dg->getCompany();
     $qb = $this->createQueryBuilder('d')->join('d.company', 'c')->where('c.id = :cid')->andWhere('d.pageUrlFull LIKE :url')->andWhere('d.id != :did')->orderBy('d.pageUrlFull', 'ASC')->setParameter('cid', $c->getId())->setParameter('url', $dg->getPageUrlFull() . '%')->setParameter('did', $dg->getId());
     $query = $qb->getQuery();
     return $query;
 }