/**
  * Updates the statistics for area requests in the current day.
  * 
  * @param \Cantiga\CoreBundle\Repository\AreaRequestEvent $event
  */
 public function onAreaRequestStatusChange(AreaRequestEvent $event)
 {
     $project = $event->getAreaRequest()->getProject();
     $values = [0 => 0, 1 => 0, 2 => 0, 3 => 0];
     $calculated = $this->conn->fetchAll('SELECT `status`, COUNT(`id`) AS `counted` FROM `' . CoreTables::AREA_REQUEST_TBL . '` WHERE `projectId` = :projectId GROUP BY `status`', [':projectId' => $project->getId()]);
     foreach ($calculated as $row) {
         $values[$row['status']] = $row['counted'];
     }
     $date = date('Y-m-d');
     $this->conn->executeQuery('INSERT INTO `' . CoreTables::STAT_ARQ_TIME_TBL . '` (`projectId`, `datePoint`, `requestsNew`, `requestsVerification`, `requestsApproved`, `requestsRejected`)' . 'VALUES(:projectId, :datePoint, :rn1, :rv1, :ra1, :rr1) ON DUPLICATE KEY UPDATE `requestsNew` = :rn2, `requestsVerification` = :rv2, `requestsApproved` = :ra2, `requestsRejected` = :rr2', [':projectId' => $project->getId(), ':datePoint' => $date, ':rn1' => $values[AreaRequest::STATUS_NEW], ':rv1' => $values[AreaRequest::STATUS_VERIFICATION], ':ra1' => $values[AreaRequest::STATUS_APPROVED], ':rr1' => $values[AreaRequest::STATUS_REVOKED], ':rn2' => $values[AreaRequest::STATUS_NEW], ':rv2' => $values[AreaRequest::STATUS_VERIFICATION], ':ra2' => $values[AreaRequest::STATUS_APPROVED], ':rr2' => $values[AreaRequest::STATUS_REVOKED]]);
 }
Beispiel #2
0
 public function onAreaRequestRevoked(AreaRequestEvent $event)
 {
     $request = $event->getAreaRequest();
     $this->mailSender->send(CoreTexts::AREA_REQUEST_REVOKED_MAIL, $request->getRequestor()->getEmail(), 'notification about area request \'' . $request->getName() . '\' revoke sent to \'' . $request->getRequestor()->getEmail() . '\'', ['request' => $request]);
 }
 public function __construct(AreaRequest $request, Area $area)
 {
     parent::__construct($request);
     $this->area = $area;
 }