Skip to content

Commit

Permalink
Merge branch master into feature/CRM-4667
Browse files Browse the repository at this point in the history
Conflicts:
package/crm/src/OroCRM/Bundle/SalesBundle/Resources/config/services.yml
  • Loading branch information
Alex Solonenko committed Jul 14, 2016
2 parents 1f2a269 + 742426d commit ad517f3
Show file tree
Hide file tree
Showing 55 changed files with 525 additions and 52 deletions.
6 changes: 6 additions & 0 deletions UPGRADE-1.10.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ UPGRADE FROM 1.9 to 1.10
- Class `OroCRM\Bundle\SalesBundle\Provider\OpportunityByStatusProvider` moved to `OroCRM\Bundle\SalesBundle\Dashboard\Provider\OpportunityByStatusProvider`. New argument: `OwnerHelper $ownerHelper`
- B2bCustomer entity extended with 2 collection fields (emails, phones)

#### OroCRMCallBundle:
- The `duration` field in `OroCRM\Bundle\CallBundle\Entity\Call` is changed to `duration` DB type
from `DateTime` which accepts a (int) duration in seconds.
Updating Call `duration` field (API POST/PUT, Forms) now accepts strings with formats '*HH*:*MM*:*SS*', '*HH*h *MM*m *SS*s' or `(int)` seconds
Retrieving Call `duration` field (API GET) now returns `(int)` seconds instead of 'HH:MM:SS' formatted string

