当前位置: 首页>>代码示例>>PHP>>正文


PHP DateTimeHelper::toUtcString方法代码示例

本文整理汇总了PHP中Mautic\CoreBundle\Helper\DateTimeHelper::toUtcString方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeHelper::toUtcString方法的具体用法?PHP DateTimeHelper::toUtcString怎么用?PHP DateTimeHelper::toUtcString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mautic\CoreBundle\Helper\DateTimeHelper的用法示例。


在下文中一共展示了DateTimeHelper::toUtcString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getDevice

 /**
  * @param           $emailIds
  * @param \DateTime $fromDate
  *
  * @return array
  */
 public function getDevice($statIds, $lead, $deviceName = null, $deviceBrand = null, $deviceModel = null, \DateTime $fromDate = null, \DateTime $toDate = null)
 {
     $sq = $this->_em->getConnection()->createQueryBuilder();
     $sq->select('es.id as id, es.device as device')->from(MAUTIC_TABLE_PREFIX . 'lead_devices', 'es');
     if (!empty($statIds)) {
         $inIds = !is_array($statIds) ? [(int) $statIds] : $statIds;
         $sq->where($sq->expr()->in('es.id', $inIds));
     }
     if ($deviceName !== null) {
         $sq->where($sq->expr()->eq('es.device', ':device'))->setParameter('device', $deviceName);
     }
     if ($deviceBrand !== null) {
         $sq->where($sq->expr()->eq('es.device_brand', ':deviceBrand'))->setParameter('deviceBrand', $deviceBrand);
     }
     if ($deviceModel !== null) {
         $sq->where($sq->expr()->eq('es.device_model', ':deviceModel'))->setParameter('deviceModel', $deviceModel);
     }
     if ($lead !== null) {
         $sq->where($sq->expr()->eq('es.lead_id', $lead->getId()));
     }
     if ($fromDate !== null) {
         //make sure the date is UTC
         $dt = new DateTimeHelper($fromDate);
         $sq->andWhere($sq->expr()->gte('es.date_added', $sq->expr()->literal($dt->toUtcString())));
     }
     if ($toDate !== null) {
         //make sure the date is UTC
         $dt = new DateTimeHelper($toDate);
         $sq->andWhere($sq->expr()->lte('es.date_added', $sq->expr()->literal($dt->toUtcString())));
     }
     //get totals
     $device = $sq->execute()->fetchAll();
     return !empty($device) ? $device[0] : [];
 }
开发者ID:Yame-,项目名称:mautic,代码行数:40,代码来源:LeadDeviceRepository.php

