protected function traceEntity(Customer $cloneCustomer, Customer $customer)
 {
     $curUser = $this->getSecurityTokenStorage()->getToken()->getUser();
     $trace = new Trace();
     $trace->setActionId($customer->getId());
     $trace->setActionType(Trace::AT_UPDATE);
     $trace->setUserId($curUser->getId());
     $trace->setCompanyId($customer->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_CUSTOMER);
     $trace->setActionId2($customer->getCompany()->getId());
     $trace->setActionEntity2(Trace::AE_COMPANY);
     $msg = '';
     if ($cloneCustomer->getLabel() != $customer->getLabel()) {
         $msg .= '<tr><td>' . $this->translate('Customer.label.label') . '</td><td>';
         if ($cloneCustomer->getLabel() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getLabel();
         }
         $msg .= '</td><td>';
         if ($customer->getLabel() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getLabel();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getNumber() != $customer->getNumber()) {
         $msg .= '<tr><td>' . $this->translate('Customer.number.label') . '</td><td>';
         if ($cloneCustomer->getNumber() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getNumberFormated();
         }
         $msg .= '</td><td>';
         if ($customer->getNumber() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getNumberFormated();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getFisc() != $customer->getFisc()) {
         $msg .= '<tr><td>' . $this->translate('Customer.fisc.label') . '</td><td>';
         if ($cloneCustomer->getFisc() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getFisc();
         }
         $msg .= '</td><td>';
         if ($customer->getFisc() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getFisc();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getPhysicaltype() != $customer->getPhysicaltype()) {
         $msg .= '<tr><td>' . $this->translate('Customer.physicaltype.label') . '</td><td>';
         if ($cloneCustomer->getPhysicaltype() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $this->translate('Customer.physicaltype.' . $cloneCustomer->getPhysicaltype());
         }
         $msg .= '</td><td>';
         if ($customer->getSexe() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $this->translate('Customer.physicaltype.' . $customer->getPhysicaltype());
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getCin() != $customer->getCin()) {
         $msg .= '<tr><td>' . $this->translate('Customer.cin.label') . '</td><td>';
         if ($cloneCustomer->getCin() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getCin();
         }
         $msg .= '</td><td>';
         if ($customer->getCin() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getCin();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getPassport() != $customer->getPassport()) {
         $msg .= '<tr><td>' . $this->translate('Customer.passport.label') . '</td><td>';
         if ($cloneCustomer->getPassport() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getPassport();
         }
         $msg .= '</td><td>';
         if ($customer->getPassport() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getPassport();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getCommercialRegister() != $customer->getCommercialRegister()) {
         $msg .= '<tr><td>' . $this->translate('Customer.commercialRegister.label') . '</td><td>';
         if ($cloneCustomer->getCommercialRegister() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getCommercialRegister();
         }
         $msg .= '</td><td>';
         if ($customer->getCommercialRegister() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getCommercialRegister();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getStreetNum() != $customer->getStreetNum()) {
         $msg .= '<tr><td>' . $this->translate('Customer.streetNum.label') . '</td><td>';
         if ($cloneCustomer->getStreetNum() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getStreetNum();
         }
         $msg .= '</td><td>';
         if ($customer->getStreetNum() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getStreetNum();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getAddress() != $customer->getAddress()) {
         $msg .= '<tr><td>' . $this->translate('Customer.address.label') . '</td><td>';
         if ($cloneCustomer->getAddress() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getAddress();
         }
         $msg .= '</td><td>';
         if ($customer->getAddress() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getAddress();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getAddress2() != $customer->getAddress2()) {
         $msg .= '<tr><td>' . $this->translate('Customer.address2.label') . '</td><td>';
         if ($cloneCustomer->getAddress2() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getAddress2();
         }
         $msg .= '</td><td>';
         if ($customer->getAddress2() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getAddress2();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getTown() != $customer->getTown()) {
         $msg .= '<tr><td>' . $this->translate('Customer.town.label') . '</td><td>';
         if ($cloneCustomer->getTown() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getTown();
         }
         $msg .= '</td><td>';
         if ($customer->getTown() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getTown();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getZipCode() != $customer->getZipCode()) {
         $msg .= '<tr><td>' . $this->translate('Customer.zipCode.label') . '</td><td>';
         if ($cloneCustomer->getZipCode() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getZipCode();
         }
         $msg .= '</td><td>';
         if ($customer->getZipCode() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getZipCode();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getCountry() != $customer->getCountry()) {
         $msg .= '<tr><td>' . $this->translate('Customer.country.label') . '</td><td>';
         if ($cloneCustomer->getCountry() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getCountry();
         }
         $msg .= '</td><td>';
         if ($customer->getCountry() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getCountry();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getPhone() != $customer->getPhone()) {
         $msg .= '<tr><td>' . $this->translate('Customer.phone.label') . '</td><td>';
         if ($cloneCustomer->getPhone() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getPhone();
         }
         $msg .= '</td><td>';
         if ($customer->getPhone() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getPhone();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getMobile() != $customer->getMobile()) {
         $msg .= '<tr><td>' . $this->translate('Customer.mobile.label') . '</td><td>';
         if ($cloneCustomer->getMobile() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getMobile();
         }
         $msg .= '</td><td>';
         if ($customer->getMobile() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getMobile();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getFax() != $customer->getFax()) {
         $msg .= '<tr><td>' . $this->translate('Customer.fax.label') . '</td><td>';
         if ($cloneCustomer->getFax() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getFax();
         }
         $msg .= '</td><td>';
         if ($customer->getFax() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getFax();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getEmail() != $customer->getEmail()) {
         $msg .= '<tr><td>' . $this->translate('Customer.email.label') . '</td><td>';
         if ($cloneCustomer->getEmail() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getEmail();
         }
         $msg .= '</td><td>';
         if ($customer->getEmail() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getEmail();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCustomer->getOtherInfos() != $customer->getOtherInfos()) {
         $msg .= '<tr><td>' . $this->translate('Customer.otherInfos.label') . '</td><td>';
         if ($cloneCustomer->getOtherInfos() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCustomer->getOtherInfos();
         }
         $msg .= '</td><td>';
         if ($customer->getOtherInfos() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $customer->getOtherInfos();
         }
         $msg .= '</td></tr>';
     }
     if (\count(\array_diff($customer->getDocs()->toArray(), $cloneCustomer->getDocs()->toArray())) != 0 || \count(\array_diff($cloneCustomer->getDocs()->toArray(), $customer->getDocs()->toArray())) != 0) {
         $msg .= '<tr><td>' . $this->translate('Customer.docs.label') . '</td><td>';
         if (\count($cloneCustomer->getDocs()) == 0) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= '<ul>';
             foreach ($cloneCustomer->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($customer->getDocs()) == 0) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= '<ul>';
             foreach ($customer->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('Customer.traceEdit', array('%customer%' => $customer->getLabel(), '%company%' => $customer->getCompany()->getCorporateName())) . $msg);
         $trace->setDtCrea(new \DateTime('now'));
         $em = $this->getEntityManager();
         $em->persist($trace);
         $em->flush();
     }
 }