protected function traceEntity(Docgroupcomptable $cloneDocgroupcomptable, Docgroupcomptable $docgroupcomptable)
 {
     $curUser = $this->getSecurityTokenStorage()->getToken()->getUser();
     $trace = new Trace();
     $trace->setActionId($docgroupcomptable->getId());
     $trace->setActionType(Trace::AT_UPDATE);
     $trace->setUserId($curUser->getId());
     $trace->setCompanyId($docgroupcomptable->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_DOCGROUPCOMPTABLE);
     $trace->setActionId2($docgroupcomptable->getCompany()->getId());
     $trace->setActionEntity2(Trace::AE_COMPANY);
     $msg = '';
     if ($cloneDocgroupcomptable->getLabel() != $docgroupcomptable->getLabel()) {
         $msg .= '<tr><td>' . $this->translate('Docgroupcomptable.label.label') . '</td><td>';
         if ($cloneDocgroupcomptable->getLabel() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneDocgroupcomptable->getLabel();
         }
         $msg .= '</td><td>';
         if ($docgroupcomptable->getLabel() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $docgroupcomptable->getLabel();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneDocgroupcomptable->getParent() != $docgroupcomptable->getParent() && ($cloneDocgroupcomptable->getParent() == null && $docgroupcomptable->getParent() != null || $cloneDocgroupcomptable->getParent() != null && $docgroupcomptable->getParent() == null || $docgroupcomptable->getParent() != null && $cloneDocgroupcomptable->getParent() != null && $cloneDocgroupcomptable->getParent()->getPageUrlFull() != $docgroupcomptable->getParent()->getPageUrlFull())) {
         $msg .= '<tr><td>' . $this->translate('Docgroupcomptable.parent.label') . '</td><td>';
         if ($cloneDocgroupcomptable->getParent() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneDocgroupcomptable->getParent()->getLabel();
         }
         $msg .= '</td><td>';
         if ($docgroupcomptable->getParent() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $docgroupcomptable->getParent()->getLabel();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneDocgroupcomptable->getOtherInfos() != $docgroupcomptable->getOtherInfos()) {
         $msg .= '<tr><td>' . $this->translate('Docgroupcomptable.otherInfos.label') . '</td><td>';
         if ($cloneDocgroupcomptable->getOtherInfos() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneDocgroupcomptable->getOtherInfos();
         }
         $msg .= '</td><td>';
         if ($docgroupcomptable->getOtherInfos() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $docgroupcomptable->getOtherInfos();
         }
         $msg .= '</td></tr>';
     }
     if (\count(\array_diff($docgroupcomptable->getDocs()->toArray(), $cloneDocgroupcomptable->getDocs()->toArray())) != 0 || \count(\array_diff($cloneDocgroupcomptable->getDocs()->toArray(), $docgroupcomptable->getDocs()->toArray())) != 0) {
         $msg .= '<tr><td>' . $this->translate('Docgroupcomptable.docs.label') . '</td><td>';
         if (\count($cloneDocgroupcomptable->getDocs()) == 0) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= '<ul>';
             foreach ($cloneDocgroupcomptable->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($docgroupcomptable->getDocs()) == 0) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= '<ul>';
             foreach ($docgroupcomptable->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('Docgroupcomptable.traceEdit', array('%docgroupcomptable%' => $docgroupcomptable->getLabel(), '%company%' => $docgroupcomptable->getCompany()->getCorporateName())) . $msg);
         $trace->setDtCrea(new \DateTime('now'));
         $em = $this->getEntityManager();
         $em->persist($trace);
         $em->flush();
     }
 }