protected function traceEntity(Company $cloneCompany, Company $company) { $curUser = $this->getSecurityTokenStorage()->getToken()->getUser(); $trace = new Trace(); $trace->setActionId($company->getId()); $trace->setActionType(Trace::AT_UPDATE); $trace->setUserId($curUser->getId()); $trace->setCompanyId($company->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_COMPANY); $msg = ''; if ($cloneCompany->getRef() != $company->getRef()) { $msg .= '<tr><td>' . $this->translate('Company.ref.label') . '</td><td>'; if ($cloneCompany->getRef() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getRef(); } $msg .= '</td><td>'; if ($company->getRef() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getRef(); } $msg .= '</td></tr>'; } if ($cloneCompany->getCorporateName() != $company->getCorporateName()) { $msg .= '<tr><td>' . $this->translate('Company.corporateName.label') . '</td><td>'; if ($cloneCompany->getCorporateName() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getCorporateName(); } $msg .= '</td><td>'; if ($company->getCorporateName() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getCorporateName(); } $msg .= '</td></tr>'; } if ($cloneCompany->getType() != $company->getType()) { $msg .= '<tr><td>' . $this->translate('Company.type.label') . '</td><td>'; if ($cloneCompany->getType() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getType()->getLabel(); } $msg .= '</td><td>'; if ($company->getType() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getType()->getLabel(); } $msg .= '</td></tr>'; } if ($cloneCompany->getTribunal() != $company->getTribunal()) { $msg .= '<tr><td>' . $this->translate('Company.tribunal.label') . '</td><td>'; if ($cloneCompany->getTribunal() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getTribunal(); } $msg .= '</td><td>'; if ($company->getTribunal() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getTribunal(); } $msg .= '</td></tr>'; } if ($cloneCompany->getFisc() != $company->getFisc()) { $msg .= '<tr><td>' . $this->translate('Company.fisc.label') . '</td><td>'; if ($cloneCompany->getFisc() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getFisc(); } $msg .= '</td><td>'; if ($company->getFisc() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getFisc(); } $msg .= '</td></tr>'; } if ($cloneCompany->getCommercialRegister() != $company->getCommercialRegister()) { $msg .= '<tr><td>' . $this->translate('Company.commercialRegister.label') . '</td><td>'; if ($cloneCompany->getCommercialRegister() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getCommercialRegister(); } $msg .= '</td><td>'; if ($company->getCommercialRegister() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getCommercialRegister(); } $msg .= '</td></tr>'; } if ($cloneCompany->getCommercialRegisterBureau() != $company->getCommercialRegisterBureau()) { $msg .= '<tr><td>' . $this->translate('Company.commercialRegisterBureau.label') . '</td><td>'; if ($cloneCompany->getCommercialRegisterBureau() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getCommercialRegisterBureau(); } $msg .= '</td><td>'; if ($company->getCommercialRegisterBureau() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getCommercialRegisterBureau(); } $msg .= '</td></tr>'; } if ($cloneCompany->getCnss() != $company->getCnss()) { $msg .= '<tr><td>' . $this->translate('Company.cnss.label') . '</td><td>'; if ($cloneCompany->getCnss() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getCnss(); } $msg .= '</td><td>'; if ($company->getCnss() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getCnss(); } $msg .= '</td></tr>'; } if ($cloneCompany->getCnssBureau() != $company->getCnssBureau()) { $msg .= '<tr><td>' . $this->translate('Company.cnssBureau.label') . '</td><td>'; if ($cloneCompany->getCnssBureau() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getCnssBureau(); } $msg .= '</td><td>'; if ($company->getCnssBureau() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getCnssBureau(); } $msg .= '</td></tr>'; } if ($cloneCompany->getPhysicalType() != $company->getPhysicalType()) { $msg .= '<tr><td>' . $this->translate('Company.physicalType.label') . '</td><td>'; if ($cloneCompany->getPhysicalType() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $this->translate('Company.physicalType.' . $cloneCompany->getPhysicalType()); } $msg .= '</td><td>'; if ($company->getPhysicalType() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $this->translate('Company.physicalType.' . $company->getPhysicalType()); } $msg .= '</td></tr>'; } if ($cloneCompany->getCin() != $company->getCin()) { $msg .= '<tr><td>' . $this->translate('Company.cin.label') . '</td><td>'; if ($cloneCompany->getCin() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getCin(); } $msg .= '</td><td>'; if ($company->getCin() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getCin(); } $msg .= '</td></tr>'; } if ($cloneCompany->getPassport() != $company->getPassport()) { $msg .= '<tr><td>' . $this->translate('Company.passport.label') . '</td><td>'; if ($cloneCompany->getPassport() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getPassport(); } $msg .= '</td><td>'; if ($company->getPassport() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getPassport(); } $msg .= '</td></tr>'; } if ($cloneCompany->getCustomsCode() != $company->getCustomsCode()) { $msg .= '<tr><td>' . $this->translate('Company.customsCode.label') . '</td><td>'; if ($cloneCompany->getCustomsCode() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getCustomsCode(); } $msg .= '</td><td>'; if ($company->getCustomsCode() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getCustomsCode(); } $msg .= '</td></tr>'; } if ($cloneCompany->getActionvn() != $company->getActionvn()) { $msg .= '<tr><td>' . $this->translate('Company.actionvn.label') . '</td><td>'; if ($cloneCompany->getActionvn() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getActionvn(); } $msg .= '</td><td>'; if ($company->getActionvn() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getActionvn(); } $msg .= '</td></tr>'; } if ($cloneCompany->getStreetNum() != $company->getStreetNum()) { $msg .= '<tr><td>' . $this->translate('Company.streetNum.label') . '</td><td>'; if ($cloneCompany->getStreetNum() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getStreetNum(); } $msg .= '</td><td>'; if ($company->getStreetNum() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getStreetNum(); } $msg .= '</td></tr>'; } if ($cloneCompany->getAddress() != $company->getAddress()) { $msg .= '<tr><td>' . $this->translate('Company.address.label') . '</td><td>'; if ($cloneCompany->getAddress() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getAddress(); } $msg .= '</td><td>'; if ($company->getAddress() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getAddress(); } $msg .= '</td></tr>'; } if ($cloneCompany->getAddress2() != $company->getAddress2()) { $msg .= '<tr><td>' . $this->translate('Company.address2.label') . '</td><td>'; if ($cloneCompany->getAddress2() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getAddress2(); } $msg .= '</td><td>'; if ($company->getAddress2() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getAddress2(); } $msg .= '</td></tr>'; } if ($cloneCompany->getTown() != $company->getTown()) { $msg .= '<tr><td>' . $this->translate('Company.town.label') . '</td><td>'; if ($cloneCompany->getTown() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getTown(); } $msg .= '</td><td>'; if ($company->getTown() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getTown(); } $msg .= '</td></tr>'; } if ($cloneCompany->getZipCode() != $company->getZipCode()) { $msg .= '<tr><td>' . $this->translate('Company.zipCode.label') . '</td><td>'; if ($cloneCompany->getZipCode() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getZipCode(); } $msg .= '</td><td>'; if ($company->getZipCode() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getZipCode(); } $msg .= '</td></tr>'; } if ($cloneCompany->getCountry() != $company->getCountry()) { $msg .= '<tr><td>' . $this->translate('Company.country.label') . '</td><td>'; if ($cloneCompany->getCountry() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getCountry(); } $msg .= '</td><td>'; if ($company->getCountry() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getCountry(); } $msg .= '</td></tr>'; } if ($cloneCompany->getPhone() != $company->getPhone()) { $msg .= '<tr><td>' . $this->translate('Company.phone.label') . '</td><td>'; if ($cloneCompany->getPhone() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getPhone(); } $msg .= '</td><td>'; if ($company->getPhone() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getPhone(); } $msg .= '</td></tr>'; } if ($cloneCompany->getMobile() != $company->getMobile()) { $msg .= '<tr><td>' . $this->translate('Company.mobile.label') . '</td><td>'; if ($cloneCompany->getMobile() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getMobile(); } $msg .= '</td><td>'; if ($company->getMobile() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getMobile(); } $msg .= '</td></tr>'; } if ($cloneCompany->getFax() != $company->getFax()) { $msg .= '<tr><td>' . $this->translate('Company.fax.label') . '</td><td>'; if ($cloneCompany->getFax() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getFax(); } $msg .= '</td><td>'; if ($company->getFax() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getFax(); } $msg .= '</td></tr>'; } if ($cloneCompany->getEmail() != $company->getEmail()) { $msg .= '<tr><td>' . $this->translate('Company.email.label') . '</td><td>'; if ($cloneCompany->getEmail() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getEmail(); } $msg .= '</td><td>'; if ($company->getEmail() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getEmail(); } $msg .= '</td></tr>'; } if ($cloneCompany->getOtherInfos() != $company->getOtherInfos()) { $msg .= '<tr><td>' . $this->translate('Company.otherInfos.label') . '</td><td>'; if ($cloneCompany->getOtherInfos() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompany->getOtherInfos(); } $msg .= '</td><td>'; if ($company->getOtherInfos() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $company->getOtherInfos(); } $msg .= '</td></tr>'; } if (\count(\array_diff($company->getSectors()->toArray(), $cloneCompany->getSectors()->toArray())) != 0 || \count(\array_diff($cloneCompany->getSectors()->toArray(), $company->getSectors()->toArray())) != 0) { $msg .= '<tr><td>' . $this->translate('Company.sectors.label') . '</td><td>'; if (\count($cloneCompany->getSectors()) == 0) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= '<ul>'; foreach ($cloneCompany->getSectors() as $sector) { $msg .= '<li>' . $sector->getLabel() . '</li>'; } $msg .= '<ul>'; } $msg .= '</td><td>'; if (\count($company->getSectors()) == 0) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= '<ul>'; foreach ($company->getSectors() as $sector) { $msg .= '<li>' . $sector->getLabel() . '</li>'; } $msg .= '<ul>'; } $msg .= '</td></tr>'; } if ($msg != '') { $msg = $tableBegin . $msg . $tableEnd; $trace->setMsg($this->translate('Company.traceEdit', array('%company%' => $company->getCorporateName())) . $msg); $trace->setDtCrea(new \DateTime('now')); $em = $this->getEntityManager(); $em->persist($trace); $em->flush(); } }