protected function traceEntity(CompanyNature $cloneCompanyNature, CompanyNature $companyNature)
 {
     $curUser = $this->getSecurityTokenStorage()->getToken()->getUser();
     $trace = new Trace();
     $trace->setActionId($companyNature->getId());
     $trace->setActionType(Trace::AT_UPDATE);
     $trace->setUserId($curUser->getId());
     $trace->setCompanyId($companyNature->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_NATURE);
     $trace->setActionId2($companyNature->getCompany()->getId());
     $trace->setActionEntity2(Trace::AE_COMPANY);
     $msg = '';
     if ($cloneCompanyNature->getLabel() != $companyNature->getLabel()) {
         $msg .= '<tr><td>' . $this->translate('CompanyNature.label.label') . '</td><td>';
         if ($cloneCompanyNature->getLabel() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCompanyNature->getLabel();
         }
         $msg .= '</td><td>';
         if ($companyNature->getLabel() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $companyNature->getLabel();
         }
         $msg .= '</td></tr>';
     }
     if ($cloneCompanyNature->getColor() != $companyNature->getColor()) {
         $msg .= '<tr><td>' . $this->translate('CompanyNature.color.label') . '</td><td>';
         if ($cloneCompanyNature->getColor() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $cloneCompanyNature->getColor() . ' &nbsp; <span style="display:inline-block; background-color: ' . $cloneCompanyNature->getColor() . ';  border: 1px solid ' . $cloneCompanyNature->getColor() . '; width: 60px; height: 20px;"></span>&nbsp;';
         }
         $msg .= '</td><td>';
         if ($companyNature->getColor() == null) {
             $msg .= '<span class="label label-warning">' . $this->translate('_NA') . '</span>';
         } else {
             $msg .= $companyNature->getColor() . ' &nbsp; <span style="display:inline-block; background-color: ' . $companyNature->getColor() . ';  border: 1px solid ' . $companyNature->getColor() . '; width: 60px; height: 20px;"></span>&nbsp;';
         }
         $msg .= '</td></tr>';
     }
     if ($msg != '') {
         $msg = $tableBegin . $msg . $tableEnd;
         $trace->setMsg($this->translate('CompanyNature.traceEdit', array('%companyNature%' => $companyNature->getLabel(), '%company%' => $companyNature->getCompany()->getCorporateName())) . $msg);
         $trace->setDtCrea(new \DateTime('now'));
         $em = $this->getEntityManager();
         $em->persist($trace);
         $em->flush();
     }
 }
Beispiel #2
0
 /**
  * All count
  *
  * @param Company $c
  * @param CompanyNature $cn
  *
  * @return Ambigous <\Doctrine\ORM\mixed, mixed, multitype:,
  *         \Doctrine\DBAL\Driver\Statement, \Doctrine\Common\Cache\mixed>
  */
 public function updateCompanyNatureNullByCompany(Company $c, CompanyNature $cn)
 {
     $rsm = new ResultSetMapping();
     $qb = $this->getEntityManager()->createNativeQuery('UPDATE acf_transactions SET nature_id =  ? FROM acf_transactions AS t INNER JOIN acf_company_mbalances AS m ON m.id = t.mbalance_id  WHERE m.company_id = ?  AND t.nature_id IS NULL AND t.transactiontype = ?', $rsm);
     $qb->setParameter(1, $cn->getId());
     $qb->setParameter(2, $c->getId());
     $qb->setParameter(3, Transaction::TTYPE_BUY);
     $qb->execute();
 }