Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/dev/1.4' into 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrebenchuk committed Nov 17, 2014
2 parents a0d0d22 + 3bb5eef commit aceed4a
Show file tree
Hide file tree
Showing 68 changed files with 2,312 additions and 624 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
CHANGELOG for 1.4.1
===================
This changelog references the relevant changes (new features, changes and bugs) done in 1.4.1 versions.
* 1.4.1 (2014-11-17)
* List of improvements and fixed bugs
<ul><li>Added MailChimp support changes</li>
<li>Added migration for b2b customers</li>
<li>Added related entities to segments filters</li>
<li>Added shopping cart management to Oro Bridge support</li>
<li>Made Email campaign entities configurable</li>
<li>Made contact address, email and phone entities extendable</li>
<li>Fixed issues with lifetime value after update</li>
<li>Fixed upload pictures/avatar to entity</li>
<li>Fixed missing Campaign details grid and chart</li>
<li>Fixed "Sync data" on cart page with invalid API credentials</li>
<li>Fixed duplicates of entities during magento import</li></ul>

CHANGELOG for 1.4.0
===================
This changelog references the relevant changes (new features, changes and bugs) done in 1.4.0 versions.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"require": {
"php": ">=5.4.9",
"oro/platform": "1.4.x-dev"
"oro/platform": "1.4.*"
},
"minimum-stability": "dev",
"prefer-stable": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ public function updateAction(EmailCampaign $entity)
*/
public function viewAction(EmailCampaign $entity)
{
return ['entity' => $entity];
$stats = $this->getDoctrine()
->getRepository("OroCRMCampaignBundle:EmailCampaignStatistics")
->getEmailCampaignStats($entity);
return ['entity' => $entity, 'stats' => $stats, 'show_stats' => (bool) array_sum($stats)];
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/OroCRM/Bundle/CampaignBundle/Entity/EmailCampaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\ConfigField;
use Oro\Bundle\OrganizationBundle\Entity\Organization;
use Oro\Bundle\UserBundle\Entity\User;
use OroCRM\Bundle\CampaignBundle\Model\ExtendEmailCampaign;
use OroCRM\Bundle\MarketingListBundle\Entity\MarketingList;

/**
Expand Down Expand Up @@ -36,7 +37,7 @@
* }
* )
*/
class EmailCampaign
class EmailCampaign extends ExtendEmailCampaign
{
const SCHEDULE_MANUAL = 'manual';
const SCHEDULE_DEFERRED = 'deferred';
Expand Down
189 changes: 186 additions & 3 deletions src/OroCRM/Bundle/CampaignBundle/Entity/EmailCampaignStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@

use Doctrine\ORM\Mapping as ORM;

use OroCRM\Bundle\CampaignBundle\Model\ExtendEmailCampaignStatistics;
use OroCRM\Bundle\MarketingListBundle\Entity\MarketingListItem;

/**
* Email Campaign Statistics.
*
* @ORM\Table(name="orocrm_campaign_email_stats")
* @ORM\Entity
* @ORM\Entity(repositoryClass="OroCRM\Bundle\CampaignBundle\Entity\Repository\EmailCampaignStatisticsRepository")
* @ORM\Table(name="orocrm_campaign_email_stats", uniqueConstraints={
* @ORM\UniqueConstraint(columns={"email_campaign_id", "marketing_list_item_id"}, name="orocrm_ec_litem_unq")
* })
* @ORM\HasLifecycleCallbacks
*/
class EmailCampaignStatistics
class EmailCampaignStatistics extends ExtendEmailCampaignStatistics
{
/**
* @var int
Expand All @@ -40,6 +43,41 @@ class EmailCampaignStatistics
*/
protected $emailCampaign;

/**
* @var int
*
* @ORM\Column(name="open_count", type="integer", nullable=true)
*/
protected $openCount;

/**
* @var int
*
* @ORM\Column(name="click_count", type="integer", nullable=true)
*/
protected $clickCount;

/**
* @var int
*
* @ORM\Column(name="bounce_count", type="integer", nullable=true)
*/
protected $bounceCount;

/**
* @var int
*
* @ORM\Column(name="abuse_count", type="integer", nullable=true)
*/
protected $abuseCount;

/**
* @var int
*
* @ORM\Column(name="unsubscribe_count", type="integer", nullable=true)
*/
protected $unsubscribeCount;

/**
* @var \DateTime
*
Expand Down Expand Up @@ -93,6 +131,151 @@ public function setEmailCampaign(EmailCampaign $emailCampaign)
return $this;
}

/**
* @return int
*/
public function getOpenCount()
{
return $this->openCount;
}

/**
* @param int $openCount
* @return EmailCampaignStatistics
*/
public function setOpenCount($openCount)
{
$this->openCount = $openCount;

return $this;
}

/**
* @return EmailCampaignStatistics
*/
public function incrementOpenCount()
{
$this->openCount++;

return $this;
}

/**
* @return int
*/
public function getClickCount()
{
return $this->clickCount;
}

/**
* @param int $clickCount
* @return EmailCampaignStatistics
*/
public function setClickCount($clickCount)
{
$this->clickCount = $clickCount;

return $this;
}

/**
* @return EmailCampaignStatistics
*/
public function incrementClickCount()
{
$this->clickCount++;

return $this;
}

/**
* @return int
*/
public function getBounceCount()
{
return $this->bounceCount;
}

/**
* @param int $bounceCount
* @return EmailCampaignStatistics
*/
public function setBounceCount($bounceCount)
{
$this->bounceCount = $bounceCount;

return $this;
}

/**
* @return EmailCampaignStatistics
*/
public function incrementBounceCount()
{
$this->bounceCount++;

return $this;
}

/**
* @return int
*/
public function getAbuseCount()
{
return $this->abuseCount;
}

/**
* @param int $abuseCount
* @return EmailCampaignStatistics
*/
public function setAbuseCount($abuseCount)
{
$this->abuseCount = $abuseCount;

return $this;
}

/**
* @return EmailCampaignStatistics
*/
public function incrementAbuseCount()
{
$this->abuseCount++;

return $this;
}

/**
* @return int
*/
public function getUnsubscribeCount()
{
return $this->unsubscribeCount;
}

/**
* @param int $unsubscribeCount
* @return EmailCampaignStatistics
*/
public function setUnsubscribeCount($unsubscribeCount)
{
$this->unsubscribeCount = $unsubscribeCount;

return $this;
}

/**
* @return EmailCampaignStatistics
*/
public function incrementUnsubscribeCount()
{
$this->unsubscribeCount++;

return $this;
}

/**
* @return \DateTime
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace OroCRM\Bundle\CampaignBundle\Entity\Repository;

use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\EntityRepository;
use OroCRM\Bundle\CampaignBundle\Entity\EmailCampaign;

class EmailCampaignStatisticsRepository extends EntityRepository
{
/**
* @param EmailCampaign $emailCampaign
* @return array
*/
public function getEmailCampaignStats(EmailCampaign $emailCampaign)
{
$qb = $this->getEntityManager()->createQueryBuilder();
$qb
->select(
[
'SUM(ecs.openCount) as open',
'SUM(ecs.clickCount) as click',
'SUM(ecs.bounceCount) as bounce',
'SUM(ecs.abuseCount) as abuse',
'SUM(ecs.unsubscribeCount) as unsubscribe'
]
)
->from('OroCRMCampaignBundle:EmailCampaignStatistics', 'ecs')
->where($qb->expr()->eq('ecs.emailCampaign', ':emailCampaign'))
->setParameter('emailCampaign', $emailCampaign);

return $qb->getQuery()->getSingleResult();
}
}
Loading

0 comments on commit aceed4a

Please sign in to comment.