Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/dev/1.10' into 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrebenchuk committed Dec 9, 2016
2 parents 2f7bc57 + e153437 commit 3bcec01
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 20 deletions.
4 changes: 4 additions & 0 deletions src/OroCRM/Bundle/AccountBundle/Resources/config/datagrid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ datagrid:
label: oro.grid.action.delete
icon: trash
link: delete_link
defaultMessages:
confirm_content: oro.ui.delete_confirm_cascade
confirm_content_params:
entity_label: '@translator->trans(oro.account.entity_label)'
mass_actions:
merge:
type: merge
Expand Down
14 changes: 14 additions & 0 deletions src/OroCRM/Bundle/CaseBundle/Resources/config/datagrid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ datagrid:
field_options:
class: OroCRMCaseBundle:CaseSource
property: label
owner:
type: choice-tree
label: oro.user.owner.label
data_name: caseEntity.owner
autocomplete_alias: users
renderedPropertyName: 'fullName'
className: 'Oro\Bundle\UserBundle\Entity\User'
enabled: false
businessUnitId:
label: oro.business_unit.label
type: choice-business-unit
data_name: caseEntity.owner
className: 'Oro\Bundle\OrganizationBundle\Entity\BusinessUnit'
enabled: false
properties:
id: ~
view_link:
Expand Down
4 changes: 3 additions & 1 deletion src/OroCRM/Bundle/MagentoBundle/Entity/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
* @ORM\Table(name="orocrm_magento_cart",
* indexes={
* @ORM\Index(name="magecart_origin_idx", columns={"origin_id"}),
* @ORM\Index(name="magecart_updated_idx",columns={"updatedAt"})
* @ORM\Index(name="magecart_updated_idx", columns={"updatedAt"}),
* @ORM\Index(name="magecart_payment_details_idx", columns={"payment_details"}),
* @ORM\Index(name="status_name_items_qty_idx", columns={"status_name", "items_qty"})
* },
* uniqueConstraints={
* @ORM\UniqueConstraint(name="unq_cart_origin_id_channel_id", columns={"origin_id", "channel_id"})
Expand Down
2 changes: 1 addition & 1 deletion src/OroCRM/Bundle/MagentoBundle/Entity/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class Customer extends ExtendCustomer implements
* @var Account
*
* @ORM\ManyToOne(targetEntity="OroCRM\Bundle\AccountBundle\Entity\Account")
* @ORM\JoinColumn(name="account_id", referencedColumnName="id", onDelete="SET NULL")
* @ORM\JoinColumn(name="account_id", referencedColumnName="id", onDelete="CASCADE")
* @ConfigField(
* defaultValues={
* "importexport"={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function setVisitEventAssociationExtension(VisitEventAssociationExtension
*/
public function getMigrationVersion()
{
return 'v1_41_2';
return 'v1_41_4';
}

/**
Expand Down Expand Up @@ -715,6 +715,8 @@ protected function createOrocrmMagentoCartTable(Schema $schema)
$table->setPrimaryKey(['id']);
$table->addIndex(['origin_id'], 'magecart_origin_idx', []);
$table->addIndex(['updatedAt'], 'magecart_updated_idx', []);
$table->addIndex(['payment_details'], 'magecart_payment_details_idx', []);
$table->addIndex(['status_name', 'items_qty'], 'status_name_items_qty_idx', []);
$table->addUniqueIndex(['origin_id', 'channel_id'], 'unq_cart_origin_id_channel_id');
}

Expand Down Expand Up @@ -1025,7 +1027,7 @@ protected function addOrocrmMagentoCustomerForeignKeys(Schema $schema)
$schema->getTable('orocrm_account'),
['account_id'],
['id'],
['onDelete' => 'SET NULL']
['onDelete' => 'CASCADE']
);
$table->addForeignKeyConstraint(
$schema->getTable('oro_user'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace OroCRM\Bundle\MagentoBundle\Migrations\Schema\v1_41_3;

use Doctrine\DBAL\Schema\Schema;

use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

class UpdateCartIndexes implements Migration
{
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
$table = $schema->getTable('orocrm_magento_cart');
if (!$table->hasIndex('magecart_payment_details_idx')) {
$table->addIndex(['payment_details'], 'magecart_payment_details_idx', []);
}
if (!$table->hasIndex('status_name_items_qty_idx')) {
$table->addIndex(['status_name', 'items_qty'], 'status_name_items_qty_idx', []);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace OroCRM\Bundle\MagentoBundle\Migrations\Schema\v1_41_4;

use Doctrine\DBAL\Schema\Schema;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

class OroCRMMagentoBundle implements Migration
{
/**
* Changes account_id to onDelete=CASCADE
*
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
$this->changeOnDeleteToCascade(
$schema,
[
'orocrm_magento_customer' => ['account_id'],
]
);
}

/**
* @param Schema $schema
* @param array $data
* [
* table name => [column name, ...],
* ...
* ]
*/
protected function changeOnDeleteToCascade(Schema $schema, array $data)
{
foreach ($data as $tableName => $columns) {
$table = $schema->getTable($tableName);
foreach ($columns as $column) {
$foreignKeys = $table->getForeignKeys();
foreach ($foreignKeys as $foreignKey) {
$foreignKeyColumns = $foreignKey->getUnquotedLocalColumns();
if ($foreignKeyColumns === [$column]) {
if ($foreignKey->getOption('onDelete') !== 'CASCADE') {
$table->removeForeignKey($foreignKey->getName());
$table->addForeignKeyConstraint(
$foreignKey->getUnqualifiedForeignTableName(),
$foreignKeyColumns,
$foreignKey->getUnquotedForeignColumns(),
['onDelete' => 'CASCADE', 'onUpdate' => $foreignKey->getOption('onUpdate')]
);
}

break;
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function visitDatasource(DatagridConfiguration $config, DatasourceInterfa
if (!is_string($part)) {
$part = $qb->expr()->orX(
$part,
$this->createItemsFunc($qb)
$this->createItemsExpr($qb)
);

$addParameter = true;
Expand Down Expand Up @@ -129,19 +129,18 @@ public function getPriority()
/**
* @param QueryBuilder $qb
*
* @return Func
* @return mixed
*/
protected function createItemsFunc(QueryBuilder $qb)
protected function createItemsExpr(QueryBuilder $qb)
{
$itemsQb = clone $qb;
$itemsQb->resetDQLParts();

$itemsQb
->select('item.entityId')
->from('OroCRMMarketingListBundle:MarketingListItem', 'item')
->andWhere('item.marketingList = :marketingListId')
->andWhere('item.entityId = ' . $qb->getRootAliases()[0]);
->andWhere('item.marketingList = :marketingListId');

return new Func('EXISTS', $itemsQb->getDQL());
return $itemsQb->expr()->in($qb->getRootAliases()[0], $itemsQb->getDQL());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ protected function createLeadsCountQb(

if ($start) {
$qb
->andWhere('l.createdAt > :start')
->andWhere('l.createdAt >= :start')
->setParameter('start', $start);
}
if ($end) {
$qb
->andWhere('l.createdAt < :end')
->andWhere('l.createdAt <= :end')
->setParameter('end', $end);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,13 @@ public function getWonOpportunitiesToDateAmount(
*/
protected function setCreationPeriod(QueryBuilder $qb, \DateTime $start = null, \DateTime $end = null)
{
$qb
->andWhere($qb->expr()->between('o.createdAt', ':dateStart', ':dateEnd'))
->setParameter('dateStart', $start)
->setParameter('dateEnd', $end);
if ($start) {
$qb->andWhere('o.createdAt >= :dateStart')->setParameter('dateStart', $start);
}

if ($end) {
$qb->andWhere('o.createdAt <= :dateEnd')->setParameter('dateEnd', $end);
}
}

/**
Expand All @@ -646,10 +649,13 @@ protected function setCreationPeriod(QueryBuilder $qb, \DateTime $start = null,
*/
protected function setClosedPeriod(QueryBuilder $qb, \DateTime $start = null, \DateTime $end = null)
{
$qb
->andWhere($qb->expr()->between('o.closeDate', ':dateStart', ':dateEnd'))
->setParameter('dateStart', $start)
->setParameter('dateEnd', $end);
if ($start) {
$qb->andWhere('o.closedAt >= :dateStart')->setParameter('dateStart', $start);
}

if ($end) {
$qb->andWhere('o.closedAt <= :dateEnd')->setParameter('dateEnd', $end);
}
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/OroCRM/Bundle/SalesBundle/Resources/config/datagrid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,12 @@ datagrid:
autocomplete_alias: users
renderedPropertyName: 'fullName'
className: 'Oro\Bundle\UserBundle\Entity\User'
businessUnitId:
label: oro.business_unit.label
type: choice-business-unit
data_name: c.owner
className: 'Oro\Bundle\OrganizationBundle\Entity\BusinessUnit'
enabled: false
accountName:
type: string
data_name: accountName
Expand Down

0 comments on commit 3bcec01

Please sign in to comment.