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