示例2: onCalendarGenerate

 /**
  * Adds events to the calendar
  *
  * @param CalendarGeneratorEvent $event
  *
  * @return void
  */
 public function onCalendarGenerate(CalendarGeneratorEvent $event)
 {
     $dates = $event->getDates();
     $router = $this->factory->getRouter();
     $now = new DateTimeHelper();
     $commonSelect = 'cl.campaign_id, c.name AS campaign_name, l.firstname, l.lastname, ce.type AS event_type, ce.name as event_name, cat.color';
     $eventTypes = array();
     $eventTypes['triggered'] = array('dateName' => 'cl.date_triggered');
     $eventTypes['upcoming'] = array('dateName' => 'cl.trigger_date');
     $query = $this->factory->getEntityManager()->getConnection()->createQueryBuilder();
     $query->from(MAUTIC_TABLE_PREFIX . 'campaign_lead_event_log', 'cl')->leftJoin('cl', MAUTIC_TABLE_PREFIX . 'campaigns', 'c', 'cl.campaign_id = c.id')->leftJoin('cl', MAUTIC_TABLE_PREFIX . 'leads', 'l', 'cl.lead_id = l.id')->leftJoin('cl', MAUTIC_TABLE_PREFIX . 'campaign_events', 'ce', 'cl.event_id = ce.id')->leftJoin('cl', MAUTIC_TABLE_PREFIX . 'categories', 'cat', 'cat.id = c.category_id AND cat.bundle="campaign"')->setParameter('start', $dates['start_date'])->setParameter('end', $dates['end_date'])->setFirstResult(0)->setMaxResults(50);
     foreach ($eventTypes as $eventKey => $eventType) {
         $query->select($commonSelect . ', ' . $eventType['dateName'] . ' AS start')->where($query->expr()->andX($query->expr()->gte($eventType['dateName'], ':start'), $query->expr()->lte($eventType['dateName'], ':end')));
         if ($eventKey == 'upcoming') {
             $query->andWhere($query->expr()->gte($eventType['dateName'], ':now'))->setParameter('now', $now->toUtcString());
         }
         $results = $query->execute()->fetchAll();
         // echo "<pre>";var_dump($results);die("</pre>");
         // We need to convert the date to a ISO8601 compliant string
         foreach ($results as &$object) {
             if ($object['firstname'] || $object['lastname']) {
                 $leadName = $object['firstname'] . ' ' . $object['lastname'];
             } else {
                 $leadName = $this->translator->trans('mautic.lead.lead.anonymous');
             }
             $date = new DateTimeHelper($object['start']);
             $object['start'] = $date->toLocalString(\DateTime::ISO8601);
             $object['url'] = $router->generate('mautic_campaign_action', array('objectAction' => 'view', 'objectId' => $object['campaign_id']), true);
             $object['attr'] = 'data-toggle="ajax"';
             $object['description'] = $this->translator->trans('mautic.campaign.event.' . $eventKey . '.description', array('%campaign%' => $object['campaign_name'], '%lead%' => $leadName));
             $object['title'] = $this->translator->trans('mautic.campaign.event.' . $eventKey, array('%event%' => $object['event_name']));
         }
         $event->addEvents($results);
     }
 }
开发者ID:woakes070048,项目名称:mautic,代码行数:42,代码来源:CalendarSubscriber.php

示例3: reverseTransform

 public function reverseTransform($rawFilters)
 {
     if (!is_array($rawFilters)) {
         return array();
     }
     foreach ($rawFilters as $k => $f) {
         if ($f['type'] == 'datetime') {
             $dt = new DateTimeHelper($f['filter'], 'Y-m-d H:i', 'local');
             $rawFilters[$k]['filter'] = $dt->toUtcString();
         }
     }
     return $rawFilters;
 }
开发者ID:woakes070048,项目名称:mautic,代码行数:13,代码来源:FieldDateTimeTransformer.php