####OroCRMTaskBundle:
- OroCRMTaskBundle moved to a separate package
- OroCRMTaskBridgeBundle was added to integrate OroCRMTaskBundle into CRM
Expand Down
3 changes: 2 additions & 1 deletion src/OroCRM/Bundle/AccountBundle/Entity/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
* },
* "security"={
* "type"="ACL",
* "group_name"=""
* "group_name"="",
* "category"="account_management"
* },
* "merge"={
* "enable"=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/**
* @outputBuffering enabled
* @dbIsolation
* @group soap
*/
class SoapAccountTest extends WebTestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@
* @ORM\Table(name="orocrm_analytics_rfm_category")
* @Config(
* defaultValues={
* "entity"={
* },
* "ownership"={
* "owner_type"="ORGANIZATION",
* "owner_field_name"="owner",
* "owner_column_name"="owner_id"
* },
* "security"={
* "type"="ACL",
* "group_name"=""
* "group_name"="",
* "category"="account_management"
* }
* }
* )
Expand Down
19 changes: 10 additions & 9 deletions src/OroCRM/Bundle/CallBundle/Entity/Call.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
* },
* "security"={
* "type"="ACL",
* "group_name"=""
* "group_name"="",
* "category"="account_management"
* },
* "grouping"={
* "groups"={"activity"}
Expand All @@ -59,7 +60,7 @@
class Call extends ExtendCall implements DatesAwareInterface
{
/**
* @var integer
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
Expand Down Expand Up @@ -118,10 +119,10 @@ class Call extends ExtendCall implements DatesAwareInterface
protected $callStatus;

/**
* @var \DateTime
* @var int
*
* @ORM\Column(name="duration", type="time", nullable=true)
* @Soap\ComplexType("dateTime", nillable=true)
* @ORM\Column(name="duration", type="duration", nullable=true)
* @Soap\ComplexType("int", nillable=true)
*/
protected $duration;

Expand Down Expand Up @@ -180,13 +181,13 @@ public function __construct()
{
parent::__construct();
$this->callDateTime = new \DateTime('now', new \DateTimeZone('UTC'));
$this->duration = new \DateTime('00:00:00', new \DateTimeZone('UTC'));
$this->duration = 0;
}

/**
* Get id
*
* @return integer
* @return int
*/
public function getId()
{
Expand Down Expand Up @@ -288,7 +289,7 @@ public function getCallDateTime()
/**
* Set duration
*
* @param \DateTime $duration
* @param int $duration
* @return Call
*/
public function setDuration($duration)
Expand All @@ -301,7 +302,7 @@ public function setDuration($duration)
/**
* Get duration
*
* @return \DateTime
* @return int
*/
public function getDuration()
{
Expand Down
2 changes: 1 addition & 1 deletion src/OroCRM/Bundle/CallBundle/Form/Type/CallType.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
)
->add(
'duration',
'oro_time_interval',
'oro_duration',
[
'required' => false,
'label' => 'orocrm.call.duration.label'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function setCommentExtension(CommentExtension $commentExtension)
*/
public function getMigrationVersion()
{
return 'v1_6';
return 'v1_7';
}

/**
Expand Down Expand Up @@ -81,7 +81,7 @@ protected function createOrocrmCallTable(Schema $schema)
$table->addColumn('phone_number', 'string', ['notnull' => false, 'length' => 255]);
$table->addColumn('notes', 'text', ['notnull' => false]);
$table->addColumn('call_date_time', 'datetime', []);
$table->addColumn('duration', 'time', ['notnull' => false]);
$table->addColumn('duration', 'duration', ['notnull' => false, 'default' => null]);
$table->addColumn('created_at', 'datetime', []);
$table->addColumn('updated_at', 'datetime', []);
$table->setPrimaryKey(['id']);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

namespace OroCRM\Bundle\CallBundle\Migrations\Schema\v1_7;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\PostgreSQL92Platform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;

use Oro\Bundle\MigrationBundle\Migration\Extension\DatabasePlatformAwareInterface;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\ParametrizedSqlMigrationQuery;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
use Oro\Bundle\MigrationBundle\Migration\SqlMigrationQuery;

class OroCRMCallBundle implements Migration, DatabasePlatformAwareInterface
{
/** @var AbstractPlatform */
protected $platform;

/** {@inheritdoc} */
public function setDatabasePlatform(AbstractPlatform $platform)
{
$this->platform = $platform;
}

/** {@inheritdoc} */
public function up(Schema $schema, QueryBag $queries)
{
// migrate column to new type
$queries->addPreQuery($this->getPlatformSQL());

// migrate oro_entity_config_field
$entityClass = 'OroCRM\\Bundle\\CallBundle\\Entity\\Call';

$migrateFieldSql = 'UPDATE oro_entity_config_field SET type = :field_type' .
' WHERE field_name = :field_name' .
' AND entity_id IN' .
' (SELECT id FROM oro_entity_config WHERE class_name = :class_name)';
$migrateEntityFieldQuery = new ParametrizedSqlMigrationQuery();
$migrateEntityFieldQuery->addSql(
$migrateFieldSql,
['field_type' => 'duration', 'field_name' => 'duration', 'class_name' => $entityClass],
['field_type' => Type::STRING, 'field_name' => Type::STRING, 'class_name' => Type::STRING]
);

$queries->addPostQuery($migrateEntityFieldQuery);
}

/**
* Gets platform dependant sql for migration
*
* @return SqlMigrationQuery
*/
private function getPlatformSQL()
{
$migrateDataSQL = 'UPDATE orocrm_call SET duration =' .
' EXTRACT(HOUR FROM duration_old) * 3600 +' .
' EXTRACT(MINUTE FROM duration_old) * 60 +' .
' EXTRACT(SECOND FROM duration_old) * 1';

if ($this->platform instanceof PostgreSQL92Platform) {
return new SqlMigrationQuery(
[
'ALTER TABLE orocrm_call RENAME COLUMN duration TO duration_old',
'ALTER TABLE orocrm_call ADD COLUMN duration int NULL DEFAULT NULL',
'COMMENT ON COLUMN orocrm_call.duration IS \'(DC2Type:duration)\'',
$migrateDataSQL,
'ALTER TABLE orocrm_call DROP COLUMN duration_old',
]
);
}

return new SqlMigrationQuery(
[
'ALTER TABLE orocrm_call CHANGE duration duration_old TIME NULL DEFAULT NULL',
'ALTER TABLE orocrm_call ADD COLUMN duration int NULL DEFAULT NULL' .
' COMMENT \'(DC2Type:duration)\'',
$migrateDataSQL,
'ALTER TABLE orocrm_call DROP COLUMN duration_old',
]
);
}
}
6 changes: 6 additions & 0 deletions src/OroCRM/Bundle/CallBundle/Resources/config/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ OroCRM\Bundle\CallBundle\Entity\Call:
- DateTime: ~
callStatus:
- NotBlank: ~
duration:
- NotBlank: ~
- Range:
min: 0
max: 2147483647
maxMessage: 'Duration is too big.'
direction:
- NotBlank: ~
phoneNumber:
Expand Down
8 changes: 4 additions & 4 deletions src/OroCRM/Bundle/CallBundle/Resources/doc/reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $request = [
"call" => [
"subject" => 'Subject',
"owner" => 1,
"duration" => '00:00:05',
"duration" => '00:01:05', // also can be "0h 1m 5s" or "65" (seconds)
"direction" => 'outgoing', // can be 'outgoing' or 'incoming'
"callDateTime" => '2015-01-01T12:00:00',
"phoneNumber" => '123-123-123',
Expand Down Expand Up @@ -104,7 +104,7 @@ Content:
"phoneNumber": "548-146-4418",
"notes": null,
"callDateTime": "2015-04-09T13:47:43+00:00",
"duration": "1970-01-01T01:26:07+00:00",
"duration": 265,
"createdAt": "2015-04-09T13:47:43+00:00",
"updatedAt": "2015-04-09T13:47:43+00:00",
"owner": "michael.wagner_39d92",
Expand All @@ -118,7 +118,7 @@ Content:
"phoneNumber": "307-204-8559",
"notes": null,
"callDateTime": "2015-04-09T13:47:43+00:00",
"duration": "1970-01-01T00:18:05+00:00",
"duration": 96,
"createdAt": "2015-04-09T13:47:43+00:00",
"updatedAt": "2015-04-09T13:47:43+00:00",
"owner": "michael.hodges_97152",
Expand Down Expand Up @@ -161,7 +161,7 @@ Content:
"phoneNumber": "969-943-7424",
"notes": null,
"callDateTime": "2015-04-09T13:47:43+00:00",
"duration": "1970-01-01T01:06:43+00:00",
"duration": 64,
"createdAt": "2015-04-09T13:47:43+00:00",
"updatedAt": "2015-04-09T13:47:43+00:00",
"owner": "william.jacobs_9108d",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function ($a) use ($id) {
$result = $this->getJsonResponseContent($this->client->getResponse(), 200);

$this->assertEquals($request['call']['subject'], $result['subject']);
$this->assertEquals(5, $result['duration']);
}

/**
Expand Down Expand Up @@ -132,4 +133,57 @@ public function testDelete(array $request)
$result = $this->client->getResponse();
$this->assertJsonResponseStatusCodeEquals($result, 404);
}

public function testCreateWithSecondsDuration()
{
$request = [
"call" => [
"subject" => 'Test Call ' . mt_rand(),
"owner" => '1',
"duration" => '23.5h 13.5s',
"direction" => 'outgoing',
"callDateTime" => date('c'),
"phoneNumber" => '123-123=123',
"callStatus" => 'completed',
"associations" => [
[
"entityName" => 'Oro\Bundle\UserBundle\Entity\User',
"entityId" => 1,
"type" => 'activity'
],
]
]
];
$this->client->request(
'POST',
$this->getUrl('oro_api_post_call'),
$request
);

$result = $this->getJsonResponseContent($this->client->getResponse(), 201);

$this->assertArrayHasKey('id', $result);

$request['id'] = $result['id'];

return $request;
}

/**
* @param array $request
*
* @depends testCreateWithSecondsDuration
*/
public function testGetWithSeconds(array $request)
{
$this->client->request(
'GET',
$this->getUrl('oro_api_get_call', ['id' => $request['id']])
);

$result = $this->getJsonResponseContent($this->client->getResponse(), 200);

$duration = (23 * 60 * 60) + (30 * 60) + 14; //23.5h 13.5s
$this->assertEquals($duration, $result['duration']);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/**
* @outputBuffering enabled
* @dbIsolation
* @group soap
*/
class CallControllerTest extends WebTestCase
{
Expand All @@ -28,7 +29,7 @@ public function testCreate()
"notes" => 'notes',
"callDateTime" => new \DateTime('now', new \DateTimeZone('UTC')),
"callStatus" => 'in_progress',
"duration" => new \DateTime('00:00:00', new \DateTimeZone('UTC')),
"duration" => '00:00:00',
"direction" => 'incoming',
);
$result = $this->soapClient->createCall($request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testBuildForm()
'notes' => 'oro_resizeable_rich_text',
'callDateTime' => 'oro_datetime',
'callStatus' => 'translatable_entity',
'duration' => 'oro_time_interval',
'duration' => 'oro_duration',
'direction' => 'translatable_entity'
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ protected function getForm()
* type="action",
* label="orocrm.campaign.acl.send_emails.label",
* description="orocrm.campaign.acl.send_emails.description",
* group_name=""
* group_name="",
* category="marketing"
* )
*
* @param EmailCampaign $entity
Expand Down
3 changes: 2 additions & 1 deletion src/OroCRM/Bundle/CampaignBundle/Entity/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
* },
* "security"={
* "type"="ACL",
* "group_name"=""
* "group_name"="",
* "category"="marketing"
* },
* "form"={
* "form_type"="orocrm_campaign_select",
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 @@ -32,7 +32,8 @@
* },
* "security"={
* "type"="ACL",
* "group_name"=""
* "group_name"="",
* "category"="marketing"
* },
* "grid"={
* "default"="orocrm-email-campaign-grid"
Expand Down
Loading

0 comments on commit ad517f3

Please sign in to comment.