/** * @param Activity $activity * @param bool $flush * @return Activity */ public function remove(Activity $activity, $flush = true) { $activity->setReplanned(null); $activity->setReplannedBy(null); $this->em->remove($activity); if ($flush) { $this->em->flush(); } return $activity; }
protected function getColor(Activity $activity = null, $replanned = false, $type = ActivityType::CALL) { if ($activity->getUser() == $this->userManager->getCurrent()) { if ($replanned) { if ($type == ActivityType::CALL) { return '#A9B7C0'; } else { return '#BBCBA3'; } } else { if ($type == ActivityType::CALL) { return '#3B90AC'; } else { return '#2E8B57'; } } } else { if ($this->authorizationChecker->isGranted('ROLE_RS')) { if ($replanned) { return '#CCCCCC'; } else { return $this->parseIdColor($activity->getAccount()->getId()); } } elseif ($this->authorizationChecker->isGranted('ROLE_RCA')) { if ($replanned) { return '#CCCCCC'; } else { return $this->parseIdColor($activity->getUser()->getId()); } } elseif ($this->authorizationChecker->isGranted('ROLE_CA')) { if ($replanned) { if ($type == ActivityType::CALL) { return '#C0B997'; } else { return '#C0B997'; } } else { if ($type == ActivityType::CALL) { return '#C0B35D'; } else { return '#C0B35D'; } } } } return '#C0B35D'; }
public function grantActivity(Activity $activity, $action = 'view') { $grant = false; if ($this->authorizationChecker->isGranted('ROLE_RS')) { $grant = true; } elseif ($this->authorizationChecker->isGranted('ROLE_RCA') || $this->authorizationChecker->isGranted('ROLE_CA')) { $agency = $this->userManager->getCurrent()->getAgency(); foreach ($activity->getUser()->getAgencies() as $histoAgence) { if ($agency == $histoAgence->getAgency()) { if ($histoAgence->getDateCreated() <= $activity->getDateCreated()) { if ($histoAgence->getEnd()) { if ($histoAgence->getEnd()->getDateEnd() > $activity->getDateCreated()) { $grant = true; } } else { $grant = true; } } } } } if ($this->authorizationChecker->isGranted('ROLE_CA') && !$this->authorizationChecker->isGranted('ROLE_RCA')) { if ($grant) { $grant = false; if ($action == 'view') { foreach ($activity->getAccount()->getOwners() as $account_owner) { if ($account_owner->getUser() == $this->userManager->getCurrent() && !$account_owner->getEnd()) { $grant = true; break; } } } else { if ($activity->getUser() == $this->userManager->getCurrent()) { $grant = true; } } } } return $grant; }
/** * Set replannedBy * * @param \Enigmatic\CRMBundle\Entity\Activity $replannedBy * @return Activity */ public function setReplannedBy(\Enigmatic\CRMBundle\Entity\Activity $replannedBy = null) { if ($replannedBy) { $replannedBy->setReplanned($this); } elseif ($this->replannedBy) { $this->replannedBy->setReplanned(null); } $this->replannedBy = $replannedBy; return $this; }
/** * Remove activities * * @param \Enigmatic\CRMBundle\Entity\Activity $activities */ public function removeActivity(\Enigmatic\CRMBundle\Entity\Activity $activities) { $this->activities->removeElement($activities); }