示例4: reverseTransform

 /**
  * Form format to database format
  *
  * @param mixed $rawFilters
  *
  * @return array|mixed
  */
 public function reverseTransform($rawFilters)
 {
     if (!is_array($rawFilters)) {
         return array();
     }
     $rawFilters = array_values($rawFilters);
     foreach ($rawFilters as $k => $f) {
         if ($f['type'] == 'datetime') {
             if (in_array($f['filter'], $this->relativeDateStrings)) {
                 continue;
             }
             $dt = new DateTimeHelper($f['filter'], 'Y-m-d H:i', 'local');
             $rawFilters[$k]['filter'] = $dt->toUtcString();
         }
     }
     return $rawFilters;
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:24,代码来源:FieldFilterTransformer.php

示例5: reverseTransform

 /**
  * {@inheritdoc}
  *
  * @return array
  */
 public function reverseTransform($filters)
 {
     if (!is_array($filters)) {
         return [];
     }
     foreach ($filters as &$f) {
         if (!isset($this->columns[$f['column']])) {
             // Likely being called by form.pre_set_data after post
             return $filters;
         }
         $type = $this->columns[$f['column']]['type'];
         if (in_array($type, ['datetime', 'date', 'time'])) {
             $dt = new DateTimeHelper($f['value'], '', 'local');
             $f['value'] = $dt->toUtcString();
         }
     }
     return $filters;
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:23,代码来源:ReportFilterDataTransformer.php

示例6: getSentCounts

 /**
  * Get sent counts based grouped by dynamic content Id.
  *
  * @param array     $dynamicContentIds
  * @param \DateTime $fromDate
  *
  * @return array
  */
 public function getSentCounts($dynamicContentIds = [], \DateTime $fromDate = null)
 {
     $q = $this->_em->getConnection()->createQueryBuilder();
     $q->select('s.dynamic_content_id, count(s.id) as sent_count')->from(MAUTIC_TABLE_PREFIX . 'dynamic_content_stats', 's')->andWhere($q->expr()->in('e.dynamic_content_id', $dynamicContentIds));
     if ($fromDate !== null) {
         //make sure the date is UTC
         $dt = new DateTimeHelper($fromDate);
         $q->andWhere($q->expr()->gte('e.date_sent', $q->expr()->literal($dt->toUtcString())));
     }
     $q->groupBy('e.dynamic_content_id');
     //get a total number of sent emails first
     $results = $q->execute()->fetchAll();
     $counts = [];
     foreach ($results as $r) {
         $counts[$r['dynamic_content_id']] = $r['sent_count'];
     }
     return $counts;
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:26,代码来源:StatRepository.php

示例7: getDeviceStats

 /**
  * @param           $emailIds
  * @param \DateTime $fromDate
  *
  * @return array
  */
 public function getDeviceStats($emailIds, \DateTime $fromDate = null, \DateTime $toDate = null)
 {
     $qb = $this->getEntityManager()->getConnection()->createQueryBuilder();
     $qb->select('count(es.id) as count, d.device as device, es.list_id')->from(MAUTIC_TABLE_PREFIX . 'email_stats_devices', 'ed')->join('ed', MAUTIC_TABLE_PREFIX . 'lead_devices', 'd', 'd.id = ed.device_id')->join('ed', MAUTIC_TABLE_PREFIX . 'email_stats', 'es', 'es.id = ed.stat_id');
     if ($emailIds != null) {
         if (!is_array($emailIds)) {
             $emailIds = [(int) $emailIds];
         }
         $qb->where($qb->expr()->in('es.email_id', $emailIds));
     }
     $qb->groupBy('es.list_id, d.device');
     if ($fromDate !== null) {
         //make sure the date is UTC
         $dt = new DateTimeHelper($fromDate);
         $qb->andWhere($qb->expr()->gte('es.date_read', $qb->expr()->literal($dt->toUtcString())));
     }
     if ($toDate !== null) {
         //make sure the date is UTC
         $dt = new DateTimeHelper($toDate);
         $qb->andWhere($qb->expr()->lte('es.date_read', $qb->expr()->literal($dt->toUtcString())));
     }
     return $qb->execute()->fetchAll();
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:29,代码来源:StatDeviceRepository.php

示例8: getListFilterExpr


//.........这里部分代码省略.........
                     case 'year_next':
                     case 'year_this':
                         $interval = substr($key, -4);
                         $dtHelper->setDateTime('midnight first day of ' . $interval . ' year', null);
                         // This year: 2015-01-01 00:00:00
                         if ($requiresBetween) {
                             // eq:
                             //  field >= 2015-01-01 00:00:00
                             //  field <  2016-01-01 00:00:00
                             // neq:
                             // field <  2015-01-01 00:00:00
                             // field >= 2016-01-01 00:00:00
                             $modifier = '+1 year';
                         } else {
                             // lt:
                             //  field < 2015-01-01 00:00:00
                             // gt:
                             //  field > 2015-12-31 23:59:59
                             // lte:
                             //  field <= 2015-12-31 23:59:59
                             // gte:
                             //  field >= 2015-01-01 00:00:00
                             if (in_array($func, array('gt', 'lte'))) {
                                 $modifier = '+1 year -1 second';
                             }
                         }
                         break;
                     default:
                         $isRelative = false;
                         break;
                 }
                 if ($isRelative) {
                     if ($requiresBetween) {
                         $startWith = $isTimestamp ? $dtHelper->toUtcString('Y-m-d H:i:s') : $dtHelper->toUtcString('Y-m-d');
                         $dtHelper->modify($modifier);
                         $endWith = $isTimestamp ? $dtHelper->toUtcString('Y-m-d H:i:s') : $dtHelper->toUtcString('Y-m-d');
                         // Use a between statement
                         $func = $func == 'neq' ? 'notBetween' : 'between';
                         $details['filter'] = array($startWith, $endWith);
                     } else {
                         if ($modifier) {
                             $dtHelper->modify($modifier);
                         }
                         $details['filter'] = $isTimestamp ? $dtHelper->toUtcString('Y-m-d H:i:s') : $dtHelper->toUtcString('Y-m-d');
                     }
                 }
             };
             if (is_array($details['filter'])) {
                 foreach ($details['filter'] as &$filterValue) {
                     $getDate($filterValue);
                 }
             } else {
                 $getDate($details['filter']);
             }
         }
         // Generate a unique alias
         $alias = $this->generateRandomParameterName();
         switch ($details['field']) {
             case 'dnc_bounced':
             case 'dnc_unsubscribed':
                 // Special handling of do not email
                 $column = str_replace('dnc_', '', $details['field']);
                 $func = $func == 'eq' && $details['filter'] || $func == 'neq' && !$details['filter'] ? 'EXISTS' : 'NOT EXISTS';
                 $subqb = $this->_em->getConnection()->createQueryBuilder()->select('null')->from(MAUTIC_TABLE_PREFIX . 'email_donotemail', $alias)->where($q->expr()->andX($q->expr()->eq($alias . '.' . $column, $exprParameter), $q->expr()->eq($alias . '.lead_id', 'l.id')));
                 // Specific lead
                 if (!empty($leadId)) {
开发者ID:kasobus,项目名称:EDENS-Mautic,代码行数:67,代码来源:LeadListRepository.php

示例9: markRead

 /**
  * Marks messages as read
  *
  * @param      $toUserId
  * @param      $fromUserId
  * @param null $upToId
  */
 public function markRead($toUserId, $fromUserId, $upToId = 0)
 {
     $now = new DateTimeHelper();
     $q = $this->_em->getConnection()->createQueryBuilder();
     $q->update(MAUTIC_TABLE_PREFIX . 'chats')->set('is_read', ':true')->setParameter('true', true, 'boolean')->set('date_read', ':readDate')->where($q->expr()->andX($q->expr()->eq('from_user', ':from'), $q->expr()->eq('to_user', ':to'), $q->expr()->lte('id', ':id')))->setParameter('readDate', $now->toUtcString())->setParameter('from', $fromUserId)->setParameter('to', $toUserId)->setParameter('id', $upToId)->execute();
 }
开发者ID:woakes070048,项目名称:mautic-chat,代码行数:13,代码来源:ChatRepository.php

示例10: hitEmail

 /**
  * @param string|Stat $stat
  * @param             $request
  * @param bool        $viaBrowser
  */
 public function hitEmail($stat, $request, $viaBrowser = false)
 {
     if (!$stat instanceof Stat) {
         $stat = $this->getEmailStatus($stat);
     }
     if (!$stat) {
         return;
     }
     $email = $stat->getEmail();
     if ((int) $stat->isRead()) {
         if ($viaBrowser && !$stat->getViewedInBrowser()) {
             //opened via browser so note it
             $stat->setViewedInBrowser($viaBrowser);
         }
     }
     $readDateTime = new DateTimeHelper();
     $stat->setLastOpened($readDateTime->getDateTime());
     $lead = $stat->getLead();
     if ($lead !== null) {
         // Set the lead as current lead
         $this->leadModel->setCurrentLead($lead);
     }
     $firstTime = false;
     if (!$stat->getIsRead()) {
         $firstTime = true;
         $stat->setIsRead(true);
         $stat->setDateRead($readDateTime->getDateTime());
         // Only up counts if associated with both an email and lead
         if ($email && $lead) {
             try {
                 $this->getRepository()->upCount($email->getId(), 'read', 1, $email->isVariant());
             } catch (\Exception $exception) {
                 error_log($exception);
             }
         }
     }
     if ($viaBrowser) {
         $stat->setViewedInBrowser($viaBrowser);
     }
     $stat->addOpenDetails(['datetime' => $readDateTime->toUtcString(), 'useragent' => $request->server->get('HTTP_USER_AGENT'), 'inBrowser' => $viaBrowser]);
     //check for existing IP
     $ipAddress = $this->ipLookupHelper->getIpAddress();
     $stat->setIpAddress($ipAddress);
     if ($this->dispatcher->hasListeners(EmailEvents::EMAIL_ON_OPEN)) {
         $event = new EmailOpenEvent($stat, $request, $firstTime);
         $this->dispatcher->dispatch(EmailEvents::EMAIL_ON_OPEN, $event);
     }
     //device granularity
     $dd = new DeviceDetector($request->server->get('HTTP_USER_AGENT'));
     $dd->parse();
     $deviceRepo = $this->leadModel->getDeviceRepository();
     $emailOpenDevice = $deviceRepo->getDevice(null, $lead, $dd->getDeviceName(), $dd->getBrand(), $dd->getModel());
     if (empty($emailOpenDevice)) {
         $emailOpenDevice = new LeadDevice();
         $emailOpenDevice->setClientInfo($dd->getClient());
         $emailOpenDevice->setDevice($dd->getDeviceName());
         $emailOpenDevice->setDeviceBrand($dd->getBrand());
         $emailOpenDevice->setDeviceModel($dd->getModel());
         $emailOpenDevice->setDeviceOs($dd->getOs());
         $emailOpenDevice->setDateOpen($readDateTime->toUtcString());
         $emailOpenDevice->setLead($lead);
         try {
             $this->em->persist($emailOpenDevice);
             $this->em->flush($emailOpenDevice);
         } catch (\Exception $exception) {
             if (MAUTIC_ENV === 'dev') {
                 throw $exception;
             } else {
                 $this->logger->addError($exception->getMessage(), ['exception' => $exception]);
             }
         }
     } else {
         $emailOpenDevice = $deviceRepo->getEntity($emailOpenDevice['id']);
     }
     if ($email) {
         $this->em->persist($email);
         $this->em->flush($email);
     }
     if (isset($emailOpenDevice) and is_object($emailOpenDevice)) {
         $emailOpenStat = new StatDevice();
         $emailOpenStat->setIpAddress($ipAddress);
         $emailOpenStat->setDevice($emailOpenDevice);
         $emailOpenStat->setDateOpened($readDateTime->toUtcString());
         $emailOpenStat->setStat($stat);
         $this->em->persist($emailOpenStat);
         $this->em->flush($emailOpenStat);
     }
     $this->em->persist($stat);
     $this->em->flush();
 }
开发者ID:Yame-,项目名称:mautic,代码行数:95,代码来源:EmailModel.php

示例11: setLastActive

 /**
  * @param $user
  */
 public function setLastActive($user)
 {
     $now = new DateTimeHelper();
     $conn = $this->_em->getConnection();
     $conn->update(MAUTIC_TABLE_PREFIX . 'users', array('last_active' => $now->toUtcString()), array('id' => (int) $user->getId()));
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:9,代码来源:UserRepository.php

示例12: analyzeMessage


//.........这里部分代码省略.........
     }
     // Search for the lead
     $stat = $leadId = $leadEmail = $emailId = null;
     if (!empty($hashId)) {
         $q = $this->db->createQueryBuilder();
         // Search by hashId
         $q->select('*')->from(MAUTIC_TABLE_PREFIX . 'email_stats', 's')->where($q->expr()->eq('s.tracking_hash', ':hash'))->setParameter('hash', $hashId);
         $results = $q->execute()->fetchAll();
         if (count($results)) {
             $stat = $results[0];
             $leadId = $stat['lead_id'];
             $leadEmail = $stat['email_address'];
             $emailId = $stat['email_id'];
             $this->logger->debug('Stat found with ID# ' . $stat['id']);
         }
         unset($results);
     }
     if (!$leadId) {
         if ($isBounce) {
             if (!empty($messageDetails['email'])) {
                 $leadEmail = $messageDetails['email'];
             } else {
                 // Email not found for the bounce so abort
                 $this->logger->error('BOUNCE ERROR: A lead could be found from the bounce email. From: ' . $message->fromAddress . '; To: ' . $message->toString . '; Subject: ' . $message->subject);
                 return false;
             }
         } else {
             $leadEmail = $message->fromAddress;
             $this->logger->debug('From address used: ' . $leadEmail);
         }
         // Search by first part and domain of email to find cases like me+mautic@domain.com
         list($email, $domain) = explode('@', strtolower($leadEmail));
         $email = $email . '%';
         $domain = '%@' . $domain;
         $q = $this->db->createQueryBuilder();
         $q->select('l.id, l.email')->from(MAUTIC_TABLE_PREFIX . 'leads', 'l')->where($q->expr()->orX($q->expr()->eq('LOWER(l.email)', ':leademail'), $q->expr()->andX($q->expr()->like('LOWER(l.email)', ':email'), $q->expr()->like('LOWER(l.email)', ':domain'))))->setParameter('leademail', strtolower($leadEmail))->setParameter('email', strtolower($email))->setParameter('domain', strtolower($domain));
         $foundLeads = $q->execute()->fetchAll();
         foreach ($foundLeads as $lead) {
             if (strtolower($lead['email']) == strtolower($leadEmail)) {
                 // Exact match
                 $leadId = $lead['id'];
                 break;
             } elseif (strpos($lead['email'], '+') === false) {
                 // Not a plus style email so not a match
                 break;
             }
             if (preg_match('#^(.*?)\\+(.*?)@(.*?)$#', $lead['email'], $parts)) {
                 $email = $parts[1] . '@' . $parts[3];
                 if (strtolower($email) == strtolower($leadEmail)) {
                     $this->logger->debug('Lead found through + alias: ' . $lead['email']);
                     $leadId = $lead['id'];
                     $leadEmail = $lead['email'];
                 }
             }
         }
         $this->logger->debug('Lead ID: ' . ($leadId ? $leadId : 'not found'));
     }
     if (!$leadId) {
         // A lead still could not be found
         return false;
     }
     // Set message details for unsubscribe requests
     if ($isUnsubscribe) {
         $messageDetails = array('remove' => true, 'email' => $leadEmail, 'rule_cat' => 'unsubscribed', 'rule_no' => '0000');
     }
     if ($isBounce && $stat) {
         // Update the stat with some details
         $openDetails = unserialize($stat['open_details']);
         if (!is_array($openDetails)) {
             $openDetails = array();
         }
         $openDetails['bounces'][] = array('datetime' => $dtHelper->toUtcString(), 'reason' => $messageDetails['rule_cat'], 'code' => $messageDetails['rule_no'], 'type' => $messageDetails['bounce_type'] === false ? 'unknown' : $messageDetails['bounce_type']);
         $this->db->update(MAUTIC_TABLE_PREFIX . 'email_stats', array('open_details' => serialize($openDetails), 'retry_count' => ++$stat['retry_count'], 'is_failed' => $messageDetails['remove'] || $stat['retry_count'] == 5 ? 1 : 0), array('id' => $stat['id']));
         $this->logger->debug('Stat updated');
     }
     // Is this a hard bounce or AN unsubscribe?
     if ($messageDetails['remove'] || $stat && $stat['retry_count'] >= 5) {
         $this->logger->debug('Adding DNC entry for ' . $leadEmail);
         // Check for an existing DNC entry
         $q = $this->db->createQueryBuilder();
         $q->select('dnc.id')->from(MAUTIC_TABLE_PREFIX . 'lead_donotcontact', 'dnc')->where('dnc.channel = "email"')->where($q->expr()->eq('dnc.lead_id', ':leadId'))->setParameter('leadId', $leadId);
         try {
             $exists = $q->execute()->fetchColumn();
         } catch (\Exception $e) {
             $this->logger->error($e->getMessage());
         }
         if (!empty($exists)) {
             $this->logger->debug('A DNC entry already exists for ' . $leadEmail);
         } else {
             $this->logger->debug('Existing not found so creating a new one.');
             // Create a DNC entry
             try {
                 $this->db->insert(MAUTIC_TABLE_PREFIX . 'lead_donotcontact', array('lead_id' => $leadId, 'channel' => 'email', 'channel_id' => $emailId, 'date_added' => $dtHelper->toUtcString(), 'reason' => $isUnsubscribe ? DoNotContact::UNSUBSCRIBED : DoNotContact::BOUNCED, 'comments' => $this->factory->getTranslator()->trans('mautic.email.bounce.reason.' . $messageDetails['rule_cat'])));
             } catch (\Exception $e) {
                 $this->logger->error($e->getMessage());
             }
         }
     }
     $this->logger->debug(print_r($messageDetails, true));
 }
开发者ID:Yame-,项目名称:mautic,代码行数:101,代码来源:MessageHelper.php

示例13: getSubmissionCountsByEmail

 /**
  * Get submission count by email by linking emails that have been associated with a page hit that has the
  * same tracking ID as a form submission tracking ID and thus assumed happened in the same session
  *
  * @param           $emailId
  * @param \DateTime $fromDate
  *
  * @return mixed
  */
 public function getSubmissionCountsByEmail($emailId, \DateTime $fromDate = null)
 {
     //link email to page hit tracking id to form submission tracking id
     $q = $this->_em->getConnection()->createQueryBuilder();
     $q->select('count(distinct(s.tracking_id)) as count, e.id, e.subject as name, e.variant_sent_count as total')->from(MAUTIC_TABLE_PREFIX . 'form_submissions', 's')->join('s', MAUTIC_TABLE_PREFIX . 'page_hits', 'h', 's.tracking_id = h.tracking_id')->join('h', MAUTIC_TABLE_PREFIX . 'emails', 'e', 'h.email_id = e.id');
     if (is_array($emailId)) {
         $q->where($q->expr()->in('e.id', $emailId))->groupBy('e.id, e.subject, e.variant_sent_count');
     } else {
         $q->where($q->expr()->eq('e.id', ':id'))->setParameter('id', (int) $emailId);
     }
     if ($fromDate != null) {
         $dh = new DateTimeHelper($fromDate);
         $q->andWhere($q->expr()->gte('s.date_submitted', ':date'))->setParameter('date', $dh->toUtcString());
     }
     $results = $q->execute()->fetchAll();
     return $results;
 }
开发者ID:smotalima,项目名称:mautic,代码行数:26,代码来源:SubmissionRepository.php

示例14: getSentCounts

 /**
  * Get sent counts based grouped by email Id
  *
  * @param array $emailIds
  *
  * @return array
  */
 public function getSentCounts($emailIds = array(), \DateTime $fromDate = null)
 {
     $q = $this->_em->getConnection()->createQueryBuilder();
     $q->select('e.email_id, count(e.id) as sentcount')->from(MAUTIC_TABLE_PREFIX . 'email_stats', 'e')->where($q->expr()->andX($q->expr()->in('e.email_id', $emailIds), $q->expr()->eq('e.is_failed', ':false')))->setParameter('false', false, 'boolean');
     if ($fromDate !== null) {
         //make sure the date is UTC
         $dt = new DateTimeHelper($fromDate);
         $q->andWhere($q->expr()->gte('e.date_read', $q->expr()->literal($dt->toUtcString())));
     }
     $q->groupBy('e.email_id');
     //get a total number of sent emails first
     $results = $q->execute()->fetchAll();
     $counts = array();
     foreach ($results as $r) {
         $counts[$r['email_id']] = $r['sentcount'];
     }
     return $counts;
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:25,代码来源:StatRepository.php

示例15: postUp


//.........这里部分代码省略.........
         }
         $templateEmailIds = array_keys($templateEmails);
         /** @var \Mautic\EmailBundle\Model\EmailModel $emailModel */
         $emailModel = $this->factory->getModel('email');
         $emails = $emailModel->getEntities(array('iterator_mode' => true, 'filter' => array('force' => array(array('column' => 'e.id', 'expr' => 'in', 'value' => $templateEmailIds)))));
         $persistListEmails = $persistTemplateEmails = $variants = array();
         // Clone since the ID may be in a bunch of serialized properties then convert new to a list based email
         while (($row = $emails->next()) !== false) {
             /** @var \Mautic\EmailBundle\Entity\Email $templateEmail */
             $templateEmail = reset($row);
             $id = $templateEmail->getId();
             $listEmail = clone $templateEmail;
             $listEmail->setEmailType('list');
             $listEmail->clearVariants();
             $listEmail->clearStats();
             $listSentCount = $templateEmails[$id]['sent_count'];
             $listReadCount = $templateEmails[$id]['read_count'];
             $currentSentCount = $templateEmail->getSentCount();
             $currentReadCount = $templateEmail->getReadCount();
             // Assume the difference between the current counts and the list counts are template related
             $templateEmail->setSentCount($currentSentCount - $listSentCount);
             $templateEmail->setReadCount($currentReadCount - $listReadCount);
             // Set the list email stats
             $listEmail->setSentCount($listSentCount);
             $listEmail->setReadCount($listReadCount);
             // Special cases for variants
             if ($variantStartDate = $templateEmail->getVariantStartDate()) {
                 // Take note that this email needs to also have it's variants
                 if (!in_array($id, $variants)) {
                     $variants[] = $id;
                 }
                 $dtHelper = new DateTimeHelper($variantStartDate);
                 $q = $this->connection->createQueryBuilder();
                 $q->select('s.email_id, count(*) as sent_count, sum(case when s.is_read then 1 else 0 end) as read_count')->from(MAUTIC_TABLE_PREFIX . 'email_stats', 's')->where($q->expr()->andX($q->expr()->isNotNull('s.list_id'), $q->expr()->eq('s.email_id', $id), $q->expr()->gte('s.date_sent', $q->expr()->literal($dtHelper->toUtcString('Y-m-d H:i:s')))))->groupBy('s.email_id');
                 $results = $q->execute()->fetchAll();
                 $variantListSentCount = $results[0]['sent_count'];
                 $variantListReadCount = $results[0]['read_count'];
                 $variantCurrentSentCount = $templateEmail->getVariantSentCount();
                 $variantCurrentReadCount = $templateEmail->getVariantReadCount();
                 // Assume the difference between the current counts and the list counts are template related
                 $templateEmail->setVariantSentCount($variantCurrentSentCount - $variantListSentCount);
                 $templateEmail->setVariantReadCount($variantCurrentReadCount - $variantListReadCount);
                 // Set the list email stats
                 $listEmail->setVariantSentCount($variantListSentCount);
                 $listEmail->setVariantReadCount($variantListReadCount);
             }
             $persistListEmails[$id] = $listEmail;
             $persistTemplateEmails[$id] = $templateEmail;
             unset($listEmail, $templateEmail);
         }
         $repo = $emailModel->getRepository();
         // Update template emails; no need to run through audit log stuff so just use repo
         $repo->saveEntities($persistTemplateEmails);
         // Create new list emails and tell audit log to use system
         define('MAUTIC_IGNORE_AUDITLOG_USER', 1);
         $emailModel->saveEntities($persistListEmails);
         // Clone variants
         $persistVariants = array();
         $processedVariants = array();
         foreach ($variants as $templateEmailId) {
             if ($persistTemplateEmails[$templateEmailId]->isVariant(true)) {
                 // A variant of another so get parent
                 $templateParent = $persistTemplateEmails[$templateEmailId]->getVariantParent();
             } else {
                 $templateParent = $persistTemplateEmails[$templateEmailId];
             }
开发者ID:Yame-,项目名称:mautic,代码行数:67,代码来源:Version20150521000000.php


注:本文中的Mautic\CoreBundle\Helper\DateTimeHelper::toUtcString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。