/** * Get Query for All Entities * * @param CompanyType $entity * * @return \Doctrine\ORM\Query */ public function getAllByCompanyTypeQuery(CompanyType $entity) { return $this->createQueryBuilder('t')->where('t.actionEntity = :entityType')->andWhere('t.actionId = :aId')->orderBy('t.dtCrea', 'ASC')->addOrderBy('t.actionType', 'ASC')->addOrderBy('t.actionEntity', 'ASC')->setParameter('entityType', Trace::AE_TYPE)->setParameter('aId', $entity->getId())->getQuery(); }
protected function traceEntity(CompanyType $cloneCompanyType, CompanyType $companyType) { $curUser = $this->getSecurityTokenStorage()->getToken()->getUser(); $trace = new Trace(); $trace->setActionId($companyType->getId()); $trace->setActionType(Trace::AT_UPDATE); $trace->setUserId($curUser->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_TYPE); $msg = ''; if ($cloneCompanyType->getLabel() != $companyType->getLabel()) { $msg .= '<tr><td>' . $this->translate('CompanyType.label.label') . '</td><td>'; if ($cloneCompanyType->getLabel() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $cloneCompanyType->getLabel(); } $msg .= '</td><td>'; if ($companyType->getLabel() == null) { $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>'; } else { $msg .= $companyType->getLabel(); } $msg .= '</td></tr>'; } if ($msg != '') { $msg = $tableBegin . $msg . $tableEnd; $trace->setMsg($this->translate('CompanyType.traceEdit', array('%companyType%' => $companyType->getLabel())) . $msg); $trace->setDtCrea(new \DateTime('now')); $em = $this->getEntityManager(); $em->persist($trace); $em->flush(); } }