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